Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

/users/u3/mtikir/PMaCInstrumentor_v1601/src/Loop.C

Go to the documentation of this file.
00001 #include <Loop.h>
00002 #include <Function.h>
00003 #include <BitSet.h>
00004 
00005 Loop::~Loop(){
00006     delete blocks;
00007 }
00008 
00009 Loop::Loop(BasicBlock* h, BasicBlock* t, FlowGraph* cfg, BitSet<BasicBlock*>* newBlocks) { 
00010     index = Invalid_UInteger_ID;
00011     head = h; 
00012     tail = t;
00013     flowGraph = cfg; 
00014     blocks = cfg->newBitSet();
00015     blocks->clear();
00016     for (uint32_t i = 0; i < cfg->getNumOfBasicBlocks(); i++){
00017         if (newBlocks->contains(i)){
00018             blocks->insert(i);
00019         }
00020     }
00021 }
00022 
00023 void Loop::print(){
00024     PRINT_INFOR("Loop %u of cfg %u: Head %d (base %#llx), tail %d among %d blocks", 
00025                  getIndex(),flowGraph->getIndex(),
00026                  head->getIndex(), head->getBaseAddress(),tail->getIndex(),
00027                  flowGraph->getNumOfBasicBlocks());
00028     for (uint32_t i = 0; i < flowGraph->getNumOfBasicBlocks(); i++){
00029         if (blocks->contains(i)){
00030             PRINT_INFOR("\tMember Block %d", i);
00031         }
00032     }
00033 }
00034 
00035 uint32_t Loop::getAllBlocks(BasicBlock** arr){
00036     ASSERT(arr != NULL);
00037     uint32_t arrIdx = 0;
00038     for (uint32_t i = 0; i < flowGraph->getNumOfBasicBlocks(); i++){
00039     if(blocks->contains(i)){
00040         arr[arrIdx++] = flowGraph->getBlock(i);
00041     }
00042     }
00043     return blocks->size();
00044 }
00045 
00046 bool Loop::isInnerLoop(Loop* loop){
00047     for (uint32_t i = 0; i < flowGraph->getNumOfBasicBlocks(); i++){
00048         if (loop->isBlockIn(i) && !isBlockIn(i)){
00049             return false;
00050         }
00051     }
00052     return true;
00053 }
00054 
00055 bool Loop::isIdenticalLoop(Loop* loop){
00056     for (uint32_t i = 0; i < flowGraph->getNumOfBasicBlocks(); i++){
00057         if (isBlockIn(i) != loop->isBlockIn(i)){
00058             return false;
00059         }
00060     }
00061     return true;
00062 }
00063 

Generated on Mon Jan 28 11:08:32 2008 for PMaCInstrumentor by doxygen 1.3.5