Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
curr.wb.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 
00037 #ifdef USE_PCH
00038 #include "be_com_pch.h"
00039 #endif /* USE_PCH */
00040 #pragma hdrstop
00041 #include <sys/types.h>
00042 #include <ctype.h>
00043 #include <limits.h>
00044 #include "wn.h"
00045 #include "wn_simp.h"
00046 #include "strtab.h"
00047 #include "opt_du.h"
00048 #include "opt_alias_mgr.h"
00049 #include "dep_graph.h"
00050 #include "prompf.h" 
00051 #include "wb_util.h"
00052 #include "wb_browser.h" 
00053 #include "wb.h"
00054 
00055 
00056 // Solaris CC workaround
00057 
00058 #if defined(_GCC_NO_PRAGMAWEAK) || defined(__CYGWIN__)
00059 void cg_sdebug(char init_buffer[]) { } 
00060 void s_lno_debug(char init_buffer[]) { }
00061 #endif
00062 
00063 #if !defined(__GNUC__) && defined(_SOLARIS_SOLARIS)
00064 
00065 #pragma weak "__1cLs_lno_debug6Fpc_v_"
00066 #pragma weak "__1cJcg_sdebug6Fpc_v_"
00067 
00068 #elif defined(__GNUC__)
00069 #pragma weak s_lno_debug__FPc
00070 #pragma weak cg_sdebug__FPc
00071 #else
00072 #pragma weak s_lno_debug__GPc
00073 #pragma weak cg_sdebug__GPc
00074 #endif
00075 
00076 extern void s_f90_lower_debug(char init_buffer[]); 
00077 extern void s_omp_debug(char init_buffer[]); 
00078 extern void s_lno_debug(char init_buffer[]); 
00079 extern void s_lwr_debug(char init_buffer[]); 
00080 extern void s_anl_debug(char init_buffer[]); 
00081 extern void s_ipl_debug(char init_buffer[]);
00082 extern void cg_sdebug(char init_buffer[]);
00083 
00084 static WB_PHASE WB_Current_Phase = WBP_NONE; 
00085 
00086 static WB_COMMAND WBS_Command_List[] =
00087 {
00088   'S', WBR_NONE, NULL, "Print info about SUMMARY_SYMBOLs",
00089   'I', WBR_NONE, NULL, "Print info about IVARs",
00090   'J', WBR_NONE, NULL, "Print info about IVAR_GLOBALs",
00091   'F', WBR_NONE, NULL, "Print info about SUMMARY_FORMALs",
00092   'G', WBR_NONE, NULL, "Print info about SUMMARY_GLOBALs",
00093   'A', WBR_NONE, NULL, "Print info about SUMMARY_ACTUALs",
00094   'V', WBR_NONE, NULL, "Print info about SUMMARY_VALUEs",
00095   'C', WBR_NONE, NULL, "Print info about SUMMARY_COMMONs",
00096   'K', WBR_NONE, NULL, "Print info about SUMMARY_COMMON_SHAPEs",
00097   'D', WBR_NONE, NULL, "Print info about SUMMARY_CONTROL_DEPENDENCEs",
00098   'L', WBR_NONE, NULL, "Print info about SUMMARY_CALLSITEs",
00099   'P', WBR_NONE, NULL, "Print info about SUMMARY_PROCEDUREs",
00100   'a', WBR_NONE, NULL, "Print info about CFG_NODE_INFOs",
00101   's', WBR_NONE, NULL, "Print info about SCALAR_INFOs",
00102   'R', WBR_NONE, NULL, "Print info about REGION_ARRAYSs",
00103   'r', WBR_NONE, NULL, "Print info about PROJECTED_REGIONs",
00104   'n', WBR_NONE, NULL, "Print info about PROJECTED_NODEs",
00105   't', WBR_NONE, NULL, "Print info about TERMs",
00106   'l', WBR_NONE, NULL, "Print info about LOOPINFOs",
00107   'p', WBR_NONE, NULL, "Print info about SUMMARY_PHIs",
00108   'x', WBR_NONE, NULL, "Print info about SUMMARY_CHIs",
00109   'T', WBR_NONE, NULL, "Print info about TCONs",
00110   'E', WBR_NONE, NULL, "Print info about SUMMARY_EXPRs",
00111   'X', WBR_NONE, NULL, "Print info about SUMMARY_STIDs",
00112   'Y', WBR_NONE, NULL, "Print info about SUMMARY_STMTs",
00113   'f', WBR_NONE, NULL, "Print info about SUMMARY_FEEDBACKs",
00114   '=', WBR_NONE, NULL, "Locate a summary at this address",
00115   'H', WBR_NONE, NULL, "Print this information",
00116   'h', WBR_NONE, NULL, "Print this information",
00117   '\0', WBR_NONE, NULL,  ""
00118 };
00119 
00120 static WB_COMMAND WB_Command_List[] =
00121 {
00122   'R', WBR_NONE,    NULL, "Go to the root of the program unit",
00123   'N', WBR_NONE,    NULL, "Go to the next node in the subtree chain",
00124   'P', WBR_NONE,    NULL, "Go to the previous node in the subtree chain",
00125   '=', WBR_NONE,    NULL, "Set the current node to the following address",
00126   '@', WBR_NONE,    NULL, "Set the current node to this numbered node",
00127   '>', WBR_NONE,    NULL, "Increase the fanciness level for printing",
00128   '<', WBR_NONE,    NULL, "Decrease the fanciness level for printing",
00129   'K', WBR_NONE,    NULL, "Print the kids of this node",
00130   'S', WBR_NONE,    NULL, "Print the list of statements under this node",
00131   'T', WBR_NONE,    NULL, "Print the tree at the current node",
00132   '%', WBR_NONE,    NULL, "Print the addresses of nodes in this subtree",
00133   's', WBR_NONE,    NULL, "Print the symbol table entry for this node",
00134   't', WBR_NONE,    NULL, "Print the type table entry for this node",
00135   'F', WBR_NONE,    NULL, "Find nodes with this symbol in the subtree",
00136   '$', WBR_NONE,    NULL, "Find symbols with this name",  
00137   'o', WBR_NONE,    NULL, "Find nodes with this operator in the subtree",
00138   'U', WBR_DU,      NULL, "Print the uses at the current node",          
00139   'D', WBR_DU,      NULL, "Print the definitions at the current node",  
00140   'G', WBR_DG,      NULL, "Print the dep graph info at the current node",  
00141   'V', WBR_DG,      NULL, "Print the vertices of the dep graph",          
00142   'v', WBR_DG,      NULL, "Go to the node with this vertex number",      
00143   'a', WBR_ALIAS,   NULL, "Print the alias info for this node",        
00144   'E', WBR_NONE,    NULL, "Go to the parent of the current node",
00145   'e', WBR_NONE,    NULL, "Print the ancestors of this node",
00146   'i', WBR_MPFMAP,  NULL, "Print the PROMPF ids for tree at this node",
00147   'I', WBR_MPFINFO, NULL, "Print the PROMPF_INFO",   
00148   'A', WBR_AAMAP,   NULL, "Print the access info at the current node",
00149   'r', WBR_REDMAP,  NULL, "Print the reduction in this subtree",
00150   'W', WBR_NONE,    NULL, "Print tree in whirl2[fc] format at current node",
00151   'f', WBR_NONE,    NULL, "Change WHIRL-TO-SOURCE language to FORTRAN",
00152   'c', WBR_NONE,    NULL, "Change WHIRL-TO-SOURCE language to C", 
00153   'L', WBR_NONE,    NULL, "Sketch the loop nests in the program unit",
00154   'M', WBR_NONE,    NULL, "Set the current node to node with this map id",
00155   'm', WBR_NONE,    NULL, "Print the map-id at this node", 
00156   'd', WBR_NONE,    NULL, "Toggle Da Vinci mode",
00157   '~', WBR_NONE,    &WBS_Command_List[0], 
00158                           "Print summary info (Type ~H for commands)", 
00159   'H', WBR_NONE,    NULL, "Print this information",
00160   'h', WBR_NONE,    NULL, "Print this information",
00161   '\0', WBR_NONE,   NULL, ""
00162 };
00163 
00164 extern void WB_Initialize(WB_BROWSER* wb, 
00165                           WN* wn_global, 
00166                           PU* pu, 
00167                           DU_MANAGER* du,
00168                           ALIAS_MANAGER* alias_mgr,
00169                           WN_MAP prompf_id_map)
00170 {
00171   wb->Set_Global_Fd(wn_global); 
00172   wb->Set_Pu(pu);
00173   wb->Set_Du(du); 
00174   wb->Set_Alias_Manager(alias_mgr); 
00175   wb->Set_Prompf_Id_Map(prompf_id_map); 
00176   wb->Set_Command_List(WB_Command_List); 
00177 } 
00178 
00179 extern void WB_Terminate(WB_BROWSER* wb)
00180 { 
00181   wb->Set_Global_Fd(NULL); 
00182   wb->Set_Du(NULL); 
00183   wb->Set_Alias_Manager(NULL); 
00184   wb->Set_Command_List(NULL); 
00185 } 
00186 
00187 extern WB_PHASE WB_Phase() 
00188 { 
00189   return WB_Current_Phase; 
00190 } 
00191 
00192 extern void WB_Set_Phase(WB_PHASE WB_Phase) 
00193 { 
00194   WB_Current_Phase = WB_Phase; 
00195 } 
00196 
00197 extern void sdebug(char init_buffer[])
00198 {
00199   switch(WB_Current_Phase) { 
00200   case WBP_F90_LOWER: 
00201     s_f90_lower_debug(init_buffer);
00202     break;
00203   case WBP_PROMPF_SA: 
00204     s_anl_debug(init_buffer);
00205     break; 
00206   case WBP_OMP_PRELOWER: 
00207     s_omp_debug(init_buffer); 
00208     break;
00209   case WBP_LNO: 
00210     s_lno_debug(init_buffer); 
00211     break; 
00212   case WBP_LOWER: 
00213     s_lwr_debug(init_buffer); 
00214     break;
00215   case WBP_IPL:
00216     s_ipl_debug(init_buffer);
00217     break; 
00218   case WBP_IPA: 
00219     cg_sdebug(init_buffer);
00220     break;
00221   default: 
00222     fprintf(stdout, "Whirl browser not valid in this phase.\n");
00223     break; 
00224   } 
00225 } 
00226 
00227 extern void swb(char init_buffer[])
00228 {
00229   sdebug(init_buffer); 
00230 } 
00231 
00232 extern void debug()
00233 { 
00234   sdebug(""); 
00235 } 
00236 
00237 extern void wb()
00238 {
00239   debug();
00240 }    
00241 
00242 extern void debug_root(WN* wn_root) 
00243 { 
00244   WB_BROWSER wb;
00245   WB_Initialize(&wb, wn_root, NULL, NULL, NULL, -1);
00246   wb.Sdebug("");
00247   WB_Terminate(&wb);
00248 }
00249 
00250 extern void wb_root(WN* wn_root)
00251 { 
00252   debug_root(wn_root);
00253 } 
00254 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines