00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <sys/types.h>
00037 #include <elf.h>
00038 #include <ctype.h>
00039 #include "wn.h"
00040 #include "wn_map.h"
00041 #include "wn_util.h"
00042 #include <stdio.h>
00043 #include "dwarf_DST.h"
00044 #if !(defined(linux) || defined(BUILD_OS_DARWIN))
00045 #include "ipc_file.h"
00046 #include "ipc_symtab_merge.h"
00047 #endif
00048 #include "ipl_summary.h"
00049
00050 #include "ipa_section.h"
00051
00052
00053
00054 #if !(defined(linux) || defined(BUILD_OS_DARWIN))
00055
00056
00057
00058
00059
00060 void SUMMARY_SYMBOL::WB_Print(FILE* fp,
00061 INT symbol_index,
00062 BOOL is_list,
00063 char* name,
00064 char* func_name,
00065 INT fancy_level)
00066 {
00067 if (func_name == NULL || func_name[0] == '\0') {
00068 fprintf(fp, "SYMBOL[%d]: \"%s\" ", symbol_index, name);
00069 } else {
00070 fprintf(fp, "SYMBOL[%d]: \"%s\":\"%s\" ", symbol_index, name, func_name);
00071 }
00072 if (fancy_level >= 2)
00073 fprintf(fp, "ST_IDX(%d) ", St_idx());
00074 fprintf(fp, "%sLOCAL %sSTATIC %sPASSED %sARRAY %s", Is_local() ? "" :
00075 "non-", Is_static() ? "" : "non-", Is_parm() ? "" : "non-",
00076 Is_array() ? "" : "non-", Is_common() ? "COMMON " : "");
00077 if (Is_common_block())
00078 fprintf(fp, "COMMON-BLOCK ");
00079 if (Is_function())
00080 fprintf(fp, "FUNCTION ");
00081 if (Get_btype() == MTYPE_UNKNOWN)
00082 fprintf(fp, "BTYPE(UNKNOWN) ");
00083 else
00084 fprintf(fp, "BTYPE(%s) ", MTYPE_name(Get_btype()));
00085 if (Is_formal())
00086 fprintf(fp, "FORMAL[%d]", Get_findex());
00087 fprintf(fp, "\n");
00088 if (!is_list || fancy_level >= 2) {
00089 fprintf(fp, " ");
00090 fprintf(fp, "ADDRESS: ");
00091 if (Is_addr_saved())
00092 fprintf(fp, "ADDR_SAVED ");
00093 if (Is_addr_f90_target())
00094 fprintf(fp, "ADDR_F90_TARGET ");
00095 if (Is_addr_passed())
00096 fprintf(fp, "ADDR_PASSED ");
00097 if (Is_addr_passed_inliner())
00098 fprintf(fp, "ADDR_PASSED_INLINE ");
00099 fprintf(fp, "\n");
00100 fprintf(fp, " ");
00101 fprintf(fp, "MOD/REF: ");
00102 if (Is_imod())
00103 fprintf(fp, "IMOD ");
00104 if (Is_dmod())
00105 fprintf(fp, "DMOD ");
00106 if (Is_iref())
00107 fprintf(fp, "IREF ");
00108 if (Is_aref())
00109 fprintf(fp, "AREF ");
00110 if (Is_dref())
00111 fprintf(fp, "DREF ");
00112 if (Is_cref())
00113 fprintf(fp, "CREF ");
00114 if (Is_cdref_preg_only())
00115 fprintf(fp, "CREF_PREG_ONLY ");
00116 if (Is_ikill())
00117 fprintf(fp, "IKILL ");
00118 if (Is_dkill())
00119 fprintf(fp, "DKILL ");
00120 if (Is_cmod())
00121 fprintf(fp, "CMOD ");
00122 if (Is_modcount())
00123 fprintf(fp, "MODCOUNT ");
00124 if (Is_parm())
00125 fprintf(fp, "PARM ");
00126 if (Is_ref())
00127 fprintf(fp, "REF ");
00128 if (Is_modref())
00129 fprintf(fp, "MODREF_ANY ");
00130 fprintf(fp, "\n");
00131 }
00132 }
00133
00134
00135
00136
00137
00138
00139 void IVAR::WB_Print(FILE* fp,
00140 INT ivar_index)
00141 {
00142 fprintf(fp, "IVAR[%d]: ", ivar_index);
00143 if (Is_Formal()) {
00144 fprintf(fp, "FORMAL_POSITION(%d) OFFSET(%d) MTYPE(%s)\n",
00145 Formal_Position(), Offset(), Machine_Types[Mtype()].name);
00146 } else {
00147 fprintf(fp, "GLOBAL(%s) OFFSET(%d) MTYPE(%s)\n",
00148 ST_name(St_Idx()), Offset(), Machine_Types[Mtype()].name);
00149 }
00150 }
00151
00152
00153
00154
00155
00156
00157 void SUMMARY_FORMAL::WB_Print(FILE* fp,
00158 INT formal_index,
00159 char* name,
00160 char* func_name)
00161 {
00162 if (func_name == NULL || func_name[0] == '\0') {
00163 fprintf(fp, "FORMAL[%d]: SYMBOL[%d] REGION[%d] \"%s\" POSITION(%d) ",
00164 formal_index, Get_symbol_index(), Get_region_index(),
00165 name, Get_position());
00166 fprintf(fp, "MTYPE(%s) ", MTYPE_name(Get_machine_type()));
00167 } else {
00168 fprintf(fp, "FORMAL[%d]: SYMBOL[%d] REGION[%d] \"%s\":\"%s\" POSITION(%d) ", formal_index, Get_symbol_index(), Get_region_index(),
00169 name, func_name, Get_position());
00170 fprintf(fp, "MTYPE(%s) ", MTYPE_name(Get_machine_type()));
00171 }
00172 if (Is_ref_parm())
00173 fprintf(fp, "REF ");
00174 if (Is_var_dim_array())
00175 fprintf(fp, "VAR_DIM_ARRAY ");
00176 fprintf(fp, "\n");
00177 }
00178
00179
00180
00181
00182
00183
00184 void SUMMARY_COMMON::WB_Print(FILE* fp,
00185 INT common_index)
00186 {
00187 fprintf(fp, "COMMON[%d]: SYMBOL[%d] COMMON_SHAPE[%d:%d]",
00188 common_index, Get_symbol_index(), Get_common_shape_index(),
00189 Get_common_shape_count());
00190 fprintf(fp, "\n");
00191 }
00192
00193
00194
00195
00196
00197
00198 void SUMMARY_COMMON_SHAPE::WB_Print(FILE* fp,
00199 INT common_shape_index)
00200 {
00201 fprintf(fp, "COMMON_SHAPE[%d]: SYMBOL[%d] ",
00202 common_shape_index, Get_symbol_index());
00203 if (Is_kind_scalar()) {
00204 fprintf(fp, "Scalar ELEMENT_SIZE(%d) OFFSET(%lld) ",
00205 Get_element_size(), Get_offset());
00206 } else if (Is_kind_array()) {
00207 fprintf(fp, "Array ");
00208 if (Is_symbolic_bounds())
00209 fprintf(fp, "<SYMBOLIC_BOUNDS> ");
00210 else
00211 fprintf(fp, "ELEMENT_SIZE(%d) DIM_COUNT(%d) [%d:%d:%d] ",
00212 Get_element_size(), Get_dim_count(), Get_lower(),
00213 Get_upper(), Get_stride());
00214 }
00215 fprintf(fp, "\n");
00216 }
00217
00218
00219
00220
00221
00222
00223 void SUMMARY_PROCEDURE::WB_Print(FILE* fp,
00224 INT procedure_index,
00225 char* name,
00226 INT fancy_level)
00227 {
00228 INT symbol_index = Get_symbol_index();
00229 fprintf(fp, "PROCEDURE[%d]: SYMBOL[%d] \"%s\" ", procedure_index,
00230 symbol_index, name);
00231 if (Get_formal_count() > 0)
00232 fprintf(fp, "FORMAL[%d:%d] ", Get_formal_index(),
00233 Get_formal_count());
00234 if (Get_global_count() > 0)
00235 fprintf(fp, "GLOBAL[%d:%d] ", Get_global_index(),
00236 Get_global_count());
00237 if (Get_callsite_count() > 0)
00238 fprintf(fp, "CALLSITE[%d:%d] ", Get_callsite_index(),
00239 Get_callsite_count());
00240 if (Get_ctrl_dep_count() > 0)
00241 fprintf(fp, "CTRL_DEP[%d:%d] ", Get_ctrl_dep_index(),
00242 Get_ctrl_dep_count());
00243 if (Get_array_section_count() > 0)
00244 fprintf(fp, "CFG_NODE[%d:%d] ", Get_array_section_index(),
00245 Get_array_section_count());
00246 fprintf(fp, "\n ");
00247 fprintf(fp, "X(VALUE[%d:%d]) X(EXPR[%d:%d]) ", Get_ex_value_index(),
00248 Get_ex_value_count(), Get_ex_expr_index(), Get_ex_expr_count());
00249 if (fancy_level >= 2) {
00250 if (Is_may_inline())
00251 fprintf(fp, "MAY_INLINE ");
00252 if (Is_must_inline())
00253 fprintf(fp, "MUST_INLINE ");
00254 if (Is_no_inline())
00255 fprintf(fp, "NO_INLINE ");
00256 if (Is_varargs())
00257 fprintf(fp, "VARARGS ");
00258 if (Is_alt_entry())
00259 fprintf(fp, "IS_ALT_ENTRY ");
00260 if (Has_alt_entry())
00261 fprintf(fp, "HAS_ALT_ENTRY ");
00262 if (Has_pstatic())
00263 fprintf(fp, "PSTATIC ");
00264 if (Is_no_delete())
00265 fprintf(fp, "NO_DELETE ");
00266 if (Is_block_data())
00267 fprintf(fp, "BLOCK_DATA ");
00268 if (Is_direct_mod_ref())
00269 fprintf(fp, "DIRECT_MOD_REF ");
00270 if (Is_exc_inline())
00271 fprintf(fp, "EXC_INLINE ");
00272 if (Has_addr_taken_reset())
00273 fprintf(fp, "ADDR_TAKEN_RESET ");
00274 if (Has_PU_freq())
00275 fprintf(fp, "PU_FREQ ");
00276 if (Has_formal_pragma())
00277 fprintf(fp, "FORMAL_PRAGMA ");
00278 if (Has_parallel_pragma())
00279 fprintf(fp, "PARALLEL_PRAGMA ");
00280 if (Has_parallel_region_pragma())
00281 fprintf(fp, "PARALLEL_REGION_PRAGMA ");
00282 if (Has_fstatic())
00283 fprintf(fp, "FSTATIC ");
00284 if (Use_lowered_return_preg())
00285 fprintf(fp, "LOWERED_RETURN_PREG ");
00286 if (Has_unknown_calls())
00287 fprintf(fp, "UNKNOWN_CALLS ");
00288 if (Has_incomplete_array_info())
00289 fprintf(fp, "INCOMPLETE_ARRAY_INFO ");
00290 if (Has_mp_needs_lno())
00291 fprintf(fp, "MP_NEEDS_LNO ");
00292 if (Has_exc_try())
00293 fprintf(fp, "EXC_TRY ");
00294 if (Has_side_effect())
00295 fprintf(fp, "SIDE_EFFECT ");
00296 if (Has_messy_regions())
00297 fprintf(fp, "MESSY_REGIONS ");
00298 if (Has_early_returns())
00299 fprintf(fp, "EARLY_RETURNS ");
00300 }
00301 fprintf(fp, "\n");
00302 }
00303
00304
00305
00306
00307
00308
00309 void SUMMARY_GLOBAL::WB_Print(FILE* fp,
00310 INT global_index)
00311 {
00312 fprintf(fp, "GLOBAL[%d]: SYMBOL[%d] MODS(%d) REFS(%d) ",
00313 global_index, Get_symbol_index(), Get_modcount(),
00314 Get_refcount());
00315 if (Is_imod())
00316 fprintf(fp, "IMOD ");
00317 if (Is_dmod())
00318 fprintf(fp, "DMOD ");
00319 if (Is_iref())
00320 fprintf(fp, "IREF ");
00321 if (Is_dref())
00322 fprintf(fp, "DREF ");
00323 if (Is_ikill())
00324 fprintf(fp, "IKILL ");
00325 if (Is_dkill())
00326 fprintf(fp, "DKILL ");
00327 fprintf(fp, "\n");
00328 }
00329
00330
00331
00332
00333
00334
00335 void SUMMARY_CALLSITE::WB_Print(FILE* fp,
00336 INT callsite_index,
00337 char* name,
00338 char* func_name)
00339 {
00340 fprintf(fp, "CALLSITE[%d]: ACTUAL[%d:%d] MAP_ID(%d) ", callsite_index,
00341 Get_actual_index(), Get_param_count(), Get_map_id());
00342 if (Is_intrinsic())
00343 fprintf(fp, "<INTRINSIC>");
00344 else if (Is_func_ptr())
00345 fprintf(fp, "<FUNC_PTR> VALUE[%d]", Get_value_index());
00346 else {
00347 if (func_name == NULL || func_name[0] == '\0')
00348 fprintf(fp, "SYMBOL[%d] \"%s\" ", Get_symbol_index(), name);
00349 else
00350 fprintf(fp, "SYMBOL[%d] \"%s\":\"%s\" ", Get_symbol_index(),
00351 name, func_name);
00352 }
00353 if (Is_must_inline())
00354 fprintf(fp, "MUST_INLINE");
00355 if (Is_no_inline())
00356 fprintf(fp, "NO_INLINE");
00357 fprintf(fp, "\n");
00358 }
00359
00360
00361
00362
00363
00364
00365 void SUMMARY_CONTROL_DEPENDENCE::WB_Print(FILE* fp,
00366 INT control_index)
00367 {
00368 if (Is_entry()) {
00369 fprintf(fp, "CTRL_DEP[%d]: <ENTRY> STMT[%d:%d] ", control_index,
00370 Get_true_stmt_index(), Get_true_count());
00371 } else if (Is_if_stmt()) {
00372 fprintf(fp, "CTRL_DEP[%d]: <IF_STMT> MAP_ID(%d) ", control_index,
00373 Get_map_id());
00374 fprintf(fp, "<TRUE> STMTS[%d:%d] <FALSE> STMTS[%d:%d] ",
00375 Get_true_stmt_index(), Get_true_count(),
00376 Get_false_stmt_index(), Get_false_count());
00377 } else if (Is_do_loop()) {
00378 fprintf(fp, "CTRL_DEP[%d]: <DO_LOOP> MAP_ID(%d) STMTS[%d:%d] ",
00379 control_index, Get_map_id(), Get_true_stmt_index(),
00380 Get_true_count());
00381 }
00382 fprintf(fp, "\n");
00383 }
00384
00385
00386
00387
00388
00389
00390 void SUMMARY_ACTUAL::WB_Print(FILE* fp,
00391 INT actual_index,
00392 char* name,
00393 char* func_name)
00394 {
00395 fprintf(fp, "ACTUAL[%d]: ", actual_index);
00396 if (Pass_type_name() != NULL) {
00397 switch (Get_pass_type()) {
00398 case PASS_UNKNOWN:
00399 fprintf(fp, "PASS(UNKNOWN) ");
00400 break;
00401 case PASS_LDID:
00402 fprintf(fp, "PASS(LDID) ");
00403 break;
00404 case PASS_LOAD:
00405 fprintf(fp, "PASS(LOAD) ");
00406 break;
00407 case PASS_MLOAD:
00408 fprintf(fp, "PASS(MLOAD) ");
00409 break;
00410 case PASS_LDA:
00411 fprintf(fp, "PASS(LDA) ");
00412 break;
00413 case PASS_ARRAY_SECTION:
00414 fprintf(fp, "PASS(ARRAY) ");
00415 break;
00416 }
00417 }
00418 if (Get_symbol_index() != -1) {
00419 if (func_name == NULL || func_name[0] == '\0')
00420 fprintf(fp, "SYMBOL[%d] \"%s\" ", Get_symbol_index(), name);
00421 else
00422 fprintf(fp, "SYMBOL[%d] \"%s\":\"%s\" ", Get_symbol_index(), name,
00423 func_name);
00424 }
00425 if (Get_value_index() != -1)
00426 fprintf(fp, "VALUE[%d] ", Get_value_index());
00427 if (Get_index() != -1)
00428 if (Get_pass_type())
00429 fprintf(fp, "REGION[%d] ", Get_index());
00430 else
00431 fprintf(fp, "SCALAR[%d] ", Get_index());
00432 fprintf(fp, "\n");
00433 }
00434 #endif
00435
00436
00437
00438
00439
00440
00441 void SUMMARY_VALUE::WB_Print(FILE* fp,
00442 INT value_index)
00443 {
00444 fprintf(fp, "VALUE[%d]: ", value_index);
00445 if (Get_mtype() != MTYPE_UNKNOWN)
00446 fprintf(fp, "%s ", MTYPE_name(Get_mtype()));
00447 if (Is_unknown())
00448 fprintf(fp, "UNKNOWN");
00449 else if (Is_int_const())
00450 fprintf(fp, "(%lld) ", Get_int_const_value());
00451 else if (Is_two_consts())
00452 fprintf(fp, "(%d,%d) ",
00453 Get_first_of_two_values(), Get_second_of_two_values());
00454 else if (Is_const_st())
00455 fprintf(fp, "CONST");
00456 else if (Is_formal())
00457 fprintf(fp, "FORMAL[%d] ", Get_formal_index());
00458 else if (Is_global()) {
00459 if (Is_global_st_idx())
00460 fprintf(fp, "GLOBAL(ST_IDX(%d)) ", Get_global_st_idx());
00461 else
00462 fprintf(fp, "GLOBAL(SYMBOL[%d]) ", Get_global_index());
00463 } else if (Is_symbol())
00464 fprintf(fp, "SYMBOL[%d] ", Get_symbol_index());
00465 else if (Is_expr())
00466 fprintf(fp, "EXPR[%d] ", Get_expr_index());
00467 else if (Is_phi())
00468 fprintf(fp, "PHI[%d] ", Get_phi_index());
00469 else if (Is_chi())
00470 fprintf(fp, "CHI[%d] ", Get_chi_index());
00471 else if (Is_callsite())
00472 fprintf(fp, "CALLSITE[%d] ", Get_callsite_index());
00473 else if (Is_not_const())
00474 fprintf(fp, "NOT_CONST");
00475 fprintf(fp, "\n");
00476 }
00477
00478 #if !(defined(linux) || defined(BUILD_OS_DARWIN))
00479
00480
00481
00482
00483
00484 void CFG_NODE_INFO::WB_Print(FILE* fp,
00485 INT cfg_index)
00486 {
00487 fprintf(fp, "CFG_NODE[%d]: ", cfg_index);
00488 if (Is_do_loop()) {
00489 fprintf(fp, "DO_LOOP: INDEX(%d) ", Get_loop_index());
00490 } else if (Is_if()) {
00491 fprintf(fp, "IF: ELSE_INDEX(%d) ", Get_else_index());
00492 } else if (Is_else()) {
00493 fprintf(fp, "IF: IF_INDEX(%d) ", Get_if_index());
00494 } else if (Is_entry()) {
00495 fprintf(fp, "ENTRY: ");
00496 } else {
00497 fprintf(fp, "<UNKNOWN>: ");
00498 }
00499 fprintf(fp, "CFG_INDEX(%d) ", Get_cd_index());
00500 if (Has_calls())
00501 fprintf(fp, "HAS_CALLS ");
00502 if (Get_def_count() > 0)
00503 fprintf(fp, "DEF REGION[%d:%d] ", Get_def_index(),
00504 Get_def_count());
00505 if (Get_use_count() > 0)
00506 fprintf(fp, "USE REGION[%d:%d] ", Get_use_index(),
00507 Get_use_count());
00508 if (Get_param_count() > 0)
00509 fprintf(fp, "PARAM REGION[%d:%d] ", Get_param_index(),
00510 Get_param_count());
00511 if (Get_formal_count() > 0)
00512 fprintf(fp, "FORMAL REGION[%d:%d] ", Get_formal_index(),
00513 Get_formal_count());
00514 if (Get_scalar_count() > 0)
00515 fprintf(fp, "SCALAR[%d:%d] ", Get_scalar_index(),
00516 Get_scalar_count());
00517 fprintf(fp, "\n");
00518 }
00519
00520
00521
00522
00523
00524
00525 void SCALAR_INFO::WB_Print(FILE* fp,
00526 INT scalar_index,
00527 char* name,
00528 char* func_name)
00529 {
00530 if (func_name == NULL || func_name[0] == '\0')
00531 fprintf(fp, "SCALAR[%d]: SYMBOL[%d] \"%s\" ",
00532 scalar_index, Get_id(), name);
00533 else
00534 fprintf(fp, "SCALAR[%d]: SYMBOL[%d] \"%s\":\"%s\" ",
00535 scalar_index, Get_id(), name, func_name);
00536 if (Get_callsite_id() != -1)
00537 fprintf(fp, "CALLSITE[%d] ", Get_callsite_id());
00538 if (Is_may_kill())
00539 fprintf(fp, "MAY_KILL ");
00540 if (Is_may_use())
00541 fprintf(fp, "MAY_USE ");
00542 if (Is_may_reduc())
00543 fprintf(fp, "MAY_REDUC ");
00544 if (Is_kill())
00545 fprintf(fp, "KILL ");
00546 if (Is_use())
00547 fprintf(fp, "USE ");
00548 if (Is_euse())
00549 fprintf(fp, "EUSE ");
00550 if (Is_call_euse())
00551 fprintf(fp, "CALL_EUSE ");
00552 if (Is_reduc())
00553 fprintf(fp, "REDUC ");
00554 if (Is_array_reduc())
00555 fprintf(fp, "ARRAY_REDUC ");
00556 if (Is_array_may_reduc())
00557 fprintf(fp, "ARRAY_MAY_REDUC ");
00558 if (Is_passed_ref())
00559 fprintf(fp, "PASSED ");
00560 if (Is_may_passed_ref())
00561 fprintf(fp, "MAY_PASS ");
00562 fprintf(fp, "\n");
00563 }
00564
00565
00566
00567
00568
00569
00570 void REGION_ARRAYS::WB_Print(FILE* fp,
00571 INT region_index,
00572 char* name,
00573 char* func_name)
00574 {
00575 if (func_name == NULL || func_name[0] == '\0')
00576 fprintf(fp, "REGION[%d]: SYMBOL[%d] \"%s\" ", region_index,
00577 Get_sym_id(), name);
00578 else
00579 fprintf(fp, "REGION[%d]: SYMBOL[%d] \"%s\":\"%s\" ", region_index,
00580 Get_sym_id(), name, func_name);
00581 fprintf(fp, "PROJ_REGION[%d:%d] ", Get_idx(), Get_count());
00582 if (Get_element_size() != 0)
00583 fprintf(fp, "ELEMENT_SIZE(%d) ", Get_element_size());
00584 if (Is_use())
00585 fprintf(fp, "USE ");
00586 else if (Is_def())
00587 fprintf(fp, "DEF ");
00588 else if (Is_passed())
00589 fprintf(fp, "PASSED ");
00590 else if (Is_may_def())
00591 fprintf(fp, "MAY_DEF ");
00592 else if (Is_may_use())
00593 fprintf(fp, "MAY_USE ");
00594 else if (Is_formal())
00595 fprintf(fp, "FORMAL ");
00596 if (Is_bad_alias())
00597 fprintf(fp, "<BAD_ALIAS>");
00598 if (Is_loop_invariant())
00599 fprintf(fp, "<LOOP_INVARIANT>");
00600 fprintf(fp, "\n");
00601 }
00602
00603
00604
00605
00606
00607
00608 void PROJECTED_REGION::WB_Print(FILE* fp,
00609 INT proj_region_index)
00610 {
00611 fprintf(fp, "PROJ_REGION[%d]: ", proj_region_index);
00612 fprintf(fp, "PROJ_NODE[%d:%d] ", Get_id(),
00613 Get_num_dims());
00614 fprintf(fp, "DEPTH(%d) ", Get_depth());
00615 if (Is_messy_region())
00616 fprintf(fp, "<MESSY> ");
00617 if (Is_unprojected_region())
00618 fprintf(fp, "<UNPROJECTED> ");
00619 if (Is_may_kill()) {
00620 fprintf(fp, "MAY_KILL ");
00621 } else if (Is_may_use()) {
00622 fprintf(fp, "MAY_USE ");
00623 } else if (Is_passed()) {
00624 fprintf(fp, " ");
00625 fprintf(fp, "\n");
00626 fprintf(fp, "PASSED ");
00627 fprintf(fp, "CALLSITE[%d] ", Get_callsite_id());
00628 fprintf(fp, "ACTUAL_POSITION(%d) ", Get_actual_id());
00629 } else if (Is_formal()) {
00630 fprintf(fp, "FORMAL ");
00631 }
00632 fprintf(fp, "\n");
00633 }
00634
00635
00636
00637
00638
00639
00640 void PROJECTED_NODE::WB_Print(FILE* fp,
00641 INT proj_node_index)
00642 {
00643 fprintf(fp, "PROJ_NODE[%d]: ", proj_node_index);
00644 if (Is_unprojected()) {
00645 fprintf(fp, "<UNPROJECTED> TERM[%d:%d] ",
00646 Get_lb_term_index(), Get_lb_term_count());
00647 } else {
00648 if (Is_messy_lb())
00649 fprintf(fp, "LB <MESSY> ");
00650 else
00651 fprintf(fp, "LB TERM[%d:%d] ", Get_lb_term_index(),
00652 Get_lb_term_count());
00653 if (Is_messy_ub())
00654 fprintf(fp, "UB <MESSY> ");
00655 else
00656 fprintf(fp, "UB TERM[%d:%d] ", Get_ub_term_index(),
00657 Get_ub_term_count());
00658 if (Is_messy_step())
00659 fprintf(fp, "STEP <MESSY> ");
00660 else
00661 fprintf(fp, "STEP TERM[%d:%d] ", Get_step_term_index(),
00662 Get_step_term_count());
00663 if (Get_segment_length_term_count() > 0)
00664 fprintf(fp, "SL TERM[%d:%d] ", Get_segment_length_term_index(),
00665 Get_segment_length_term_count());
00666 if (Get_segment_stride_term_count() > 0)
00667 fprintf(fp, "SS TERM[%d:%d] ", Get_segment_stride_term_index(),
00668 Get_segment_stride_term_count());
00669 }
00670 if (Is_assumed_shape())
00671 fprintf(fp, "<ASSUMED_SHAPE> ");
00672 fprintf(fp, "\n");
00673 }
00674
00675
00676
00677
00678
00679
00680 void TERM::WB_Print(FILE* fp,
00681 INT term_index)
00682 {
00683 fprintf(fp, "TERM[%d]: ", term_index);
00684 switch (Get_type()) {
00685 case LTKIND_NONE:
00686 fprintf(fp, "NONE ");
00687 break;
00688 case LTKIND_CONST:
00689 fprintf(fp, "CONST(%d)", Get_coeff());
00690 break;
00691 case LTKIND_LINDEX:
00692 fprintf(fp, "LINDEX(%d) * (%d) ", Get_desc(), Get_coeff());
00693 break;
00694 case LTKIND_SUBSCR:
00695 fprintf(fp, "SUBSCR(%d) * (%d) ", Get_desc(), Get_coeff());
00696 break;
00697 case LTKIND_IV:
00698 fprintf(fp, "IVAR[%d] * (%d) ", Get_desc(), Get_coeff());
00699 break;
00700 default:
00701 fprintf(fp, " ");
00702 break;
00703 }
00704 fprintf(fp, "\n");
00705 }
00706
00707
00708
00709
00710
00711
00712 void LOOPINFO::WB_Print(FILE* fp,
00713 INT loop_info_index)
00714 {
00715 fprintf(fp, "LOOP[%d]: ", loop_info_index);
00716 if (Is_messy_lb())
00717 fprintf(fp, "LB <MESSY> ");
00718 else
00719 fprintf(fp, "LB TERM[%d:%d] ", Get_lb_term_index(),
00720 Get_lb_term_count());
00721 if (Is_messy_ub())
00722 fprintf(fp, "UB <MESSY> ");
00723 else
00724 fprintf(fp, "UB TERM[%d:%d] ", Get_ub_term_index(),
00725 Get_ub_term_count());
00726 if (Is_messy_step())
00727 fprintf(fp, "STEP <MESSY> ");
00728 else
00729 fprintf(fp, "STEP TERM[%d:%d] ", Get_step_term_index(),
00730 Get_step_term_count());
00731 fprintf(fp, "NEST_LEVEL(%d)\n", Get_nest_level());
00732 }
00733
00734
00735
00736
00737
00738
00739 void SUMMARY_PHI::WB_Print(FILE* fp,
00740 INT phi_index)
00741 {
00742 fprintf(fp, "PHI[%d]: ", phi_index);
00743 for (INT i = 0; i < 2; i++) {
00744 fprintf(fp, "(");
00745 fprintf(fp, "CTRL_DEP[%d] ", Get_ctrl_dep_index(i));
00746 fprintf(fp, "%s", Get_branch(i) ? "T " : "F ");
00747 if (Is_value(i))
00748 fprintf(fp, "VALUE[%d]", Get_node_index(i));
00749 if (Is_expr(i))
00750 fprintf(fp, "EXPR[%d]", Get_node_index(i));
00751 if (Is_phi(i))
00752 fprintf(fp, "PHI[%d]", Get_node_index(i));
00753 if (Is_chi(i))
00754 fprintf(fp, "CHI[%d]", Get_node_index(i));
00755 fprintf(fp, ") ");
00756 }
00757 fprintf(fp, "\n");
00758 }
00759
00760
00761
00762
00763
00764
00765 void SUMMARY_CHI::WB_Print(FILE* fp,
00766 INT chi_index,
00767 char* name,
00768 char* func_name)
00769 {
00770 fprintf(fp, "CHI[%d]: CALLSITE[%d] ", chi_index, Get_call_index());
00771 if (Get_symbol_index() != -1) {
00772 if (func_name == NULL || func_name[0] == '\0')
00773 fprintf(fp, "SYMBOL[%d] \"%s\" ", Get_symbol_index(), name);
00774 else
00775 fprintf(fp, "SYMBOL[%d] \"%s\":\"%s\" ", Get_symbol_index(),
00776 name, func_name);
00777 }
00778 if (Is_chi_value())
00779 fprintf(fp, "VALUE[%d] ", Get_node_index());
00780 if (Is_chi_phi())
00781 fprintf(fp, "PHI[%d] ", Get_node_index());
00782 if (Is_chi_expr())
00783 fprintf(fp, "EXPR[%d] ", Get_node_index());
00784 if (Is_chi_chi())
00785 fprintf(fp, "CHI[%d] ", Get_node_index());
00786 fprintf(fp, "\n");
00787 }
00788 #endif
00789
00790
00791
00792
00793
00794
00795 void SUMMARY_EXPR::Node(FILE* fp,
00796 INT kid)
00797 {
00798 if (Is_expr_value(kid))
00799 fprintf(fp, "VALUE[%d] ", Get_node_index(kid));
00800 if (Is_expr_phi(kid))
00801 fprintf(fp, "PHI[%d] ", Get_node_index(kid));
00802 if (Is_expr_expr(kid))
00803 fprintf(fp, "EXPR[%d] ", Get_node_index(kid));
00804 if (Is_expr_chi(kid))
00805 fprintf(fp, "CHI[%d] ", Get_node_index(kid));
00806 }
00807
00808
00809
00810
00811
00812
00813 void SUMMARY_EXPR::WB_Print(FILE* fp,
00814 INT expr_index)
00815 {
00816 fprintf(fp, "EXPR[%d]: ", expr_index);
00817 if (Is_expr_unknown()) {
00818 fprintf(fp, "<UNKNOWN>\n");
00819 return;
00820 }
00821 fprintf(fp, "%s ", Get_mtype() == MTYPE_UNKNOWN
00822 ? "?" : MTYPE_name(Get_mtype()));
00823 fputs(OPCODE_name(Get_opcode()), fp);
00824 fprintf(fp, " ");
00825 if (Has_const_operand()) {
00826 if (Get_kid() == 0) {
00827 Node(fp, 0);
00828 if (OPCODE_nkids(Get_opcode()) == 2)
00829 fprintf(fp, "%lld ", Get_const_value());
00830 } else {
00831 fprintf(fp, "%lld ", Get_const_value());
00832 Node(fp, 0);
00833 }
00834 } else {
00835 Node(fp, 0);
00836 Node(fp, 1);
00837 }
00838 if (Is_trip_count())
00839 fprintf(fp, " <TRIP COUNT> ");
00840 fprintf(fp, "\n");
00841 }
00842
00843 #if !(defined(linux) || defined(BUILD_OS_DARWIN))
00844
00845
00846
00847
00848
00849 void SUMMARY_STID::WB_Print(FILE* fp,
00850 INT stid_index,
00851 char* name,
00852 char* func_name)
00853 {
00854 fprintf(fp, "STID[%d]: ", stid_index);
00855 if (func_name == NULL || func_name[0] == '\0')
00856 fprintf(fp, "Scalar SYMBOL[%d] \"%s\" ",
00857 Get_symbol_index(), name);
00858 else
00859 fprintf(fp, "Scalar SYMBOL[%d] \"%s\":\"%s\" ",
00860 Get_symbol_index(), name, func_name);
00861 if (Get_value_index() != -1)
00862 fprintf(fp, "VALUE[%d] ", Get_value_index());
00863 if (Is_always_executed())
00864 fprintf(fp, "<ALWAYS EXECUTED> ");
00865 fprintf(fp, "\n");
00866 }
00867
00868
00869
00870
00871
00872
00873 void SUMMARY_STMT::WB_Print(FILE* fp,
00874 INT stmt_index,
00875 char* name,
00876 char* func_name)
00877 {
00878 fprintf(fp, "STMT[%d]: ", stmt_index);
00879 if (Is_expr())
00880 fprintf(fp, "EXPR[%d] ", Get_expr_index());
00881 else if (Is_var()) {
00882 if (func_name == NULL || func_name[0] == '\0')
00883 fprintf(fp, "SYMBOL[%d] \"%s\" ", Get_var_index(), name);
00884 else
00885 fprintf(fp, "SYMBOL[%d] \"%s\":\"%s\" ", Get_var_index(),
00886 name, func_name);
00887 fprintf(fp, "MOD_COUNT(%d) REF_COUNT(%d) ADDR_TAKEN_COUNT(%d) ",
00888 Get_write_count(), Get_ref_count(),
00889 Get_addr_taken_count());
00890 } else if (Is_call())
00891 fprintf(fp, "CALLSITE[%d] ", Get_call_index());
00892 else if (Is_cond())
00893 fprintf(fp, "CTRL_DEP[%d] ", Get_cond_index());
00894 else if (Is_array_ref())
00895 fprintf(fp, "ARRAY MAP_ID(%d) ", Get_array_ref_map_id());
00896 else if (Is_stid())
00897 fprintf(fp, "STID[%d] ", Get_stid_index());
00898 else
00899 fprintf(fp, "UNKNOWN_TYPE ");
00900 fprintf(fp, "\n");
00901 }
00902
00903
00904
00905
00906
00907
00908 void SUMMARY_FEEDBACK::WB_Print(FILE* fp,
00909 INT feedback_index)
00910 {
00911 fprintf(fp, "FEEDBACK[%d]: ", feedback_index);
00912 fprintf(fp, "CYCLE(%lld) FREQ(%d) BB_COUNT(%d) STMT_COUNT(%d) ",
00913 Get_cycle_count(), Get_frequency_count(),
00914 Get_effective_bb_count(), Get_effective_stmt_count());
00915 fprintf(fp, "\n");
00916 }
00917 #endif