Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
ipa_section_print.cxx
Go to the documentation of this file.
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 //* -*-Mode: c++;-*- (Tell emacs to use c++ mode) */
00037 //
00038 // ====================================================================
00039 // ====================================================================
00040 //
00041 // $Author:
00042 // $Source:
00043 //
00044 // Revision history:
00045 //  30-JAN-97 - Original Version
00046 //
00047 // Description:
00048 //
00049 // This module contains the IPA array section summary 
00050 // file related print routines
00051 //
00052 // ====================================================================
00053 // ====================================================================
00054 
00055 #include <elf.h>
00056 #include <sys/elf_whirl.h>
00057 #include <sys/types.h>
00058 
00059 #include "defs.h"
00060 #include "ipa_section.h"
00061 #include "ipl_summary.h"
00062 
00063 #ifndef IPA_SUMMARY
00064 
00065 #include "ipc_file.h"           // IP_FILE_HDR
00066 #include "ipc_symtab_merge.h"   // Aux_Pu_Table
00067 #include "ipo_defs.h"           // IPA_NODE_CONTEXT
00068 #include "ipa_section_main.h"   // IPA_Ivar_Count, IPA_Ivar_Global_Count
00069 
00070 
00071 // file static arrays used to get access to summary 
00072 // information when print methods are invoked from IPA
00073 static SUMMARY_SYMBOL* IPA_Symbol = NULL;
00074 
00075 void
00076 Init_IPA_Print_Arrays (IPA_NODE* node)
00077 {
00078   IPA_Symbol = IPA_get_symbol_array (node);
00079   IPA_get_ivar_array (node, IPA_Ivar_Count);
00080 }
00081 
00082 static char* 
00083 Symbol_Name(SUMMARY_SYMBOL* ss)
00084 {
00085   if (ST_IDX_level(ss->St_idx()) > GLOBAL_SYMTAB) {
00086     ST_IDX func_st_idx = ss->Get_st_idx_func();
00087     PU_IDX pu_idx = ST_pu(&St_Table[func_st_idx]);
00088     NODE_INDEX node_index = AUX_PU_node(Aux_Pu_Table[pu_idx]);
00089     IPA_NODE* cnode = IPA_Call_Graph->Graph()->Node_User(node_index);
00090     IPA_NODE_CONTEXT context(cnode);
00091     return ST_name(ss->St_idx());
00092   } 
00093   else {
00094     return ST_name(St_Table[ss->St_idx()]);
00095   }
00096 }
00097 
00098 #else
00099 
00100 #include "ipl_summarize.h"
00101 
00102 extern SUMMARY *Summary;
00103 extern IVAR_ARRAY *Ivar;
00104 
00105 #endif
00106 
00107 //===================================================================
00108 //      Print the loop info
00109 //===================================================================
00110 void LOOPINFO::Print_file(FILE *fp)
00111 {
00112   if (Is_messy_ub())
00113     fprintf(fp, "messy upper, ");
00114   else
00115     fprintf(fp, "not messy upper, ");
00116   
00117   if (Is_messy_lb())
00118     fprintf(fp, "messy lower, ");
00119   else
00120     fprintf(fp, "not messy lower, ");
00121 
00122   if (Is_messy_step())
00123     fprintf(fp, "messy step, ");
00124   else
00125     fprintf(fp, "not messy step, ");
00126   
00127   if (Is_messy_bounds())
00128     fprintf(fp, "messy bounds \n");
00129 
00130   fprintf(fp, "nest-level = %d \n", Get_nest_level());
00131 
00132   fprintf(fp, "Lower bound terms: term array index = %d , count = %d \n", 
00133           Get_lb_term_index(), Get_lb_term_count());
00134 
00135   fprintf(fp, "Upper bound terms: term array index = %d , count = %d \n", 
00136           Get_ub_term_index(), Get_ub_term_count());
00137 
00138   fprintf(fp, "Step bound terms: term array index = %d , count = %d \n", 
00139           Get_step_term_index(), Get_step_term_count());          
00140 
00141 }
00142 
00143 //===================================================================
00144 //      Print the region arrays information as written out to file, with
00145 //      the index, size information
00146 //===================================================================
00147 void
00148 REGION_ARRAYS::Print_file(FILE* fp)
00149 {
00150   if (Is_bad_alias())
00151     fprintf(fp, "Has bad alias, ");
00152   if (Is_loop_invariant())
00153     fprintf(fp, "Is loop invariant, ");
00154   if (Is_use())
00155     fprintf(fp, "Is_use, ");
00156   else if (Is_def())
00157     fprintf(fp, "Is_def, ");
00158   else if (Is_passed())
00159     fprintf(fp, "Is_passed, ");
00160   else if (Is_may_def())
00161     fprintf(fp, "Is_may_def, ");
00162   else if (Is_may_use())
00163     fprintf(fp, "Is_may_use, ");
00164   else if (Is_formal())
00165     fprintf(fp, "Is_formal, ");
00166   else
00167     fprintf(fp, "UNKNOWN type. ");
00168 
00169   fprintf(fp, "\nSymbol id = %d \n", _sym_index);
00170   fprintf(fp, "Element size = %d \n", _element_size);
00171 
00172   fprintf(fp, "Id into PROJECTED_REGION_ARRAY = %d, count = %d \n", 
00173           Get_idx(), Get_count());
00174 }
00175 
00176 //===================================================================
00177 //      Print the projected node information as written out to file, with
00178 //      index and size information
00179 //===================================================================
00180 void
00181 PROJECTED_NODE::Print_file(FILE *fp)
00182 {
00183   fprintf(fp, "%smessy lower, ", Is_messy_lb() ? "" : "non-");
00184   fprintf(fp, "%smessy upper, ", Is_messy_ub() ? "" : "non-");
00185   fprintf(fp, "%smessy step, ", Is_messy_step() ? "" : "non-");
00186   fprintf(fp, "%sprojected", Is_unprojected() ? "NOT" : "");
00187   if (Is_assumed_shape()) 
00188     fprintf(fp, ", assumed_shape");
00189   fprintf(fp, "\n terms in lower: idx = %d, count = %d\n", 
00190           Get_lb_term_index(), Get_lb_term_count());
00191   fprintf(fp, " terms in upper: idx = %d, count = %d\n", 
00192           Get_ub_term_index(), Get_ub_term_count());
00193   fprintf(fp, " terms in step:  idx = %d, count = %d \n", 
00194           Get_step_term_index(), Get_step_term_count());
00195   if (Get_segment_length_term_count() > 0)
00196     fprintf(fp, " terms in segment length: idx = %d, count = %d\n", 
00197             Get_segment_length_term_index(), Get_segment_length_term_count());
00198   if (Get_segment_stride_term_count() > 0)
00199     fprintf(fp, " terms in segment stride: idx = %d, count = %d\n", 
00200             Get_segment_stride_term_index(), Get_segment_stride_term_count());
00201 }
00202 
00203 //===================================================================
00204 //      Print the control flow information as written out to file, with
00205 //      index and size information
00206 //===================================================================
00207 void
00208 CFG_NODE_INFO::Print_file(FILE *fp)
00209 {
00210   if (Is_do_loop()) {
00211     fprintf(fp, "TYPE: CFG_DO_LOOP, loopinfo index = %d", Get_loop_index());
00212     if (Is_executed()) {
00213       fprintf(fp, "ALWAYS executed");
00214     }
00215     fprintf(fp, "\n");
00216   }
00217   else if (Is_if()) {
00218     fprintf(fp, "TYPE: CFG_IF\n");
00219     fprintf(fp, "ELSE cfg node index = %d \n", Get_else_index());
00220   }
00221   else if (Is_else()) {
00222     fprintf(fp, "TYPE: CFG_ELSE \n");
00223     fprintf(fp, "IF cfg node index = %d \n", Get_if_index());
00224   }
00225   else if (Is_entry()) {
00226     fprintf(fp, "TYPE: CFG_ENTRY \n");
00227   }
00228   else {
00229     fprintf(fp, "TYPE: UNKNOWN \n");
00230   }
00231 
00232   fprintf(fp, "Control Dependence Index: %d\n", Get_cd_index());
00233 
00234   if (Has_calls()) {
00235     fprintf(fp, "Has calls \n");
00236   }
00237 
00238   // print all the array kills
00239   fprintf(fp,"array kills: offset into REGIONS_ARRAY = %d, count = %d\n", 
00240           Get_def_index(), Get_def_count());
00241 
00242   // print all the array uses
00243   fprintf(fp, "array uses: offset into REGIONS_ARRAY = %d, count = %d\n", 
00244           Get_use_index(), Get_use_count());
00245 
00246   // print all the parameter array sections
00247   fprintf(fp,"array params: offset into REGIONS_ARRAY = %d, count = %d\n",
00248           Get_param_index(), Get_param_count());
00249 
00250   // print all the formal array sections
00251   fprintf(fp,"array formals: offset into REGIONS_ARRAY = %d, count = %d\n",
00252           Get_formal_index(), Get_formal_count());
00253 
00254   // print all the scalar 
00255   fprintf(fp, "scalar info: offset into INT_ARRAY = %d, count = %d \n", 
00256           Get_scalar_index(), Get_scalar_count());
00257 }
00258 
00259 //===================================================================
00260 //      Print the projected region information as written out to file, with
00261 //      index and size information
00262 //===================================================================
00263 void 
00264 PROJECTED_REGION::Print_file(FILE *fp)
00265 {
00266   if (Is_messy_region())
00267     fputs("messy region", fp);
00268   else
00269     fputs("non-messy region", fp);
00270 
00271   if (Is_unprojected_region())
00272     fputs(", unprojected region, ", fp);
00273   else
00274     fputs(", projected region, ", fp);
00275 
00276   fprintf(fp, "num dims = %d, depth = %d \n", Get_num_dims(), Get_depth());
00277 
00278   if (Is_passed())
00279     fprintf(fp, "parameter array section, callsite_id = %d, actual_pos = %d\n",
00280             Get_callsite_id(), Get_actual_id());
00281 
00282   fprintf(fp, "id into projected node array = %d \n", Get_id());
00283 }
00284 
00285 //====================================================================
00286 //       Print the linex array, which is simply a linear expression 
00287 //====================================================================
00288 void
00289 LINEX::Print_file(FILE* fp)
00290 {
00291   for (INT i = 0; i < _larray.Elements(); ++i) {
00292     _larray[i].Print_file(fp);
00293   }
00294 }
00295 
00296 //====================================================================
00297 //      Print a linex array, which is simply a linear expression
00298 //====================================================================
00299 void
00300 LINEX::Print(FILE *fp)
00301 {
00302 #ifdef IPA_SUMMARY
00303   if (Trace_Sections) {
00304     if (_larray.Lastidx() == -1) { 
00305       fprintf(TFile, "NULL linex \n");
00306       fprintf(stdout, "NULL linex \n");
00307     } 
00308   }
00309 #endif
00310   for (INT i = 0; i <= _larray.Lastidx(); ++i) {
00311     _larray[i].Print(fp, FALSE);
00312     if (i < _larray.Lastidx()) {
00313       fprintf(fp, "+");
00314     }
00315   }
00316 }
00317 
00318 //
00319 //====================================================================
00320 //       Print an ivar
00321 // ====================================================================
00322 void 
00323 IVAR::Print (FILE* fp)
00324 {
00325   fprintf(fp, "IVAR: ");
00326   if (Is_Formal()) {
00327     fprintf(fp, "FORMAL_POSITION = %d, OFFSET = %d, MTYPE = %s\n",
00328             Formal_Position(), Offset(), Machine_Types[Mtype()].name);
00329   }
00330   else {
00331     fprintf(fp, "GLOBAL %s, OFFSET = %d, MTYPE = %s\n",
00332             ST_name(St_Idx()), Offset(), Machine_Types[Mtype()].name);
00333   }
00334 }
00335 
00336 //-----------------------------------------------------------------------
00337 // NAME: IVAR::IPA_LNO_Print_File
00338 // FUNCTION: Print the IVAR at index 'ivar_index' to file 'fp' in a format 
00339 //   compatible for the IPA_LNO_WRITE trace. 
00340 //-----------------------------------------------------------------------
00341 
00342 void IVAR::IPA_LNO_Print_File(FILE* fp, INT ivar_index)
00343 {
00344   fprintf(fp, "IVAR");
00345   if (ivar_index == -1) {
00346     fprintf(fp, ":");
00347   }
00348   else {
00349     fprintf(fp, "[%d]:", ivar_index);
00350   }
00351   if (Is_Formal()) {
00352     fprintf(fp, "FORMAL_POSITION = %d, OFFSET = %d, MTYPE = %s\n",
00353             Formal_Position(), Offset(), Machine_Types[Mtype()].name);
00354   }
00355   else {
00356     fprintf(fp, "GLOBAL %s, OFFSET = %d, MTYPE = %s\n",
00357             ST_name(St_Idx()), Offset(), Machine_Types[Mtype()].name);
00358   }
00359 } 
00360 
00361 //====================================================================
00362 //       Print a TERM of a linex array
00363 // ====================================================================
00364 void
00365 TERM::Print(FILE *fp, BOOL newline)
00366 {
00367   switch (Get_type()) {
00368   
00369   case LTKIND_NONE:
00370     fprintf(fp,"?");
00371     break;
00372 
00373   case LTKIND_CONST:
00374     fprintf(fp,"%d", Get_coeff());
00375     break;
00376 
00377   case LTKIND_LINDEX:
00378     fprintf(fp,"loop_index(%d)*%d", Get_desc(), Get_coeff());
00379     break;
00380 
00381   case LTKIND_SUBSCR:
00382     fprintf(fp,"dim(%d)*%d", Get_desc(), Get_coeff());
00383     break;
00384 
00385   case LTKIND_IV:
00386     fprintf(fp,"IVAR[%d]*%d", Get_desc(), Get_coeff());
00387     break;
00388   }
00389   
00390   if (newline) {
00391     fprintf(fp, "\n");
00392   }
00393 }
00394 
00395 // ====================================================================
00396 //      Print a linex term to a file
00397 // ====================================================================
00398 void 
00399 TERM::Print_file (FILE* fp)
00400 {
00401   switch (Get_type())
00402     {
00403     case LTKIND_NONE:
00404       fprintf(fp,"unknown TERM\n");
00405       break;
00406 
00407     case LTKIND_CONST:
00408       fprintf(fp,"CONST:+ %d\n", Get_coeff());
00409       break;
00410 
00411     case LTKIND_LINDEX:
00412       fprintf(fp,"LINDEX: + loop_index(%d)*%d\n", Get_desc(), Get_coeff());
00413       break;
00414 
00415     case LTKIND_SUBSCR:
00416       fprintf(fp,"SUBSCR: + dim(%d)*%d\n", Get_desc(), Get_coeff());
00417       break;
00418 
00419     case LTKIND_IV:
00420       fprintf(fp,"IVAR: + IVAR[%d]*%d\n", Get_desc(), Get_coeff());
00421       break;
00422 
00423     default:
00424       fprintf(fp, "UNKNOWN TYPE:%d  something is wrong\n", Get_type());
00425       break;
00426     }
00427 }
00428 
00429 //-----------------------------------------------------------------------
00430 // NAME: TERM::IPA_LNO_Print_File
00431 // FUNCTION: Print the TERM at index 'term_index' to file 'fp' in a format 
00432 //   compatible for the IPA_LNO_WRITE trace. 
00433 //-----------------------------------------------------------------------
00434 
00435 void TERM::IPA_LNO_Print_File(FILE* fp, 
00436                               INT term_index)
00437 { 
00438   if (term_index == -1)
00439     fprintf(fp, "TERM: ");
00440   else 
00441     fprintf(fp, "TERM[%d]: ", term_index);
00442   switch (Get_type()) {
00443   case LTKIND_NONE:
00444     fprintf(fp, "NONE ");
00445     break;
00446   case LTKIND_CONST:
00447     fprintf(fp, "CONST(%d)", Get_coeff());
00448     break;
00449   case LTKIND_LINDEX:
00450     fprintf(fp, "LINDEX(%d) * (%d) ", Get_desc(), Get_coeff());
00451     break;
00452   case LTKIND_SUBSCR:
00453     fprintf(fp, "SUBSCR(%d) * (%d) ", Get_desc(), Get_coeff());
00454     break;
00455   case LTKIND_IV:
00456     fprintf(fp, "IVAR[%d] * (%d) ", Get_desc(), Get_coeff());
00457     break;
00458   default:
00459     fprintf(fp, " ");
00460     break;
00461   }
00462   fprintf(fp, "\n");
00463 } 
00464 
00465 //====================================================================
00466 //       Print the information written out to file
00467 //====================================================================
00468 void 
00469 SCALAR_INFO::Print_file(FILE *fp)
00470 {
00471   fprintf(fp, "SCALAR_INFO: ");
00472   fprintf(fp, "id:%d, call_id:%d, TYPE: ", Get_id(), Get_callsite_id());
00473   if (Is_may_kill())
00474     fprintf(fp, "may kill: ");
00475   if (Is_may_use())
00476     fprintf(fp, "may use: ");
00477   if (Is_may_reduc())
00478     fprintf(fp, "may reduc: ");
00479   if (Is_kill())
00480     fprintf(fp, "kill: ");
00481   if (Is_use())
00482     fprintf(fp, "use: ");
00483   if (Is_euse())
00484     fprintf(fp, "euse: ");
00485   if (Is_call_euse())
00486     fprintf(fp, "call euse: ");
00487   if (Is_reduc())
00488     fprintf(fp, "reduc: ");
00489   if (Is_array_reduc())
00490     fprintf(fp, "array reduc: ");
00491   if (Is_array_may_reduc())
00492     fprintf(fp, "may array reduc: ");
00493   if (Is_passed_ref())
00494     fprintf(fp, "passed ref: ");
00495   if (Is_may_passed_ref())
00496     fprintf(fp, "may passed ref: ");
00497   fprintf(fp, "\n");
00498 }
00499 //===================================================================
00500 //      Print the projected kernel
00501 //===================================================================
00502 void PROJECTED_KERNEL::Print(FILE *fp)
00503 {
00504   INT i;
00505 
00506   fprintf(fp, "+++++PROJECTED_KERNEL_START+++++\n");
00507 
00508   if (Is_messy_kernel())
00509     fprintf(fp, "messy, ");
00510   else
00511     fprintf(fp, "non-messy, ");
00512 
00513   if (Is_projected())
00514     fprintf(fp, "projected, ");
00515   else
00516     fprintf(fp, "unprojected, ");
00517 
00518   fprintf(fp, "num dims = %d, ", Get_num_dims());
00519   fprintf(fp, "depth = %d, ", Get_depth());
00520   fprintf(fp, "proj level = %d ", Get_projected_level());
00521   fprintf(fp, "\n");
00522 
00523   // check for is independent
00524   fprintf(fp, "is_independent = [");
00525   for (i = 0; i < Get_depth(); i++) {
00526     if (Is_independent(i))
00527       fprintf(fp, "TRUE");
00528     else 
00529       fprintf(fp, "FALSE");
00530     if (i < Get_depth() - 1)
00531       fprintf(fp, ",");
00532   } 
00533   fprintf(fp, "]\n");
00534   for (i=0; i < Get_num_dims(); ++i) {
00535     LINEX *l;
00536     if (l = Get_linex(i)) {
00537       fprintf(fp, "input_linex[%d] = ", i);
00538       l->Print(fp);
00539       fprintf(fp, "\n");
00540     }
00541   }
00542   if (Get_region() != NULL)
00543     fprintf(fp, "region = 0x%p\n", Get_region());
00544   for (i = 0; i < Get_num_dims(); i++) {
00545     LINEX *l;
00546     if (l = Get_Difference(i)) { 
00547       fprintf(fp, "difference[%d] = ", i);
00548       l->Print(fp); 
00549       fprintf(fp, "\n");
00550     }
00551   }
00552   fprintf(fp, "+++++PROJECTED_KERNEL_FINISHED+++++\n");
00553 }
00554 
00555 //===================================================================
00556 //      Print the loop info
00557 //===================================================================
00558 void LOOPINFO::Print(FILE *fp)
00559 {
00560   LINEX *l;
00561   INT i;
00562 
00563   fprintf(fp, "\n+++++LOOPINFO_START+++++\n");
00564   if (Is_messy_ub())
00565     fprintf(fp, "messy upper, ");
00566   else
00567     fprintf(fp, "not messy upper, ");
00568   
00569   if (Is_messy_lb())
00570     fprintf(fp, "messy lower, ");
00571   else
00572     fprintf(fp, "not messy lower, ");
00573 
00574   if (Is_messy_step())
00575     fprintf(fp, "messy step, ");
00576   else
00577     fprintf(fp, "not messy step, ");
00578   
00579   if (Is_messy_bounds())
00580     fprintf(fp, "messy bounds \n");
00581 
00582   fprintf(fp, "nest-level = %d\n", Get_nest_level());
00583 
00584   l = Get_lower_linex();
00585   if (l)
00586     {
00587       fprintf(fp, "\n Lower bound linex \n");
00588       l->Print(fp);
00589     }
00590   else
00591     fprintf(fp, "\n NULL lower bound linex \n");
00592 
00593 
00594   l = Get_upper_linex();
00595   if (l) 
00596     {
00597       fprintf(fp, "\n Upper bound linex \n");
00598       l->Print(fp);
00599     }
00600   else
00601     fprintf(fp, "\n NULL upper bound linex \n");
00602 
00603 
00604   l = Get_step_linex();
00605   if (l)
00606     {
00607       fprintf(fp, "\n Step linex \n");
00608       l->Print(fp);
00609     }
00610   else
00611     fprintf(fp, "\n NULL step linex \n");
00612 
00613   if (Get_kernels() != NULL)
00614     {
00615       PROJECTED_KERNEL_ARRAY *k = Get_kernels();
00616       for (i=0; i<k->Lastidx();++i)
00617         {
00618           PROJECTED_KERNEL* kernel = &(*k)[i];
00619           kernel->Print(fp);
00620         }
00621     }
00622 
00623   fprintf(fp, "+++++LOOPINFO_FINISHED+++++\n");
00624 }
00625 
00626 
00627 //===================================================================
00628 //       Print the projected node
00629 //===================================================================
00630 void PROJECTED_NODE::Print(FILE* fp)
00631 {
00632   LINEX* l;
00633 
00634   fprintf(fp, "[");
00635 
00636   if (Is_messy_lb()) {
00637     fprintf(fp, "messy");
00638   }
00639   else if (l = Get_lower_linex()) {
00640     l->Print(fp);
00641   }
00642   else {
00643     fprintf(fp, "?");
00644   }
00645 
00646   fprintf(fp, ":");  
00647 
00648   if (Is_messy_ub()) {
00649     fprintf(fp, "messy");
00650   }
00651   else if (l = Get_upper_linex()) {
00652     l->Print(fp);
00653   }
00654   else {
00655     fprintf(fp, "?");
00656   }
00657 
00658   fprintf(fp, ":");  
00659 
00660   if (Is_messy_step()) {
00661     fprintf(fp, "messy");
00662   }
00663   else if (l = Get_step_linex()) {
00664     l->Print(fp);
00665   }
00666   else {
00667     fprintf(fp, "?");
00668   }
00669 
00670   if (Get_segment_length_linex() && Get_segment_stride_linex()) {
00671     fprintf(fp, ":");
00672     Get_segment_length_linex()->Print(fp);
00673     fprintf(fp, ":");
00674     Get_segment_stride_linex()->Print(fp);
00675   }
00676 
00677   fprintf(fp, "]");  
00678   fflush(fp);
00679 }
00680 
00681 //-----------------------------------------------------------------------
00682 // NAME: PROJECTED_NODE::IPA_LNO_Print_File
00683 // FUNCTION: Print the PROJECTED_NODE at index 'pn_index' to file 'fp' 
00684 //   in a format compatible for the IPA_LNO_WRITE trace. 
00685 //-----------------------------------------------------------------------
00686 
00687 void PROJECTED_NODE::IPA_LNO_Print_File(FILE* fp, 
00688                                         INT pn_index)
00689 { 
00690   if (pn_index == -1)
00691     fprintf(fp, "PROJ_NODE: ");
00692   else 
00693     fprintf(fp, "PROJ_NODE[%d]: ", pn_index);
00694   if (Is_unprojected()) {
00695     fprintf(fp, "<UNPROJECTED> TERM[%d:%d] ",
00696       Get_lb_term_index(), Get_lb_term_count());
00697   } else {
00698     if (Is_messy_lb())
00699       fprintf(fp, "LB <MESSY> ");
00700     else
00701       fprintf(fp, "LB TERM[%d:%d] ", Get_lb_term_index(),
00702         Get_lb_term_count());
00703     if (Is_messy_ub())
00704       fprintf(fp, "UB <MESSY> ");
00705     else
00706       fprintf(fp, "UB TERM[%d:%d] ", Get_ub_term_index(),
00707         Get_ub_term_count());
00708     if (Is_messy_step())
00709       fprintf(fp, "STEP <MESSY> ");
00710     else
00711       fprintf(fp, "STEP TERM[%d:%d] ", Get_step_term_index(),
00712         Get_step_term_count());
00713     fprintf(fp, "\n  ");
00714     fprintf(fp, "SEG LEN TERM[%d:%d] ", Get_segment_length_term_index(),
00715       Get_segment_length_term_count());
00716     fprintf(fp, "SEG STR TERM[%d:%d] ", Get_segment_stride_term_index(),
00717       Get_segment_stride_term_count());
00718   }
00719   if (Is_assumed_shape())
00720     fprintf(fp, "<ASSUMED_SHAPE> ");
00721   fprintf(fp, "\n");
00722 } 
00723 
00724 //===================================================================
00725 //      Print the projected region
00726 //===================================================================
00727 void PROJECTED_REGION::Print(FILE *fp)
00728 {
00729   if (Is_unprojected_region()) {
00730     fprintf(fp, "UN-");
00731   }
00732   fprintf(fp, "PROJECTED_REGION: ");
00733 
00734   if (Is_messy_region()) {
00735     fprintf(fp, "messy region");
00736   }
00737   else {
00738     PROJECTED_ARRAY* pa = Get_projected_array();
00739     if (pa && pa != (void*)-1) {
00740       for (INT i = 0; i < Get_num_dims(); ++i) {
00741         Get_projected_node(i)->Print(fp);
00742       } 
00743     }
00744   }
00745 
00746   fprintf(fp, "  depth = %d\n", Get_depth());
00747 
00748 #ifdef IPA_SUMMARY  
00749   if (Is_passed())
00750     fprintf(fp, "parameter array section, callsite_id = %d, actual_pos = %d\n",
00751             Get_callsite_id(), Get_actual_id());
00752   fprintf(fp, "\n");
00753 
00754 // projected kernel exists in the case of the summary phase
00755   PROJECTED_KERNEL* p;
00756   if (p = Get_projected_kernel()) 
00757     p->Print(fp);
00758   fprintf(fp, "\n");
00759 #endif
00760 }
00761 
00762 //-----------------------------------------------------------------------
00763 // NAME: PROJECTED_REGION::IPA_LNO_Print_File
00764 // FUNCTION: Print the PROJECTED_REGION at index 'pr_index' to file 'fp' 
00765 //   in a format compatible for the IPA_LNO_WRITE trace. 
00766 //-----------------------------------------------------------------------
00767 
00768 void PROJECTED_REGION::IPA_LNO_Print_File(FILE* fp, 
00769                                           INT pr_index)
00770 {
00771   if (pr_index == -1)
00772     fprintf(fp, "PROJ_REGION: ");
00773   else 
00774     fprintf(fp, "PROJ_REGION[%d]: ", pr_index);
00775   fprintf(fp, "PROJ_NODE[%d:%d] ", Get_id(),
00776     Get_num_dims());
00777   fprintf(fp, "DEPTH(%d) ", Get_depth());
00778   if (Is_messy_region())
00779     fprintf(fp, "<MESSY> ");
00780   if (Is_unprojected_region())
00781     fprintf(fp, "<UNPROJECTED> ");
00782   if (Is_may_kill()) {
00783     fprintf(fp, "MAY_KILL ");
00784   } else if (Is_may_use()) {
00785     fprintf(fp, "MAY_USE ");
00786   } else if (Is_passed()) {
00787     fprintf(fp, "                  ");
00788     fprintf(fp, "\n");
00789     fprintf(fp, "PASSED ");
00790     fprintf(fp, "CALLSITE[%d] ", Get_callsite_id());
00791     fprintf(fp, "ACTUAL_POSITION(%d) ",  Get_actual_id());
00792   } else if (Is_formal()) {
00793     fprintf(fp, "FORMAL ");
00794   }
00795   fprintf(fp, "\n");
00796 }
00797 
00798 //===================================================================
00799 //      Print the projected region 
00800 //===================================================================
00801 void 
00802 PROJECTED_REGION_INFO::Print(FILE *fp)
00803 {
00804   if (Get_projected_region())
00805     Get_projected_region()->Print(fp);
00806 }
00807 
00808 //===================================================================
00809 // Print the region arrays
00810 //===================================================================
00811 void 
00812 REGION_ARRAYS::Print(FILE *fp)
00813 {
00814   fprintf(fp, "REGION_ARRAYS for ");
00815 #ifdef IPA_SUMMARY
00816   fprintf(fp, "%s", Summary->Get_symbol(Get_sym_id())->Get_Name());
00817 #else
00818   fprintf(fp, "%s", Symbol_Name(&IPA_Symbol[Get_sym_id()]));
00819 #endif
00820 
00821   fprintf(fp, ", element size = %d, ", Get_element_size());
00822 
00823   if (Is_bad_alias())
00824     fprintf(fp, "bad alias, ");
00825 
00826   if (Is_loop_invariant())
00827     fprintf(fp, "loop invariant, ");
00828 
00829   if (Is_def())
00830     fprintf(fp, "def\n");
00831   else if (Is_use())
00832     fprintf(fp, "use\n");
00833   else if (Is_passed())
00834     fprintf(fp, "passed\n");
00835   else if (Is_may_def())
00836     fprintf(fp, "may def\n");
00837   else if (Is_may_use())
00838     fprintf(fp, "may use\n");
00839   else if (Is_formal())
00840     fprintf(fp, "formal\n");
00841   else
00842     fprintf(fp, "UNKNOWN type\n");
00843 
00844   if (PROJECTED_REGION_INFO_ARRAY* p = Get_projected_region_array()) {
00845     for (INT i = 0; i < p->Elements(); ++i) {
00846       (*p)[i].Print(fp);
00847     }
00848   }
00849 }
00850 
00851 //===================================================================
00852 // Print the control flow node information
00853 //===================================================================
00854 void 
00855 CFG_NODE_INFO::Print(FILE *fp)
00856 {
00857   if (Has_calls())
00858     fprintf(fp, "Has calls \n");
00859 
00860   INT i;
00861 
00862   // print all the array kills
00863   fprintf(fp," +++++++++ARRAY KILLS_START+++++++++\n"); 
00864   ARRAY_OF_REGION_ARRAYS* defs = Get_def_array();
00865   for (i = 0; i < defs->Elements(); ++i) {
00866     (*defs)[i].Print(fp);
00867   }  
00868   fprintf(fp," +++++++++ARRAY KILLS_FINISHED+++++++++\n");
00869 
00870   // print all the array uses
00871   ARRAY_OF_REGION_ARRAYS* uses = Get_use_array();
00872   fprintf(fp," +++++++++ARRAY EUSES_START+++++++++\n");
00873   for (i = 0 ; i < uses->Elements(); ++i) {
00874     (*uses)[i].Print(fp);
00875   }
00876   fprintf(fp," +++++++++ARRAY EUSES_FINISHED+++++++++\n");
00877 
00878   // print all the scalar kills
00879   fprintf(fp," +++++++++SCALAR_INFO_START+++++++++\n");
00880   INT_ARRAY* scalar_defs = Get_scalar_def_array();
00881   for (i = 0; i < scalar_defs->Elements();++i) {
00882     SCALAR_INFO* idr = &(*scalar_defs)[i];
00883 #ifdef IPA_SUMMARY
00884     fprintf(fp, "symbol: %s\n", Summary->Get_symbol(idr->Get_id())->Get_Name());
00885 #else
00886     fprintf(fp, "symbol: %s\n", Symbol_Name(&IPA_Symbol[idr->Get_id()]));
00887 #endif
00888   }
00889   fprintf(fp," +++++++++SCALAR_INFO_FINISHED+++++++++\n");
00890 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines