mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-13 09:33:50 +00:00
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
This commit is contained in:
parent
3773094a1d
commit
748697d242
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,8 @@ using std::cerr;
|
||||
BBLiveVar::BBLiveVar(const BasicBlock *bb, unsigned id)
|
||||
: BB(bb), POID(id) {
|
||||
InSetChanged = OutSetChanged = false;
|
||||
|
||||
calcDefUseSets();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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 ];
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ using std::cerr;
|
||||
BBLiveVar::BBLiveVar(const BasicBlock *bb, unsigned id)
|
||||
: BB(bb), POID(id) {
|
||||
InSetChanged = OutSetChanged = false;
|
||||
|
||||
calcDefUseSets();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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 ];
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user