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
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #define __STDC_LIMIT_MACROS
00054 #include <stdint.h>
00055 #if defined(BUILD_OS_DARWIN)
00056 #include <darwin_elf.h>
00057 #else
00058 #include <elf.h>
00059 #endif
00060
00061 #if 0 // SC
00062 #include "defs.h"
00063 #else
00064 #include "workaround.h"
00065 #endif
00066 #if 0 // SC
00067 #include "strtab.h"
00068 #endif
00069 #include "ipl_summary.h"
00070 #if 0 // SC
00071 #include "ipc_symtab_merge.h"
00072 #include "ipl_tlog.h"
00073 #endif // SC
00074
00075
00076 SUMMARY_SYMBOL *Ipl_Summary_Symbol;
00077 const INT MODREF_MAX_STRING_LENGTH = 1000;
00078 char Modref_Buf[MODREF_MAX_STRING_LENGTH];
00079 BOOL IPA_Trace_Mod_Ref = FALSE;
00080
00081
00082
00083 typedef enum {
00084 MAY_INLINE = 0,
00085 MUST_INLINE = 1,
00086 NO_INLINE = 2,
00087 VARARG = 3,
00088 ALTENTRY = 4,
00089 HAS_ALTENTRY= 5,
00090 HAS_PSTATIC = 6,
00091 DIRC_MODREF = 7,
00092 IS_EXCP_INL = 8,
00093 NO_DEL = 9,
00094 BLK_DATA = 10,
00095 ADDR_TAKEN_RS= 11,
00096 PU_FREQ_RS = 12,
00097 PARA_PRAG = 13,
00098 PARA_RG_PRAG = 14,
00099 FSTATIC = 15,
00100 UNK_CALLS = 16,
00101 MP_NEED_LNO = 17,
00102 SID_EF_PRAG = 18,
00103 MESSY_RGN = 19,
00104 UNSTRUC_FLW = 20,
00105 FORML_PRAG = 21,
00106 FLAGS_SHIFT_MAX = 31,
00107 } PROC_FLAG_BITS;
00108
00109 void
00110 SUMMARY_PROCEDURE::Print (FILE *fp, INT32 id) const
00111 {
00112 INT flags = 0;
00113 fprintf (fp, "[%6d] %6d %6d %08x %3d %6d %4d %4d %4d %4d ", id, Get_bb_count(), Get_stmt_count(), Get_state(),
00114 Get_formal_count(), Get_global_count(), Get_callsite_count(),Get_ctrl_dep_count(),Get_ex_value_count(),Get_ex_expr_count());
00115
00116 #if 0 // SC
00117 , Get_array_section_count(), Get_array_section_index());
00118 #endif
00119
00120 if ( Is_may_inline() )
00121 flags |= (1<<MAY_INLINE);
00122
00123 if ( Is_must_inline() )
00124 flags |= (1<<MUST_INLINE);
00125
00126 if ( Is_no_inline() )
00127 flags |= (1<<NO_INLINE);
00128
00129 if ( Is_varargs() )
00130 flags |= (1<<VARARG);
00131
00132 if ( Is_alt_entry() )
00133 flags |= (1<<ALTENTRY);
00134
00135 if ( Has_alt_entry() )
00136 flags |= (1<<HAS_ALTENTRY);
00137
00138 if ( Has_pstatic() )
00139 flags |= (1<<HAS_PSTATIC);
00140
00141 if (Is_direct_mod_ref() )
00142 flags |= (1<<DIRC_MODREF);
00143
00144 if (Is_exc_inline() )
00145 flags |= (1<<IS_EXCP_INL);
00146
00147 if (Is_no_delete() )
00148 flags |= (1<<NO_DEL);
00149
00150 if (Is_block_data() )
00151 flags |= (1<<BLK_DATA);
00152
00153 if (Has_addr_taken_reset() )
00154 flags |= (1<<ADDR_TAKEN_RS);
00155
00156 if (Has_PU_freq() )
00157 flags |= (1<<PU_FREQ_RS);
00158
00159 if (Has_formal_pragma() )
00160 flags |= (1<<FORML_PRAG);
00161
00162 if (Has_parallel_pragma() )
00163 flags |= (1<<PARA_PRAG);
00164
00165 if (Has_parallel_region_pragma() )
00166 flags |= (1<<PARA_RG_PRAG);
00167
00168 if (Has_fstatic() )
00169 flags |= (1<<FSTATIC);
00170
00171 if (Has_unknown_calls() )
00172 flags |= (1<<UNK_CALLS);
00173
00174 #if 0 // SC
00175 if (Has_incomplete_array_info () )
00176 fputs (", incomplete array info", fp);
00177 #endif
00178
00179 if (Has_mp_needs_lno() )
00180 flags |= (1<<MP_NEED_LNO);
00181
00182 #ifdef KEY
00183 if (Has_pragma_side_effect() )
00184 #else
00185 if (Has_side_effect() )
00186 #endif
00187 flags |= (1<<SID_EF_PRAG);
00188
00189 if (Has_messy_regions() )
00190 flags |= (1<<MESSY_RGN);
00191
00192 if (Has_unstructured_cflow())
00193 flags |= (1<<UNSTRUC_FLW);
00194
00195 fprintf( fp, "%8x\n", flags);
00196 fprintf ( fp, " -- %5d %5d %5d %5d %5d%5d ",
00197 Get_formal_index(), Get_global_index(), Get_callsite_index(), Get_ctrl_dep_index(),Get_ex_value_index(), Get_ex_expr_index() );
00198
00199 #if 0 // SC
00200 fprintf ( fp, "\n\t\t%d common_count (%d) feedback (%d)\n\t\t",
00201 Get_common_count(), Get_common_index(), Get_feedback_index());
00202 #endif
00203
00204 if ( Ipl_Summary_Symbol ) {
00205 Ipl_Summary_Symbol[Get_symbol_index()].Print (fp);
00206 }
00207 fprintf( fp, "\n");
00208 }
00209
00210
00211 void
00212
00213 #if 1 // SC
00214 #define TFile stdout
00215 #endif
00216
00217 SUMMARY_PROCEDURE::Trace ( INT32 id ) const
00218 {
00219 Print ( TFile, id );
00220 }
00221
00222 void
00223 SUMMARY_PROCEDURE::Print_array (FILE* fp, INT32 size ) const
00224 {
00225 INT i;
00226 fprintf(fp, "%s %s\n", SBar, "(Procedures)");
00227 fprintf ( fp, " Proc bb_cnt stmts state fml glbls call cdep val expr Flags\n Indices:-\n");
00228 for ( i=0; i<size; ++i )
00229 this[i].Print ( fp, i );
00230 }
00231
00232
00233 void
00234 SUMMARY_PROCEDURE::Trace_array ( INT32 size ) const
00235 {
00236 Print_array ( TFile, size );
00237 }
00238
00239
00240
00241 void
00242 SUMMARY_FEEDBACK::Print (FILE *f) const
00243 {
00244 #if 0 // SC
00245 fprintf (f, "cycle = ");
00246 Get_cycle_count().Print(f);
00247 fprintf (f, ", freq. = ");
00248 Get_frequency_count().Print(f);
00249 fprintf (f, ", bb_count = %d, stmt_count = %d\n",
00250 Get_effective_bb_count (), Get_effective_stmt_count ());
00251 #else
00252 fprintf(f,"NYI\n");
00253 #endif
00254 }
00255
00256
00257 void
00258 SUMMARY_FEEDBACK::Print_array (FILE *f, INT32 size) const
00259 {
00260 fprintf (f, "%sStart feedback array\n%s", SBar, SBar);
00261 for (INT i = 0; i < size; i++) {
00262 fprintf (f, "FEEDBACK[%d]: ", i);
00263 this[i].Print (f);
00264 }
00265 fprintf (f, "%sEnd feedback array\n%s", SBar, SBar );
00266
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 void
00278 SUMMARY_CALLSITE::Print (FILE* f) const
00279 {
00280 fprintf (f, "%6d %6d %6d %s",
00281 Get_param_count(), Get_actual_index(),
00282 Get_map_id(), Is_func_ptr() ? ", FPTR" : "" );
00283
00284 if (Is_must_inline())
00285 fputs ("pragma inline \n", f);
00286 if (Is_no_inline())
00287 fputs ("pragma no inline \n", f);
00288 if (Is_intrinsic ()) {
00289 fputs (", intrinsic\n", f);
00290 } else if (Is_func_ptr ())
00291 fprintf (f, ": VALUE[%d]\n", Get_value_index ());
00292 else {
00293 fputs (": ", f);
00294 Ipl_Summary_Symbol[Get_symbol_index()].Print (f);
00295 }
00296 }
00297
00298
00299
00300 void
00301 SUMMARY_CALLSITE::Trace () const
00302 {
00303 Print ( TFile );
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 void
00316 SUMMARY_CALLSITE::Print_array (FILE* f, INT32 size) const
00317 {
00318 INT i;
00319
00320 fprintf(f, "%s (%s)\n", SBar, "CallSites");
00321 fprintf(f, "Callsite Actuals Map_id Type\n");
00322
00323 for ( i=0; i<size; ++i ) {
00324 fprintf ( f, "[%6d] ", i );
00325 this[i].Print ( f );
00326 }
00327 }
00328
00329
00330
00331 void
00332 SUMMARY_CALLSITE::Trace_array ( INT32 size ) const
00333 {
00334 Print_array ( TFile, size );
00335 }
00336
00337
00338
00339
00340
00341
00342
00343 void
00344 SUMMARY_FORMAL::Print ( FILE* fp ) const
00345 {
00346 fprintf ( fp, "%3d ", Get_position() );
00347 fprintf ( fp, "%3d ", Get_region_index());
00348 fprintf ( fp, "%08x ", Get_ty());
00349 #if 0 // SC
00350 fprintf ( fp, "MTYPE(%s) ", MTYPE_name(Get_machine_type()));
00351 #else
00352 fprintf ( fp, "MTYPE(%s) ", "SL");
00353 #endif
00354 if (Is_ref_parm ())
00355 fputs ("byRef ", fp);
00356 if (Is_var_dim_array ())
00357 fputs ("varDimAry ", fp);
00358 Ipl_Summary_Symbol[Get_symbol_index()].Print (fp);
00359 }
00360
00361
00362
00363 void
00364 SUMMARY_FORMAL::Trace ( void ) const
00365 {
00366 Print ( TFile );
00367 }
00368
00369
00370
00371 void
00372 SUMMARY_FORMAL::Print_array (FILE* fp, INT32 size) const
00373 {
00374 INT i;
00375 fprintf(fp, "%s (%s)\n",SBar, "Formals");
00376 fprintf(fp, " Formal Pos Rid TyIdx Type\n");
00377 for ( i=0; i<size; ++i ) {
00378 fprintf ( fp, "[%5d] ", i );
00379 this[i].Print ( fp );
00380 }
00381
00382 }
00383
00384
00385
00386 void
00387 SUMMARY_FORMAL::Trace_array ( INT32 size ) const
00388 {
00389 Print_array ( TFile, size );
00390 }
00391
00392
00393 const char *
00394 SUMMARY_ACTUAL::Pass_type_name (void) const
00395 {
00396 switch (Get_pass_type()) {
00397 case PASS_UNKNOWN:
00398 return "Unk";
00399 case PASS_LDID:
00400 return "Ldid";
00401 case PASS_LOAD:
00402 return "Load";
00403 case PASS_MLOAD:
00404 return "Mload";
00405 case PASS_LDA:
00406 return "Lda";
00407 case PASS_ARRAY_SECTION:
00408 return "Ary_Scn";
00409 }
00410 return 0;
00411 }
00412
00413
00414 void
00415 SUMMARY_ACTUAL::Print (FILE *f, INT32 id) const
00416 {
00417 fprintf (f, "[%6d]: ", id);
00418 #if 0
00419 if (Get_symbol_index () != -1)
00420 Ipl_Summary_Symbol[Get_symbol_index()].Print (f);
00421 #endif
00422
00423 fprintf (f, "%06x ", Get_ty());
00424
00425 #if 0 // SC
00426 if (Get_pass_type() == PASS_ARRAY_SECTION)
00427 fprintf (f, " Section Idx = %d", Get_index());
00428 else
00429 #endif
00430
00431 fprintf (f, " %5d ", Get_index());
00432 fprintf (f, " %5d ", Get_value_index ());
00433 INT tmp = Is_value_parm() ? 1 : 0;
00434 fprintf (f, " %2d", tmp);
00435 const char *p = Pass_type_name ();
00436 if (p)
00437 fprintf (f, " %s\n", p);
00438 else
00439 fprintf (f, " PASS_%d\n", Get_pass_type());
00440
00441
00442 }
00443
00444 void
00445 SUMMARY_ACTUAL::Print_array (FILE *f, INT32 size) const
00446 {
00447 fprintf(f, "%s (%s)\n", SBar, "Actuals");
00448 fprintf(f, " Actual TyIdx SclrIdx ValIdx ByV PassTyp\n");
00449 for (INT i = 0; i < size; i++)
00450 this[i].Print (f, i);
00451
00452 }
00453
00454
00455
00456 const char *
00457 SUMMARY_VALUE::Const_type_name (void) const
00458 {
00459 switch (Get_const_type()) {
00460 case VALUE_UNKNOWN:
00461 return "Unk ";
00462 case VALUE_INT_CONST:
00463 return "Int_C ";
00464 case VALUE_TWO_CONSTS:
00465 return "2_Cs ";
00466 case VALUE_CONST:
00467 return "Const ";
00468 case VALUE_FORMAL:
00469 return "Formal";
00470 case VALUE_GLOBAL:
00471 return "Global";
00472 case VALUE_SYMBOL:
00473 return "Symbol";
00474 case VALUE_EXPR:
00475 return "Expr ";
00476 case VALUE_PHI:
00477 return "Phi ";
00478 case VALUE_CHI:
00479 return "Chi ";
00480 case VALUE_NOT_CONST:
00481 return "Not_C ";
00482 }
00483 return 0;
00484 }
00485
00486
00487 void
00488 SUMMARY_VALUE::Print_const_value (FILE *f, const SUMMARY_SYMBOL* symbol) const
00489 {
00490 if (Is_addr_of ()) {
00491 if (!Is_convertible_to_global ())
00492 fputs ("stack ", f);
00493 fputs ("Addr of ", f);
00494 }
00495
00496 switch (Get_const_type()) {
00497
00498 case VALUE_UNKNOWN:
00499 fputs ("*UNKNOWN*", f);
00500 return;
00501
00502 case VALUE_INT_CONST:
00503 fprintf (f, "%lld", Get_int_const_value ());
00504 return;
00505
00506 case VALUE_TWO_CONSTS:
00507 fprintf (f, "0x%x or 0x%x", Get_first_of_two_values(),
00508 Get_second_of_two_values());
00509 return;
00510
00511 case VALUE_CONST:
00512 {
00513 #if 0 // SC
00514 const ST& st = St_Table[Get_const_st_idx ()];
00515 if (ST_sym_class (st) == CLASS_CONST)
00516 fputs (Targ_Print (NULL, Tcon_Table[ST_tcon (st)]), f);
00517 else {
00518 fprintf (f, "GLOBAL %s", ST_name (st));
00519 }
00520 #else
00521 fprintf(f, "VALUE CONST: NYI\n");
00522 #endif // SC
00523 }
00524 return;
00525
00526 case VALUE_FORMAL:
00527 fprintf (f, "ValF[%d]", Get_formal_index());
00528 return;
00529
00530 case VALUE_GLOBAL:
00531 fputs ("GLOBAL ", f);
00532 if (Is_global_st_idx()) {
00533 fprintf(f, "ST_IDX = %d", Get_global_st_idx ());
00534 } else {
00535 if (symbol)
00536 symbol[Get_global_index()].Print (f);
00537 else {
00538 if (Get_global_index () != -1)
00539 fprintf (f, "index = %d", Get_global_index ());
00540 else
00541 fprintf (f, "ST_IDX = 0x%x", Get_global_st_idx ());
00542 }
00543 }
00544 return;
00545
00546 case VALUE_SYMBOL:
00547 if (symbol)
00548 symbol[Get_symbol_index()].Print (f);
00549 else
00550 fprintf (f, "Symbol index = %d", Get_symbol_index ());
00551 return;
00552
00553 case VALUE_EXPR:
00554 fprintf (f, "ValE[%d]", Get_expr_index());
00555 return;
00556
00557 case VALUE_PHI:
00558 fprintf (f, "ValP[%d]", Get_phi_index());
00559 return;
00560
00561 case VALUE_CHI:
00562 fprintf (f, "ValC[%d]", Get_chi_index ());
00563 return;
00564
00565 case VALUE_NOT_CONST:
00566 fputc ('?', f);
00567 return;
00568
00569 }
00570
00571 fputs ("*print function missing*", f);
00572
00573 }
00574
00575
00576 void
00577 SUMMARY_VALUE::Print (FILE *f, INT32 id) const
00578 {
00579 const char *p;
00580
00581 fprintf (f, "[%5d] ", id);
00582 p = Const_type_name ();
00583 if (p)
00584 fprintf (f, "%s ", p);
00585 else
00586 fprintf (f, "Const_%3d ", Get_const_type());
00587
00588 #if 0 // SC
00589 fprintf (f, "type = %s, ", Get_mtype() == MTYPE_UNKNOWN ? "?" :
00590 MTYPE_name (Get_mtype()));
00591 if (Is_addr_of ())
00592 fprintf (f, "target type = %s, ", Target_mtype() == MTYPE_UNKNOWN ?
00593 "?" : MTYPE_name (Target_mtype()));
00594 #else
00595 fprintf (f, "%s, ", "Mtyp_name NYI");
00596 if (Is_addr_of ())
00597 fprintf (f, "@%s, ","Mtyp_name NYI");
00598 #endif
00599 fputs (" ", f);
00600
00601
00602 Print_const_value (f, Ipl_Summary_Symbol);
00603
00604 fputc ('\n', f);
00605
00606 }
00607
00608
00609 void
00610 SUMMARY_VALUE::Print_array (FILE *f, INT32 size) const
00611 {
00612 fprintf(f, "%s (%s)\n",SBar,"Value");
00613 fprintf(f, " Val_Id Type Value \n");
00614 for (INT i = 0; i < size; i++)
00615 this[i].Print (f, i);
00616 }
00617
00618
00619 void
00620 SUMMARY_CHI::Print (FILE *f) const
00621 {
00622 fprintf (f, " %5d ", Get_call_index ());
00623
00624 switch (_type) {
00625 case CHI_VALUE:
00626 fprintf (f, "V[%5d] ", Get_node_index ());
00627 break;
00628 case CHI_PHI:
00629 fprintf (f, "P[%5d] ", Get_node_index ());
00630 break;
00631 case CHI_EXPR:
00632 fprintf (f, "E[%5d] ", Get_node_index ());
00633 break;
00634 case CHI_CHI:
00635 fprintf (f, "C[%5d] ", Get_node_index ());
00636 break;
00637 }
00638
00639 if (_symbol_index != -1)
00640 Ipl_Summary_Symbol[_symbol_index].Print (f);
00641 else
00642 fputc ('\n', f);
00643
00644 }
00645
00646
00647 void
00648 SUMMARY_CHI::Print_array (FILE *f, INT32 size) const
00649 {
00650 fprintf(f, "%s (%s)\n", SBar,"Chi's");
00651 fprintf(f, " Chi Callsite Value\n");
00652 for (INT i = 0; i < size; i++) {
00653 fprintf (f, "[%5d] ", i);
00654 this[i].Print (f);
00655 }
00656
00657 }
00658
00659 void
00660 SUMMARY_EXPR::Print_node (FILE *f, INT kid) const
00661 {
00662 if (Is_expr_value (kid))
00663 fprintf (f, " V[%5d]", Get_node_index (kid));
00664 else if (Is_expr_phi (kid))
00665 fprintf (f, " P[%5d]", Get_node_index (kid));
00666 else if (Is_expr_expr (kid))
00667 fprintf (f, " E[%5d]", Get_node_index (kid));
00668 else if (Is_expr_chi (kid))
00669 fprintf (f, " C[%5d]", Get_node_index (kid));
00670
00671 }
00672
00673
00674 void
00675 SUMMARY_EXPR::Print (FILE *f) const
00676 {
00677 if (Is_expr_unknown ()) {
00678 fputs ("unknown\n", f);
00679 return;
00680 }
00681
00682 if (Has_const_operand ()) {
00683 if (Get_kid () == 0) {
00684 Print_node (f);
00685 if (OPCODE_nkids (Get_opcode ()) == 2)
00686 fprintf (f, " 0x%llx", Get_const_value ());
00687 } else {
00688 fprintf (f, " 0x%llx", Get_const_value ());
00689 Print_node (f);
00690 }
00691 } else {
00692
00693 Print_node (f, 0);
00694 Print_node (f, 1);
00695 }
00696
00697 fprintf (f, "%s ", Get_mtype () == MTYPE_UNKNOWN ?
00698 #if 0
00699 "?" : MTYPE_name (Get_mtype ()));
00700 #else
00701 "?" : " MTY_name NYI");
00702 #endif
00703
00704 fputs (Get_opcode() == OPCODE_UNKNOWN
00705 #if 0
00706 ? "<UNKNOWN>" : OPCODE_name (Get_opcode ()), f);
00707 #else
00708 ? "<UNKNOWN>" : " OPC_name NYI", f);
00709 #endif
00710
00711 if (Is_trip_count())
00712 fprintf(f, " <TRIP COUNT> ");
00713
00714 fprintf(f, "\n");
00715
00716 }
00717
00718
00719 void
00720 SUMMARY_EXPR::Print_array (FILE *f, INT32 size) const
00721 {
00722 fprintf(f, "%s (%s)\n", SBar, "Exprs");
00723 fprintf(f, " Expr Val/Expr Val/Expr Rettyp OperInfo\n");
00724 for (INT i = 0; i < size; i++) {
00725 fprintf (f, " [%5d]: ", i);
00726 this[i].Print (f);
00727 }
00728
00729 }
00730
00731
00732 void
00733 SUMMARY_PHI::Print (FILE *f) const
00734 {
00735 for (INT i = 0; i < 2; i++) {
00736 switch (kids[i]._type) {
00737 case PHI_UNKNOWN:
00738 fprintf (f, "UNKNOWN ");
00739 break;
00740 case PHI_VALUE:
00741 fprintf (f, "V[%5d] ", Get_node_index (i));
00742 break;
00743 case PHI_EXPR:
00744 fprintf (f, "E[%5d] ", Get_node_index (i));
00745 break;
00746 case PHI_PHI:
00747 fprintf (f, "PHI[%d] ", Get_node_index (i));
00748 break;
00749 case PHI_CHI:
00750 fprintf (f, "CHI[%d] ", Get_node_index (i));
00751 break;
00752 }
00753
00754 fprintf (f, "(if CTRL_DEP[%d] is %s) ", Get_ctrl_dep_index (i),
00755 Get_branch (i) ? "true" : "false");
00756 }
00757
00758 fputc ('\n', f);
00759
00760 }
00761
00762
00763 void
00764 SUMMARY_PHI::Print_array (FILE *f, INT32 size) const
00765 {
00766 fprintf (f, "%sStart phi array\n%s", SBar, SBar);
00767 for (INT i = 0; i < size; i++) {
00768 fprintf (f, "PHI[%d]: ", i);
00769 this[i].Print (f);
00770 }
00771 fprintf (f, "%sEnd phi array\n%s", SBar, SBar );
00772
00773 }
00774
00775
00776
00777 void
00778 SUMMARY_STMT::Print (FILE *f) const
00779 {
00780 switch (_stmt_type) {
00781 case STMT_EXPR:
00782 fprintf (f, "E[%9d]", Get_expr_index ());
00783 break;
00784 case STMT_VAR:
00785 fprintf(f, "S_Var ");
00786 Ipl_Summary_Symbol[Get_var_index()].Print (f);
00787 break;
00788 case STMT_CALL:
00789 fprintf (f, "CaSite[%4d]", Get_call_index ());
00790 break;
00791 case STMT_CD:
00792 fprintf (f, "C-Dep[%5d]", Get_cond_index ());
00793 break;
00794 case STMT_ARRAY_REF:
00795 fprintf (f, "Ary M_id %3d", Get_array_ref_map_id ());
00796 break;
00797 case STMT_STID:
00798 fprintf (f, "GlbSt[%5d]", Get_stid_index());
00799 break;
00800 default:
00801 fprintf(f, "UNK ");
00802 break;
00803 }
00804 }
00805
00806
00807 void
00808 SUMMARY_STMT::Print_array (FILE *f, INT32 size) const
00809 {
00810 fprintf(f, "%s (%s)\n", SBar, "Stmts");
00811 fprintf(f, " Stmt Type Stmt Type\n");
00812 for (INT i = 0; i < size; i++) {
00813 fprintf (f, "[%5d] ", i);
00814 this[i].Print (f);
00815 if ((i%2) == 1) {
00816 i++;
00817 fprintf (f, " [%5d] ", i);
00818 this[i].Print (f);
00819 }
00820 fprintf(f, "\n");
00821 }
00822
00823 }
00824
00825
00826
00827
00828 void
00829 SUMMARY_CONTROL_DEPENDENCE::Print (FILE *f) const
00830 {
00831 INT i;
00832
00833 if (Is_entry ()) {
00834 fprintf (f, "Entry pt:\n");
00835 fprintf (f, " Stmts, count %d: ", Get_true_count ());
00836 } if (Is_if_stmt ()) {
00837 fprintf (f, "If: map_id = %d, E[%d]\n", Get_map_id (),
00838 Get_expr_index ());
00839 fprintf (f, " True stmts, count %d: ", Get_true_count ());
00840 } else if (Is_do_loop ()) {
00841 fprintf (f, "Do[%4d]: map_id %d\n", Get_do_loop_index (),
00842 Get_map_id ());
00843 fprintf (f, " Loop Stmts, count %d: ", Get_true_count ());
00844 }
00845
00846 for (i = Get_true_stmt_index ();
00847 i < Get_true_stmt_index () + Get_true_count ();
00848 i++)
00849
00850 fprintf (f, "S[%d] ", i);
00851 fputc ('\n', f);
00852
00853 if (Is_if_stmt ()) {
00854 fprintf (f, " False stmts, count %d: ", Get_false_count ());
00855
00856 for (i = Get_false_stmt_index ();
00857 i < Get_false_stmt_index () + Get_false_count ();
00858 i++)
00859
00860 fprintf (f, "S[%d] ", i);
00861
00862 fputc ('\n', f);
00863 }
00864
00865 }
00866
00867 void
00868 SUMMARY_CONTROL_DEPENDENCE::Print_array (FILE *f, INT32 size) const
00869 {
00870 fprintf(f, "%s (%s)\n", SBar, "Control-Dep");
00871 fprintf(f, "Ctrl-Dep Type \n");
00872 for (INT i = 0; i < size; i++) {
00873 fprintf (f, " [%5d]: ", i);
00874 this[i].Print (f);
00875 }
00876
00877 }
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 const char *
00897 SUMMARY_SYMBOL::Get_Name ( void ) const
00898 {
00899 #if 0 // SC
00900
00901 if (Ipl_Summary_Symbol == NULL)
00902 return "";
00903 return ST_name (St_idx ());
00904 #else
00905 printf("Summary_sym::get_name NYI ");
00906 return "";
00907 #endif
00908 }
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926 void
00927 SUMMARY_SYMBOL::Print(FILE *fp,
00928 INT idx,
00929 char* symbol_name,
00930 char* function_name) const
00931 {
00932 INT32 id = -1;
00933
00934 #if 0 // SC
00935
00936 if ((Ipl_Summary_Symbol != NULL ) && (idx == -1)) {
00937 id = this - Ipl_Summary_Symbol;
00938 }
00939
00940 if (idx == -1)
00941 fprintf ( fp, "SYMBOL[%d] ", id );
00942 else
00943 fprintf( fp, "SYMBOL[F%d] ", Get_findex());
00944
00945 INT ss = 0;
00946 if (symbol_name != NULL && function_name != NULL) {
00947 ss = sprintf(Modref_Buf, " \"%s\":\"%s\"", symbol_name, function_name);
00948 } else if (ST_IDX_level(St_idx()) == GLOBAL_SYMTAB) {
00949 ss = sprintf(Modref_Buf, " \"%s\"", ST_name(St_idx()));
00950 }
00951 sprintf(&Modref_Buf[ss],
00952 " type = %s, %sLOCAL, %sSTATIC, %sPASSED(common), %s",
00953 Get_btype () == MTYPE_UNKNOWN ? "?" : MTYPE_name (Get_btype()),
00954 Is_local() ? "" : "non-",
00955 Is_static() ? "" : "non-",
00956 Is_parm() ? "" : "not " ,
00957 Is_common() ? "COMMON, ": "");
00958 fprintf (fp, "%s", Modref_Buf);
00959 #else
00960 INT ss = 0;
00961 sprintf(&Modref_Buf[ss], "Symbol_print NYI ");
00962 #endif // SC
00963
00964 if ( IPA_Trace_Mod_Ref ) {
00965 #if 0 // SC
00966 Ipl_record_tlog("MOD_REF", 0, "%s", Modref_Buf);
00967 #else
00968 printf("SYMBOL_Print NYI\n");
00969 #endif
00970 }
00971
00972 INT32 cc = 0;
00973 if (Is_common_block()) {
00974 fputs (" Cblk", fp);
00975 cc += sprintf(Modref_Buf + cc," Cblk");
00976 }
00977 if (Is_function()) {
00978 fputs (" Func", fp);
00979 cc += sprintf(Modref_Buf + cc," Func");
00980 }
00981 if (Is_imod()) {
00982 fputs (" IMod", fp);
00983 cc += sprintf(Modref_Buf + cc," IMod");
00984 }
00985 if (Is_dmod()) {
00986 fputs (" DMod", fp);
00987 cc += sprintf(Modref_Buf + cc," DMod");
00988 }
00989 if (Is_iref()) {
00990 fputs (" IRef", fp);
00991 cc += sprintf(Modref_Buf + cc," IRef");
00992 }
00993 if (Is_dref()) {
00994 fputs (" DRef", fp);
00995 cc += sprintf(Modref_Buf + cc," DRef");
00996 }
00997 if (Is_ikill()) {
00998 fputs (" IKill", fp);
00999 cc += sprintf(Modref_Buf + cc," IKill");
01000 }
01001 if (Is_dkill()) {
01002 fputs (" DKill", fp);
01003 cc += sprintf(Modref_Buf + cc," DKill");
01004 }
01005 if (Is_parm()) {
01006 fputs (" Parm", fp);
01007 cc += sprintf(Modref_Buf + cc," Parm");
01008 }
01009
01010 if (Is_formal()) {
01011 cc += sprintf (Modref_Buf+cc, " Formal[%d]", Get_findex ());
01012 fprintf (fp, " Formal[%d]", Get_findex ());
01013 }
01014 if (Is_cref()) {
01015 fputs (" CRef", fp);
01016 cc += sprintf(Modref_Buf+cc, " CRef");
01017 }
01018 if (Is_cdref_preg_only() ) {
01019 fputs (" CDrefPregOnly",fp);
01020 cc += sprintf(Modref_Buf+cc, " CDrefPregOnly");
01021 }
01022 if (Is_addr_saved() || Is_addr_f90_target() || Is_addr_passed()) {
01023 const char *sep = "";
01024 fputs (" Addr_taken_and", fp );
01025 cc += sprintf( Modref_Buf+cc, " Addr_taken_and ");
01026 if (Is_addr_saved()) {
01027 fprintf ( fp, "%sSaved", sep );
01028 cc += sprintf( Modref_Buf+cc, "%sSaved", sep);
01029 sep = "|";
01030 }
01031 if (Is_addr_f90_target()) {
01032 fprintf ( fp, "%sIS_F90_TARGET", sep );
01033 cc += sprintf( Modref_Buf+cc, "%sIS_F90_TARGET", sep);
01034 sep = "|";
01035 }
01036 if (Is_addr_passed()) {
01037 fprintf ( fp, "%sPassed", sep );
01038 cc += sprintf( Modref_Buf+cc, "%sPassed", sep);
01039 }
01040 }
01041 if (Used_in_array_section()) {
01042 fputs(" USED_IN_ARRAY_SECTION", fp);
01043 cc += sprintf( Modref_Buf+cc, " USED_IN_ARRAY_SECTION" );
01044 }
01045 if (Common_io_no_pad()) {
01046 fputs(" I/O", fp);
01047 cc += sprintf( Modref_Buf+cc, " I/O:NoPad" );
01048 }
01049 if (Common_read_no_cprop()) {
01050 fputs(" I/O", fp);
01051 cc += sprintf( Modref_Buf+cc, " NoCprop" );
01052 }
01053 fputc ('\n', fp );
01054 if ( IPA_Trace_Mod_Ref )
01055 #if 0 // SC
01056 Ipl_record_tlog("MOD_REF", 0, "%s", Modref_Buf);
01057 #else
01058 printf("SYMBOL_Print end NYI\n");
01059
01060 #endif
01061 }
01062
01063
01064
01065 void
01066 SUMMARY_SYMBOL::Trace () const
01067 {
01068 Print ( TFile );
01069 }
01070
01071
01072
01073
01074
01075 void
01076 SUMMARY_SYMBOL::Print_array (FILE* fp, INT32 size,
01077 DYN_ARRAY<char*>* symbol_names,
01078 DYN_ARRAY<char*>* function_names) const
01079 {
01080 INT32 i;
01081
01082 fprintf ( fp, "%sStart symbol array\n%s", SBar, SBar );
01083 for ( i = 0; i< size; ++i ) {
01084 this[i].Print ( fp,
01085 -1,
01086 symbol_names ? (*symbol_names)[i] : NULL,
01087 function_names ? (*function_names)[i] : NULL);
01088 }
01089 fprintf ( fp, "%sEnd symbol array\n%s", SBar, SBar );
01090 }
01091
01092
01093
01094 void
01095 SUMMARY_SYMBOL::Trace_array ( INT32 size ) const
01096 {
01097 Print_array ( TFile, size );
01098 }
01099
01100
01101
01102
01103
01104
01105
01106 void
01107 SUMMARY_GLOBAL::Print ( FILE *fp ) const
01108 {
01109 SUMMARY_SYMBOL *sym = &(Ipl_Summary_Symbol[Get_symbol_index()]);
01110
01111 fprintf ( fp, "%5d %5d ", Get_refcount(), Get_modcount());
01112
01113 if ( Is_imod() ) fprintf ( fp, " Imod ");
01114 if ( Is_dmod() ) fprintf ( fp, " Dmod ");
01115 if ( Is_iref() ) fprintf ( fp, " Iref ");
01116 if ( Is_dref() ) fprintf ( fp, " Dref ");
01117 if ( Is_aref() ) fprintf ( fp, " Aref ");
01118 if ( Is_ikill() ) fprintf ( fp, " Ikill ");
01119 if ( Is_dkill() ) fprintf ( fp, " Dkill");
01120 if ( sym->Is_cref() ) fprintf ( fp, " Cref ");
01121 if ( sym->Is_cmod() ) fprintf ( fp, " Cmod ");
01122 fprintf( fp, " %s", sym->Get_Name() );
01123
01124 fprintf ( fp, "\n" );
01125 }
01126
01127
01128
01129 void
01130 SUMMARY_GLOBAL::Trace ( void ) const
01131 {
01132 Print ( TFile );
01133 }
01134
01135
01136
01137
01138
01139 void
01140 SUMMARY_GLOBAL::Print_array (FILE* fp, INT32 size ) const
01141 {
01142 INT i;
01143
01144 fprintf ( fp, "%s (%s)\n", SBar, "Globals" );
01145 fprintf ( fp, " Global Refs Mods Types and Name\n" );
01146 for ( i = 0; i< size; ++i ) {
01147 fprintf ( fp, "[%5d]: ", i );
01148 this[i].Print ( fp );
01149 }
01150 }
01151
01152
01153
01154 void
01155 SUMMARY_GLOBAL::Trace_array ( INT32 size ) const
01156 {
01157 Print_array ( TFile, size );
01158 }
01159
01160
01161
01162
01163
01164
01165
01166 void
01167 SUMMARY_COMMON::Print ( FILE *fp, INT32 id ) const
01168 {
01169 fprintf ( fp, "COMMON[%d]: ", id );
01170
01171 if ( Is_initialized() )
01172 fprintf ( fp, ", initialized" );
01173
01174 if ( Has_bad_equiv() )
01175 fprintf ( fp, ", bad equivalence " );
01176
01177 if ( Has_bad_split_equiv() )
01178 fprintf ( fp, ", bad split equivalence " );
01179 else
01180 fprintf ( fp, ", not bad split equivalence ");
01181
01182 if ( Has_array_constants() )
01183 fprintf ( fp, ", array constants " );
01184 else
01185 fprintf ( fp, ", no array constants ");
01186
01187 if ( Has_equivalences() )
01188 fprintf ( fp, ", equivalences " );
01189 else
01190 fprintf ( fp, ", no equivalences " );
01191
01192 if (Has_unstructured_cflow())
01193 fprintf( fp, ", unstructured cflow ");
01194 else
01195 fprintf( fp, ", no unstructured cflow ");
01196
01197 fprintf(fp, "\n");
01198
01199 fprintf ( fp, ", common shape index = %d, common shape count = %d \n",
01200 Get_common_shape_index(), Get_common_shape_count() );
01201
01202 if ( Ipl_Summary_Symbol ) {
01203 Ipl_Summary_Symbol[Get_symbol_index()].Print ( fp );
01204 }
01205 }
01206
01207
01208
01209 void
01210 SUMMARY_COMMON::Trace ( INT32 id ) const
01211 {
01212 Print ( TFile, id );
01213 }
01214
01215
01216 void
01217 SUMMARY_COMMON::Print_array (FILE* fp, INT32 size ) const
01218 {
01219 INT i;
01220
01221 fprintf ( fp, "%sStart common array\n%s", SBar, SBar );
01222 for ( i=0; i<size; ++i ) {
01223 this[i].Print ( fp, i );
01224 }
01225 fprintf ( fp, "%sEnd common array \n%s", SBar, SBar );
01226 }
01227
01228
01229
01230
01231 void
01232 SUMMARY_STID::Print ( FILE *fp, INT32 id ) const
01233 {
01234 fprintf ( fp, "GLOBAL_STID[%d]: ", id );
01235 fprintf ( fp, "symbol index = %d, value index = %d",
01236 Get_symbol_index(), Get_value_index() );
01237 if ( Is_always_executed() )
01238 fprintf ( fp, ", always executed");
01239 if ( Is_array_assignment() ) {
01240 fprintf ( fp, ", array assignment");
01241 if ( Has_constant_subscript() )
01242 fprintf ( fp, ", constant subscript = %d", Get_array_subscript());
01243 else
01244 fprintf ( fp, ", non-constant subscript");
01245 }
01246 fprintf(fp, "\n");
01247 if ( Ipl_Summary_Symbol && Get_symbol_index() != -1 )
01248 Ipl_Summary_Symbol[Get_symbol_index()].Print ( fp );
01249 }
01250
01251
01252 void
01253 SUMMARY_STID::Trace ( INT32 id ) const
01254 {
01255 Print ( TFile, id );
01256 }
01257
01258
01259 void
01260 SUMMARY_STID::Print_array (FILE* fp, INT32 size ) const
01261 {
01262 INT i;
01263
01264 fprintf ( fp, "%sStart STID COMMON array\n%s", SBar, SBar );
01265 for ( i=0; i<size; ++i ) {
01266 this[i].Print ( fp, i );
01267 }
01268 fprintf ( fp, "%sEnd STID COMMON array \n%s", SBar, SBar );
01269 }
01270
01271 void
01272 SUMMARY_STID::Trace_array ( INT32 size ) const
01273 {
01274 Print_array ( TFile, size );
01275 }
01276
01277
01278
01279 void
01280 SUMMARY_COMMON_SHAPE::Print ( FILE *fp, INT32 id ) const
01281 {
01282 fprintf ( fp, "COMMON_SHAPE[%d]: ", id );
01283
01284 if ( Is_kind_array() )
01285 fprintf ( fp, " array" );
01286
01287 if ( Is_kind_scalar() ) {
01288 fprintf ( fp, " scalar, element size = %d, offset = %lld, symbol_id = %d \n", Get_element_size(), Get_offset(), Get_symbol_index());
01289 }
01290
01291 if ( Is_symbolic_bounds() )
01292 fprintf ( fp, ", symbolic bounds \n" );
01293
01294 if (Is_kind_array() && (!Is_symbolic_bounds()))
01295 fprintf (fp,
01296 ", upper = %d, lower = %d, stride = %d, element_size= %d, symbol_id = %d \n",Get_upper(), Get_lower(), Get_stride(),Get_element_size(), Get_symbol_index() );
01297 }
01298
01299
01300
01301
01302 void
01303 SUMMARY_COMMON_SHAPE::Trace ( INT32 id ) const
01304 {
01305 Print ( TFile, id );
01306 }
01307
01308 void
01309 SUMMARY_COMMON_SHAPE::Print_array (FILE* fp, INT32 size ) const
01310 {
01311 INT i;
01312
01313 fprintf ( fp, "%sStart common shape array\n%s", SBar, SBar );
01314 for ( i=0; i<size; ++i ) {
01315 this[i].Print ( fp, i );
01316 }
01317 fprintf ( fp, "%sEnd common shape array \n%s", SBar, SBar );
01318 }
01319
01320
01321
01322 void
01323 SUMMARY_COMMON_SHAPE::Trace_array ( INT32 size ) const
01324 {
01325 Print_array ( TFile, size );
01326 }
01327
01328
01329 void
01330 SUMMARY_STRUCT_ACCESS::Print ( FILE *fp, INT32 id ) const
01331 {
01332 UINT i;
01333 #if 0 // SC
01334 fprintf ( fp, "FLD ACCESS [%d]: name:%s ", id,Get_ty_name() );
01335 for(i=0; i<max_hot_num;i++){
01336 if(Get_hot_fld_id(i)==0)
01337 break;
01338 fprintf ( fp, " field_id= %d, count = %lld \n", Get_hot_fld_id(i),Get_hot_fld(i));
01339 }
01340 #else
01341 fprintf(fp, "SUMMARY_STRUCT_ACCESS::Print NYI\n");
01342 #endif
01343 }
01344 void
01345 SUMMARY_STRUCT_ACCESS::Trace_array ( INT32 size ) const
01346 {
01347 Print_array ( TFile, size );
01348 }
01349 void
01350 SUMMARY_STRUCT_ACCESS::Print_array (FILE* fp, INT32 size ) const
01351 {
01352 INT i;
01353
01354 fprintf ( fp, "%sStart fld access array\n%s", SBar, SBar );
01355 for ( i=0; i<size; ++i ) {
01356 this[i].Print ( fp, i );
01357 }
01358 fprintf ( fp, "%sEnd fld access array \n%s", SBar, SBar );
01359 }
01360 void
01361 SUMMARY_STRUCT_ACCESS::Trace ( INT32 id ) const
01362 {
01363 Print ( TFile, id );
01364 }
01365
01366 #ifdef KEY
01367 void
01368 SUMMARY_TY_INFO::Print ( FILE *fp ) const
01369 {
01370 fprintf ( fp, "TYPE [%d]: ", Get_ty() );
01371 if (Is_ty_no_split()) fprintf ( fp, "no_split " );
01372
01373 fprintf ( fp, "\n");
01374 }
01375
01376 void
01377 SUMMARY_TY_INFO::Print_array (FILE* fp, INT32 size ) const
01378 {
01379 fprintf ( fp, "%sStart type array\n%s", SBar, SBar );
01380 for ( INT i=0; i<size; ++i ) {
01381 this[i].Print ( fp );
01382 }
01383 fprintf ( fp, "%sEnd type array \n%s", SBar, SBar );
01384 }
01385
01386 void
01387 SUMMARY_TY_INFO::Trace_array ( INT32 size ) const
01388 {
01389 Print_array ( TFile, size );
01390 }
01391
01392 void
01393 SUMMARY_TY_INFO::Trace ( void ) const
01394 {
01395 Print ( TFile );
01396 }
01397 #endif
01398
01399