blob: 4e66d9a762c96724ddedc7303f99a9b70d4abeba [file] [log] [blame]
Ruchira Sasanka8e604792001-09-14 21:18:34 +00001#include "llvm/CodeGen/IGNode.h"
2
3
Ruchira Sasanka4f3eb222002-01-07 19:19:18 +00004//-----------------------------------------------------------------------------
5// Constructor
6//-----------------------------------------------------------------------------
Ruchira Sasanka8e604792001-09-14 21:18:34 +00007IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind),
Ruchira Sasanka0e62aa62001-10-19 21:39:31 +00008 AdjList(),
Ruchira Sasanka8e604792001-09-14 21:18:34 +00009 ParentLR(PLR)
10{
11 OnStack = false;
12 CurDegree = -1 ;
13 ParentLR->setUserIGNode( this );
14}
15
16
Ruchira Sasanka4f3eb222002-01-07 19:19:18 +000017//-----------------------------------------------------------------------------
18// Sets this IGNode on stack and reduce the degree of neighbors
19//-----------------------------------------------------------------------------
20void IGNode::pushOnStack()
21{
Ruchira Sasanka8e604792001-09-14 21:18:34 +000022 OnStack = true;
Ruchira Sasankaa9e45c82001-11-03 22:01:09 +000023 int neighs = AdjList.size();
Ruchira Sasanka8e604792001-09-14 21:18:34 +000024
Ruchira Sasankaa9e45c82001-11-03 22:01:09 +000025 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();
Ruchira Sasanka8e604792001-09-14 21:18:34 +000031}
32
Ruchira Sasanka4f3eb222002-01-07 19:19:18 +000033//-----------------------------------------------------------------------------
34// Deletes an adjacency node. IGNodes are deleted when coalescing merges
35// two IGNodes together.
36//-----------------------------------------------------------------------------
Ruchira Sasanka8e604792001-09-14 21:18:34 +000037void 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}