Ruchira Sasanka | 8e60479 | 2001-09-14 21:18:34 +0000 | [diff] [blame] | 1 | #include "llvm/CodeGen/IGNode.h" |
| 2 | |
| 3 | |
Ruchira Sasanka | 4f3eb22 | 2002-01-07 19:19:18 +0000 | [diff] [blame^] | 4 | //----------------------------------------------------------------------------- |
| 5 | // Constructor |
| 6 | //----------------------------------------------------------------------------- |
Ruchira Sasanka | 8e60479 | 2001-09-14 21:18:34 +0000 | [diff] [blame] | 7 | IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind), |
Ruchira Sasanka | 0e62aa6 | 2001-10-19 21:39:31 +0000 | [diff] [blame] | 8 | AdjList(), |
Ruchira Sasanka | 8e60479 | 2001-09-14 21:18:34 +0000 | [diff] [blame] | 9 | ParentLR(PLR) |
| 10 | { |
| 11 | OnStack = false; |
| 12 | CurDegree = -1 ; |
| 13 | ParentLR->setUserIGNode( this ); |
| 14 | } |
| 15 | |
| 16 | |
Ruchira Sasanka | 4f3eb22 | 2002-01-07 19:19:18 +0000 | [diff] [blame^] | 17 | //----------------------------------------------------------------------------- |
| 18 | // Sets this IGNode on stack and reduce the degree of neighbors |
| 19 | //----------------------------------------------------------------------------- |
| 20 | void IGNode::pushOnStack() |
| 21 | { |
Ruchira Sasanka | 8e60479 | 2001-09-14 21:18:34 +0000 | [diff] [blame] | 22 | OnStack = true; |
Ruchira Sasanka | a9e45c8 | 2001-11-03 22:01:09 +0000 | [diff] [blame] | 23 | int neighs = AdjList.size(); |
Ruchira Sasanka | 8e60479 | 2001-09-14 21:18:34 +0000 | [diff] [blame] | 24 | |
Ruchira Sasanka | a9e45c8 | 2001-11-03 22:01:09 +0000 | [diff] [blame] | 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(); |
Ruchira Sasanka | 8e60479 | 2001-09-14 21:18:34 +0000 | [diff] [blame] | 31 | } |
| 32 | |
Ruchira Sasanka | 4f3eb22 | 2002-01-07 19:19:18 +0000 | [diff] [blame^] | 33 | //----------------------------------------------------------------------------- |
| 34 | // Deletes an adjacency node. IGNodes are deleted when coalescing merges |
| 35 | // two IGNodes together. |
| 36 | //----------------------------------------------------------------------------- |
Ruchira Sasanka | 8e60479 | 2001-09-14 21:18:34 +0000 | [diff] [blame] | 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 | } |