Commit 88df8760 authored by Misha Brukman's avatar Misha Brukman
Browse files

* Eliminate `using' directive

* Fix order of #includes
* Make code layout more consistent
* Eliminate extraneous whitespace and comment-lines

llvm-svn: 9433
parent dc07775d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -11,12 +11,11 @@
// 
//===----------------------------------------------------------------------===//

#include "RegAllocCommon.h"
#include "InterferenceGraph.h"
#include "IGNode.h"
#include "InterferenceGraph.h"
#include "RegAllocCommon.h"
#include "Support/STLExtras.h"
#include <algorithm>
using std::cerr;

// for asserting this IG node is infact in the IGNodeList of this class
inline static void assertIGNode(const InterferenceGraph *IG,
+24 −49
Original line number Diff line number Diff line
@@ -11,9 +11,9 @@
// 
//===----------------------------------------------------------------------===//

#include "RegClass.h"
#include "RegAllocCommon.h"
#include "IGNode.h"
#include "RegAllocCommon.h"
#include "RegClass.h"
#include "llvm/Target/TargetRegInfo.h"

//----------------------------------------------------------------------------
@@ -41,21 +41,17 @@ void RegClass::colorAllRegs()
{
  if (DEBUG_RA >= RA_DEBUG_Coloring)
    std::cerr << "Coloring IG of reg class " << RegClassID << " ...\n";

                                        // pre-color IGNodes
  pushAllIGNodes();                     // push all IG Nodes

  unsigned int StackSize = IGNodeStack.size();    
  IGNode *CurIGNode;

                                        // for all LRs on stack
  for (unsigned int IGN=0; IGN < StackSize; IGN++) {    
  
    CurIGNode = IGNodeStack.top();      // pop the IGNode on top of stack
    IGNodeStack.pop();
    colorIGNode (CurIGNode);            // color it
  }

}


@@ -89,24 +85,15 @@ void RegClass::pushAllIGNodes()

  do {
    //get node with min spill cost
    //
    IGNode *IGNodeSpill =  getIGNodeWithMinSpillCost(); 
   
    //  push that node on to stack
    //
    IGNodeStack.push(IGNodeSpill);

    // set its OnStack flag and decrement degree of neighs 
    //
    IGNodeSpill->pushOnStack(); 
   
    // now push NON-constrained ones, if any
    //
    NeedMoreSpills = !pushUnconstrainedIGNodes(); 

    if (DEBUG_RA >= RA_DEBUG_Coloring)
      std::cerr << "\nConstrained IG Node found !@!" << IGNodeSpill->getIndex();

  } while(NeedMoreSpills);            // repeat until we have pushed all 

}
@@ -163,9 +150,7 @@ bool RegClass::pushUnconstrainedIGNodes()
//----------------------------------------------------------------------------
// Get the IGNode with the minimum spill cost
//----------------------------------------------------------------------------
IGNode * RegClass::getIGNodeWithMinSpillCost()
{

IGNode * RegClass::getIGNodeWithMinSpillCost() {
  unsigned int IGNodeListSize = IG.getIGNodeList().size(); 
  double MinSpillCost = 0;
  IGNode *MinCostIGNode = NULL;
@@ -173,7 +158,6 @@ IGNode * RegClass::getIGNodeWithMinSpillCost()

  // pass over IGNodeList to find the IGNode with minimum spill cost
  // among all IGNodes that are not yet pushed on to the stack
  //
  for (unsigned int i =0; i  < IGNodeListSize; i++) {
    IGNode *IGNode = IG.getIGNodeList()[i];
    
@@ -181,7 +165,6 @@ IGNode * RegClass::getIGNodeWithMinSpillCost()
      continue;

    if (!IGNode->isOnStack()) {

      double SpillCost = (double) IGNode->getParentLR()->getSpillCost() /
	(double) (IGNode->getCurDegree() + 1);
    
@@ -189,13 +172,10 @@ IGNode * RegClass::getIGNodeWithMinSpillCost()
	MinSpillCost = SpillCost;
	MinCostIGNode = IGNode;
	isFirstNode = false;
      }

      else if( MinSpillCost > SpillCost) {
      } else if (MinSpillCost > SpillCost) {
	MinSpillCost = SpillCost;
	MinCostIGNode = IGNode;
      }

    }
  }
  
@@ -204,13 +184,10 @@ IGNode * RegClass::getIGNodeWithMinSpillCost()
}



//----------------------------------------------------------------------------
// Color the IGNode using the machine specific code.
//----------------------------------------------------------------------------
void RegClass::colorIGNode(IGNode *const Node)
{

void RegClass::colorIGNode(IGNode *const Node) {
  if (! Node->hasColor())   {          // not colored as an arg etc.
   
    // init all elements of to  IsColorUsedAr  false;
@@ -242,8 +219,7 @@ void RegClass::colorIGNode(IGNode *const Node)
    // call the target specific code for coloring
    //
    MRC->colorIGNode(Node, IsColorUsedArr);
  }
  else {
  } else {
    if (DEBUG_RA >= RA_DEBUG_Coloring) {
      std::cerr << " Node " << Node->getIndex();
      std::cerr << " already colored with color " << Node->getColor() << "\n";
@@ -257,7 +233,6 @@ void RegClass::colorIGNode(IGNode *const Node)
      std::cerr << " - could not find a color (needs spilling)\n";
    }
  }

}

void RegClass::printIGNodeList() const {