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