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