1 //===-- IGNode.cpp --------------------------------------------------------===//
3 // class IGNode for coloring-based register allocation for LLVM.
5 //===----------------------------------------------------------------------===//
11 //-----------------------------------------------------------------------------
12 // Sets this IGNode on stack and reduce the degree of neighbors
13 //-----------------------------------------------------------------------------
15 void IGNode::pushOnStack() {
17 int neighs = AdjList.size();
20 std::cerr << "\nAdj List size = " << neighs;
21 assert(0 && "Invalid adj list size");
24 for(int i=0; i < neighs; i++)
25 AdjList[i]->decCurDegree();
28 //-----------------------------------------------------------------------------
29 // Deletes an adjacency node. IGNodes are deleted when coalescing merges
30 // two IGNodes together.
31 //-----------------------------------------------------------------------------
33 void IGNode::delAdjIGNode(const IGNode *Node) {
34 std::vector<IGNode *>::iterator It=find(AdjList.begin(), AdjList.end(), Node);
35 assert( It != AdjList.end() ); // the node must be there
39 //-----------------------------------------------------------------------------
40 // Get the number of unique neighbors if these two nodes are merged
41 //-----------------------------------------------------------------------------
44 IGNode::getCombinedDegree(const IGNode* otherNode) const
46 std::vector<IGNode*> nbrs(AdjList);
47 nbrs.insert(nbrs.end(), otherNode->AdjList.begin(), otherNode->AdjList.end());
48 sort(nbrs.begin(), nbrs.end());
49 std::vector<IGNode*>::iterator new_end = unique(nbrs.begin(), nbrs.end());
50 return new_end - nbrs.begin();