1 //===-- IGNode.cpp --------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements an Interference graph node for coloring-based register
13 //===----------------------------------------------------------------------===//
19 //-----------------------------------------------------------------------------
20 // Sets this IGNode on stack and reduce the degree of neighbors
21 //-----------------------------------------------------------------------------
23 void IGNode::pushOnStack() {
25 int neighs = AdjList.size();
28 std::cerr << "\nAdj List size = " << neighs;
29 assert(0 && "Invalid adj list size");
32 for (int i=0; i < neighs; i++)
33 AdjList[i]->decCurDegree();
36 //-----------------------------------------------------------------------------
37 // Deletes an adjacency node. IGNodes are deleted when coalescing merges
38 // two IGNodes together.
39 //-----------------------------------------------------------------------------
41 void IGNode::delAdjIGNode(const IGNode *Node) {
42 std::vector<IGNode *>::iterator It=find(AdjList.begin(), AdjList.end(), Node);
43 assert(It != AdjList.end() && "The node must be there!");
47 //-----------------------------------------------------------------------------
48 // Get the number of unique neighbors if these two nodes are merged
49 //-----------------------------------------------------------------------------
52 IGNode::getCombinedDegree(const IGNode* otherNode) const {
53 std::vector<IGNode*> nbrs(AdjList);
54 nbrs.insert(nbrs.end(), otherNode->AdjList.begin(), otherNode->AdjList.end());
55 sort(nbrs.begin(), nbrs.end());
56 std::vector<IGNode*>::iterator new_end = unique(nbrs.begin(), nbrs.end());
57 return new_end - nbrs.begin();