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 #ifdef USE_PCH
00052 #include "common_com_pch.h"
00053 #endif
00054 #pragma hdrstop
00055
00056 #define USE_STANDARD_TYPES 1
00057
00058 #include "defs.h"
00059 #include "tracing.h"
00060 #include "glob.h"
00061 #include "opcode.h"
00062 #include "xstats.h"
00063 #include "stab.h"
00064 #include "wio.h"
00065
00066 UINT32 PU_Olimit;
00067 UINT32 Max_Src_Olimit;
00068
00069
00070 INT32 PU_WN_Cnt;
00071 INT32 Total_WN_Cnt;
00072 INT32 PU_WN_BB_Cnt;
00073 INT32 PU_WN_Stmt_Cnt;
00074 INT32 PU_WN_Call_Cnt;
00075 INT32 PU_WN_Loop_Cnt;
00076 INT32 PU_BB_Cnt;
00077 INT32 Total_BB_Cnt;
00078 INT32 PU_OP_Cnt;
00079 INT32 Total_OP_Cnt;
00080 INT32 PU_Size;
00081 INT32 Total_Code_Size;
00082 INT32 PU_TN_Cnt;
00083 INT32 Total_TN_Cnt;
00084
00085
00086 INT32 Misaligned_Cnt;
00087 INT32 Temp_Var_Cnt;
00088 INT32 Total_Temp_Var_Cnt;
00089 INT32 Spill_Var_Cnt;
00090 INT32 Total_Spill_Var_Cnt;
00091
00092 #ifdef FRONT_END
00093 #if defined(FRONT_END_C) || defined(FRONT_END_CPLUSPLUS)
00094 #define PHASE_NAME "c fe"
00095 #else
00096 #define PHASE_NAME "f77 fe"
00097 #endif
00098 #else
00099 #define PHASE_NAME "be"
00100 #endif
00101
00102
00103 void
00104 Count_WN_Operator (OPERATOR opr, TYPE_ID rtype, INT32& bbs, INT32& stmts,
00105 INT32& calls)
00106 {
00107
00108 if (OPERATOR_is_non_scf(opr)) {
00109 ++bbs;
00110 } else if (OPERATOR_is_stmt(opr)) {
00111 if (OPERATOR_is_call(opr)) {
00112 ++bbs;
00113 ++calls;
00114 } else if (opr == OPR_IO) {
00115
00116
00117 ++bbs;
00118 ++calls;
00119 } else if (! OPERATOR_is_not_executable(opr)) {
00120 ++stmts;
00121 if (MTYPE_is_complex(rtype) && OPERATOR_is_store(opr)) {
00122 ++stmts;
00123 }
00124 }
00125 } else if (OPERATOR_is_scf(opr)) {
00126 if (opr != OPR_BLOCK) {
00127
00128 ++bbs;
00129 }
00130
00131
00132 } else if ((rtype == MTYPE_FQ || rtype == MTYPE_CQ) &&
00133 OPERATOR_is_expression(opr) &&
00134 !OPERATOR_is_load(opr) &&
00135 !OPERATOR_is_leaf(opr) ) {
00136
00137 ++bbs;
00138 ++calls;
00139 } else if (opr == OPR_CAND || opr == OPR_CIOR) {
00140
00141
00142
00143 ++bbs;
00144 }
00145 }
00146
00147
00148 void
00149 Count_WN_Node (WN *node, INT32 *bbs, INT32 *stmts)
00150 {
00151 Count_WN_Operator (WN_operator (node), WN_rtype (node), *bbs, *stmts,
00152 PU_WN_Call_Cnt);
00153 if (WN_opcode(node) == OPC_IO) {
00154 INT i;
00155 for (i=0; i<WN_kid_count(node); i++) {
00156 WN *kid = WN_kid(node, i);
00157 if (WN_opcode(kid) == OPC_IO_ITEM
00158 && (WN_io_item(kid) == IOC_END
00159 || WN_io_item(kid)==IOC_ERR)
00160
00161 && WN_opcode(WN_kid0(kid)) == OPC_GOTO)
00162 {
00163
00164 (*bbs)++;
00165 }
00166 }
00167 }
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 void
00181 Initialize_Stats ( void )
00182 {
00183 Total_WN_Cnt = 0;
00184 PU_WN_Cnt = 0;
00185 Total_BB_Cnt = 0;
00186 PU_WN_BB_Cnt = 0;
00187 PU_WN_Stmt_Cnt = 0;
00188 PU_WN_Call_Cnt = 0;
00189 PU_WN_Loop_Cnt = 0;
00190 PU_BB_Cnt = 0;
00191 PU_OP_Cnt = 0;
00192 Total_OP_Cnt = 0;
00193 PU_Size = 0;
00194 Total_Code_Size = 0;
00195 PU_TN_Cnt = 0;
00196 Total_TN_Cnt = 0;
00197
00198 Misaligned_Cnt = 0;
00199 Temp_Var_Cnt = 0;
00200 Total_Temp_Var_Cnt = 0;
00201 Spill_Var_Cnt = 0;
00202 Total_Spill_Var_Cnt = 0;
00203 Max_Src_Olimit = 0;
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 void
00216 Initialize_PU_Stats ( void )
00217 {
00218 PU_WN_Cnt = 0;
00219 PU_WN_BB_Cnt = 0;
00220 PU_WN_Stmt_Cnt = 0;
00221 PU_WN_Call_Cnt = 0;
00222 PU_WN_Loop_Cnt = 0;
00223 PU_BB_Cnt = 0;
00224 PU_OP_Cnt = 0;
00225 PU_TN_Cnt = 0;
00226 PU_Size = 0;
00227
00228 Temp_Var_Cnt = 0;
00229 Spill_Var_Cnt = 0;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 void
00242 Print_PU_Stats ( void )
00243 {
00244
00245 if ( Get_Trace(TKIND_INFO, TINFO_STATS) == 0 ) return;
00246
00247 fprintf(TFile, "PU %s stats for %s:\n", PHASE_NAME, Orig_PU_Name);
00248 fprintf ( TFile, "WNs in PU: %d\n", PU_WN_Cnt);
00249 #ifdef BACK_END
00250 fprintf ( TFile, "WN BBs in PU: %d\n", PU_WN_BB_Cnt);
00251 fprintf ( TFile, "WN Stmts in PU: %d\n", PU_WN_Stmt_Cnt);
00252 fprintf ( TFile, "WN Calls in PU: %d\n", PU_WN_Call_Cnt);
00253 fprintf ( TFile, "BBs in PU: %d\n", PU_BB_Cnt);
00254 fprintf ( TFile, "OPs in PU: %d\n", PU_OP_Cnt);
00255 fprintf ( TFile, "TNs in PU: %d\n", PU_TN_Cnt);
00256 fprintf ( TFile, "STs in PU: %d, PREGs in PU: %d\n",
00257 Scope_tab[CURRENT_SYMTAB].st_tab->Size (),
00258 Scope_tab[CURRENT_SYMTAB].preg_tab->Size ());
00259 fprintf ( TFile, "%d temporary variables, %d spill temporaries\n",
00260 Temp_Var_Cnt, Spill_Var_Cnt);
00261 fprintf ( TFile, "Size of PU: %d bytes\n", PU_Size);
00262 #endif
00263 fprintf (TFile, "\n");
00264
00265
00266 Total_WN_Cnt += PU_WN_Cnt;
00267 Total_BB_Cnt += PU_BB_Cnt;
00268 Total_OP_Cnt += PU_OP_Cnt;
00269 Total_TN_Cnt += PU_TN_Cnt;
00270 Total_Temp_Var_Cnt += Temp_Var_Cnt;
00271 Total_Spill_Var_Cnt += Spill_Var_Cnt;
00272 Total_Code_Size += PU_Size;
00273 }
00274
00275 void
00276 Print_Total_Stats ( void )
00277 {
00278
00279 if ( Get_Trace(TKIND_INFO, TINFO_STATS) == 0 ) return;
00280
00281 fprintf(TFile, "Total %s stats for compilation:\n", PHASE_NAME);
00282 fprintf ( TFile, "WNs in file: %d\n", Total_WN_Cnt);
00283 #ifdef BACK_END
00284 fprintf ( TFile, "BBs in file: %d\n", Total_BB_Cnt);
00285 fprintf ( TFile, "OPs in file: %d\n", Total_OP_Cnt);
00286 fprintf ( TFile, "TNs in file: %d\n", Total_TN_Cnt);
00287 fprintf ( TFile, "Code size in file: %d bytes\n", Total_Code_Size);
00288
00289 fprintf ( TFile, "%d temporary variables, %d spill temporaries\n",
00290 Total_Temp_Var_Cnt, Total_Spill_Var_Cnt);
00291
00292 fprintf ( TFile, "Misaligned memory references: %d\n", Misaligned_Cnt);
00293 #endif
00294 }