diff options
Diffstat (limited to 'lib/CodeGen/RegAlloc/IGNode.cpp')
-rw-r--r-- | lib/CodeGen/RegAlloc/IGNode.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp index c8fca7a23b..caee296166 100644 --- a/lib/CodeGen/RegAlloc/IGNode.cpp +++ b/lib/CodeGen/RegAlloc/IGNode.cpp @@ -36,3 +36,19 @@ void IGNode::delAdjIGNode(const IGNode *Node) { assert( It != AdjList.end() ); // the node must be there AdjList.erase(It); } + +//----------------------------------------------------------------------------- +// Get the number of unique neighbors if these two nodes are merged +//----------------------------------------------------------------------------- + +unsigned +IGNode::getCombinedDegree(const IGNode* otherNode) const +{ + std::vector<IGNode*> nbrs(AdjList); + nbrs.insert(nbrs.end(), otherNode->AdjList.begin(), otherNode->AdjList.end()); + sort(nbrs.begin(), nbrs.end()); + std::vector<IGNode*>::iterator new_end = unique(nbrs.begin(), nbrs.end()); + return new_end - nbrs.begin(); +} + + |