Make LoopDeptCalculator be an internal artifact of how RegAlloc is implemented,
[oota-llvm.git] / lib / Target / SparcV9 / RegAlloc / IGNode.cpp
1 #include "llvm/CodeGen/IGNode.h"
2 #include <algorithm>
3 #include <iostream>
4 using std::cerr;
5
6 //-----------------------------------------------------------------------------
7 // Constructor
8 //-----------------------------------------------------------------------------
9 IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind),
10                                                          ParentLR(PLR)
11 {
12   OnStack = false;
13   CurDegree = -1 ;
14   ParentLR->setUserIGNode( this );
15 }
16
17
18 //-----------------------------------------------------------------------------
19 // Sets this IGNode on stack and reduce the degree of neighbors  
20 //-----------------------------------------------------------------------------
21 void IGNode::pushOnStack()             
22 {                                     
23   OnStack = true; 
24   int neighs = AdjList.size();
25
26   if( neighs < 0) {
27     cerr << "\nAdj List size = " << neighs;
28     assert(0 && "Invalid adj list size");
29   }
30
31   for(int i=0; i < neighs; i++)
32     AdjList[i]->decCurDegree();
33 }
34  
35 //-----------------------------------------------------------------------------
36 // Deletes an adjacency node. IGNodes are deleted when coalescing merges
37 // two IGNodes together.
38 //-----------------------------------------------------------------------------
39 void IGNode::delAdjIGNode(const IGNode *const Node) {
40   std::vector<IGNode *>::iterator It = 
41     find(AdjList.begin(), AdjList.end(), Node);
42   assert( It != AdjList.end() );      // the node must be there
43     
44   AdjList.erase(It);
45 }