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 #include "tracing.h"
00047 #include "ipfec_defs.h"
00048 #include "prdb_util.h"
00049 #include "prdb.h"
00050
00051
00052 void PRDB_term()
00053 {
00054 Delete_PRDB();
00055 }
00056
00057 void
00058 Test_PRDB(REGION* region, PARTITION_GRAPH* graph)
00059 {
00060 TOPOLOGICAL_REGIONAL_CFG_ITER top_iter(region->Regional_Cfg());
00061 REGIONAL_CFG_NODE* cfg_node = *top_iter;
00062 if(cfg_node->Is_Region()) return;
00063 Is_True(!graph->Cycle_Detector(), ("Cycle partitioin graph detected!!!"));
00064 Is_True(!graph->Illegal_Partition(), ("Illegal partition detected!!!"));
00065 BB* bb, *bb2;
00066 BB_CONTAINER bbs;
00067 BB_CONTAINER::iterator iter, iter1;
00068 for (top_iter; top_iter!=0; ++top_iter)
00069 {
00070 REGIONAL_CFG_NODE *node = *top_iter;
00071 if ( node -> Is_Region()) continue;
00072
00073 bb = node -> BB_Node();
00074 bbs.push_back(bb);
00075 }
00076
00077 TN_OP_PAIR tn_op1, tn_op2;
00078 for(iter = bbs.begin(); iter != bbs.end(); ++iter) {
00079 bb = *iter;
00080 if(BB_last_op(bb))
00081 tn_op1.second = OP_prev(BB_last_op(bb));
00082 if(!tn_op1.second) continue;
00083 tn_op1.first = OP_results(tn_op1.second)>0?
00084 OP_result(tn_op1.second, 0):OP_opnd(tn_op1.second, 0);
00085 Is_True(tn_op1.first, (" Illegal TN \n"));
00086 if(!TN_is_register(tn_op1.first)||
00087 TN_register_class(tn_op1.first) != ISA_REGISTER_CLASS_predicate)
00088 continue;
00089 for(iter1 = bbs.begin(); iter1 != bbs.end(); ++iter1) {
00090 bb2 = *iter1;
00091 if(BB_last_op(bb2))
00092 tn_op2.second = OP_prev(BB_last_op(bb2));
00093 if(!tn_op2.second) continue;
00094 tn_op2.first = OP_results(tn_op2.second)>0?
00095 OP_result(tn_op2.second, 0):OP_opnd(tn_op2.second, 0);
00096 Is_True(tn_op2.first, (" Illegal TN \n"));
00097 if(!TN_is_register(tn_op2.first)||
00098 TN_register_class(tn_op2.first) != ISA_REGISTER_CLASS_predicate)
00099 continue;
00100 if(Get_Trace(TP_A_PRDB, TT_PRDB_VERBOSE)){
00101 fPrint_TN ( TFile, "tn1-:%s", tn_op1.first);
00102 fprintf(TFile, " probability is %f; ", graph->Get_Probability(tn_op1.first));
00103 fPrint_TN ( TFile, "and tn2-:%s", tn_op2.first);
00104 fprintf(TFile, " probability is %f.\n", graph->Get_Probability(tn_op2.first));
00105 fPrint_TN ( TFile, "tn1-:%s", tn_op1.first);
00106 fprintf(TFile, "/");
00107 fPrint_TN ( TFile, "tn2-:%s", tn_op2.first);
00108 fprintf(TFile, " probability is %f\n", graph->Get_Probability(tn_op1.first,tn_op2.first));
00109 }
00110 }
00111 TP_ALLOCATOR tp_allocator;
00112 TP_CONTAINER tp_result(tp_allocator);
00113 if(graph->Get_Complementary(&tp_result, tn_op1, bb))
00114 {
00115 TP_CONTAINER::iterator tp_iter;
00116 fPrint_TN ( TFile, "tn1-:%s", tn_op1.first);
00117 fprintf(TFile, " cpty w.s.t BB-%d includes: ", BB_id(bb));
00118 for(tp_iter=tp_result.begin();tp_iter!=tp_result.end();tp_iter++)
00119 {
00120 fPrint_TN(TFile," %s ", (*tp_iter)->first);
00121 }
00122 }
00123 }
00124 }
00125
00126 void
00127 Verify_PRDB(REGION* region, PRDB_GEN* prdb)
00128 {
00129 if(region->Region_Type() == IMPROPER ||
00130 region->Is_No_Further_Opt())
00131 return;
00132 PARTITION_GRAPH* graph = prdb->Partition_Graph(region);
00133 for (TOPOLOGICAL_REGIONAL_CFG_ITER iter( region -> Regional_Cfg());
00134 iter!=0;
00135 ++iter)
00136 {
00137 REGIONAL_CFG_NODE *node = *iter;
00138 if ( node -> Is_Region())
00139 continue;
00140
00141 BB* bb = node -> BB_Node();
00142 OP* op;
00143 FOR_ALL_BB_OPs(bb, op){
00144 PG_CONTAINER* node_set = (PG_CONTAINER*)OP_MAP_Get(graph->Tn_Node_Map(), op);
00145 Is_True(node_set, ("No partition node set mapped to op!"));
00146 }
00147 }
00148 }
00149