00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SCHED_RES_AWARE_included
00009 #define SCHED_RES_AWARE_included
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
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 #include "defs.h"
00082 #include "ipfec_defs.h"
00083 #include "ipfec_options.h"
00084
00085 #include "tracing.h"
00086 #include "errors.h"
00087
00088 #include "op.h"
00089 #include "bb.h"
00090 #include "be_util.h"
00091
00092 #include "region.h"
00093 #include "sched_cand.h"
00094
00095 #include <list>
00096
00097 class VIGILANT_PNT {
00098 private:
00099 OP* _op;
00100 INT32 _pending_adv_ld;
00101
00102 public:
00103 VIGILANT_PNT (OP* op) : _op(op) {
00104 _pending_adv_ld = 0;
00105 }
00106
00107 ~VIGILANT_PNT (void) {}
00108
00109 OP* Op (void) const { return _op; }
00110
00111 INT32 Pending_Adv_Ld (void) const { return _pending_adv_ld; }
00112 void Inc_Pending_Adv_Ld (void) { _pending_adv_ld ++; }
00113 void Dec_Pending_Adv_Ld (void) {
00114 _pending_adv_ld--;
00115 Is_True (_pending_adv_ld >= 0,
00116 ("The number of pending advanced load is negative"));
00117 }
00118 void Set_Pending_Adv_Ld (INT num) { _pending_adv_ld = num; }
00119
00120
00121 static BOOL Candidate (OP* op) {
00122 return OP_chk_a(op) || OP_like_store(op) ||
00123 OP_load(op) && !OP_no_alias(op);
00124 }
00125 };
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 typedef mempool_allocator<VIGILANT_PNT*> VIGILANT_PNT_ALLOC;
00137 typedef std::list<VIGILANT_PNT*, VIGILANT_PNT_ALLOC> VIGILANT_PNT_LIST;
00138 typedef VIGILANT_PNT_LIST::iterator VIGILANT_PNT_LIST_ITER;
00139
00140 class BB_VIGILANT_PNT_MGR {
00141 private:
00142 MEM_POOL* _mp;
00143 BB* _bb;
00144
00145 VIGILANT_PNT_LIST _vigilant_pnt_list;
00146 VIGILANT_PNT _exit_vp;
00147
00148 public:
00149 BB_VIGILANT_PNT_MGR (MEM_POOL* mp, BB* bb) :
00150 _mp(mp), _vigilant_pnt_list(mp), _bb(bb), _exit_vp(NULL) { }
00151 void Init (void);
00152 ~BB_VIGILANT_PNT_MGR (void) {};
00153
00154 BB* Bb (void) const { return _bb; }
00155
00156
00157 void Update_Vp_For_Compensation_Code (OP* bookeeping);
00158
00159 VIGILANT_PNT_LIST& Vigilant_point_list (void)
00160 { return _vigilant_pnt_list;}
00161
00162 VIGILANT_PNT* Find (OP* op) {
00163 if (!VIGILANT_PNT::Candidate (op)) { return NULL; }
00164 for (VIGILANT_PNT_LIST_ITER iter = _vigilant_pnt_list.begin ();
00165 iter != _vigilant_pnt_list.end (); iter++) {
00166 VIGILANT_PNT* pnt = *iter;
00167 if (pnt->Op () == op) {
00168 return pnt;
00169 }
00170 }
00171 return NULL;
00172 }
00173
00174 VIGILANT_PNT* Add_Vigilant_Point (OP* op, VIGILANT_PNT* vp=NULL) {
00175 Is_True (VIGILANT_PNT::Candidate (op),
00176 ("Op is not qualified to be a vigilant point"));
00177 Is_True (Find (op) == NULL, ("Duplicated vigilant point"));
00178 if (!vp) {
00179 vp = CXX_NEW(VIGILANT_PNT(op), _mp);
00180 }
00181 _vigilant_pnt_list.push_back (vp);
00182 return vp;
00183 }
00184
00185 VIGILANT_PNT* Remove_Vigilant_Point (OP* op) {
00186 for (VIGILANT_PNT_LIST_ITER iter = _vigilant_pnt_list.begin ();
00187 iter != _vigilant_pnt_list.end (); iter++) {
00188 if ((*iter)->Op() == op) {
00189 VIGILANT_PNT* vp = *iter;
00190 _vigilant_pnt_list.erase(iter);
00191 return vp;
00192 }
00193 }
00194 return NULL;
00195 }
00196
00197 VIGILANT_PNT& Vp_for_Exit (void) { return _exit_vp; }
00198 };
00199
00200 typedef mempool_allocator<BB_VIGILANT_PNT_MGR*> BB_VIGILANT_PNT_MGR_ALLOC;
00201 typedef std::list<BB_VIGILANT_PNT_MGR*, BB_VIGILANT_PNT_MGR_ALLOC>
00202 BB_VIGILANT_PNT_MGR_LIST;
00203 typedef BB_VIGILANT_PNT_MGR_LIST::iterator BB_VIGILANT_PNT_MGR_LIST_ITER;
00204
00205 class DATA_SPEC_RES_CONSTRAIT_MGR {
00206 private:
00207 MEM_POOL* _mp;
00208 REGION* _rgn;
00209 BB_VIGILANT_PNT_MGR_LIST* _buckets[32];
00210 INT hash_idx (BB* blk) const {
00211 return BB_id(blk) % (sizeof(_buckets)/(sizeof(_buckets[0])));
00212 }
00213
00214 BB_VIGILANT_PNT_MGR* Find (BB* blk) {
00215 INT idx = hash_idx (blk);
00216 for (BB_VIGILANT_PNT_MGR_LIST_ITER iter = _buckets[idx]->begin ();
00217 iter != _buckets[idx]->end(); iter++) {
00218 if ((*iter)->Bb() == blk) return *iter;
00219 }
00220 return NULL;
00221 }
00222
00223 void Update_Pending_Adv_Ld_Info
00224 (BB* blk, OP* upperbound, OP* lowerbound, OP* sched_op);
00225
00226 BOOL There_Exist_Misc_Dep_Arc (OP* pred, OP* succ);
00227
00228 BOOL Check_Res_Constraint_Helper
00229 (BB* bb, OP* predbound, OP* succbound, OP* op);
00230
00231 public:
00232 DATA_SPEC_RES_CONSTRAIT_MGR (MEM_POOL* mp);
00233 ~DATA_SPEC_RES_CONSTRAIT_MGR (void) {}
00234
00235
00236 void Init (REGION* gscope);
00237 void Init (BB* lscope);
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 BOOL Check_Res_Constraint (REGION* rgn, OP* op, SRC_BB_INFO* src_info);
00248 BOOL Check_Res_Constraint (BB* bb, OP* op);
00249
00250 VIGILANT_PNT* Get_Vigilant_Point (OP* op)
00251 { return Find (OP_bb(op))->Find (op); }
00252 VIGILANT_PNT* Add_Vigilant_Point (OP* op,VIGILANT_PNT* vp=NULL)
00253 { return Find (OP_bb(op))->Add_Vigilant_Point (op, vp); }
00254 VIGILANT_PNT* Remove_Vigilant_Point (OP* op) {
00255 return Find (OP_bb(op))->Remove_Vigilant_Point (op);
00256 }
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 void Update_Pending_Adv_Ld_Info (SRC_BB_INFO* srcinfo, OP* schedop);
00267
00268 void Update_Vp_For_Compensation_Code
00269 (OP* bookeeping, BB* compensation_blk);
00270
00271 void Print (FILE* f);
00272 };
00273
00274 #endif // SCHED_RES_AWARE_included