Minor change: Methods that return ValueSet's that are guaranteed to be valid
authorChris Lattner <sabre@nondot.org>
Tue, 5 Feb 2002 04:20:12 +0000 (04:20 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 5 Feb 2002 04:20:12 +0000 (04:20 +0000)
return references instead of pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1719 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
include/llvm/CodeGen/FunctionLiveVarInfo.h
lib/Analysis/LiveVar/BBLiveVar.cpp
lib/Analysis/LiveVar/BBLiveVar.h
lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
lib/CodeGen/InstrSched/SchedPriorities.cpp
lib/CodeGen/RegAlloc/IGNode.cpp
lib/CodeGen/RegAlloc/IGNode.h
lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
lib/Target/SparcV9/LiveVar/BBLiveVar.h
lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
lib/Target/SparcV9/RegAlloc/IGNode.cpp
lib/Target/SparcV9/RegAlloc/IGNode.h
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/SparcV9RegInfo.cpp

index 07cf225b2cac2389679a3ce35900113c511f50b3..d107350dab86f8dbe039fbc58212c3621694f7e0 100644 (file)
@@ -119,17 +119,17 @@ public:
   // --------- Functions to access analysis results -------------------
 
   // gets OutSet of a BB
-  const ValueSet *getOutSetOfBB(const BasicBlock *BB) const;
+  const ValueSet &getOutSetOfBB(const BasicBlock *BB) const;
 
   // gets InSet of a BB
-  const ValueSet *getInSetOfBB(const BasicBlock *BB) const;
+  const ValueSet &getInSetOfBB(const BasicBlock *BB) const;
 
   // gets the Live var set BEFORE an instruction
-  const ValueSet *getLiveVarSetBeforeMInst(const MachineInstr *MI,
+  const ValueSet &getLiveVarSetBeforeMInst(const MachineInstr *MI,
                                            const BasicBlock *BB);
 
   // gets the Live var set AFTER an instruction
-  const ValueSet *getLiveVarSetAfterMInst(const MachineInstr *MI,
+  const ValueSet &getLiveVarSetAfterMInst(const MachineInstr *MI,
                                           const BasicBlock *BB);
 };
 
index 07cf225b2cac2389679a3ce35900113c511f50b3..d107350dab86f8dbe039fbc58212c3621694f7e0 100644 (file)
@@ -119,17 +119,17 @@ public:
   // --------- Functions to access analysis results -------------------
 
   // gets OutSet of a BB
-  const ValueSet *getOutSetOfBB(const BasicBlock *BB) const;
+  const ValueSet &getOutSetOfBB(const BasicBlock *BB) const;
 
   // gets InSet of a BB
-  const ValueSet *getInSetOfBB(const BasicBlock *BB) const;
+  const ValueSet &getInSetOfBB(const BasicBlock *BB) const;
 
   // gets the Live var set BEFORE an instruction
-  const ValueSet *getLiveVarSetBeforeMInst(const MachineInstr *MI,
+  const ValueSet &getLiveVarSetBeforeMInst(const MachineInstr *MI,
                                            const BasicBlock *BB);
 
   // gets the Live var set AFTER an instruction
-  const ValueSet *getLiveVarSetAfterMInst(const MachineInstr *MI,
+  const ValueSet &getLiveVarSetAfterMInst(const MachineInstr *MI,
                                           const BasicBlock *BB);
 };
 
index dc0cbc14600a1b8d3412fe173852e54b999461e1..35548f6b2e79aa6396bc30de883c83c37f2f25de 100644 (file)
@@ -18,6 +18,8 @@ using std::cerr;
 BBLiveVar::BBLiveVar(const BasicBlock *bb, unsigned id)
   : BB(bb), POID(id) {
   InSetChanged = OutSetChanged = false;
+
+  calcDefUseSets();
 }
 
 //-----------------------------------------------------------------------------
index 1fc91f1330021bb1e00b50174e942f67400df98d..442eb22c7310810a101900519de4ab66ed7792d9 100644 (file)
@@ -31,11 +31,12 @@ class BBLiveVar {
                     const BasicBlock *PredBB);
 
   // To add an operand which is a def
-  void  addDef(const Value *Op); 
+  void addDef(const Value *Op); 
 
   // To add an operand which is a use
-  void  addUse(const Value *Op);
+  void addUse(const Value *Op);
 
+  void calcDefUseSets();         // calculates the Def & Use sets for this BB
  public:
   BBLiveVar(const BasicBlock *BB, unsigned POID);
 
@@ -44,18 +45,16 @@ class BBLiveVar {
 
   inline unsigned getPOId() const { return POID; }
 
-  void calcDefUseSets();         // calculates the Def & Use sets for this BB
   bool applyTransferFunc();      // calcultes the In in terms of Out 
 
   // calculates Out set using In sets of the predecessors
   bool applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap);    
 
-  inline const ValueSet *getOutSet() const { return &OutSet; }
-  inline const ValueSet  *getInSet() const { return &InSet; }
+  inline const ValueSet &getOutSet() const { return OutSet; }
+  inline const ValueSet  &getInSet() const { return InSet; }
 
   void printAllSets() const;      // for printing Def/In/Out sets
   void printInOutSets() const;    // for printing In/Out sets
 };
 
 #endif
-
index a4dbef1cf0728d4bf40ab92fd12e1e008dd4d407..5205a19182d5cc3d27dbb9645c8d71e0c0aa64e3 100644 (file)
@@ -20,12 +20,12 @@ AnalysisID MethodLiveVarInfo::ID(AnalysisID::create<MethodLiveVarInfo>());
 //-----------------------------------------------------------------------------
 
 // gets OutSet of a BB
-const ValueSet *MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
+const ValueSet &MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getOutSet();
 }
 
 // gets InSet of a BB
-const ValueSet *MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
+const ValueSet &MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getInSet();
 }
 
@@ -65,8 +65,6 @@ void MethodLiveVarInfo::constructBBs(const Method *M) {
     BBLiveVar *LVBB = new BBLiveVar(BB, POId);  
     BB2BBLVMap[BB] = LVBB;              // insert the pair to Map
     
-    LVBB->calcDefUseSets();             // calculates the def and in set
-
     if (DEBUG_LV)
       LVBB->printAllSets();
   }
@@ -155,14 +153,14 @@ void MethodLiveVarInfo::releaseMemory() {
 // Gives live variable information before a machine instruction
 //-----------------------------------------------------------------------------
 
-const ValueSet *
+const ValueSet &
 MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
                                            const BasicBlock *BB) {
   if (const ValueSet *LVSet = MInst2LVSetBI[MInst]) {
-    return LVSet;                      // if found, just return the set
+    return *LVSet;                      // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);          // else, calc for all instrs in BB
-    return MInst2LVSetBI[MInst];
+    return *MInst2LVSetBI[MInst];
   }
 }
 
@@ -170,15 +168,15 @@ MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
 //-----------------------------------------------------------------------------
 // Gives live variable information after a machine instruction
 //-----------------------------------------------------------------------------
-const ValueSet * 
+const ValueSet & 
 MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
                                            const BasicBlock *BB) {
 
   if (const ValueSet *LVSet = MInst2LVSetAI[MI]) {
-    return LVSet;                       // if found, just return the set
+    return *LVSet;                      // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);           // else, calc for all instrs in BB
-    return MInst2LVSetAI[MI];
+    return *MInst2LVSetAI[MI];
   }
 }
 
@@ -224,7 +222,7 @@ void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
   const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec();
 
   ValueSet *CurSet = new ValueSet();
-  const ValueSet *SetAI = getOutSetOfBB(BB); // init SetAI with OutSet
+  const ValueSet *SetAI = &getOutSetOfBB(BB);  // init SetAI with OutSet
   set_union(*CurSet, *SetAI);                  // CurSet now contains OutSet
 
   // iterate over all the machine instructions in BB
index 74f659993e2a9d5efc8a47ac5f1714bb63bda3ec..fed3f941fef58b44537b9c72e286159368ccd96b 100644 (file)
@@ -276,16 +276,14 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
   // else check if instruction is a last use and save it in the hash_map
   bool hasLastUse = false;
   const BasicBlock* bb = graphNode->getBB();
-  const ValueSet *liveVars =
-    methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
+  const ValueSet &LVs = methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
   
-  for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
-    if (liveVars->find(*vo) == liveVars->end()) {
+  for (MachineInstr::val_const_op_iterator vo(minstr); !vo.done(); ++vo)
+    if (!LVs.count(*vo)) {
       hasLastUse = true;
       break;
     }
-  
-  lastUseMap[minstr] = hasLastUse;
-  return hasLastUse;
+
+  return lastUseMap[minstr] = hasLastUse;
 }
 
index a2257420529e712fb9d484129a00ac02b712e1e9..795e8b71524e64e39b761e22c4fc579ff66704ee 100644 (file)
@@ -3,27 +3,15 @@
 #include <iostream>
 using std::cerr;
 
-//-----------------------------------------------------------------------------
-// Constructor
-//-----------------------------------------------------------------------------
-IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind),
-                                                         ParentLR(PLR)
-{
-  OnStack = false;
-  CurDegree = -1 ;
-  ParentLR->setUserIGNode( this );
-}
-
-
 //-----------------------------------------------------------------------------
 // Sets this IGNode on stack and reduce the degree of neighbors  
 //-----------------------------------------------------------------------------
-void IGNode::pushOnStack()             
-{                                     
+
+void IGNode::pushOnStack() {
   OnStack = true; 
   int neighs = AdjList.size();
 
-  ifneighs < 0) {
+  if (neighs < 0) {
     cerr << "\nAdj List size = " << neighs;
     assert(0 && "Invalid adj list size");
   }
@@ -36,10 +24,9 @@ void IGNode::pushOnStack()
 // Deletes an adjacency node. IGNodes are deleted when coalescing merges
 // two IGNodes together.
 //-----------------------------------------------------------------------------
-void IGNode::delAdjIGNode(const IGNode *const Node) {
-  std::vector<IGNode *>::iterator It = 
-    find(AdjList.begin(), AdjList.end(), Node);
+
+void IGNode::delAdjIGNode(const IGNode *Node) {
+  std::vector<IGNode *>::iterator It=find(AdjList.begin(), AdjList.end(), Node);
   assert( It != AdjList.end() );      // the node must be there
-    
   AdjList.erase(It);
 }
index bdaedf8c134c66ae3c14f24e9bb20f54916b576c..177800c5bb9648d6a5138714ca49a7c2e5bab5f4 100644 (file)
@@ -37,11 +37,9 @@ class RegClass;
 //----------------------------------------------------------------------------
 
 class IGNode {
-  const int Index;            // index within IGNodeList 
-
-  bool OnStack;               // this has been pushed on to stack for coloring
-
-  std::vector<IGNode *> AdjList;   // adjacency list for this live range
+  const unsigned Index;         // index within IGNodeList 
+  bool OnStack;                 // this has been pushed on to stack for coloring
+  std::vector<IGNode *> AdjList;// adjacency list for this live range
 
   int CurDegree;     
   //
@@ -50,12 +48,14 @@ class IGNode {
   // Decremented when a neighbor is pushed on to the stack. 
   // After that, never incremented/set again nor used.
 
-  LiveRange *const ParentLR;  // parent LR (cannot be a const)
+  LiveRange *const ParentLR;
 public:
 
-  // constructor
-  //
-  IGNode(LiveRange *LR, unsigned index);
+  IGNode(LiveRange *LR, unsigned index) : Index(index), ParentLR(LR) {
+    OnStack = false;
+    CurDegree = -1;
+    ParentLR->setUserIGNode(this);
+  }
 
   inline unsigned int getIndex() const { return Index; }
 
index 01e4879cf87dd534be6ae847ca2a0445bad4882b..b296cae139f61334654681194a7cfdf4f00ba4ee 100644 (file)
@@ -290,11 +290,11 @@ void PhyRegAlloc::buildInterferenceGraphs()
     //
     for( ; MInstIterator != MIVec.end(); ++MInstIterator) {  
 
-      const MachineInstr * MInst = *MInstIterator; 
+      const MachineInstr *MInst = *MInstIterator; 
 
       // get the LV set after the instruction
       //
-      const ValueSet *LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, *BBI);
+      const ValueSet &LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, *BBI);
     
       const bool isCallInst = TM.getInstrInfo().isCall(MInst->getOpCode());
 
@@ -304,7 +304,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
        // coloring algo to avoid allocating volatile colors to live ranges
        // that span across calls (since they have to be saved/restored)
        //
-       setCallInterferences( MInst,  LVSetAI);
+       setCallInterferences(MInst, &LVSetAI);
       }
 
 
@@ -315,7 +315,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
                if( OpI.isDef() ) {     
          // create a new LR iff this operand is a def
          //
-         addInterference(*OpI, LVSetAI, isCallInst );
+         addInterference(*OpI, &LVSetAI, isCallInst);
        } 
 
        // Calculate the spill cost of each live range
@@ -339,7 +339,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
       if(  NumOfImpRefs > 0 ) {
        for(unsigned z=0; z < NumOfImpRefs; z++) 
          if( MInst->implicitRefIsDefined(z) )
-           addInterference( MInst->getImplicitRef(z), LVSetAI, isCallInst );
+           addInterference( MInst->getImplicitRef(z), &LVSetAI, isCallInst );
       }
 
 
@@ -418,7 +418,7 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
 //----------------------------------------------------------------------------
 void PhyRegAlloc::addInterferencesForArgs() {
   // get the InSet of root BB
-  const ValueSet *InSet = LVI->getInSetOfBB(Meth->front());  
+  const ValueSet &InSet = LVI->getInSetOfBB(Meth->front());  
 
   // get the argument list
   const Method::ArgumentListType& ArgList = Meth->getArgumentList();  
@@ -428,7 +428,7 @@ void PhyRegAlloc::addInterferencesForArgs() {
 
 
   for( ; ArgIt != ArgList.end() ; ++ArgIt) {  // for each argument
-    addInterference((Value*)*ArgIt, InSet, false); // add interferences between 
+    addInterference((Value*)*ArgIt, &InSet, false);// add interferences between 
                                               // args and LVars at start
     if( DEBUG_RA > 1)
       cerr << " - %% adding interference for  argument "
@@ -682,13 +682,13 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
   unsigned RegType = MRI.getRegType( LR );
   int SpillOff = LR->getSpillOffFromFP();
   RegClass *RC = LR->getRegClass();
-  const ValueSet *LVSetBef =  LVI->getLiveVarSetBeforeMInst(MInst, BB);
+  const ValueSet &LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB);
 
   mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) );
   
   MachineInstr *MIBef=NULL,  *AdIMid=NULL, *MIAft=NULL;
   
-  int TmpRegU = getUsableUniRegAtMI(RC, RegType, MInst,LVSetBef, MIBef, MIAft);
+  int TmpRegU = getUsableUniRegAtMI(RC, RegType, MInst,&LVSetBef, MIBef, MIAft);
   
   // get the added instructions for this instruciton
   AddedInstrns *AI = AddedInstrMap[ MInst ];
index 74f659993e2a9d5efc8a47ac5f1714bb63bda3ec..fed3f941fef58b44537b9c72e286159368ccd96b 100644 (file)
@@ -276,16 +276,14 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
   // else check if instruction is a last use and save it in the hash_map
   bool hasLastUse = false;
   const BasicBlock* bb = graphNode->getBB();
-  const ValueSet *liveVars =
-    methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
+  const ValueSet &LVs = methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
   
-  for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
-    if (liveVars->find(*vo) == liveVars->end()) {
+  for (MachineInstr::val_const_op_iterator vo(minstr); !vo.done(); ++vo)
+    if (!LVs.count(*vo)) {
       hasLastUse = true;
       break;
     }
-  
-  lastUseMap[minstr] = hasLastUse;
-  return hasLastUse;
+
+  return lastUseMap[minstr] = hasLastUse;
 }
 
index dc0cbc14600a1b8d3412fe173852e54b999461e1..35548f6b2e79aa6396bc30de883c83c37f2f25de 100644 (file)
@@ -18,6 +18,8 @@ using std::cerr;
 BBLiveVar::BBLiveVar(const BasicBlock *bb, unsigned id)
   : BB(bb), POID(id) {
   InSetChanged = OutSetChanged = false;
+
+  calcDefUseSets();
 }
 
 //-----------------------------------------------------------------------------
index 1fc91f1330021bb1e00b50174e942f67400df98d..442eb22c7310810a101900519de4ab66ed7792d9 100644 (file)
@@ -31,11 +31,12 @@ class BBLiveVar {
                     const BasicBlock *PredBB);
 
   // To add an operand which is a def
-  void  addDef(const Value *Op); 
+  void addDef(const Value *Op); 
 
   // To add an operand which is a use
-  void  addUse(const Value *Op);
+  void addUse(const Value *Op);
 
+  void calcDefUseSets();         // calculates the Def & Use sets for this BB
  public:
   BBLiveVar(const BasicBlock *BB, unsigned POID);
 
@@ -44,18 +45,16 @@ class BBLiveVar {
 
   inline unsigned getPOId() const { return POID; }
 
-  void calcDefUseSets();         // calculates the Def & Use sets for this BB
   bool applyTransferFunc();      // calcultes the In in terms of Out 
 
   // calculates Out set using In sets of the predecessors
   bool applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap);    
 
-  inline const ValueSet *getOutSet() const { return &OutSet; }
-  inline const ValueSet  *getInSet() const { return &InSet; }
+  inline const ValueSet &getOutSet() const { return OutSet; }
+  inline const ValueSet  &getInSet() const { return InSet; }
 
   void printAllSets() const;      // for printing Def/In/Out sets
   void printInOutSets() const;    // for printing In/Out sets
 };
 
 #endif
-
index a4dbef1cf0728d4bf40ab92fd12e1e008dd4d407..5205a19182d5cc3d27dbb9645c8d71e0c0aa64e3 100644 (file)
@@ -20,12 +20,12 @@ AnalysisID MethodLiveVarInfo::ID(AnalysisID::create<MethodLiveVarInfo>());
 //-----------------------------------------------------------------------------
 
 // gets OutSet of a BB
-const ValueSet *MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
+const ValueSet &MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getOutSet();
 }
 
 // gets InSet of a BB
-const ValueSet *MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
+const ValueSet &MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getInSet();
 }
 
@@ -65,8 +65,6 @@ void MethodLiveVarInfo::constructBBs(const Method *M) {
     BBLiveVar *LVBB = new BBLiveVar(BB, POId);  
     BB2BBLVMap[BB] = LVBB;              // insert the pair to Map
     
-    LVBB->calcDefUseSets();             // calculates the def and in set
-
     if (DEBUG_LV)
       LVBB->printAllSets();
   }
@@ -155,14 +153,14 @@ void MethodLiveVarInfo::releaseMemory() {
 // Gives live variable information before a machine instruction
 //-----------------------------------------------------------------------------
 
-const ValueSet *
+const ValueSet &
 MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
                                            const BasicBlock *BB) {
   if (const ValueSet *LVSet = MInst2LVSetBI[MInst]) {
-    return LVSet;                      // if found, just return the set
+    return *LVSet;                      // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);          // else, calc for all instrs in BB
-    return MInst2LVSetBI[MInst];
+    return *MInst2LVSetBI[MInst];
   }
 }
 
@@ -170,15 +168,15 @@ MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
 //-----------------------------------------------------------------------------
 // Gives live variable information after a machine instruction
 //-----------------------------------------------------------------------------
-const ValueSet * 
+const ValueSet & 
 MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
                                            const BasicBlock *BB) {
 
   if (const ValueSet *LVSet = MInst2LVSetAI[MI]) {
-    return LVSet;                       // if found, just return the set
+    return *LVSet;                      // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);           // else, calc for all instrs in BB
-    return MInst2LVSetAI[MI];
+    return *MInst2LVSetAI[MI];
   }
 }
 
@@ -224,7 +222,7 @@ void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
   const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec();
 
   ValueSet *CurSet = new ValueSet();
-  const ValueSet *SetAI = getOutSetOfBB(BB); // init SetAI with OutSet
+  const ValueSet *SetAI = &getOutSetOfBB(BB);  // init SetAI with OutSet
   set_union(*CurSet, *SetAI);                  // CurSet now contains OutSet
 
   // iterate over all the machine instructions in BB
index a2257420529e712fb9d484129a00ac02b712e1e9..795e8b71524e64e39b761e22c4fc579ff66704ee 100644 (file)
@@ -3,27 +3,15 @@
 #include <iostream>
 using std::cerr;
 
-//-----------------------------------------------------------------------------
-// Constructor
-//-----------------------------------------------------------------------------
-IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind),
-                                                         ParentLR(PLR)
-{
-  OnStack = false;
-  CurDegree = -1 ;
-  ParentLR->setUserIGNode( this );
-}
-
-
 //-----------------------------------------------------------------------------
 // Sets this IGNode on stack and reduce the degree of neighbors  
 //-----------------------------------------------------------------------------
-void IGNode::pushOnStack()             
-{                                     
+
+void IGNode::pushOnStack() {
   OnStack = true; 
   int neighs = AdjList.size();
 
-  ifneighs < 0) {
+  if (neighs < 0) {
     cerr << "\nAdj List size = " << neighs;
     assert(0 && "Invalid adj list size");
   }
@@ -36,10 +24,9 @@ void IGNode::pushOnStack()
 // Deletes an adjacency node. IGNodes are deleted when coalescing merges
 // two IGNodes together.
 //-----------------------------------------------------------------------------
-void IGNode::delAdjIGNode(const IGNode *const Node) {
-  std::vector<IGNode *>::iterator It = 
-    find(AdjList.begin(), AdjList.end(), Node);
+
+void IGNode::delAdjIGNode(const IGNode *Node) {
+  std::vector<IGNode *>::iterator It=find(AdjList.begin(), AdjList.end(), Node);
   assert( It != AdjList.end() );      // the node must be there
-    
   AdjList.erase(It);
 }
index bdaedf8c134c66ae3c14f24e9bb20f54916b576c..177800c5bb9648d6a5138714ca49a7c2e5bab5f4 100644 (file)
@@ -37,11 +37,9 @@ class RegClass;
 //----------------------------------------------------------------------------
 
 class IGNode {
-  const int Index;            // index within IGNodeList 
-
-  bool OnStack;               // this has been pushed on to stack for coloring
-
-  std::vector<IGNode *> AdjList;   // adjacency list for this live range
+  const unsigned Index;         // index within IGNodeList 
+  bool OnStack;                 // this has been pushed on to stack for coloring
+  std::vector<IGNode *> AdjList;// adjacency list for this live range
 
   int CurDegree;     
   //
@@ -50,12 +48,14 @@ class IGNode {
   // Decremented when a neighbor is pushed on to the stack. 
   // After that, never incremented/set again nor used.
 
-  LiveRange *const ParentLR;  // parent LR (cannot be a const)
+  LiveRange *const ParentLR;
 public:
 
-  // constructor
-  //
-  IGNode(LiveRange *LR, unsigned index);
+  IGNode(LiveRange *LR, unsigned index) : Index(index), ParentLR(LR) {
+    OnStack = false;
+    CurDegree = -1;
+    ParentLR->setUserIGNode(this);
+  }
 
   inline unsigned int getIndex() const { return Index; }
 
index 01e4879cf87dd534be6ae847ca2a0445bad4882b..b296cae139f61334654681194a7cfdf4f00ba4ee 100644 (file)
@@ -290,11 +290,11 @@ void PhyRegAlloc::buildInterferenceGraphs()
     //
     for( ; MInstIterator != MIVec.end(); ++MInstIterator) {  
 
-      const MachineInstr * MInst = *MInstIterator; 
+      const MachineInstr *MInst = *MInstIterator; 
 
       // get the LV set after the instruction
       //
-      const ValueSet *LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, *BBI);
+      const ValueSet &LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, *BBI);
     
       const bool isCallInst = TM.getInstrInfo().isCall(MInst->getOpCode());
 
@@ -304,7 +304,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
        // coloring algo to avoid allocating volatile colors to live ranges
        // that span across calls (since they have to be saved/restored)
        //
-       setCallInterferences( MInst,  LVSetAI);
+       setCallInterferences(MInst, &LVSetAI);
       }
 
 
@@ -315,7 +315,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
                if( OpI.isDef() ) {     
          // create a new LR iff this operand is a def
          //
-         addInterference(*OpI, LVSetAI, isCallInst );
+         addInterference(*OpI, &LVSetAI, isCallInst);
        } 
 
        // Calculate the spill cost of each live range
@@ -339,7 +339,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
       if(  NumOfImpRefs > 0 ) {
        for(unsigned z=0; z < NumOfImpRefs; z++) 
          if( MInst->implicitRefIsDefined(z) )
-           addInterference( MInst->getImplicitRef(z), LVSetAI, isCallInst );
+           addInterference( MInst->getImplicitRef(z), &LVSetAI, isCallInst );
       }
 
 
@@ -418,7 +418,7 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
 //----------------------------------------------------------------------------
 void PhyRegAlloc::addInterferencesForArgs() {
   // get the InSet of root BB
-  const ValueSet *InSet = LVI->getInSetOfBB(Meth->front());  
+  const ValueSet &InSet = LVI->getInSetOfBB(Meth->front());  
 
   // get the argument list
   const Method::ArgumentListType& ArgList = Meth->getArgumentList();  
@@ -428,7 +428,7 @@ void PhyRegAlloc::addInterferencesForArgs() {
 
 
   for( ; ArgIt != ArgList.end() ; ++ArgIt) {  // for each argument
-    addInterference((Value*)*ArgIt, InSet, false); // add interferences between 
+    addInterference((Value*)*ArgIt, &InSet, false);// add interferences between 
                                               // args and LVars at start
     if( DEBUG_RA > 1)
       cerr << " - %% adding interference for  argument "
@@ -682,13 +682,13 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
   unsigned RegType = MRI.getRegType( LR );
   int SpillOff = LR->getSpillOffFromFP();
   RegClass *RC = LR->getRegClass();
-  const ValueSet *LVSetBef =  LVI->getLiveVarSetBeforeMInst(MInst, BB);
+  const ValueSet &LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB);
 
   mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) );
   
   MachineInstr *MIBef=NULL,  *AdIMid=NULL, *MIAft=NULL;
   
-  int TmpRegU = getUsableUniRegAtMI(RC, RegType, MInst,LVSetBef, MIBef, MIAft);
+  int TmpRegU = getUsableUniRegAtMI(RC, RegType, MInst,&LVSetBef, MIBef, MIAft);
   
   // get the added instructions for this instruciton
   AddedInstrns *AI = AddedInstrMap[ MInst ];
index 9af470aa0124f91c8f867e0c58827b0842eac65b..f910c9b44154a4942ef089f8dfdeeb65dc44d50d 100644 (file)
@@ -1251,11 +1251,11 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst,
   }
 
 
-  const ValueSet *LVSetAft =  PRA.LVI->getLiveVarSetAfterMInst(MInst, BB);
-  ValueSet::const_iterator LIt = LVSetAft->begin();
+  const ValueSet &LVSetAft =  PRA.LVI->getLiveVarSetAfterMInst(MInst, BB);
+  ValueSet::const_iterator LIt = LVSetAft.begin();
 
   // for each live var in live variable set after machine inst
-  for( ; LIt != LVSetAft->end(); ++LIt) {
+  for( ; LIt != LVSetAft.end(); ++LIt) {
 
    //  get the live range corresponding to live var
     LiveRange *const LR = PRA.LRI.getLiveRangeForValue(*LIt );    
@@ -1302,25 +1302,25 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst,
              // Handle IntCCRegType specially since we cannot directly 
              // push %ccr on to the stack
 
-             const ValueSet *LVSetBef = 
+             const ValueSet &LVSetBef = 
                PRA.LVI->getLiveVarSetBeforeMInst(MInst, BB);
 
              // get a free INTEGER register
              int FreeIntReg = 
                PRA.getUsableUniRegAtMI(LR->getRegClass(), IntRegType, MInst, 
-                                    LVSetBef, AdIBefCC, AdIAftCC);
+                                        &LVSetBef, AdIBefCC, AdIAftCC);
 
              // insert the instructions in reverse order since we are
              // adding them to the front of InstrnsBefore
 
              if(AdIAftCC)
-               (PRA.AddedInstrMap[MInst]->InstrnsBefore).push_front(AdIAftCC);
+               PRA.AddedInstrMap[MInst]->InstrnsBefore.push_front(AdIAftCC);
 
              AdICpCC = cpCCR2IntMI(FreeIntReg);
-             (PRA.AddedInstrMap[MInst]->InstrnsBefore).push_front(AdICpCC);
+             PRA.AddedInstrMap[MInst]->InstrnsBefore.push_front(AdICpCC);
 
              if(AdIBefCC)
-               (PRA.AddedInstrMap[MInst]->InstrnsBefore).push_front(AdIBefCC);
+               PRA.AddedInstrMap[MInst]->InstrnsBefore.push_front(AdIBefCC);
 
              if(DEBUG_RA) {
                cerr << "\n!! Inserted caller saving (push) inst for %ccr:";
@@ -1332,13 +1332,13 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst,
            } else  {  
              // for any other register type, just add the push inst
              AdIBef = cpReg2MemMI(Reg, getFramePointer(), StackOff, RegType );
-             ((PRA.AddedInstrMap[MInst])->InstrnsBefore).push_front(AdIBef);
+             PRA.AddedInstrMap[MInst]->InstrnsBefore.push_front(AdIBef);
            }
 
 
            //---- Insert code for popping the reg from the stack ----------
 
-           if( RegType == IntCCRegType ) {
+           if (RegType == IntCCRegType) {
 
              // Handle IntCCRegType specially since we cannot directly 
              // pop %ccr on from the stack
@@ -1346,16 +1346,16 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst,
              // get a free INT register
              int FreeIntReg = 
                PRA.getUsableUniRegAtMI(LR->getRegClass(), IntRegType, MInst, 
-                                    LVSetAft, AdIBefCC, AdIAftCC);
+                                        &LVSetAft, AdIBefCC, AdIAftCC);
              
              if(AdIBefCC)
-               (PRA.AddedInstrMap[MInst]->InstrnsAfter).push_back(AdIBefCC);
+               PRA.AddedInstrMap[MInst]->InstrnsAfter.push_back(AdIBefCC);
 
              AdICpCC = cpInt2CCRMI(FreeIntReg);
-             (PRA.AddedInstrMap[MInst]->InstrnsAfter).push_back(AdICpCC);
+             PRA.AddedInstrMap[MInst]->InstrnsAfter.push_back(AdICpCC);
            
              if(AdIAftCC)
-               (PRA.AddedInstrMap[MInst]->InstrnsAfter).push_back(AdIAftCC);
+               PRA.AddedInstrMap[MInst]->InstrnsAfter.push_back(AdIAftCC);
 
              if(DEBUG_RA) {
 
@@ -1368,10 +1368,10 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst,
            } else {
              // for any other register type, just add the pop inst
              AdIAft = cpMem2RegMI(getFramePointer(), StackOff, Reg, RegType );
-             ((PRA.AddedInstrMap[MInst])->InstrnsAfter).push_back(AdIAft);
+             PRA.AddedInstrMap[MInst]->InstrnsAfter.push_back(AdIAft);
            }
            
-           PushedRegSet.insert( Reg );
+           PushedRegSet.insert(Reg);
 
            if(DEBUG_RA) {
              cerr << "\nFor call inst:" << *MInst;