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
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 #ifndef GRA_INTERFERE_INCLUDED
00071 #define GRA_INTERFERE_INCLUDED
00072
00073 #ifndef GRA_INTERFERE_RCS_ID
00074 #define GRA_INTERFERE_RCS_ID
00075 #ifdef _KEEP_RCS_ID
00076 static char *gra_interfere_rcs_id = "$Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/gra_mon/SCCS/s.gra_interfere.h $ $Revision: 1.2 $";
00077 #endif
00078 #endif
00079
00080
00081 class LRANGE;
00082 class LRANGE_VSET;
00083 class INTERFERE_DEREF;
00084
00085 typedef INTERFERE_DEREF* INTERFERE;
00086
00087
00088
00089
00090 class INTERFERE_DEREF {
00091 public:
00092 INTERFERE_DEREF(void) {}
00093 ~INTERFERE_DEREF(void) {}
00094
00095
00096 BOOL Is_Vec(void) { return ((INTPTR) this) & ((INTPTR) 1); }
00097 LRANGE_VSET *Vec(void) {
00098 Is_True(Is_Vec(), ("Interfere not a vector"));
00099 return (LRANGE_VSET *) (((INTPTR) this) & ~ ((INTPTR) 1)); }
00100 BOOL Is_Bitset(void) { return (((INTPTR) this) & ((INTPTR) 1)) == 0;}
00101 LRANGE_SET *Bitset(void) {
00102 Is_True(Is_Bitset(), ("Interfere not a bitset"));
00103 return (LRANGE_SET *) this; }
00104 INT32 Count(void) { if (Is_Vec())
00105 return Vec()->Count();
00106 else return LRANGE_SET_Size(Bitset()); }
00107
00108
00109 INTERFERE Add_Neighbor(LRANGE *lrange, LRANGE_SUBUNIVERSE *subuniverse);
00110 INTERFERE Remove_Neighbor(LRANGE *lrange, LRANGE_SUBUNIVERSE *subuniverse);
00111 INTERFERE Replace_Neighbor(LRANGE* old_lr, LRANGE* new_lr,
00112 LRANGE_SUBUNIVERSE* subuniverse);
00113 };
00114
00115 class INTERFERE_MGR {
00116 MEM_POOL neighbor_vec_pool;
00117
00118
00119
00120 LRANGE** neighbor_vec;
00121 size_t neighbor_vec_size;
00122 LRANGE_SUBUNIVERSE* neighbor_subuniverse;
00123 size_t neighbor_count;
00124 INT neighbor_id_max;
00125
00126 public:
00127 INTERFERE_MGR(void) {
00128 MEM_POOL_Initialize(&neighbor_vec_pool,"GRA interference creation pool",
00129 FALSE);
00130 }
00131 ~INTERFERE_MGR(void) {}
00132
00133
00134 INTERFERE Make_Vec(LRANGE_VSET *vec) {
00135 Is_True((((INTPTR) vec) & ((INTPTR) 1)) == 0,("Low bit unexpectedly set"));
00136 return (INTERFERE) (((INTPTR) vec) | ((INTPTR) 1));
00137 }
00138 INTERFERE Make_Bitset(LRANGE_SET *set) {
00139 Is_True((((INTPTR) set) & ((INTPTR) 1)) == 0,("Low bit unexpectedly set"));
00140 return (INTERFERE) set;
00141 }
00142
00143
00144 INTERFERE Create_Empty( LRANGE_SUBUNIVERSE* subuniverse );
00145 void Create_Begin( LRANGE_SUBUNIVERSE* subuniverse );
00146 void Create_Add_Neighbor( LRANGE* neighbor );
00147 INTERFERE Create_End( void );
00148 };
00149
00150 extern INTERFERE_MGR intf_mgr;
00151
00152
00153 class INTERFERE_ITER {
00154 struct {
00155 LRANGE_SET* set;
00156 LRANGE* current;
00157 LRANGE_SUBUNIVERSE* subuniverse;
00158 } set_iter;
00159 LRANGE_VSET_ITER vec_iter;
00160 BOOL is_set;
00161 public:
00162 INTERFERE_ITER(void) {}
00163 ~INTERFERE_ITER(void) {}
00164
00165 void Init(INTERFERE intf, LRANGE_SUBUNIVERSE *subuniv) {
00166
00167
00168 if (intf->Is_Vec()) {
00169 is_set = FALSE;
00170 vec_iter.Init(intf->Vec());
00171 }
00172 else {
00173 is_set = TRUE;
00174 set_iter.set = intf->Bitset();
00175 set_iter.subuniverse = subuniv;
00176 set_iter.current = LRANGE_SET_ChooseS(set_iter.set, subuniv);
00177 }
00178 }
00179 BOOL Done(void) { if (is_set)
00180 return set_iter.current== LRANGE_SET_CHOOSE_FAILURE;
00181 else return vec_iter.Done(); }
00182 LRANGE *Current(void) { return is_set ? set_iter.current: vec_iter.Current();}
00183 void Step(void) {
00184 if (is_set)
00185 set_iter.current = LRANGE_SET_Choose_NextS(set_iter.set,
00186 set_iter.current, set_iter.subuniverse);
00187 else vec_iter.Step(); }
00188 };
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 class LRANGE_NEIGHBOR_ITER {
00201 public:
00202 void (*step)(LRANGE_NEIGHBOR_ITER *);
00203
00204
00205
00206 BOOL done;
00207 LRANGE* current;
00208
00209
00210
00211 ISA_REGISTER_CLASS rc;
00212
00213 union {
00214
00215 struct ll {
00216 LRANGE* lrange;
00217 } l;
00218 struct cc {
00219 GRA_BB* current_bb;
00220 } c;
00221 } u;
00222 INTERFERE_ITER neighbor_iter;
00223 LRANGE_LIVE_GBB_ITER live_gbb_iter;
00224 GRA_BB_LOCAL_LRANGE_ITER bb_local_iter;
00225 INTERFERE_ITER bb_live_global_iter;
00226
00227 LRANGE_NEIGHBOR_ITER(void) {}
00228 ~LRANGE_NEIGHBOR_ITER(void) {}
00229
00230 BOOL Done(void) { return done; }
00231 LRANGE *Current(void) { return current; }
00232 void Step(void) { (*step)(this); }
00233
00234 void Init(LRANGE *lrange, GRA_REGION *region);
00235 };
00236
00237 #endif