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