aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-02-05 04:20:12 +0000
committerChris Lattner <sabre@nondot.org>2002-02-05 04:20:12 +0000
commit748697d2421051b3ff1263d13cccaf410f3e7034 (patch)
tree78b10a43c512846fce169c36f72c2a7a4c9bc43f /lib/CodeGen
parent3773094a1da7d7fc76a2491211fadf734c3b8645 (diff)
Minor change: Methods that return ValueSet's that are guaranteed to be valid
return references instead of pointers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/InstrSched/SchedPriorities.cpp12
-rw-r--r--lib/CodeGen/RegAlloc/IGNode.cpp25
-rw-r--r--lib/CodeGen/RegAlloc/IGNode.h18
-rw-r--r--lib/CodeGen/RegAlloc/PhyRegAlloc.cpp18
4 files changed, 29 insertions, 44 deletions
diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp
index 74f659993e..fed3f941fe 100644
--- a/lib/CodeGen/InstrSched/SchedPriorities.cpp
+++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp
@@ -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;
}
diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp
index a225742052..795e8b7152 100644
--- a/lib/CodeGen/RegAlloc/IGNode.cpp
+++ b/lib/CodeGen/RegAlloc/IGNode.cpp
@@ -4,26 +4,14 @@
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();
- if( neighs < 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);
}
diff --git a/lib/CodeGen/RegAlloc/IGNode.h b/lib/CodeGen/RegAlloc/IGNode.h
index bdaedf8c13..177800c5bb 100644
--- a/lib/CodeGen/RegAlloc/IGNode.h
+++ b/lib/CodeGen/RegAlloc/IGNode.h
@@ -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; }
diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
index 01e4879cf8..b296cae139 100644
--- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
@@ -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 ];