diff options
Diffstat (limited to 'lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp')
-rw-r--r-- | lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp index 3f57eccd89..f54cbb09e8 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp @@ -1,14 +1,14 @@ //===-- InterferenceGraph.cpp ---------------------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// -// +// // Interference graph for coloring-based register allocation for LLVM. -// +// //===----------------------------------------------------------------------===// #include "IGNode.h" @@ -28,12 +28,12 @@ inline static void assertIGNode(const InterferenceGraph *IG, //----------------------------------------------------------------------------- // Constructor: Records the RegClass and initalizes IGNodeList. -// The matrix is NOT yet created by the constructor. Call createGraph() +// The matrix is NOT yet created by the constructor. Call createGraph() // to create it after adding all IGNodes to the IGNodeList. //----------------------------------------------------------------------------- InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC) { - IG = NULL; - Size = 0; + IG = NULL; + Size = 0; if( DEBUG_RA >= RA_DEBUG_Interference) std::cerr << "Interference graph created!\n"; } @@ -58,15 +58,15 @@ InterferenceGraph:: ~InterferenceGraph() { // Creates (dynamically allocates) the bit matrix necessary to hold the // interference graph. //----------------------------------------------------------------------------- -void InterferenceGraph::createGraph() -{ +void InterferenceGraph::createGraph() +{ Size = IGNodeList.size(); - IG = new char*[Size]; + IG = new char*[Size]; for( unsigned int r=0; r < Size; ++r) IG[r] = new char[Size]; // init IG matrix - for(unsigned int i=0; i < Size; i++) + for(unsigned int i=0; i < Size; i++) for(unsigned int j=0; j < Size; j++) IG[i][j] = 0; } @@ -89,27 +89,27 @@ void InterferenceGraph::addLRToIG(LiveRange *const LR) //----------------------------------------------------------------------------- void InterferenceGraph::setInterference(const LiveRange *const LR1, const LiveRange *const LR2 ) { - assert(LR1 != LR2); + assert(LR1 != LR2); IGNode *IGNode1 = LR1->getUserIGNode(); IGNode *IGNode2 = LR2->getUserIGNode(); - assertIGNode(this, IGNode1); + assertIGNode(this, IGNode1); assertIGNode(this, IGNode2); - + unsigned row = IGNode1->getIndex(); unsigned col = IGNode2->getIndex(); char *val; - if( DEBUG_RA >= RA_DEBUG_Interference) - std::cerr << "setting intf for: [" << row << "][" << col << "]\n"; + if( DEBUG_RA >= RA_DEBUG_Interference) + std::cerr << "setting intf for: [" << row << "][" << col << "]\n"; - ( row > col) ? val = &IG[row][col]: val = &IG[col][row]; + ( row > col) ? val = &IG[row][col]: val = &IG[col][row]; if( ! (*val) ) { // if this interf is not previously set - *val = 1; // add edges between nodes - IGNode1->addAdjIGNode( IGNode2 ); + *val = 1; // add edges between nodes + IGNode1->addAdjIGNode( IGNode2 ); IGNode2->addAdjIGNode( IGNode1 ); } @@ -122,17 +122,17 @@ void InterferenceGraph::setInterference(const LiveRange *const LR1, unsigned InterferenceGraph::getInterference(const LiveRange *const LR1, const LiveRange *const LR2) const { assert(LR1 != LR2); - assertIGNode(this, LR1->getUserIGNode()); + assertIGNode(this, LR1->getUserIGNode()); assertIGNode(this, LR2->getUserIGNode()); const unsigned int row = LR1->getUserIGNode()->getIndex(); const unsigned int col = LR2->getUserIGNode()->getIndex(); - char ret; + char ret; if (row > col) ret = IG[row][col]; - else - ret = IG[col][row]; + else + ret = IG[col][row]; return ret; } @@ -141,11 +141,11 @@ unsigned InterferenceGraph::getInterference(const LiveRange *const LR1, //---------------------------------------------------------------------------- // Merge 2 IGNodes. The neighbors of the SrcNode will be added to the DestNode. // Then the IGNode2L will be deleted. Necessary for coalescing. -// IMPORTANT: The live ranges are NOT merged by this method. Use +// IMPORTANT: The live ranges are NOT merged by this method. Use // LiveRangeInfo::unionAndUpdateLRs for that purpose. //---------------------------------------------------------------------------- -void InterferenceGraph::mergeIGNodesOfLRs(const LiveRange *LR1, +void InterferenceGraph::mergeIGNodesOfLRs(const LiveRange *LR1, LiveRange *LR2) { assert( LR1 != LR2); // cannot merge the same live range @@ -165,31 +165,31 @@ void InterferenceGraph::mergeIGNodesOfLRs(const LiveRange *LR1, // for all neighs of SrcNode - for(unsigned i=0; i < SrcDegree; i++) { - IGNode *NeighNode = SrcNode->getAdjIGNode(i); + for(unsigned i=0; i < SrcDegree; i++) { + IGNode *NeighNode = SrcNode->getAdjIGNode(i); LiveRange *const LROfNeigh = NeighNode->getParentLR(); // delete edge between src and neigh - even neigh == dest - NeighNode->delAdjIGNode(SrcNode); + NeighNode->delAdjIGNode(SrcNode); // set the matrix posn to 0 betn src and neigh - even neigh == dest const unsigned NInd = NeighNode->getIndex(); - ( SrcInd > NInd) ? (IG[SrcInd][NInd]=0) : (IG[NInd][SrcInd]=0) ; + ( SrcInd > NInd) ? (IG[SrcInd][NInd]=0) : (IG[NInd][SrcInd]=0) ; - if( LR1 != LROfNeigh) { // if the neigh != dest - + if( LR1 != LROfNeigh) { // if the neigh != dest + // add edge betwn Dest and Neigh - if there is no current edge - setInterference(LR1, LROfNeigh ); + setInterference(LR1, LROfNeigh ); } - + } IGNodeList[ SrcInd ] = NULL; // SrcNode is no longer necessary - LR2 must be deleted by the caller - delete( SrcNode ); + delete( SrcNode ); } @@ -216,10 +216,10 @@ void InterferenceGraph::setCurDegreeOfIGNodes() //--------------------- debugging (Printing) methods ----------------------- //---------------------------------------------------------------------------- -// Print the IGnodes +// Print the IGnodes //---------------------------------------------------------------------------- void InterferenceGraph::printIG() const { - for(unsigned i=0; i < Size; i++) { + for(unsigned i=0; i < Size; i++) { const IGNode *const Node = IGNodeList[i]; if(Node) { std::cerr << " [" << i << "] "; |