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
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00345 #ifndef dep_INCLUDED
00346 #define dep_INCLUDED "dep.h"
00347
00348 #ifdef _KEEP_RCS_ID
00349 static char *dep_rcs_id = dep_INCLUDED "$Revision$";
00350 #endif
00351
00352 #ifndef dvector_INCLUDED
00353 #include "dvector.h"
00354 #endif
00355 #ifndef access_vector_INCLUDED
00356 #include "access_vector.h"
00357 #endif
00358
00359
00360 enum DEP_RESULT { DEP_INDEPENDENT, DEP_DEPENDENT, DEP_CONTINUE};
00361 typedef STACK<const SYMBOL *> SYMBOL_STACK;
00362 class REGION_UN;
00363
00364 class DEPV_NODE: public SLIST_NODE {
00365 DECLARE_SLIST_NODE_CLASS( DEPV_NODE);
00366 public:
00367 DEPV *Depv;
00368 DEPV_NODE(DEPV *depv) { Depv = depv; };
00369 ~DEPV_NODE() { DEPV_Free(Default_Mem_Pool,Depv);};
00370 void Normalize_Step(INT dim, INT64 step, BOOL *is_indep);
00371 void Print(FILE *fp, mUINT8 num_dim) const;
00372 void Lex_Pos_Decompose(MEM_POOL *pool,class DEPV_LIST *pos,
00373 class DEPV_LIST *neg,mUINT8 dv_dim, INT first_dim,
00374 BOOL keep_pos_equals, BOOL keep_neg_equals);
00375 void Blockable_Part(MEM_POOL *pool, class DEPV_LIST* dl_block,
00376 mUINT8 num_unused_dim, mUINT8 dv_dim, INT start_depth, INT stop_depth);
00377 BOOL Equal(DEPV_NODE *node2, mUINT8 num_dim);
00378 };
00379
00380 class ARA_REF;
00381
00382
00383 class DEPV_COEFF
00384 {
00385 public:
00386 INT32 *_coeff;
00387 INT32 _first_var;
00388 INT32 _num_dim;
00389 DEPV_COEFF(INT32 *coeff, INT32 first_var, INT32 num_dim) {
00390 _coeff = coeff;
00391 _first_var = first_var;
00392 _num_dim = num_dim;
00393 }
00394 };
00395
00396
00397
00398
00399
00400 class DEPV_COMPUTE
00401 {
00402 friend class DEPV_LIST;
00403 DEPV_COMPUTE(const DEPV_COMPUTE&);
00404 DEPV_COMPUTE& operator= (const DEPV_COMPUTE&);
00405 private:
00406 MEM_POOL *_pool;
00407 DEPV_COMPUTE() {;}
00408 ~DEPV_COMPUTE() {;}
00409 INT64 *_step1;
00410 INT64 *_step2;
00411 void Set_Step(const DOLOOP_STACK *s1, const DOLOOP_STACK *s2);
00412 void Print(FILE *fp) const;
00413 void Compute(DEPV_LIST *result,WN *ref1, ARA_REF *array_ref1,
00414 WN *ref2, ARA_REF *array_ref2,
00415 UINT8 common_nest,mUINT8 dv_dim,
00416 BOOL use_bounds, MEM_POOL *pool,
00417 const DOLOOP_STACK *s1, const DOLOOP_STACK *s2);
00418 BOOL Same_Permutation(WN *ref1, WN *ref2, ACCESS_ARRAY **perm1,
00419 ACCESS_ARRAY **perm2, WN *outer_loop);
00420
00421 enum { MAX_ROWS=99, MAX_COLS=30};
00422 DEP_RESULT Trivial_Test(const ACCESS_ARRAY *a1, const ACCESS_ARRAY *a2,
00423 mUINT8 dv_dim, mUINT16 common_nest,
00424 BOOL *non_trivial_dim, BOOL *seen_non_trivial) const;
00425 BOOL Same_Monotonic(WN *array1_index, WN *array2_index,
00426 const ACCESS_VECTOR *av1, const ACCESS_VECTOR *av2,
00427 mUINT16 common_nest, mUINT16 dv_dim,
00428 const DOLOOP_STACK *s1) const;
00429 BOOL Same_Monotonic(WN *array1, WN *array2,
00430 const ACCESS_ARRAY *a1, const ACCESS_ARRAY *a2,
00431 mUINT16 common_nest, mUINT16 dv_dim,
00432 const DOLOOP_STACK *s1) const;
00433 const WN *Find_First_Ldid_For_Symbol(const WN *wn,const SYMBOL *symb)const;
00434 BOOL Simple_Gcd_Indep(ACCESS_ARRAY *a1, ACCESS_ARRAY *a2,
00435 INT common_nest, INT dv_dim) const;
00436 BOOL Simple_Gcd_Indep(ACCESS_VECTOR *av1, ACCESS_VECTOR *av2) const;
00437 mUINT16 Common_Nest(const DOLOOP_STACK *s1, const DOLOOP_STACK *s2) const;
00438 static BOOL Equiv_Dims(const WN *array1, const WN *array2);
00439 static BOOL Equiv_Dim(const WN *exp1, const WN *exp2) ;
00440 static BOOL Equiv_Dims(const WN* wn_array, ARA_REF* ara_ref);
00441 static BOOL Equiv_Dims(ARA_REF* ara_ref, const WN* wn_array);
00442 static BOOL Equiv_Dims(ARA_REF* ara_ref1, ARA_REF* ara_ref2);
00443
00444 static mINT32 _work_eq[MAX_ROWS][MAX_COLS];
00445 static mINT32 _work_le[MAX_ROWS][MAX_COLS];
00446 static mINT32 _tmp[MAX_COLS];
00447 static INT64 _work_eq_const[MAX_ROWS];
00448 static INT64 _work_le_const[MAX_ROWS];
00449 INT _work_eq_rows;
00450 INT _work_le_rows;
00451 INT _work_cols;
00452 BOOL Copy_Equals_To_Work(const ACCESS_ARRAY *a1, const ACCESS_ARRAY *a2,
00453 SYMBOL_STACK *symbol_stack, const BOOL *non_trivial_dim);
00454 BOOL Copy_Equal_To_Work(ACCESS_VECTOR *av1, ACCESS_VECTOR *av2,
00455 SYMBOL_STACK *symbol_stack);
00456 BOOL Copy_Equal_To_Work(ACCESS_VECTOR *av, DEPV_COEFF *coeff,
00457 SYMBOL_STACK *symbol_stack,BOOL is_first_ref);
00458 BOOL Copy_Le_To_Work(ACCESS_VECTOR *av, DEPV_COEFF *coeff,
00459 SYMBOL_STACK *symbol_stack, BOOL is_first_ref, BOOL negate_av);
00460 BOOL Create_Dummy_Vars(INT number, SYMBOL_STACK *symbol_stack, INT& result);
00461 BOOL Copy_Stride_To_Work(ACCESS_VECTOR *av, DEPV_COEFF *coeff,
00462 INT stride, SYMBOL_STACK *symbol_stack, BOOL is_first_ref);
00463 BOOL Copy_Call_Ref_To_Work(ACCESS_ARRAY *aa, DEPV_COEFF *coeff,
00464 SYMBOL_STACK *symbol_stack, BOOL is_first_ref);
00465 BOOL Copy_Call_To_Work(REGION_UN &image1, SYMBOL_STACK *symbol_stack,
00466 DEPV_COEFF *coeff, BOOL is_first_ref);
00467 BOOL Copy_Bounds_To_Work(const DOLOOP_STACK *s1, const DOLOOP_STACK *s2,
00468 SYMBOL_STACK *symbol_stack);
00469 BOOL Copy_Bound_To_Work(INT var_num,ACCESS_VECTOR *bound,
00470 SYMBOL_STACK *symbol_stack,BOOL is_ref1);
00471 DEP_RESULT Find_Init_Distance_Used(DEPV *init_distance, BOOL *is_used,
00472 INT dv_dim) const;
00473 void Bounds_Set_Is_Used(BOOL *is_used, BOOL *bounds_used,
00474 INT *num_bounds_used) const;
00475 void Set_Map_Used(const BOOL *is_used,INT *num_used,INT *map_used) const;
00476 void Copy_To_Soe(const BOOL *is_used, const BOOL *bounds_used,
00477 const INT *map_used, class SYSTEM_OF_EQUATIONS *soe) const;
00478 void Compute_Dep_Vectors(class SYSTEM_OF_EQUATIONS *soe, const INT *is_used,
00479 const INT *map_used,DEPV *input_dependence,
00480 DEPV_LIST *result, BOOL same_references, INT dv_dim,INT num_bad_outer) ;
00481 INT First_Star(const DEPV *vector, const INT *is_used) const;
00482 void Add_Direction(class SYSTEM_OF_EQUATIONS *soe, INT i,
00483 const INT *map_used, DIRECTION direction);
00484
00485 INT _nd1,_nd2;
00486
00487 INT _first_dv1;
00488 INT _first_non_com1;
00489 INT _first_dv2;
00490 INT _first_non_com2;
00491 INT _first_symbol;
00492 void Print_Work(FILE *fp);
00493 public:
00494 static DEP_RESULT Base_Test(const WN *wn1, ARA_REF *ara_ref1,
00495 const WN *wn2,ARA_REF *ara_ref2);
00496 static WN * Find_Def(WN *wn1);
00497
00498 };
00499
00500
00501 class DEPV_LIST: public SLIST {
00502 DECLARE_SLIST_CLASS( DEPV_LIST, DEPV_NODE )
00503 mUINT8 _dv_dim;
00504 mUINT8 _num_unused_dim;
00505 MEM_POOL *_pool;
00506
00507 public:
00508 void Print(FILE *fp) const;
00509 DEPV_LIST(class DEPV_ARRAY *array, MEM_POOL *pool);
00510 DEPV_LIST(WN *ref1, WN *ref2, mUINT8 common_nest, mUINT8 dv_dim,
00511 BOOL use_bounds, MEM_POOL *pool, const DOLOOP_STACK *s1,
00512 const DOLOOP_STACK *s2);
00513 DEPV_LIST(mUINT8 dv_dim, mUINT8 num_unused_dim, MEM_POOL *pool) {
00514 _dv_dim = dv_dim;
00515 _num_unused_dim = num_unused_dim;
00516 _pool = pool;
00517 }
00518 void Append(DEPV *depv,INT num_bad_outer);
00519 void Normalize_Step(INT64 *step);
00520 BOOL Is_Lexpos() const;
00521 BOOL Contains_All_Equals() const;
00522 mUINT8 Num_Dim() const { return _dv_dim; }
00523 mUINT8 Num_Unused_Dim() const { return _num_unused_dim; }
00524 void Remove_Unused_Dim(INT count) {_num_unused_dim -= count; }
00525 void Lex_Pos_Decompose(MEM_POOL *pool,DEPV_LIST *pos, DEPV_LIST *neg,
00526 BOOL keep_pos_equals, BOOL keep_neg_equals);
00527 void Blockable_Part(MEM_POOL *pool, class DEPV_LIST* dl_block,
00528 mUINT8 num_unused_dim, mUINT8 dv_dim, INT start_depth, INT stop_depth);
00529 DEP Convert_To_Dep();
00530 BOOL Is_Inner_Single_Distance();
00531 BOOL Is_Inner_Non_Zero_Single_Distance();
00532 void Eliminate_Inner_Carried();
00533 void Eliminate_Inner_Carried_Or_All_Equals();
00534 void Eliminate_Non_Distance_Carried_By(INT i);
00535 void Remove_Duplicates();
00536 ~DEPV_LIST();
00537 };
00538
00539
00540
00541 class DEPV_ITER: public SLIST_ITER {
00542 DECLARE_SLIST_ITER_CLASS( DEPV_ITER, DEPV_NODE ,DEPV_LIST)
00543 public:
00544 ~DEPV_ITER() {}
00545 };
00546
00547 class DEPV_CONST_ITER: public SLIST_ITER {
00548 DECLARE_SLIST_CONST_ITER_CLASS(DEPV_CONST_ITER, DEPV_NODE ,DEPV_LIST)
00549 public:
00550 ~DEPV_CONST_ITER() {}
00551 };
00552
00553 class DEPV_ARRAY {
00554 private:
00555 mUINT8 _num_vec;
00556 mUINT8 _dim;
00557 DEPV _data[1];
00558 DEPV_ARRAY() { FmtAssert(0,("Constructor of DEPV_ARRAY called")); }
00559 friend DEPV_ARRAY *Create_DEPV_ARRAY(mUINT8 num_vec,mUINT8 num_dim,
00560 mUINT8 num_unused_dim,MEM_POOL*);
00561 friend DEPV_ARRAY *Create_DEPV_ARRAY(DEPV_LIST *depv_list, MEM_POOL *pool);
00562 friend void Delete_DEPV_ARRAY(DEPV_ARRAY *array, MEM_POOL *pool);
00563 public:
00564 mUINT8 Num_Vec() const { return _num_vec; }
00565 mUINT8 Num_Dim() const { return _dim&15; }
00566 mUINT8 Num_Unused_Dim() const { return (_dim&240) >> 4; }
00567 void Set_Num_Unused_Dim(mUINT8 unused_dim) { _dim = (unused_dim << 4) | Num_Dim(); };
00568 void Remove_Unused_Dim(INT count) {_dim -= (count << 4); }
00569 DEPV_ARRAY *Shorten(UINT num_dim, MEM_POOL *pool);
00570 DEP *Shorten_To_Dep(MEM_POOL *pool);
00571 DEPV *Union(MEM_POOL *pool);
00572 DEPV *Depv(mUINT8 i) { return &_data[i*Num_Dim()]; }
00573 const DEPV *Depv(mUINT8 i) const { return &_data[i*Num_Dim()]; }
00574 void Print(FILE *fp) const;
00575 DEPV_ARRAY(const DEPV_ARRAY&);
00576 DEPV_ARRAY& operator= (const DEPV_ARRAY&);
00577 INT Max_Level() const;
00578 BOOL Equal_Through_Depth (INT depth);
00579 BOOL One_Equal_Through_Depth (INT depth);
00580 INT Loop_Carrying_Dependence();
00581 BOOL Is_Blockable(INT start_depth, INT stop_depth);
00582 };
00583
00584 extern DEPV_ARRAY *Create_DEPV_ARRAY(mUINT8 num_vec,
00585 mUINT8 num_dim, mUINT8 nun_unused_dim,MEM_POOL *pool);
00586 extern DEPV_ARRAY *Create_DEPV_ARRAY(DEPV_LIST *depv_list,MEM_POOL *pool);
00587 extern DEPV_ARRAY *Create_DEPV_ARRAY(const DEPV_ARRAY *,MEM_POOL *);
00588 extern void Delete_DEPV_ARRAY(DEPV_ARRAY *array, MEM_POOL *pool);
00589 extern DEPV_LIST *Lex_Pos_Compose(MEM_POOL *pool,DEPV_LIST *pos,DEPV_LIST *neg);
00590
00591
00592
00593 #endif // dep_INCLUDED