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