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