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
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
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 #ifndef _ara_region_INCLUDED
00095 #define _ara_region_INCLUDED
00096
00097 #include <stdlib.h>
00098 #ifndef defs_INCLUDED
00099 #include "defs.h"
00100 #endif
00101 #ifndef cxx_template_INCLUDED
00102 #include "cxx_template.h"
00103 #endif
00104 #ifndef cxx_base_INCLUDED
00105 #include "cxx_base.h"
00106 #endif
00107 #ifndef wn_INCLUDED
00108 #include "wn.h"
00109 #endif
00110 #ifndef access_vector_INCLUDED
00111 #include "access_vector.h"
00112 #endif
00113 #ifndef soe_INCLUDED
00114 #include "soe.h"
00115 #endif
00116
00117
00118 extern MEM_POOL ARA_memory_pool;
00119 class KERNEL_IMAGE;
00120 class KERNEL_LIST;
00121 class ARA_LOOP_INFO;
00122
00123 typedef STACK<INT> INT_ST;
00124
00125 enum ARA_REGION_TYPE {
00126 ARA_TOP, ARA_BOTTOM, ARA_TOO_MESSY, ARA_NORMAL
00127 };
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 class CON_PAIR {
00143
00144 public:
00145
00146 ACCESS_VECTOR *_ac_v;
00147 INT32 *_coeff;
00148
00149 CON_PAIR() {
00150 _ac_v = NULL;
00151 _coeff = NULL;
00152 }
00153
00154 CON_PAIR(CON_PAIR* c, INT dim);
00155
00156 CON_PAIR(ACCESS_VECTOR *av) {
00157 _coeff = NULL;
00158 _ac_v = CXX_NEW(ACCESS_VECTOR(av,&ARA_memory_pool), &ARA_memory_pool);
00159 }
00160
00161 CON_PAIR(ACCESS_VECTOR *av, INT* coeff, INT dim, MEM_POOL* mem_pool) {
00162 if (coeff != NULL) {
00163 _coeff = CXX_NEW_ARRAY(INT, dim, mem_pool);
00164 for (INT i = 0; i < dim; i++)
00165 _coeff[i] = coeff[i];
00166 } else {
00167 _coeff = NULL;
00168 }
00169 _ac_v = CXX_NEW(ACCESS_VECTOR(av, mem_pool), mem_pool);
00170 }
00171
00172
00173 CON_PAIR(SYSTEM_OF_EQUATIONS *soe, const INT i, const SYMBOL_LIST *syms);
00174
00175 CON_PAIR(const CON_PAIR &a, const INT dim);
00176
00177 ~CON_PAIR() {
00178 if (_ac_v) {
00179 CXX_DELETE(_ac_v, &ARA_memory_pool);
00180 _ac_v = NULL;
00181 }
00182 if (_coeff) {
00183 CXX_DELETE_ARRAY(_coeff, &ARA_memory_pool);
00184 _coeff = NULL;
00185 }
00186 }
00187
00188 BOOL Has_Formal_Parameter();
00189 ACCESS_VECTOR * Access_Vector(){ return _ac_v; }
00190 INT32 * Coeff() { return _coeff; }
00191 friend BOOL Equivalent(const CON_PAIR &a, const CON_PAIR &b, const INT dim);
00192 void Print(FILE *fp, INT dim) const;
00193 void WB_Print(FILE *fp, INT dim) const;
00194 INT WB_Print(char* bf, INT ccount, INT dim) const;
00195 void Print_Analysis_Info(FILE *fp, INT dim, DOLOOP_STACK &do_stack);
00196
00197 };
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 class AXLE_NODE {
00214
00215 public:
00216
00217
00218 CON_PAIR *lo;
00219
00220
00221
00222 CON_PAIR *up;
00223
00224
00225
00226
00227 INT16 step;
00228
00229 AXLE_NODE() {
00230 lo = up = NULL;
00231 step = 1;
00232 }
00233
00234 AXLE_NODE(AXLE_NODE* a, INT dim);
00235
00236 AXLE_NODE(const AXLE_NODE &a, const INT dim) {
00237 step = a.step;
00238 if (a.lo) lo = CXX_NEW(CON_PAIR(*a.lo,dim),&ARA_memory_pool);
00239 if (a.up) up = CXX_NEW(CON_PAIR(*a.up,dim),&ARA_memory_pool);
00240 }
00241
00242 ~AXLE_NODE() {
00243 if (lo) CXX_DELETE(lo, &ARA_memory_pool);
00244 if (up) CXX_DELETE(up, &ARA_memory_pool);
00245 }
00246
00247 BOOL Has_Formal_Parameter();
00248 void Clear();
00249
00250
00251 void Set_Axle(const SYSTEM_OF_EQUATIONS *soe,
00252 const INT i, const INT j, const SYMBOL_LIST *syms,
00253 const INT depth, const INT dim,
00254 const INT_ST & non_const_loops,
00255 const INT stride);
00256
00257 void Set_Axle_Eq(const SYSTEM_OF_EQUATIONS *soe,
00258 const INT i, const INT j, const SYMBOL_LIST *syms,
00259 const INT depth, const INT dim,
00260 const INT_ST & non_const_loops,
00261 const INT stride);
00262
00263 void Set_Axle_Le(const SYSTEM_OF_EQUATIONS *soe,
00264 const INT i, const INT j, const SYMBOL_LIST *syms,
00265 const INT depth, const INT dim,
00266 const INT_ST & non_const_loops,
00267 const INT stride);
00268
00269 void Set_Axle(const CON_PAIR *lo_new, const CON_PAIR *up_new,
00270 const INT16 step_new, const INT dim);
00271 void Set_To_Kernel_Image(const AXLE_NODE &a, const INT dim, const INT kernel_offset);
00272 void Init_To_Access(ACCESS_VECTOR *av);
00273
00274 friend BOOL Equivalent(const AXLE_NODE &a,
00275 const AXLE_NODE &b, const INT dim);
00276
00277 void Print(FILE *fp, INT dim) const;
00278 void WB_Print(FILE *fp, INT dim) const;
00279 INT WB_Print(char* bf, INT ccount, INT dim) const;
00280 void Print_Analysis_Info(FILE *fp, INT dim, INT indent, DOLOOP_STACK &do_stack);
00281
00282 };
00283
00284
00285
00286
00287
00288
00289
00290 class REGION : public SLIST_NODE {
00291
00292 public:
00293
00294 INT32 _dim;
00295 AXLE_NODE *_axle;
00296 mUINT16 _depth;
00297 ARA_REGION_TYPE _type;
00298 BOOL _coupled;
00299 ACCESS_ARRAY *_conditions;
00300 KERNEL_IMAGE *_kernel;
00301 STACK<WN*> _wn_list;
00302
00303
00304 REGION(WN* wn, ARA_LOOP_INFO *ara_loop_info);
00305 REGION(WN* wn, ACCESS_ARRAY* array);
00306 REGION(const REGION &a);
00307 REGION(REGION* r);
00308 REGION(const INT depth, const INT dim):_wn_list(&ARA_memory_pool)
00309 {
00310
00311 _type = ARA_TOO_MESSY;
00312 _axle = NULL;
00313 _conditions = NULL;
00314 _kernel = NULL;
00315 _depth = depth;
00316 _dim = dim;
00317
00318 }
00319
00320 ~REGION() {
00321
00322 if (_axle != NULL) CXX_DELETE_ARRAY(_axle, &ARA_memory_pool);
00323 if (_conditions != NULL) CXX_DELETE(_conditions, &ARA_memory_pool);
00324
00325 }
00326
00327 BOOL Has_Formal_Parameter();
00328 INT16 Num_Dim() { return _dim; }
00329 AXLE_NODE & Dim(INT32 i) { return _axle[i]; }
00330 void Set_Too_Messy() { _type = ARA_TOO_MESSY; }
00331 const KERNEL_IMAGE * Kernel(){ return _kernel; }
00332 BOOL Is_Too_Messy() const { return _type==ARA_TOO_MESSY; }
00333 BOOL Is_Empty() const { return _type==ARA_BOTTOM; }
00334 BOOL Is_All() const { return _type==ARA_TOP; }
00335 BOOL Is_Included(const REGION &a, const ARA_LOOP_INFO &ara_info);
00336 BOOL Is_Coupled() const { return _coupled; }
00337 BOOL Contains(WN* array_wn);
00338 BOOL Is_Loop_Invariant(WN *loop);
00339 REGION & Region_Projection(const INT pos, const ARA_LOOP_INFO &ara_info);
00340 void Set_Region(const SYSTEM_OF_EQUATIONS * soe,
00341 const SYMBOL_LIST * syms,
00342 const INT_ST & non_const_loops,
00343 const INT strides[]);
00344
00345 void Set_Region(const SYSTEM_OF_EQUATIONS * soe,
00346 const SYMBOL_LIST * syms,
00347 const INT_ST & non_const_loops,
00348 INT strides[],
00349 const INT pivot_row,
00350 const INT pos, const INT step, const INT projected_axle);
00351
00352 void Print(FILE *fp) const;
00353 void WB_Print(FILE *fp) const;
00354 INT WB_Print(char* bf, INT ccount) const;
00355 void Print_Analysis_Info(FILE *fp, INT indent, DOLOOP_STACK &do_stack);
00356
00357 friend REGION * Region_Intersect(const REGION &a, const REGION &b, const ARA_LOOP_INFO &ara_info);
00358 friend REGION * Region_Union(const REGION &a, const REGION &b, const ARA_LOOP_INFO &ara_info);
00359 friend INT Region_Compare(const REGION &a, const REGION &b, const ARA_LOOP_INFO &ara_info);
00360 friend void Add_To_SOE(const REGION &a, const INT pos,
00361 SYSTEM_OF_EQUATIONS *soe,
00362 SYMBOL_LIST *syms, INT_ST & non_const_loops,
00363 const BOOL convert_equation,
00364 const ARA_LOOP_INFO &ara_info);
00365
00366 };
00367
00368
00369 class REGION_UN : public SLIST {
00370 DECLARE_SLIST_CLASS(REGION_UN, REGION);
00371
00372 public:
00373
00374 ~REGION_UN(){
00375 while (!Is_Empty()) CXX_DELETE(Remove_Headnode(), &ARA_memory_pool);
00376 }
00377
00378 BOOL Has_Formal_Parameter();
00379 BOOL Is_Bottom() { return (Is_Empty() || Head()->Is_Empty()); }
00380 BOOL Is_All() { return (Head() && Head()->Is_All()); }
00381 BOOL Is_Included(const REGION &a, const ARA_LOOP_INFO &ara_info);
00382 BOOL Is_Included(const REGION_UN &a, const ARA_LOOP_INFO &ara_info);
00383 BOOL Contains(WN *array_wn);
00384 WN * Any_Wn();
00385
00386 REGION_UN & Add_Region(REGION *a, const ARA_LOOP_INFO &ara_info);
00387 REGION_UN & RegionUN_Projection(const INT depth, ARA_LOOP_INFO &ara_info);
00388 void Print(FILE *fp) const;
00389 void WB_Print(FILE *fp) const;
00390 INT WB_Print(char* bf, INT ccount) const;
00391 void Print_Analysis_Info(FILE *fp, INT indent, DOLOOP_STACK &do_stack);
00392
00393 friend REGION_UN * RegionUN_Intersect(const REGION_UN &a, const REGION_UN &b, const ARA_LOOP_INFO &ara_info);
00394 friend REGION_UN * RegionUN_Union(const REGION_UN &a, const REGION_UN &b, const ARA_LOOP_INFO &ara_info);
00395 friend BOOL RegionUN_LE(const REGION_UN &a, const REGION_UN &b, const ARA_LOOP_INFO &ara_info);
00396 friend BOOL RegionUN_EQ(const REGION_UN &a, const REGION_UN &b, const ARA_LOOP_INFO &ara_info);
00397
00398 };
00399
00400 class REGION_ITER : public SLIST_ITER {
00401 DECLARE_SLIST_ITER_CLASS(REGION_ITER, REGION, REGION_UN);
00402 };
00403
00404 class REGION_CONST_ITER : public SLIST_ITER {
00405 DECLARE_SLIST_CONST_ITER_CLASS(REGION_CONST_ITER, REGION, REGION_UN);
00406 };
00407
00408 #endif
00409