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 #ifndef ipa_section_INCLUDED
00038 #define ipa_section_INCLUDED
00039
00040 #ifdef IPA_SUMMARY
00041 #ifndef loop_info_INCLUDED
00042 #include "loop_info.h"
00043 #endif
00044 #ifndef cxx_hash_INCLUDED
00045 #include "cxx_hash.h"
00046 #endif
00047 #else
00048
00049 #ifndef defs_INCLUDED
00050 #include "defs.h"
00051 #endif
00052
00053 #ifndef wn_INCLUDED
00054 #include "wn.h"
00055 #endif
00056
00057 #ifndef access_vector_INCLUDED
00058 #include "access_vector.h"
00059 #endif
00060
00061 #ifndef cxx_memory_INCLUDED
00062 #include "cxx_memory.h"
00063 #endif
00064
00065 #ifndef cxx_base_INCLUDED
00066 #include "cxx_base.h"
00067 #endif
00068
00069 #ifndef opt_du_INCLUDED
00070 #include "optimizer.h"
00071 #endif
00072
00073 #endif
00074
00075
00076 class IPA_LNO_READ_FILE;
00077
00078 extern BOOL Trace_Sections;
00079
00080 typedef STACK<INT> INT_ST;
00081
00082 #define CONST_DESC 255
00083
00084
00085 enum IPA_SECTION_TYPE {
00086 IPA_DEF = 1,
00087 IPA_USE = 2,
00088 IPA_REDUC = 3,
00089 IPA_PASS = 4,
00090 IPA_UNKNOWN = 5
00091 };
00092
00093
00094 enum LTKIND {
00095 LTKIND_NONE,
00096 LTKIND_CONST,
00097 LTKIND_LINDEX,
00098 LTKIND_SUBSCR,
00099 LTKIND_IV
00100 };
00101
00102
00103
00104 enum ACTION_TYPE {
00105 ACTION_EQ,
00106 ACTION_LO,
00107 ACTION_UP
00108 };
00109
00110 typedef mINT32 COEFF;
00111 typedef mUINT16 DESCR;
00112
00113
00114
00115
00116
00117 class LOOP_SYMBOL
00118 {
00119 private:
00120 mUINT32 _ivar_index;
00121
00122 public:
00123 LOOP_SYMBOL (UINT32 index) :
00124 _ivar_index (index)
00125 {}
00126
00127 BOOL operator== (const LOOP_SYMBOL& other)
00128 {
00129 return (_ivar_index == other._ivar_index);
00130 }
00131
00132 UINT32 Ivar_Index () const { return _ivar_index; }
00133
00134 void Print (FILE* fp) { fprintf(fp, "IVAR[%d]\n", _ivar_index); }
00135 };
00136
00137 typedef DYN_ARRAY<LOOP_SYMBOL> LOOP_SYMBOL_ARRAY;
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 class IVAR
00148 {
00149 private:
00150 union {
00151 mUINT32 _formal_position;
00152 ST_IDX _st_idx;
00153 } u;
00154
00155 WN_OFFSET _offset;
00156 mTYPE_ID _mtype;
00157 mBOOL _is_formal;
00158
00159 public:
00160 IVAR (UINT32 position, WN_OFFSET offset, TYPE_ID mtype)
00161 {
00162 u._formal_position = position;
00163 _offset = offset;
00164 _mtype = mtype;
00165 _is_formal = TRUE;
00166 }
00167
00168 IVAR (const ST* st, WN_OFFSET offset, TYPE_ID mtype)
00169 {
00170 u._st_idx = ST_st_idx(st);
00171 _offset = offset;
00172 _mtype = mtype;
00173 _is_formal = FALSE;
00174 }
00175
00176 IVAR ()
00177 {
00178 u._formal_position = 0;
00179 u._st_idx = ST_IDX_ZERO;
00180 _offset = 0;
00181 _mtype = 0;
00182 _is_formal = FALSE;
00183 }
00184
00185 BOOL Is_Formal () const { return _is_formal; }
00186
00187 UINT32 Formal_Position () const
00188 {
00189 FmtAssert(_is_formal, ("IVAR::Formal_Position(): IVAR is not a formal"));
00190 return u._formal_position;
00191 }
00192
00193 void Set_Formal_Position(UINT32 formal_position)
00194 {
00195 _is_formal = TRUE;
00196 u._formal_position = formal_position;
00197 }
00198
00199 ST_IDX St_Idx () const
00200 {
00201 FmtAssert(!_is_formal, ("IVAR::St_Idx(): IVAR is a formal"));
00202 return u._st_idx;
00203 }
00204
00205 WN_OFFSET Offset () const { return _offset; }
00206
00207 void Set_Offset(WN_OFFSET offset) { _offset = offset; }
00208
00209 TYPE_ID Mtype () const { return _mtype; }
00210
00211 void Set_Mtype (TYPE_ID mtype) { _mtype = mtype; }
00212
00213 BOOL operator== (const IVAR& other) const
00214 {
00215 return (_is_formal == other._is_formal &&
00216 _offset == other._offset &&
00217 _mtype == other._mtype &&
00218 ((_is_formal && u._formal_position == other.u._formal_position) ||
00219 (!_is_formal && u._st_idx == other.u._st_idx)));
00220 }
00221
00222 void Set_St_Idx (ST_IDX new_st_idx)
00223 {
00224 _is_formal = FALSE;
00225 u._st_idx = new_st_idx;
00226 }
00227
00228 void Print (FILE* fp = stderr);
00229
00230 void WB_Print (FILE* fp, INT ivar_index);
00231
00232 void IPA_LNO_Print_File (FILE* fp = stderr, INT ivar_index = -1);
00233
00234 void IPA_LNO_Print (FILE* fp = stderr,
00235 IPA_LNO_READ_FILE* IPA_LNO_File = NULL);
00236
00237 };
00238
00239 typedef DYN_ARRAY<IVAR> IVAR_ARRAY;
00240
00241
00242
00243
00244 class TERM
00245 {
00246 private:
00247 COEFF _coeff;
00248 DESCR _desc;
00249 LTKIND _kind : 8;
00250 mUINT8 _projected_level;
00251
00252 public:
00253
00254 TERM (LTKIND kind, COEFF coeff, DESCR descr, mUINT8 level) :
00255 _coeff (coeff),
00256 _desc (descr),
00257 _kind (kind),
00258 _projected_level (level)
00259 {}
00260
00261 TERM (const TERM* term) :
00262 _coeff (term->_coeff),
00263 _desc (term->_desc),
00264 _kind (term->_kind),
00265 _projected_level (term->_projected_level)
00266 {}
00267
00268 void Set_coeff (COEFF w) { _coeff = w; }
00269 COEFF Get_coeff () const { return _coeff; }
00270
00271 void Set_desc (DESCR b) { _desc = b; }
00272 DESCR Get_desc () const { return _desc; }
00273
00274 void Set_type (LTKIND kind) { _kind = kind; }
00275 LTKIND Get_type () const { return _kind; }
00276
00277 void Set_projected_level (mUINT8 level) { _projected_level = level; }
00278 mUINT8 Get_projected_level () const { return _projected_level; }
00279
00280 BOOL Equivalent(TERM& t);
00281
00282 BOOL Is_equal(TERM* t, INT count);
00283
00284 void Print(FILE* fp = stderr, BOOL newline = TRUE);
00285
00286 void Print_file(FILE* fp = stderr);
00287
00288 void IPA_LNO_Print(FILE* fp = stderr, IPA_LNO_READ_FILE* ilr_file = NULL);
00289
00290 void IPA_LNO_Print_File(FILE* fp = stderr, INT term_index = -1);
00291
00292 void WB_Print(FILE* fp, INT term_index);
00293 };
00294
00295 typedef DYN_ARRAY<TERM> TERM_ARRAY;
00296
00297
00298 class LOOPINFO;
00299
00300
00301
00302
00303 class LINEX
00304 {
00305 private:
00306 TERM_ARRAY _larray;
00307
00308 public:
00309
00310 LINEX (MEM_POOL* m) { new (&_larray) TERM_ARRAY(m); }
00311
00312
00313 ~LINEX () { _larray.Free_array(); }
00314
00315
00316 mINT32 Num_terms () const { return _larray.Lastidx(); }
00317
00318 TERM* Get_term(INT32 idx) const { return &(_larray)[idx]; }
00319
00320 void Set_term(const TERM* term) { _larray.AddElement(TERM(term)); }
00321
00322 void Set_term(LTKIND kind, COEFF coeff, DESCR descr, mUINT8 level)
00323 {
00324 _larray.AddElement(TERM(kind, coeff, descr, level));
00325 }
00326
00327 void Set_linex_terms(INT start_index, INT end_index, TERM* term);
00328
00329
00330 INT Get_constant_term();
00331
00332
00333 void Copy(LINEX *to);
00334
00335
00336 BOOL Loop_coeff_terms_equal(LINEX* l);
00337
00338
00339 INT Num_loop_coeff_terms();
00340
00341
00342
00343 BOOL Has_loop_coeff(INT i);
00344
00345
00346 void Add_access(SYSTEM_OF_EQUATIONS *soe,
00347 mUINT8 depth,
00348 INT num_dim,
00349 INT axle,
00350 INT num_syms,
00351 ACTION_TYPE act,
00352 LOOP_SYMBOL_ARRAY* sym,
00353 BOOL trace);
00354
00355 void Print(FILE* fp = stderr);
00356 void Print_file(FILE* fp = stderr);
00357
00358 void Map_access_vector(ACCESS_VECTOR* av, BOOL Is_LNO,
00359 IPA_LNO_READ_FILE* IPA_LNO_File);
00360
00361
00362 void Map_from_SOE(const SYSTEM_OF_EQUATIONS* soe,
00363 INT i,
00364 const LOOP_SYMBOL_ARRAY* syms,
00365 INT depth,
00366 INT dim,
00367 INT which_array,
00368 BOOL is_lower_bound);
00369
00370
00371
00372 void Free_terms();
00373
00374 BOOL Equivalent(LINEX &b);
00375
00376
00377 INT Max(LINEX*l);
00378
00379
00380
00381 BOOL Is_const();
00382
00383
00384 LINEX* Merge(LINEX* l);
00385
00386
00387 LINEX* Subtract(LINEX* l);
00388
00389 void Init(MEM_POOL* m);
00390
00391 void Add_coupled_terms(LINEX* from);
00392
00393 void Simplify();
00394 void LNO_Simplify(IPA_LNO_READ_FILE* IPA_LNO_File, WN* wn_call);
00395 void Substitute_Lindex(INT lindex, LINEX* lx_substitute);
00396 void Remove_Zero_Terms();
00397 BOOL Has_Local_Symbol();
00398 };
00399
00400 typedef DYN_ARRAY<LINEX> LINEX_ARRAY;
00401
00402 class PROJECTED_KERNEL;
00403 typedef DYN_ARRAY<PROJECTED_KERNEL> PROJECTED_KERNEL_ARRAY;
00404 #ifdef IPA_SUMMARY
00405 extern IVAR_ARRAY *Ivar;
00406
00407
00408 typedef
00409 HASH_TABLE<LOOPINFO*,DO_LOOP_INFO_BASE*> LOOPINFO_TO_DLI_MAP;
00410 extern LOOPINFO_TO_DLI_MAP* IPL_Loopinfo_Map;
00411
00412
00413 class PROJECTED_REGION;
00414 typedef
00415 HASH_TABLE<PROJECTED_REGION*,ACCESS_ARRAY*> PROJ_REGION_TO_ACCESS_ARRAY_MAP;
00416 extern PROJ_REGION_TO_ACCESS_ARRAY_MAP* IPL_Access_Array_Map;
00417
00418 #endif
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429 class LOOPINFO
00430 {
00431 private:
00432 #define MESSY_UPPER_BOUND 0x01
00433 #define MESSY_LOWER_BOUND 0x02
00434 #define MESSY_STRIDE 0x04
00435 #define MESSY_BOUNDS 0x08
00436 #define MESSY_ANY_BOUNDS 0x0f
00437
00438 mINT8 _nest_level;
00439 mINT8 _flags;
00440
00441 MEM_POOL* _mem_pool;
00442
00443
00444 PROJECTED_KERNEL_ARRAY* _kernel;
00445
00446 union {
00447 struct {
00448 LINEX* _upper_linex;
00449 LINEX* _lower_linex;
00450 LINEX* _step_linex;
00451 LOOP_SYMBOL_ARRAY* _symbols;
00452 mINT16 _cd_idx;
00453 } u3;
00454 struct {
00455 mINT16 _upper_index;
00456 mINT16 _lower_index;
00457 mINT16 _step_index;
00458 mUINT8 _upper_count;
00459 mUINT8 _lower_count;
00460 mUINT8 _step_count;
00461 } u2;
00462 } u1;
00463
00464 public:
00465
00466 LOOPINFO(MEM_POOL* m) { BZERO(this, sizeof(LOOPINFO)); _mem_pool = m; }
00467
00468 LOOPINFO(MEM_POOL* m, INT32 cd_idx);
00469
00470 MEM_POOL* Mem_Pool() const { return _mem_pool; }
00471 void Set_Mem_Pool(MEM_POOL* m) { _mem_pool = m; }
00472
00473 mINT8 Get_nest_level() const { return _nest_level; }
00474 void Set_nest_level(mINT8 level) { _nest_level = level; }
00475
00476 mINT8 Get_flags() const { return _flags; }
00477 void Set_flags(mINT8 f) { _flags = f; }
00478
00479 mINT16 Get_cd_idx() const { return u1.u3._cd_idx; };
00480 void Set_cd_idx(mINT16 cd_idx) { u1.u3._cd_idx = cd_idx;};
00481
00482 LINEX* Get_upper_linex() const { return u1.u3._upper_linex; }
00483 LINEX* Get_lower_linex() const { return u1.u3._lower_linex; }
00484 LINEX* Get_step_linex() const { return u1.u3._step_linex; }
00485
00486 mINT32 Get_ub_term_index() const { return u1.u2._upper_index; }
00487 mINT32 Get_lb_term_index() const { return u1.u2._lower_index; }
00488 mINT32 Get_step_term_index() const { return u1.u2._step_index; }
00489 mUINT8 Get_ub_term_count() const { return u1.u2._upper_count; }
00490 mUINT8 Get_lb_term_count() const { return u1.u2._lower_count; }
00491 mUINT8 Get_step_term_count() const { return u1.u2._step_count; }
00492
00493 void Set_ub_term_index(mINT16 i) { u1.u2._upper_index = i; }
00494 void Set_lb_term_index(mINT16 i) { u1.u2._lower_index = i; }
00495 void Set_step_term_index(mINT16 i) { u1.u2._step_index = i; }
00496 void Set_ub_term_count(mUINT8 i) { u1.u2._upper_count = i; }
00497 void Set_lb_term_count(mUINT8 i) { u1.u2._lower_count = i; }
00498 void Set_step_term_count(mUINT8 i) { u1.u2._step_count = i; }
00499
00500 BOOL Is_messy_ub() const { return _flags & MESSY_UPPER_BOUND; }
00501 BOOL Is_messy_lb() const { return _flags & MESSY_LOWER_BOUND; }
00502 BOOL Is_messy_step() const { return _flags & MESSY_STRIDE; }
00503 BOOL Is_messy_bounds() const { return _flags & MESSY_BOUNDS; }
00504 BOOL Is_messy_any_bounds() const { return _flags & MESSY_ANY_BOUNDS; }
00505
00506 void Set_messy_ub () { _flags |= MESSY_UPPER_BOUND; }
00507 void Set_messy_lb() { _flags |= MESSY_LOWER_BOUND; }
00508 void Set_messy_step() { _flags |= MESSY_STRIDE; }
00509 void Set_messy_bounds() { _flags |= MESSY_ANY_BOUNDS; }
00510
00511 #ifdef IPA_SUMMARY
00512 void Map_do_loop_info(DO_LOOP_INFO_BASE* dli);
00513 #endif
00514
00515 void Create_linex(TERM* term);
00516
00517 LINEX* Build_linex(ACCESS_VECTOR* av);
00518
00519 PROJECTED_KERNEL_ARRAY* Get_kernels() const { return _kernel; }
00520
00521 void Add_bound(LINEX* l,
00522 SYSTEM_OF_EQUATIONS* soe,
00523 mUINT8 depth,
00524 INT num_dim,
00525 INT num_syms,
00526 LOOP_SYMBOL_ARRAY* sym);
00527
00528
00529
00530 void Print(FILE* fp = stderr);
00531 void Print_file(FILE* fp = stderr);
00532 void WB_Print(FILE* fp, INT loop_info_index);
00533
00534 LOOP_SYMBOL_ARRAY* Get_symbol_array() const { return u1.u3._symbols;};
00535
00536 LINEX* Min_value();
00537 LINEX* Max_value();
00538 };
00539
00540 typedef DYN_ARRAY<LOOPINFO> LOOPINFO_ARRAY;
00541
00542
00543
00544
00545
00546
00547 class PROJECTED_NODE
00548 {
00549 private:
00550 #define MESSY_UPPER_BOUND 0x01
00551 #define MESSY_LOWER_BOUND 0x02
00552 #define MESSY_STRIDE 0x04
00553 #define UNPROJECTED 0x08
00554 #define ASSUMED_SHAPE 0x10
00555
00556 union {
00557 struct {
00558 LINEX* _lb_linex;
00559 LINEX* _ub_linex;
00560 LINEX* _step_linex;
00561 LINEX* _segment_length_linex;
00562 LINEX* _segment_stride_linex;
00563 } u0;
00564 struct {
00565 mINT32 _lb_term_index : 24;
00566 mUINT32 _lb_term_count : 8;
00567 mINT32 _ub_term_index : 24;
00568 mUINT32 _ub_term_count : 8;
00569 mINT32 _step_term_index : 24;
00570 mUINT32 _step_term_count : 8;
00571 mINT32 _segment_length_term_index : 24;
00572 mUINT32 _segment_length_term_count : 8;
00573 mINT32 _segment_stride_term_index : 24;
00574 mUINT32 _segment_stride_term_count : 8;
00575 } u1;
00576 } u2;
00577
00578 mUINT32 _flags;
00579 MEM_POOL* _mem_pool;
00580
00581 public:
00582 void Init(MEM_POOL* m);
00583
00584 void Set_Mem_Pool(MEM_POOL* mem_pool) { _mem_pool = mem_pool; }
00585 MEM_POOL* Mem_Pool() { return _mem_pool; }
00586
00587 LINEX* Get_lower_linex() const { return (u2.u0._lb_linex); }
00588 void Set_lower_linex(LINEX* l) { u2.u0._lb_linex = l; }
00589
00590 LINEX* Get_upper_linex() const { return (u2.u0._ub_linex); }
00591 void Set_upper_linex(LINEX* l) { u2.u0._ub_linex = l; }
00592
00593 LINEX* Get_step_linex() const { return (u2.u0._step_linex); }
00594 void Set_step_linex(LINEX* l) { u2.u0._step_linex = l; }
00595
00596 LINEX* Get_segment_length_linex() const {
00597 return (u2.u0._segment_length_linex);
00598 }
00599 void Set_segment_length_linex(LINEX* l) {
00600 u2.u0._segment_length_linex = l;
00601 }
00602
00603 LINEX* Get_segment_stride_linex() const {
00604 return (u2.u0._segment_stride_linex);
00605 }
00606 void Set_segment_stride_linex(LINEX* l) {
00607 u2.u0._segment_stride_linex = l;
00608 }
00609
00610 mINT32 Get_lb_term_index() const { return u2.u1._lb_term_index; }
00611 void Set_lb_term_index(mINT32 i) { u2.u1._lb_term_index = i; }
00612
00613 mUINT32 Get_lb_term_count() const { return u2.u1._lb_term_count; }
00614 void Set_lb_term_count(mUINT32 i) { u2.u1._lb_term_count = i; }
00615
00616 mINT32 Get_ub_term_index() const { return u2.u1._ub_term_index; }
00617 void Set_ub_term_index(mINT32 i) { u2.u1._ub_term_index = i; }
00618
00619 mUINT32 Get_ub_term_count() const { return u2.u1._ub_term_count; }
00620 void Set_ub_term_count(mUINT32 i) { u2.u1._ub_term_count =i; }
00621
00622 mINT32 Get_step_term_index() const { return u2.u1._step_term_index; }
00623 void Set_step_term_index(mINT32 i) { u2.u1._step_term_index=i; }
00624
00625 mUINT32 Get_step_term_count() const { return u2.u1._step_term_count; }
00626 void Set_step_term_count(mUINT32 i) { u2.u1._step_term_count = i; }
00627
00628 mINT32 Get_segment_length_term_index() const {
00629 return u2.u1._segment_length_term_index;
00630 }
00631 void Set_segment_length_term_index(mINT32 i) {
00632 u2.u1._segment_length_term_index=i;
00633 }
00634
00635 mINT32 Get_segment_length_term_count() const {
00636 return u2.u1._segment_length_term_count;
00637 }
00638 void Set_segment_length_term_count(mINT32 i) {
00639 u2.u1._segment_length_term_count=i;
00640 }
00641
00642 mINT32 Get_segment_stride_term_index() const {
00643 return u2.u1._segment_stride_term_index;
00644 }
00645 void Set_segment_stride_term_index(mINT32 i) {
00646 u2.u1._segment_stride_term_index=i;
00647 }
00648
00649 mINT32 Get_segment_stride_term_count() const {
00650 return u2.u1._segment_stride_term_count;
00651 }
00652 void Set_segment_stride_term_count(mINT32 i) {
00653 u2.u1._segment_stride_term_count=i;
00654 }
00655
00656 BOOL Is_messy_ub() const { return _flags & MESSY_UPPER_BOUND;}
00657 void Set_messy_ub() { _flags |= MESSY_UPPER_BOUND; }
00658
00659 BOOL Is_messy_lb() const { return _flags & MESSY_LOWER_BOUND; }
00660 void Set_messy_lb() { _flags |= MESSY_LOWER_BOUND; }
00661
00662 BOOL Is_messy_step() const { return _flags & MESSY_STRIDE; }
00663 void Set_messy_step() { _flags |= MESSY_STRIDE; }
00664
00665 BOOL Has_a_messy_bound() const
00666 { return _flags & (MESSY_UPPER_BOUND | MESSY_LOWER_BOUND | MESSY_STRIDE); }
00667
00668 BOOL Has_all_messy_bounds() const {
00669 return ((_flags & MESSY_UPPER_BOUND) &&
00670 (_flags & MESSY_LOWER_BOUND) &&
00671 (_flags & MESSY_STRIDE));
00672 }
00673
00674 void Set_all_messy_bounds()
00675 {_flags |= (MESSY_UPPER_BOUND | MESSY_LOWER_BOUND | MESSY_STRIDE); }
00676
00677 BOOL Is_unprojected() const { return _flags & UNPROJECTED; }
00678 void Set_unprojected() { _flags |= UNPROJECTED; }
00679 void Reset_is_unprojected() { _flags &= ~UNPROJECTED; }
00680
00681 BOOL Is_assumed_shape() const { return _flags & ASSUMED_SHAPE; }
00682 void Set_assumed_shape() { _flags |= ASSUMED_SHAPE; }
00683
00684 mUINT32 Get_flags() const { return _flags; }
00685 void Set_flags(mUINT32 flags) { _flags = flags; }
00686
00687
00688 void Create_linex(TERM* t);
00689
00690
00691 INT Get_constant_term();
00692
00693 void Set_linexs(const SYSTEM_OF_EQUATIONS *soe,
00694 INT i,
00695 INT j,
00696 const LOOP_SYMBOL_ARRAY *syms,
00697 INT depth,
00698 INT dim,
00699 INT stride);
00700
00701 void Set_linexs(LINEX* low_new,
00702 LINEX* up_new,
00703 LINEX* step_new,
00704 LINEX* segment_length_new,
00705 LINEX* segment_stride_new);
00706
00707 void Set_linex_eq(const SYSTEM_OF_EQUATIONS *soe,
00708 INT i,
00709 INT j,
00710 const LOOP_SYMBOL_ARRAY *syms,
00711 INT depth,
00712 INT dim,
00713 INT stride);
00714
00715 void Set_linex_le(const SYSTEM_OF_EQUATIONS *soe,
00716 INT i,
00717 INT j,
00718 const LOOP_SYMBOL_ARRAY *syms,
00719 INT depth,
00720 INT dim,
00721 INT stride);
00722
00723
00724 void Set_constant_linexs(INT32 upper,
00725 INT32 lower,
00726 INT32 step,
00727 INT32 segment_length,
00728 INT32 segment_stride);
00729
00730
00731 void Set_constant_two_strided_section(INT32 lower,
00732 INT32 upper,
00733 INT32 step,
00734 INT32 seg_len,
00735 INT32 seg_stride);
00736
00737
00738 void Reset_node();
00739
00740 BOOL Equivalent( PROJECTED_NODE &b);
00741
00742
00743 void Copy(PROJECTED_NODE *to);
00744
00745
00746 void Print(FILE *fp = stderr);
00747 void Print_file(FILE* fp = stderr);
00748 void IPA_LNO_Print(FILE *fp = stderr,
00749 IPA_LNO_READ_FILE* IPA_LNO_File = NULL);
00750 void IPA_LNO_Print_File(FILE *fp = stderr, INT pn_index = -1);
00751 void WB_Print(FILE* fp, INT proj_node_index);
00752
00753 void Set_to_kernel_image(PROJECTED_NODE* pn_kernel, LINEX* lx_offset);
00754
00755 void Fill_Out();
00756
00757 void Simplify();
00758 void LNO_Simplify(IPA_LNO_READ_FILE* IPA_LNO_File, WN* wn_call);
00759 BOOL Matching_Segment_Stride(PROJECTED_NODE* pn);
00760 };
00761
00762 typedef DYN_ARRAY<PROJECTED_NODE> PROJECTED_ARRAY;
00763
00764 class PROJECTED_KERNEL;
00765
00766
00767
00768
00769
00770 class PROJECTED_REGION
00771 {
00772 private:
00773 #define MESSY_REGION 1
00774 #define NON_MESSY_REGION 2
00775 #define UNPROJECTED_REGION 4
00776 #define IS_MAY_KILL 8
00777 #define IS_MAY_USE 16
00778 #define IS_PASSED 32
00779 #define IS_FORMAL 64
00780
00781 union {
00782 PROJECTED_ARRAY* _region;
00783 mINT32 _id;
00784 } u1;
00785
00786 mINT16 _type;
00787 mUINT8 _num_dims;
00788 mUINT8 _depth;
00789
00790
00791
00792 union {
00793 mINT32 _projected_kernel;
00794 PROJECTED_KERNEL *_p;
00795 struct {
00796 mINT16 _callsite_id;
00797 mINT16 _actual_id;
00798 } u22;
00799 } u2;
00800
00801 MEM_POOL* _mem_pool;
00802
00803 public:
00804
00805 PROJECTED_REGION(ACCESS_ARRAY* ar,
00806 MEM_POOL* mem_pool,
00807 LOOPINFO *loop,
00808 BOOL in_ipl = TRUE,
00809 IPA_LNO_READ_FILE* IPA_LNO_File = NULL);
00810
00811 PROJECTED_REGION(PROJECTED_REGION* p);
00812
00813 PROJECTED_REGION(mINT16 type,
00814 mUINT8 depth,
00815 mUINT8 num_dim,
00816 MEM_POOL* mem_pool);
00817
00818
00819 void Set_Mem_Pool(MEM_POOL* mem_pool) { _mem_pool = mem_pool; }
00820 MEM_POOL* Mem_Pool() { return _mem_pool; }
00821
00822 void Set_callsite_id(INT16 id) { u2.u22._callsite_id = id;};
00823 INT16 Get_callsite_id() const { return u2.u22._callsite_id;};
00824
00825 void Set_actual_id(INT16 id) { u2.u22._actual_id = id;};
00826 INT16 Get_actual_id() const { return u2.u22._actual_id;};
00827
00828 void Set_id(INT32 i) { u1._id = i;};
00829 INT32 Get_id() const { return u1._id;};
00830
00831 void Set_type(mINT16 type) { _type = type;};
00832 mINT16 Get_type() const { return _type; };
00833
00834 void Set_num_dims(mUINT8 num_dims) { _num_dims = num_dims;};
00835 mUINT8 Get_num_dims() const { return _num_dims;};
00836
00837 void Set_depth(mUINT8 depth) { _depth = depth;};
00838 mUINT8 Get_depth() const { return _depth;};
00839
00840 mINT32 Get_projected_kernel_id() const { return u2._projected_kernel;};
00841 void Set_projected_kernel_id(mINT32 id) { u2._projected_kernel = id; };
00842
00843 PROJECTED_KERNEL* Get_projected_kernel() const { return u2._p;};
00844 void Set_projected_kernel(PROJECTED_KERNEL *p) { u2._p = p;};
00845
00846 BOOL Is_unprojected_region() const { return _type &
00847 UNPROJECTED_REGION;};
00848 void Set_unprojected() { _type = _type | UNPROJECTED_REGION;};
00849
00850 void Reset_is_unprojected() { _type = _type & ~UNPROJECTED_REGION;};
00851
00852 BOOL Is_messy_region() const { return _type & MESSY_REGION;};
00853 void Set_messy_region() { _type = _type | MESSY_REGION;};
00854
00855 void Reset_messy_region() { _type = _type & ~MESSY_REGION;};
00856
00857 BOOL Is_may_kill() const { return _type & IS_MAY_KILL;};
00858 void Set_is_may_kill() { _type = _type | IS_MAY_KILL;};
00859
00860 BOOL Is_may_use() const { return _type & IS_MAY_USE;};
00861 void Set_is_may_use() { _type = _type | IS_MAY_USE;};
00862
00863 BOOL Is_passed() const { return _type & IS_PASSED;};
00864 void Set_is_passed() { _type = _type | IS_PASSED;};
00865
00866 BOOL Is_formal() const { return _type & IS_FORMAL;};
00867 void Set_is_formal() { _type = _type | IS_FORMAL;};
00868
00869 void Set_projected_node(PROJECTED_NODE *node) {
00870 u1._region->AddElement(*node);
00871 }
00872 PROJECTED_NODE* Get_projected_node(INT i) { return &(*u1._region)[i]; }
00873
00874 BOOL Has_Messy_Bounds();
00875 BOOL Has_Important_Messy_Bounds();
00876 void Set_Messy_If_Local_Symbol();
00877
00878 void Copy_projected_node(PROJECTED_NODE* node);
00879 void Copy_write(PROJECTED_REGION *p_in);
00880
00881 void Set_projected_array(PROJECTED_ARRAY* region) { u1._region = region; }
00882 PROJECTED_ARRAY* Get_projected_array() const { return u1._region; }
00883
00884
00885
00886 INT Compare(PROJECTED_REGION *b);
00887
00888 LINEX_ARRAY* Map_to_linex_array();
00889
00890 void Project(INT depth, LOOPINFO *l);
00891 PROJECTED_REGION *Union(PROJECTED_REGION &b, const LOOPINFO& l);
00892
00893 BOOL May_Union(PROJECTED_REGION& b, BOOL trace);
00894
00895 void Set_region(SYSTEM_OF_EQUATIONS *soe,
00896 LOOP_SYMBOL_ARRAY *syms,
00897 INT stride[],
00898 INT pivot_row,
00899 INT pos,
00900 INT loop_step,
00901 INT projected_axle);
00902
00903 BOOL Equivalent(PROJECTED_REGION* p);
00904
00905 BOOL Constant_bounds(mUINT8 num_dims);
00906
00907 void Print(FILE* fp = stderr);
00908 void Print_file(FILE* fp = stderr);
00909 void IPA_LNO_Print(FILE* fp = stderr, IPA_LNO_READ_FILE*
00910 IPA_LNO_File = NULL);
00911 void IPA_LNO_Print_File(FILE* fp = stderr, INT pr_index = -1);
00912 void WB_Print(FILE* fp, INT proj_region_index);
00913
00914 void Simplify();
00915 void LNO_Simplify(IPA_LNO_READ_FILE* IPA_LNO_File, WN* wn_call);
00916 void Fill_Out();
00917 BOOL Matching_Segment_Stride(PROJECTED_REGION* pr);
00918 };
00919
00920 typedef DYN_ARRAY<PROJECTED_REGION> PROJECTED_REGION_ARRAY;
00921
00922
00923
00924
00925
00926
00927 class PROJECTED_KERNEL
00928 {
00929 private:
00930 #define PROJECTED 1
00931 #define MESSY_KERNEL 2
00932 LINEX_ARRAY* _array;
00933 BOOL *_is_independent;
00934 mINT16 _projected_level;
00935 mUINT8 _depth;
00936 mUINT8 _type;
00937 LINEX_ARRAY* _difference;
00938 union {
00939 PROJECTED_REGION *_region;
00940 INT _id;
00941 } u1;
00942 MEM_POOL* _mem_pool;
00943
00944 public:
00945
00946 void Set_Mem_Pool(MEM_POOL* mem_pool) { _mem_pool = mem_pool; }
00947 MEM_POOL* Mem_Pool() { return _mem_pool; }
00948
00949 void Init(PROJECTED_REGION*, LOOPINFO*);
00950
00951 BOOL Is_independent(mINT32 i) const { return _is_independent[i];};
00952
00953 void Set_depth(mUINT8 depth) { _depth = depth;};
00954 mUINT8 Get_depth() const { return _depth;};
00955
00956 void Set_projected_level(mINT16 level)
00957 { _projected_level = level;};
00958
00959 void Set_region(PROJECTED_REGION* r) { u1._region = r;};
00960 PROJECTED_REGION* Get_region() const { return u1._region;};
00961
00962 mINT16 Get_projected_level() { return _projected_level;};
00963 mINT16 Get_num_dims() { return _array->Lastidx()+1;};
00964
00965 LINEX* Get_linex(INT32 i) { return &(*_array)[i]; };
00966
00967 void Set_is_projected() { _type = _type | PROJECTED;};
00968 BOOL Is_projected() const { return _type & PROJECTED;};
00969
00970 void Set_messy_kernel() { _type = _type | MESSY_KERNEL;};
00971 BOOL Is_messy_kernel() const { return _type & MESSY_KERNEL;};
00972
00973 void Project(mUINT8 depth, LOOPINFO* loop);
00974 void Print(FILE* fp = stderr);
00975
00976 LINEX_ARRAY* Get_Difference() {return _difference;};
00977 LINEX* Get_Difference(INT i)
00978 {return _difference != NULL && i <= _difference->Lastidx()
00979 ? &(*_difference)[i] : NULL;};
00980 void Set_Difference(PROJECTED_REGION* pr);
00981 };
00982
00983
00984
00985
00986 class PROJECTED_REGION_INFO
00987 {
00988 private:
00989 PROJECTED_REGION *_p;
00990
00991 public:
00992 void Set_projected_region(PROJECTED_REGION *p) { _p = p; };
00993 PROJECTED_REGION*
00994 Get_projected_region() { return _p;};
00995 void Print(FILE *fp = stderr);
00996 };
00997
00998 typedef DYN_ARRAY<PROJECTED_REGION_INFO> PROJECTED_REGION_INFO_ARRAY;
00999
01000 #define IPL_HAS_BAD_ALIAS 1
01001 #define IPL_IS_LOOP_INVARIANT 2
01002 #define IPL_IS_DEF 4 // is it a definition?
01003 #define IPL_IS_USE 8 // is it a use?
01004 #define IPL_IS_PASSED 16 // is is passed?
01005 #define IPL_IS_MAY_USE 32 // may be used
01006 #define IPL_IS_MAY_DEF 64 // may be defined
01007 #define IPL_IS_FORMAL 128 // is a formal parameter
01008
01009
01010
01011
01012 class REGION_ARRAYS
01013 {
01014 private:
01015 mUINT8 _type;
01016 mINT32 _sym_index;
01017 mINT32 _element_size;
01018
01019 union {
01020 PROJECTED_REGION_INFO_ARRAY *_regions;
01021 struct {
01022 mINT32 _idx;
01023 mINT32 _count;
01024 } u2;
01025 } u1;
01026
01027 public:
01028 REGION_ARRAYS(MEM_POOL *m, mINT32 index) {
01029 u1._regions = (PROJECTED_REGION_INFO_ARRAY*)
01030 CXX_NEW(PROJECTED_REGION_INFO_ARRAY(m),m);
01031 _type = 0;
01032 _sym_index = index;
01033 }
01034
01035 void Set_type(mUINT8 t ) { _type = t;};
01036 mUINT8 Get_type() const { return _type;};
01037
01038 void Init(mINT32 index, mINT32 element_size, MEM_POOL *m);
01039
01040 void Copy_write(REGION_ARRAYS *r);
01041
01042 PROJECTED_REGION_INFO_ARRAY*
01043 Get_projected_region_array() const { return u1._regions; };
01044
01045 void Set_has_bad_alias() { _type = _type | IPL_HAS_BAD_ALIAS;};
01046 BOOL Is_bad_alias() const { return _type & IPL_HAS_BAD_ALIAS ;};
01047
01048 void Set_is_loop_invariant() { _type = _type |
01049 IPL_IS_LOOP_INVARIANT;};
01050 BOOL Is_loop_invariant() const { return _type & IPL_IS_LOOP_INVARIANT;};
01051
01052 void Set_is_use() { _type = _type | IPL_IS_USE;};
01053 BOOL Is_use() const { return _type & IPL_IS_USE;};
01054
01055 void Set_is_def() { _type = _type | IPL_IS_DEF;};
01056 BOOL Is_def() const { return _type & IPL_IS_DEF;};
01057
01058 void Set_is_passed() { _type = _type | IPL_IS_PASSED;};
01059 BOOL Is_passed() const { return _type & IPL_IS_PASSED;};
01060
01061 void Set_is_may_def() { _type = _type | IPL_IS_MAY_DEF;};
01062 BOOL Is_may_def() const { return _type & IPL_IS_MAY_DEF;};
01063
01064 void Set_is_may_use() { _type = _type | IPL_IS_MAY_USE;};
01065 BOOL Is_may_use() const { return _type & IPL_IS_MAY_USE;};
01066
01067 void Set_is_formal() { _type = _type | IPL_IS_FORMAL;};
01068 BOOL Is_formal() const { return _type & IPL_IS_FORMAL;};
01069
01070 mINT32 Get_sym_id() const { return _sym_index;};
01071 void Set_sym_id(INT id) { _sym_index = id;};
01072
01073 mINT32 Get_element_size() const {return _element_size;};
01074 void Set_element_size(mINT32 element_size) {_element_size = element_size;};
01075
01076
01077 mINT32 Get_idx() const { return u1.u2._idx;};
01078 void Set_idx(mINT32 id) { u1.u2._idx = id; };
01079
01080
01081
01082 mINT32 Get_count() const { return u1.u2._count; };
01083 void Set_count(mINT32 count) { u1.u2._count = count;};
01084
01085 PROJECTED_REGION*
01086 Get_Projected_Region(INT i);
01087
01088
01089 void Print(FILE *fp = stderr);
01090 void Print_file(FILE* fp = stderr);
01091 void WB_Print(FILE* fp, INT region_index, const char* name, const char* func_name);
01092 };
01093
01094 typedef DYN_ARRAY<REGION_ARRAYS> ARRAY_OF_REGION_ARRAYS;
01095
01096
01097 #define IPA_SCALAR_MAY_KILL 1
01098 #define IPA_SCALAR_MAY_USE 2
01099 #define IPA_SCALAR_MAY_REDUC 4
01100 #define IPA_SCALAR_KILL 8
01101 #define IPA_SCALAR_USE 16
01102 #define IPA_SCALAR_REDUC 32
01103 #define IPA_ARRAY_REDUC 64
01104 #define IPA_ARRAY_MAY_REDUC 128
01105 #define IPA_SCALAR_PASSED 256
01106 #define IPA_SCALAR_EUSE 512
01107 #define IPA_SCALAR_CALL_EUSE 1024
01108 #define IPA_SCALAR_MAY_PASS 2048
01109 class SCALAR_INFO
01110 {
01111 public:
01112 mINT32 _index;
01113 mINT16 _type;
01114 mINT16 _call_index;
01115
01116 public:
01117 mINT32 Get_id() const { return _index;};
01118 void Set_id(mINT32 i) { _index = i;};
01119
01120 mINT16 Get_type() const { return _type;};
01121 void Set_type(mINT16 t) { _type = t;};
01122
01123 void Set_callsite_id(mINT16 c) { _call_index = c;};
01124 mINT16 Get_callsite_id() const { return _call_index;};
01125
01126 void Set_may_kill() { _type = _type | IPA_SCALAR_MAY_KILL;};
01127 BOOL Is_may_kill() const { return _type & IPA_SCALAR_MAY_KILL;};
01128
01129 void Set_may_use() { _type = _type | IPA_SCALAR_MAY_USE;};
01130 BOOL Is_may_use() const { return _type & IPA_SCALAR_MAY_USE;};
01131
01132 void Set_may_reduc() { _type = _type | IPA_SCALAR_MAY_REDUC;};
01133 BOOL Is_may_reduc() const { return _type & IPA_SCALAR_MAY_REDUC;};
01134
01135 void Set_kill() { _type = _type | IPA_SCALAR_KILL;};
01136 BOOL Is_kill() const { return _type & IPA_SCALAR_KILL;};
01137
01138 void Set_use() { _type = _type | IPA_SCALAR_USE;};
01139 BOOL Is_use() const { return _type & IPA_SCALAR_USE;};
01140
01141 void Set_euse() { _type = _type | IPA_SCALAR_EUSE;};
01142 BOOL Is_euse() const { return _type & IPA_SCALAR_EUSE;};
01143
01144 void Set_call_euse() { _type = _type | IPA_SCALAR_CALL_EUSE;};
01145 BOOL Is_call_euse() const { return _type & IPA_SCALAR_CALL_EUSE;};
01146
01147 void Set_reduc() { _type = _type | IPA_SCALAR_REDUC;};
01148 BOOL Is_reduc() const { return _type & IPA_SCALAR_REDUC;};
01149
01150 void Set_array_reduc() { _type = _type | IPA_ARRAY_REDUC;};
01151 BOOL Is_array_reduc() const { return _type & IPA_ARRAY_REDUC;};
01152
01153 void Set_array_may_reduc() { _type = _type | IPA_ARRAY_MAY_REDUC;};
01154 BOOL Is_array_may_reduc() const { return _type & IPA_ARRAY_MAY_REDUC;};
01155
01156 void Set_passed_ref() { _type = _type | IPA_SCALAR_PASSED;};
01157 BOOL Is_passed_ref() const { return _type & IPA_SCALAR_PASSED;};
01158
01159 void Set_may_passed_ref() { _type = _type | IPA_SCALAR_MAY_PASS;};
01160 BOOL Is_may_passed_ref() const { return _type & IPA_SCALAR_MAY_PASS;};
01161
01162 SCALAR_INFO () { _type = 0; _call_index =-1; _index = 0;};
01163 void Init() { _type =0; _call_index = -1; _index =0; };
01164
01165 void Print_file(FILE *fp = stderr);
01166 void Print(FILE *fp = stderr) { Print_file(fp); };
01167 void WB_Print(FILE* fp, INT scalar_index, const char* name, const char* func_name);
01168 };
01169
01170 typedef DYN_ARRAY<SCALAR_INFO> INT_ARRAY;
01171
01172
01173
01174
01175
01176 class CFG_NODE_INFO
01177 {
01178 private:
01179 union {
01180 ARRAY_OF_REGION_ARRAYS *_def;
01181 mINT32 _def_index;
01182 } u1;
01183 union {
01184 ARRAY_OF_REGION_ARRAYS *_use;
01185 mINT32 _use_index;
01186 } u2;
01187 union {
01188 ARRAY_OF_REGION_ARRAYS *_param;
01189 mINT32 _param_index;
01190 } u3;
01191 union {
01192 INT_ARRAY *_scalar_info;
01193 mINT32 _scalar_index;
01194 } u4;
01195 union {
01196 LOOPINFO *_loop;
01197 mINT32 _index;
01198 } u5;
01199 union {
01200 ARRAY_OF_REGION_ARRAYS *_formal;
01201 mINT32 _formal_index;
01202 } u6;
01203
01204 mINT16 _def_count;
01205 mINT16 _use_count;
01206 mINT16 _param_count;
01207 mINT16 _scalar_count;
01208 mINT16 _formal_count;
01209
01210 enum _cfg_type {
01211 CFG_IF = 1,
01212 CFG_DO_LOOP = 2,
01213 CFG_ENTRY = 3,
01214 CFG_ELSE = 4,
01215 CFG_UNKNOWN = 5
01216 } _type : 4;
01217
01218 enum _cfg_state {
01219 CFG_STATE_CLEAR = 0x0,
01220 CFG_HAS_CALLS = 0x1,
01221 CFG_IS_EXECUTED = 0x2
01222
01223
01224
01225 } _state : 4;
01226
01227 mINT32 _cd_index : 24;
01228
01229 public:
01230
01231 #if 0
01232 void Set_type(enum cfg_type t) { _type = t;};
01233 enum cfg_type Get_type() { return _type;};
01234 #endif
01235 void Set_type_if() { _type = CFG_IF; }
01236 void Set_type_do_loop() { _type = CFG_DO_LOOP; }
01237 void Set_type_entry() { _type = CFG_ENTRY; }
01238 void Set_type_else() { _type = CFG_ELSE; }
01239
01240 BOOL Is_if() const { return _type == CFG_IF; }
01241 BOOL Is_do_loop() const { return _type == CFG_DO_LOOP; }
01242 BOOL Is_entry() const { return _type == CFG_ENTRY; }
01243 BOOL Is_else() const { return _type == CFG_ELSE; }
01244
01245 #if 0
01246 void Set_state(mUINT8 s) { _state = s;};
01247 mUINT8 Get_state() const { return _state;};
01248 #endif
01249 void Set_has_calls() { _state = (_cfg_state) (_state | CFG_HAS_CALLS); }
01250 void Set_is_executed() { _state = (_cfg_state) (_state | CFG_IS_EXECUTED); }
01251
01252 BOOL Has_calls() const { return _state & CFG_HAS_CALLS; }
01253 BOOL Is_executed() const { return _state & CFG_IS_EXECUTED; }
01254
01255 void Set_cd_index(INT index) { _cd_index = index; }
01256 INT Get_cd_index() const { return _cd_index; }
01257
01258 CFG_NODE_INFO (MEM_POOL* m, INT16 index) {
01259 u1._def = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01260 u2._use = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01261 u3._param = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01262 u4._scalar_info = (INT_ARRAY*)CXX_NEW(INT_ARRAY(m), m);
01263 u5._loop = (LOOPINFO*)CXX_NEW(LOOPINFO(m, index), m);
01264 u6._formal = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01265 _state = CFG_STATE_CLEAR;
01266 _type = CFG_UNKNOWN;
01267 _cd_index = -1;
01268 }
01269
01270 void Init (MEM_POOL* m) {
01271 u1._def = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01272 u2._use = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01273 u3._param = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01274 u4._scalar_info = (INT_ARRAY*)CXX_NEW(INT_ARRAY(m), m);
01275 u5._loop = NULL;
01276 u6._formal = (ARRAY_OF_REGION_ARRAYS*)CXX_NEW(ARRAY_OF_REGION_ARRAYS(m), m);
01277 _state = CFG_STATE_CLEAR;
01278 _type = CFG_UNKNOWN;
01279 _cd_index = -1;
01280 }
01281
01282 void Init_Out () {
01283 BZERO(this, sizeof(CFG_NODE_INFO));
01284 _type = CFG_UNKNOWN;
01285 }
01286
01287 void Add_array_param(PROJECTED_REGION *p, mINT32 sym_index,
01288 mINT32 element_size, INT16 callsite_id,
01289 INT16 actual_id);
01290 void Add_formal_array(PROJECTED_REGION *p, mINT32 element_size,
01291 mINT32 idx_symbol, mINT32 idx_formal);
01292 void Add_def_array(PROJECTED_REGION* p, mINT32 element_size,
01293 mINT32 sym_index);
01294 void Add_may_def_array(PROJECTED_REGION* p, mINT32 element_size,
01295 mINT32 sym_index);
01296 void Add_use_array(PROJECTED_REGION* p, mINT32 element_size,
01297 mINT32 sym_index);
01298 void Add_may_use_array(PROJECTED_REGION* p, mINT32 element_size,
01299 mINT32 sym_index);
01300
01301 void Add_scalar_def(mINT32 id);
01302 void Add_scalar_use(mINT32 id);
01303 void Add_scalar_reduc(mINT32 id);
01304 void Add_array_reduc(mINT32 id);
01305 void Add_array_may_reduc(mINT32 id);
01306 void Add_scalar_may_reduc(mINT32 id);
01307 void Add_scalar_may_def(mINT32 id);
01308 void Add_scalar_may_use(mINT32 id);
01309 INT Add_scalar_ref_passed(mINT32 id, mINT16 callsite_id);
01310 INT Add_scalar_ref_may_passed(mINT32 id, mINT16 callsite_id);
01311
01312 ARRAY_OF_REGION_ARRAYS* Get_def_array() const { return u1._def; }
01313 ARRAY_OF_REGION_ARRAYS* Get_use_array() const { return u2._use; }
01314 ARRAY_OF_REGION_ARRAYS* Get_param_array() const { return u3._param; }
01315 ARRAY_OF_REGION_ARRAYS* Get_formal_array() const { return u6._formal; }
01316
01317 INT_ARRAY* Get_scalar_array() const { return u4._scalar_info; }
01318 INT_ARRAY* Get_scalar_def_array() const { return u4._scalar_info; }
01319 INT_ARRAY* Get_scalar_use_array() const { return u4._scalar_info; }
01320 INT_ARRAY* Get_scalar_reduc_array() const { return u4._scalar_info; }
01321 INT_ARRAY* Get_array_reduc() const { return u4._scalar_info; }
01322
01323 LOOPINFO *Get_loopinfo() const { return u5._loop; }
01324 void Set_loopinfo(LOOPINFO *l) { u5._loop = l; }
01325
01326 void Print(FILE *fp = stderr);
01327 void Print_file(FILE *fp = stderr);
01328 void WB_Print(FILE* fp, INT cfg_index);
01329
01330
01331 void Set_def_count(INT count) { _def_count = count; }
01332 void Set_def_index(INT index) {u1._def_index = index; }
01333
01334 INT Get_def_count() const { return _def_count; }
01335 INT Get_def_index() const { return u1._def_index; }
01336
01337 void Set_use_count(INT count) { _use_count = count; }
01338 void Set_use_index(INT index) { u2._use_index = index; }
01339
01340 INT Get_use_count() const { return _use_count; }
01341 INT Get_use_index() const { return u2._use_index; }
01342
01343 void Set_param_count(INT count) { _param_count = count; }
01344 void Set_param_index(INT index) { u3._param_index = index; }
01345
01346 INT Get_param_count() const { return _param_count; }
01347 INT Get_param_index() const { return u3._param_index; }
01348
01349 void Set_scalar_count(INT count) { _scalar_count = count; }
01350 void Set_scalar_index(INT index) { u4._scalar_index = index; }
01351
01352 INT Get_scalar_count() const { return _scalar_count; }
01353 INT Get_scalar_index() const { return u4._scalar_index; }
01354
01355 void Set_formal_count(INT count) { _formal_count = count; }
01356 void Set_formal_index(INT index) { u6._formal_index = index; }
01357
01358 INT Get_formal_count() const { return _formal_count; }
01359 INT Get_formal_index() const { return u6._formal_index; }
01360
01361 void Set_loop_index(INT index) { u5._index = index; }
01362 INT Get_loop_index() const { return u5._index; }
01363
01364
01365 void Set_else_index(INT index) {
01366 if (Is_if())
01367 u5._index = index;
01368 else
01369 Fail_FmtAssertion("Invalid type when setting else index for CFG_NODE\n");
01370 };
01371
01372 INT Get_else_index() {
01373 if (Is_if())
01374 return u5._index;
01375 else
01376 Fail_FmtAssertion("Invalid type when using Get else index for CFG_NODE");
01377 return -1;
01378 };
01379
01380
01381 void Set_if_index(INT index) {
01382 if (Is_else())
01383 u5._index = index;
01384 else
01385 Fail_FmtAssertion("Invalid type when using Set_if_index for CFG_NODE");
01386 };
01387
01388
01389 INT Get_if_index() {
01390 if (Is_else())
01391 return u5._index;
01392 else
01393 Fail_FmtAssertion("Invalid type when using Get_if_index for CFG_NODE");
01394 return -1;
01395 };
01396
01397 };
01398
01399
01400 extern void Init_ivar_arrays();
01401
01402 typedef DYN_ARRAY<CFG_NODE_INFO> CFG_NODE_INFO_ARRAY;
01403
01404
01405
01406
01407 class INT_IDS
01408 {
01409 private:
01410 INT32 _id;
01411 INT32 _cd_idx;
01412
01413 public:
01414 INT32 Get_id() const { return _id;};
01415 void Set_id(INT32 i) { _id = i;};
01416
01417 INT32 Get_cd_idx() const { return _cd_idx;};
01418 void Set_cd_idx(INT32 t) { _cd_idx = t;};
01419 };
01420
01421
01422
01423
01424 class TLOG_INFO
01425 {
01426 private:
01427 INT _cterm_count, _lterm_count, _iv_g_term_count, _iv_term_count;
01428 INT _sub_term_count;
01429
01430 public:
01431 TLOG_INFO() { BZERO(this, sizeof(TLOG_INFO)); };
01432 INT& Get_cterm_count() { return _cterm_count;};
01433 INT& Get_lterm_count() { return _lterm_count;};
01434 INT& Get_iv_gterm_count() { return _iv_g_term_count;};
01435 INT& Get_iv_term_count() { return _iv_term_count;};
01436 INT& Get_sub_term_count() { return _sub_term_count;};
01437
01438 void Set_cterm_count(INT count ) {_cterm_count = count;};
01439 void Set_lterm_count(INT count ) {_lterm_count = count;};
01440 void Set_iv_gterm_count(INT count) {_iv_g_term_count = count;};
01441 void Set_iv_term_count(INT count ) {_iv_term_count = count;};
01442 void Set_sub_term_count(INT count ) {_sub_term_count = count;};
01443
01444 };
01445
01446
01447
01448
01449 class ARRAY_SUMMARY
01450 {
01451 private:
01452 MEM_POOL _array_pool;
01453 MEM_POOL _local_array_pool;
01454 MEM_POOL _write_pool;
01455 IVAR_ARRAY *_ivar;
01456 TERM_ARRAY *_term_array;
01457 PROJECTED_ARRAY *_project_nodes;
01458 PROJECTED_REGION_ARRAY *_projected_regions;
01459 ARRAY_OF_REGION_ARRAYS *_region_arrays;
01460 CFG_NODE_INFO_ARRAY *_cfg_nodes;
01461 LOOPINFO_ARRAY *_loop_nodes;
01462 INT_IDS *_actual_scalar_info_map;
01463 INT *_cd_map;
01464 INT _formal_start_idx;
01465 INT _formal_count;
01466 INT _actual_start_idx;
01467 INT _actual_count;
01468 INT _callsite_start_idx;
01469 INT _callsite_count;
01470 TLOG_INFO *_tlog_info;
01471
01472 public:
01473 void Init(INT formal_count, INT formal_idx,
01474 INT actual_count, INT actual_idx,
01475 INT callsite_count, INT callsite_idx,
01476 INT cd_size)
01477 {
01478 MEM_POOL_Initialize(&_array_pool, "array section pool", 0);
01479 MEM_POOL_Initialize(&_local_array_pool, "local array pool", 0);
01480 MEM_POOL_Initialize(&_write_pool, "write array pool", 0);
01481 MEM_POOL_Push(&_array_pool);
01482 MEM_POOL_Push(&_local_array_pool);
01483 MEM_POOL_Push(&_write_pool);
01484 _ivar = CXX_NEW(IVAR_ARRAY(&_write_pool), &_write_pool);
01485 _term_array = CXX_NEW(TERM_ARRAY(&_write_pool), &_write_pool);
01486 _project_nodes = CXX_NEW(PROJECTED_ARRAY(&_write_pool),
01487 &_write_pool);
01488 _projected_regions =
01489 CXX_NEW(PROJECTED_REGION_ARRAY(&_write_pool), &_write_pool);
01490 _region_arrays =
01491 CXX_NEW(ARRAY_OF_REGION_ARRAYS(&_write_pool), &_write_pool);
01492 _cfg_nodes =
01493 CXX_NEW(CFG_NODE_INFO_ARRAY(&_write_pool), &_write_pool);
01494 _loop_nodes =
01495 CXX_NEW(LOOPINFO_ARRAY(&_write_pool), &_write_pool);
01496 _actual_scalar_info_map = (INT_IDS*)
01497 MEM_POOL_Alloc(&_write_pool, sizeof(INT_IDS)*(actual_count+1));
01498 _formal_start_idx = formal_idx;
01499 _formal_count = formal_count;
01500 _actual_start_idx = actual_idx;
01501 _actual_count = actual_count;
01502 _callsite_start_idx = callsite_idx;
01503 _callsite_count = callsite_count;
01504 BZERO(_actual_scalar_info_map, sizeof(INT_IDS)*(actual_count+1));
01505 if (cd_size)
01506 _cd_map = (INT*)
01507 MEM_POOL_Alloc(&_write_pool, sizeof(INT)*cd_size);
01508 _tlog_info = CXX_NEW(TLOG_INFO(), &_write_pool);;
01509 Init_ivar_arrays();
01510
01511 };
01512
01513 void Finalize()
01514 {
01515 MEM_POOL_Pop(&_array_pool);
01516 MEM_POOL_Pop(&_local_array_pool);
01517 MEM_POOL_Pop(&_write_pool);
01518
01519 MEM_POOL_Delete(&_array_pool);
01520 MEM_POOL_Delete(&_local_array_pool);
01521 MEM_POOL_Delete(&_write_pool);
01522 };
01523
01524 MEM_POOL* Get_local_pool() { return &_local_array_pool;};
01525 MEM_POOL* Get_array_pool() { return &_array_pool;};
01526 MEM_POOL* Get_write_pool() { return &_write_pool;};
01527
01528 IVAR_ARRAY* Get_ivar_array() const { return _ivar;};
01529 TERM_ARRAY* Get_term_array() { return _term_array;};
01530 PROJECTED_ARRAY* Get_projected_array()
01531 { return _project_nodes; };
01532 PROJECTED_REGION_ARRAY* Get_projected_region_array()
01533 { return _projected_regions;};
01534 ARRAY_OF_REGION_ARRAYS* Get_region_array()
01535 { return _region_arrays; };
01536 CFG_NODE_INFO_ARRAY *Get_cfg_node_array()
01537 { return _cfg_nodes;};
01538 LOOPINFO_ARRAY *Get_loopinfo_array()
01539 { return _loop_nodes;};
01540
01541 INT_IDS* Get_actual_scalar_info_map() { return _actual_scalar_info_map;};
01542
01543 INT Get_actual_scalar_info_id(INT id) {
01544 return _actual_scalar_info_map[id].Get_id();
01545 };
01546
01547 INT Get_actual_scalar_info_cd_idx(INT id) {
01548 return _actual_scalar_info_map[id].Get_cd_idx();
01549 };
01550
01551 void Set_actual_scalar_info_map(INT id, INT cd_idx, INT actual_id) {
01552 _actual_scalar_info_map[actual_id].Set_id(id);
01553 _actual_scalar_info_map[actual_id].Set_cd_idx(cd_idx);
01554 };
01555
01556 INT* Get_cd_map() const { return _cd_map;};
01557 IVAR* Get_ivar_array(INT i);
01558 TERM* Get_term_array(INT i);
01559 PROJECTED_NODE* Get_projected_array(INT i);
01560 PROJECTED_REGION* Get_projected_region_array(INT i);
01561 REGION_ARRAYS* Get_region_array(INT i);
01562 CFG_NODE_INFO *Get_cfg_node_array(INT i);
01563 LOOPINFO *Get_loopinfo_array(INT i);
01564 TLOG_INFO* Get_tlog_info() const { return _tlog_info;};
01565
01566 INT Get_ivar_array_count() const { return _ivar->Lastidx()+1;};
01567 INT Get_term_array_count() const { return _term_array->Lastidx()+1;};
01568 INT Get_projected_array_count() const
01569 { return _project_nodes->Lastidx() + 1; };
01570 INT Get_projected_region_array_count() const
01571 { return _projected_regions->Lastidx() + 1;};
01572 INT Get_region_array_count() const
01573 { return _region_arrays->Lastidx() + 1; };
01574 INT Get_cfg_node_array_count() const
01575 { return _cfg_nodes->Lastidx() + 1;};
01576 INT Get_loopinfo_array_count() const
01577 { return _loop_nodes->Lastidx() + 1;};
01578 INT Get_formal_start_idx() const
01579 { return _formal_start_idx;};
01580 INT Get_formal_count() const
01581 { return _formal_count;};
01582 INT Get_actual_start_idx() const
01583 { return _actual_start_idx;};
01584 INT Get_actual_count() const
01585 { return _actual_count;};
01586 INT Get_callsite_start_idx() const
01587 { return _callsite_start_idx;};
01588 INT Get_callsite_count() const
01589 { return _callsite_count;};
01590
01591 void Record_tlogs(TERM_ARRAY* t, INT offset);
01592 };
01593
01594 #endif