mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-12 17:25:49 +00:00
Use getRegClassID() instead of getRegClass()->getID(), since it's there.
Shorten the markSuggestedColorUsable method. Add a switch for saving reg. alloc. state (coming soon). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8697 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -39,6 +39,10 @@ DRA_opt("dregalloc", cl::Hidden, cl::location(DEBUG_RA),
|
|||||||
clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"),
|
clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"),
|
||||||
0));
|
0));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
SaveRegAllocState("save-ra-state", cl::Hidden,
|
||||||
|
cl::desc("write reg. allocator state into module"));
|
||||||
|
|
||||||
FunctionPass *getRegisterAllocator(TargetMachine &T) {
|
FunctionPass *getRegisterAllocator(TargetMachine &T) {
|
||||||
return new PhyRegAlloc (T);
|
return new PhyRegAlloc (T);
|
||||||
}
|
}
|
||||||
@@ -76,7 +80,7 @@ void PhyRegAlloc::createIGNodeListsAndIGs() {
|
|||||||
// if the Value * is not null, and LR is not yet written to the IGNodeList
|
// if the Value * is not null, and LR is not yet written to the IGNodeList
|
||||||
if (!(L->getUserIGNode()) ) {
|
if (!(L->getUserIGNode()) ) {
|
||||||
RegClass *const RC = // RegClass of first value in the LR
|
RegClass *const RC = // RegClass of first value in the LR
|
||||||
RegClassList[ L->getRegClass()->getID() ];
|
RegClassList[ L->getRegClassID() ];
|
||||||
RC->addLRToIG(L); // add this LR to an IG
|
RC->addLRToIG(L); // add this LR to an IG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,7 +431,7 @@ bool PhyRegAlloc::markAllocatedRegs(MachineInstr* MInst)
|
|||||||
// An operand may have a color whether or not it needs spilling
|
// An operand may have a color whether or not it needs spilling
|
||||||
if (LR->hasColor())
|
if (LR->hasColor())
|
||||||
MInst->SetRegForOperand(OpNum,
|
MInst->SetRegForOperand(OpNum,
|
||||||
MRI.getUnifiedRegNum(LR->getRegClass()->getID(),
|
MRI.getUnifiedRegNum(LR->getRegClassID(),
|
||||||
LR->getColor()));
|
LR->getColor()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -675,7 +679,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
|
|||||||
// This may insert code before and after MInst to free up the value. If so,
|
// This may insert code before and after MInst to free up the value. If so,
|
||||||
// this code should be first/last in the spill sequence before/after MInst.
|
// this code should be first/last in the spill sequence before/after MInst.
|
||||||
int TmpRegU=(LR->hasColor()
|
int TmpRegU=(LR->hasColor()
|
||||||
? MRI.getUnifiedRegNum(LR->getRegClass()->getID(),LR->getColor())
|
? MRI.getUnifiedRegNum(LR->getRegClassID(),LR->getColor())
|
||||||
: getUsableUniRegAtMI(RegType, &LVSetBef, MInst, MIBef,MIAft));
|
: getUsableUniRegAtMI(RegType, &LVSetBef, MInst, MIBef,MIAft));
|
||||||
|
|
||||||
// Set the operand first so that it this register does not get used
|
// Set the operand first so that it this register does not get used
|
||||||
@@ -1118,10 +1122,10 @@ void PhyRegAlloc::colorIncomingArgs()
|
|||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// This method calls setSugColorUsable method of each live range. This
|
// This method determines whether the suggested color of each live range
|
||||||
// will determine whether the suggested color of LR is really usable.
|
// is really usable, and then calls its setSuggestedColorUsable() method to
|
||||||
// A suggested color is not usable when the suggested color is volatile
|
// record the answer. A suggested color is NOT usable when the suggested color
|
||||||
// AND when there are call interferences
|
// is volatile AND when there are call interferences.
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
void PhyRegAlloc::markUnusableSugColors()
|
void PhyRegAlloc::markUnusableSugColors()
|
||||||
@@ -1132,16 +1136,10 @@ void PhyRegAlloc::markUnusableSugColors()
|
|||||||
for (; HMI != HMIEnd ; ++HMI ) {
|
for (; HMI != HMIEnd ; ++HMI ) {
|
||||||
if (HMI->first) {
|
if (HMI->first) {
|
||||||
LiveRange *L = HMI->second; // get the LiveRange
|
LiveRange *L = HMI->second; // get the LiveRange
|
||||||
if (L) {
|
if (L && L->hasSuggestedColor ())
|
||||||
if (L->hasSuggestedColor()) {
|
L->setSuggestedColorUsable
|
||||||
int RCID = L->getRegClass()->getID();
|
(!(MRI.isRegVolatile (L->getRegClassID (), L->getSuggestedColor ())
|
||||||
if (MRI.isRegVolatile( RCID, L->getSuggestedColor()) &&
|
&& L->isCallInterference ()));
|
||||||
L->isCallInterference() )
|
|
||||||
L->setSuggestedColorUsable( false );
|
|
||||||
else
|
|
||||||
L->setSuggestedColorUsable( true );
|
|
||||||
}
|
|
||||||
} // if L->hasSuggestedColor()
|
|
||||||
}
|
}
|
||||||
} // for all LR's in hash map
|
} // for all LR's in hash map
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,10 @@ DRA_opt("dregalloc", cl::Hidden, cl::location(DEBUG_RA),
|
|||||||
clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"),
|
clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"),
|
||||||
0));
|
0));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
SaveRegAllocState("save-ra-state", cl::Hidden,
|
||||||
|
cl::desc("write reg. allocator state into module"));
|
||||||
|
|
||||||
FunctionPass *getRegisterAllocator(TargetMachine &T) {
|
FunctionPass *getRegisterAllocator(TargetMachine &T) {
|
||||||
return new PhyRegAlloc (T);
|
return new PhyRegAlloc (T);
|
||||||
}
|
}
|
||||||
@@ -76,7 +80,7 @@ void PhyRegAlloc::createIGNodeListsAndIGs() {
|
|||||||
// if the Value * is not null, and LR is not yet written to the IGNodeList
|
// if the Value * is not null, and LR is not yet written to the IGNodeList
|
||||||
if (!(L->getUserIGNode()) ) {
|
if (!(L->getUserIGNode()) ) {
|
||||||
RegClass *const RC = // RegClass of first value in the LR
|
RegClass *const RC = // RegClass of first value in the LR
|
||||||
RegClassList[ L->getRegClass()->getID() ];
|
RegClassList[ L->getRegClassID() ];
|
||||||
RC->addLRToIG(L); // add this LR to an IG
|
RC->addLRToIG(L); // add this LR to an IG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,7 +431,7 @@ bool PhyRegAlloc::markAllocatedRegs(MachineInstr* MInst)
|
|||||||
// An operand may have a color whether or not it needs spilling
|
// An operand may have a color whether or not it needs spilling
|
||||||
if (LR->hasColor())
|
if (LR->hasColor())
|
||||||
MInst->SetRegForOperand(OpNum,
|
MInst->SetRegForOperand(OpNum,
|
||||||
MRI.getUnifiedRegNum(LR->getRegClass()->getID(),
|
MRI.getUnifiedRegNum(LR->getRegClassID(),
|
||||||
LR->getColor()));
|
LR->getColor()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -675,7 +679,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
|
|||||||
// This may insert code before and after MInst to free up the value. If so,
|
// This may insert code before and after MInst to free up the value. If so,
|
||||||
// this code should be first/last in the spill sequence before/after MInst.
|
// this code should be first/last in the spill sequence before/after MInst.
|
||||||
int TmpRegU=(LR->hasColor()
|
int TmpRegU=(LR->hasColor()
|
||||||
? MRI.getUnifiedRegNum(LR->getRegClass()->getID(),LR->getColor())
|
? MRI.getUnifiedRegNum(LR->getRegClassID(),LR->getColor())
|
||||||
: getUsableUniRegAtMI(RegType, &LVSetBef, MInst, MIBef,MIAft));
|
: getUsableUniRegAtMI(RegType, &LVSetBef, MInst, MIBef,MIAft));
|
||||||
|
|
||||||
// Set the operand first so that it this register does not get used
|
// Set the operand first so that it this register does not get used
|
||||||
@@ -1118,10 +1122,10 @@ void PhyRegAlloc::colorIncomingArgs()
|
|||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// This method calls setSugColorUsable method of each live range. This
|
// This method determines whether the suggested color of each live range
|
||||||
// will determine whether the suggested color of LR is really usable.
|
// is really usable, and then calls its setSuggestedColorUsable() method to
|
||||||
// A suggested color is not usable when the suggested color is volatile
|
// record the answer. A suggested color is NOT usable when the suggested color
|
||||||
// AND when there are call interferences
|
// is volatile AND when there are call interferences.
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
void PhyRegAlloc::markUnusableSugColors()
|
void PhyRegAlloc::markUnusableSugColors()
|
||||||
@@ -1132,16 +1136,10 @@ void PhyRegAlloc::markUnusableSugColors()
|
|||||||
for (; HMI != HMIEnd ; ++HMI ) {
|
for (; HMI != HMIEnd ; ++HMI ) {
|
||||||
if (HMI->first) {
|
if (HMI->first) {
|
||||||
LiveRange *L = HMI->second; // get the LiveRange
|
LiveRange *L = HMI->second; // get the LiveRange
|
||||||
if (L) {
|
if (L && L->hasSuggestedColor ())
|
||||||
if (L->hasSuggestedColor()) {
|
L->setSuggestedColorUsable
|
||||||
int RCID = L->getRegClass()->getID();
|
(!(MRI.isRegVolatile (L->getRegClassID (), L->getSuggestedColor ())
|
||||||
if (MRI.isRegVolatile( RCID, L->getSuggestedColor()) &&
|
&& L->isCallInterference ()));
|
||||||
L->isCallInterference() )
|
|
||||||
L->setSuggestedColorUsable( false );
|
|
||||||
else
|
|
||||||
L->setSuggestedColorUsable( true );
|
|
||||||
}
|
|
||||||
} // if L->hasSuggestedColor()
|
|
||||||
}
|
}
|
||||||
} // for all LR's in hash map
|
} // for all LR's in hash map
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user