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 #include "defs.h"
00041 #include "config.h"
00042 #include "mempool.h"
00043 #include "tracing.h"
00044 #include "timing.h"
00045 #include "cgir.h"
00046 #include "cg.h"
00047 #include "cg_flags.h"
00048 #include "ttype.h"
00049 #include "bitset.h"
00050 #include "bb_set.h"
00051 #include "freq.h"
00052 #include "whirl2ops.h"
00053 #include "dominate.h"
00054 #include "findloops.h"
00055 #include "cg_sched_est.h"
00056 #include "opt_points_to.h"
00057 #include "opt_alias_mgr.h"
00058
00059 #include "hb.h"
00060 #include "hb_path.h"
00061 #include "hb_trace.h"
00062
00063 FILE *HB_TFile;
00064
00066 void
00067 HB_Trace_Init(void)
00069
00070
00071
00073 {
00074 if (HB_Trace(HB_TRACE_TO_STDOUT)) {
00075 HB_TFile = stdout;
00076 } else {
00077 HB_TFile = TFile;
00078 }
00079 }
00080
00082 void
00083 HB_PATH_Trace(HB_PATH* path)
00085
00086
00087
00089 {
00090 fprintf(HB_TFile, "<HB> Path data:\n");
00091 fprintf(HB_TFile, "<HB> Priority: %lf\n", HB_PATH_Priority(path));
00092 fprintf(HB_TFile, "<HB> Probability: %lf\n", HB_PATH_Probability(path));
00093 fprintf(HB_TFile, "<HB> Hazard Multiplier: %lf\n",
00094 HB_PATH_Hazard_Multiplier(path));
00095 fprintf(HB_TFile, "<HB> Number Ops: %d\n", HB_PATH_Num_Ops(path));
00096 fprintf(HB_TFile, "<HB> Schedule Height: %d\n",
00097 HB_PATH_Schedule_Height(path));
00098 BB_SET_Print(HB_PATH_Blocks(path), HB_TFile);
00099 fprintf(HB_TFile, "\n");
00100 }
00101
00102
00104 void
00105 HB_Trace_If_Convert_Blocks(HB* hb)
00107
00108
00109
00111 {
00112 fprintf(HB_TFile, "\n<HB> Hyperblock entry: BB%d\n", BB_id(HB_Entry(hb)));
00113 if (HB_Exit(hb)) {
00114 fprintf(HB_TFile, "<HB> Hyperblock exit: BB%d\n", BB_id(HB_Exit(hb)));
00115 }
00116 if (HB_Fall_Thru_Exit(hb)) {
00117 fprintf(HB_TFile, "<HB> Hyperblock fall thru exit: BB%d\n",
00118 BB_id(HB_Fall_Thru_Exit(hb)));
00119 }
00120 fprintf(HB_TFile, "<HB> If-converting following blocks: ");
00121 BB_SET_Print(HB_Blocks(hb), HB_TFile);
00122 fprintf(HB_TFile, "\n");
00123 }
00124
00126 void
00127 HB_Trace_HB_List()
00129
00130
00131
00133 {
00134 std::list<HB*>::iterator hbi;
00135
00136 fprintf(HB_TFile, "\n<HB> Current hyperblocks: \n");
00137 for (hbi = HB_list.begin(); hbi != HB_list.end(); hbi++) {
00138 fprintf(HB_TFile, " ");
00139 (*hbi)->Print();
00140 fprintf(HB_TFile, "\n");
00141 }
00142 }
00143
00144
00145
00146
00147
00148 void HB::Print(void)
00149 {
00150 if (blocks) {
00151 BB_SET_Print(blocks, HB_TFile);
00152 } else {
00153 fprintf(HB_TFile,"{}");
00154 }
00155
00156 fprintf(HB_TFile," %d/",BB_id(entry));
00157 if (exit) {
00158 fprintf(HB_TFile,"%d",BB_id(exit));
00159 }
00160 if (fall_thru_exit) {
00161 fprintf(HB_TFile,"/%d",BB_id(fall_thru_exit));
00162 }
00163
00164 fprintf(HB_TFile, "\n");
00165 }
00166
00167
00168
00169 static void Indent(INT indent)
00170 {
00171 INT i;
00172 for (i=0; i < indent*3; i++) {
00173 putc(' ',HB_TFile);
00174 }
00175 }
00176
00178 void
00179 HB_Trace_Print_Cand_Tree(HB_CAND_TREE* c, INT indent)
00181
00182
00183
00185 {
00186 if (!c) return;
00187
00188 HB * hb = HB_CAND_TREE_Candidate(c);
00189 Indent(indent);
00190 if (HB_CAND_TREE_Check_Flag(c,HCT_ERASE)) {
00191 fprintf(HB_TFile, "E");
00192 }
00193 hb->Print();
00194 if (!HB_CAND_TREE_Kids(c).empty()) {
00195 std::list<HB_CAND_TREE*>::iterator k;
00196 for (k = HB_CAND_TREE_Kids(c).begin(); k != HB_CAND_TREE_Kids(c).end();
00197 k++) {
00198 if (BB_SET_ContainsP(HB_Blocks(HB_CAND_TREE_Candidate(c)),
00199 HB_Blocks(HB_CAND_TREE_Candidate(*k)))) {
00200 HB_Trace_Print_Cand_Tree(*k, indent+1);
00201 } else {
00202 Indent(indent+1);
00203 fprintf(HB_TFile, "Bad subtree ");
00204 BB_SET_Print(HB_Blocks(HB_CAND_TREE_Candidate(*k)),HB_TFile);
00205 fprintf(HB_TFile, "\n");
00206 HB_Trace_Print_Cand_Tree(*k, indent+1);
00207 }
00208 }
00209 }
00210 }
00211
00213 void
00214 HB_Trace_Candidates(const char* tstring, std::list<HB_CAND_TREE*>& cands)
00216
00217
00218
00220 {
00221 std::list<HB_CAND_TREE*>::iterator c;
00222
00223 fprintf(HB_TFile, "\n<HB> Candidates after %s: \n", tstring);
00224 for (c = cands.begin(); c != cands.end(); c++) {
00225 HB_Trace_Print_Cand_Tree(*c,0);
00226 fprintf(HB_TFile, "\n");
00227 }
00228 }
00229
00230
00231 void dump_cand_tree(HB_CAND_TREE* c)
00232 {
00233 FILE *f;
00234 f = HB_TFile;
00235 HB_TFile = stdout;
00236 HB_Trace_Print_Cand_Tree(c,0);
00237 HB_TFile = f;
00238 }
00239
00240 void dump_cand_trees(std::list<HB_CAND_TREE*> &cands)
00241 {
00242 std::list<HB_CAND_TREE*>::iterator c;
00243 printf("-----------------------\n");
00244 for (c = cands.begin(); c != cands.end(); c++) {
00245 dump_cand_tree(*c);
00246 printf("\n");
00247 }
00248 }
00249
00250 void dump_hb(HB *hb)
00251 {
00252 FILE *f;
00253 f = HB_TFile;
00254 HB_TFile = stdout;
00255 hb->Print();
00256 printf("block list { ");
00257 std::list<BB*>::iterator bbi;
00258 FOR_ALL_BB_STLLIST_ITEMS_FWD(hb->block_list, bbi) {
00259 printf("%d ",BB_id(*bbi));
00260 }
00261 printf("}\n");
00262 HB_TFile = f;
00263 }
00264
00265