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
00326 #ifndef snl_deps_INCLUDED
00327 #define snl_deps_INCLUDED "snl_deps.h"
00328
00329 #ifdef _KEEP_RCS_ID
00330 static char *snl_deps_rcs_id = snl_deps_INCLUDED "$Revision$";
00331 #endif
00332
00333 class ARRAY_DIRECTED_GRAPH16;
00334 #ifndef cxx_graph_INCLUDED
00335 #include "cxx_graph.h"
00336 #endif
00337 #ifndef graph_template_INCLUDED
00338 #include "graph_template.h"
00339 #endif
00340
00341 class SNL_DEP {
00342 public:
00343 INT Distance;
00344 enum {SNL_DEP_PLUS, SNL_DEP_MINUS, SNL_DEP_EXACT, SNL_DEP_STAR} Moreless;
00345 SNL_DEP(DEP d);
00346 SNL_DEP() {Distance = 0; Moreless = SNL_DEP_EXACT;}
00347 DEP Dep() const;
00348 friend SNL_DEP operator * (INT a, const SNL_DEP& d);
00349 friend SNL_DEP operator + (const SNL_DEP& dd, const SNL_DEP& d);
00350 void operator += (const SNL_DEP& d);
00351 void Print(FILE* f) const;
00352 BOOL Unbounded_Max() const {
00353 return Moreless == SNL_DEP_STAR || Moreless == SNL_DEP_PLUS;
00354 }
00355 BOOL Unbounded_Min() const {
00356 return Moreless == SNL_DEP_STAR || Moreless == SNL_DEP_MINUS;
00357 }
00358 BOOL Max() const {
00359 Is_True(!Unbounded_Max(), ("Bad call to SNL_DEP::Max()"));
00360 return Distance;
00361 }
00362 BOOL Min() const {
00363 Is_True(!Unbounded_Min(), ("Bad call to SNL_DEP::Min()"));
00364 return Distance;
00365 }
00366 void Negate_Me() {
00367 Distance = -Distance;
00368 if (Moreless == SNL_DEP_PLUS)
00369 Moreless = SNL_DEP_MINUS;
00370 else if (Moreless == SNL_DEP_MINUS)
00371 Moreless = SNL_DEP_PLUS;
00372 }
00373 SNL_DEP Negate() const {
00374 SNL_DEP newd = *this;
00375 newd.Negate_Me();
00376 return newd;
00377 }
00378 };
00379
00380 class SNL_DEP_INFO;
00381
00382 class SNL_DEP_MATRIX {
00383
00384 public:
00385
00386 SNL_DEP_MATRIX(const SNL_DEP_INFO&, MEM_POOL*);
00387 SNL_DEP_MATRIX(const SNL_DEP_MATRIX*, MEM_POOL*);
00388 ~SNL_DEP_MATRIX();
00389
00390 SNL_DEP operator ()(INT d, INT i) const {
00391 Is_True(d >= 0 && d < _ndep, ("Depenendence number out of range"));
00392 Is_True(i >= 0 && i < _nloops, ("Depth number out of range"));
00393 return _deps[d*_nloops + i];
00394 }
00395 SNL_DEP& operator ()(INT d, INT i) {
00396 Is_True(d >= 0 && d < _ndep, ("Depenendence number out of range"));
00397 Is_True(i >= 0 && i < _nloops, ("Depth number out of range"));
00398 return _deps[d*_nloops + i];
00399 }
00400 void Print(FILE*) const;
00401 BOOL Is_Legal() const;
00402 BOOL Is_Fully_Permutable(INT from, INT to) const;
00403 BOOL Is_Fully_Permutable() const
00404 { return Is_Fully_Permutable(0, Nloops()-1); }
00405 void Apply(const IMAT& u, INT first);
00406 void Apply(const INT* permutation);
00407
00408 INT Ndep() const {return _ndep;}
00409 INT Nloops() const {return _nloops;}
00410 MEM_POOL* Pool() const {return _pool;}
00411
00412 private:
00413
00414 SNL_DEP* _deps;
00415 INT _ndep;
00416 INT _nloops;
00417 MEM_POOL* _pool;
00418 };
00419
00420 struct SNL_DEP_INFO_BAD_DEP_ENTRY {
00421 EINDEX16 e;
00422
00423 mINT16 loop;
00424
00425 };
00426 typedef DYN_ARRAY<SNL_DEP_INFO_BAD_DEP_ENTRY> SNL_DEP_INFO_BAD_DEPS;
00427
00428 extern void Print(FILE*f, const SNL_DEP_INFO_BAD_DEPS&);
00429
00430 class SNL_DEP_INFO {
00431
00432 friend class SNL_ANAL_INFO;
00433
00434 public:
00435
00436 const DEPV_LIST& Dv_List() const {return _dv_list;}
00437 BOOL All_Stars() const {return _all_stars;}
00438 INT Nloops() const {return _nloops;}
00439 INT First_Component() const {return _first_component;}
00440 MEM_POOL* Pool() const {return _pool;}
00441 const DOLOOP_STACK& Stack1() const {return _stack1;}
00442 const DOLOOP_STACK& Stack2() const {return _stack2;}
00443
00444 SNL_DEP_INFO(INT firstc, INT nloops, INT num_unused_dim,
00445 const DOLOOP_STACK& stk, MEM_POOL* pool);
00446 ~SNL_DEP_INFO() {}
00447
00448 void Enter(const DEPV*, INT, EINDEX16 edge, BOOL parallel=FALSE);
00449 void Enter(const DEPV_ARRAY*, EINDEX16 edge, BOOL parallel=FALSE);
00450 void Print(FILE* f) const;
00451 void Set_All_Stars(BOOL v) {_all_stars = v;}
00452 IMAT* U_Fully_Permutable(INT from, INT to, MEM_POOL*mp) const;
00453 IMAT* U_Fully_Permutable(MEM_POOL*mp) const
00454 { return U_Fully_Permutable(0, Nloops()-1, mp); }
00455 const SNL_DEP_INFO_BAD_DEPS& Bad_Deps() const {return _bad_deps;}
00456
00457 private:
00458
00459 DEPV_LIST _dv_list;
00460 BOOL _all_stars;
00461 INT _nloops;
00462 INT _first_component;
00463 MEM_POOL* _pool;
00464 DOLOOP_STACK _stack1;
00465 DOLOOP_STACK _stack2;
00466 SNL_DEP_INFO_BAD_DEPS _bad_deps;
00467
00468 SNL_DEP_INFO();
00469
00470 };
00471
00472 struct LEX_DEPTH {
00473 INT Lex;
00474 INT Depth;
00475 LEX_DEPTH(INT l, INT d) : Lex(l), Depth(d) {}
00476 LEX_DEPTH(INT l) : Lex(l), Depth(-1)
00477 {Is_True(l == 0, ("Bad use of LEX_DEPTH(INT) constructor"));}
00478 LEX_DEPTH() : Lex(0), Depth(-1) {}
00479 LEX_DEPTH(const LEX_DEPTH& ld) : Lex(ld.Lex), Depth(ld.Depth) {}
00480 };
00481
00482 struct SNL_ANAL_INFO {
00483
00484
00485
00486
00487
00488 struct CONST_BOUNDS_INFO {
00489 CONST_BOUNDS_INFO(const DOLOOP_STACK*);
00490 BOOL Lbconst(INT loop, INT index) const {
00491 Is_True(index < loop, ("Bad call to Lbconst()"));
00492 return loop<64 && index<64 ? (_lbconst[loop]&(INT64(1)<<index)) != 0 : 0;
00493 }
00494 BOOL Ubconst(INT loop, INT index) const {
00495 Is_True(index < loop, ("Bad call to Ubconst()"));
00496 return loop<64 && index<64 ? (_ubconst[loop]&(INT64(1)<<index)) != 0 : 0;
00497 }
00498 void Print(FILE* f) const;
00499
00500 private:
00501
00502 mINT64 _lbconst[64];
00503 mINT64 _ubconst[64];
00504 };
00505
00506 const SNL_DEP_INFO& Body_Deps() const {return _body_deps;}
00507 const SNL_DEP_INFO& Imperfect_Deps() const {return _imperfect_deps;}
00508 MEM_POOL* Pool() const {return _pool;}
00509
00510 SNL_ANAL_INFO(const SNL_NEST_INFO*,
00511 BOOL gtransform,
00512 ARRAY_DIRECTED_GRAPH16*,
00513 MEM_POOL*);
00514 ~SNL_ANAL_INFO();
00515
00516 LEX_DEPTH Find_Lex(WN* ldst) const
00517 { return _lexinfo.Find(ldst); }
00518 void Print(FILE* f) const;
00519
00520 BOOL Above_Main_Nest(INT lex) const
00521 { return lex <= _lex_last_above_innermost; }
00522 BOOL Below_Main_Nest(INT lex) const
00523 { return lex >= _lex_first_below_innermost; }
00524
00525 BOOL Above_Is_Distributable() const
00526 { return _above_is_distributable;}
00527 BOOL Below_Is_Distributable() const
00528 { return _below_is_distributable;}
00529
00530 private:
00531
00532 SNL_ANAL_INFO();
00533
00534 void Enter_Lex(WN* ldst, LEX_DEPTH ld) {
00535 _lexinfo.Enter(ldst, ld);
00536 }
00537 void Enter_Deps(WN*, LEX_DEPTH);
00538
00539 enum {HT_ELTS=247};
00540 HASH_TABLE<WN*,LEX_DEPTH> _lexinfo;
00541 INT _lex_last_above_innermost;
00542 INT _lex_first_below_innermost;
00543 SNL_DEP_INFO _body_deps;
00544 SNL_DEP_INFO _imperfect_deps;
00545 MEM_POOL* _pool;
00546 BOOL _above_is_distributable;
00547 BOOL _below_is_distributable;
00548 WN* _inner_loop;
00549 INT _depth_inner;
00550 const CONST_BOUNDS_INFO _ci;
00551 };
00552
00553 #endif