mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
Simplify RegScavenger::FindUnusedReg.
- Drop the Candidates argument and fix all callers. Now that RegScavenger tracks available registers accurately, there is no need to restict the search. - Make sure that no aliases of the found register are in use. This was a potential bug. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79369 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -98,15 +98,9 @@ public:
|
|||||||
/// getRegsUsed - return all registers currently in use in used.
|
/// getRegsUsed - return all registers currently in use in used.
|
||||||
void getRegsUsed(BitVector &used, bool includeReserved);
|
void getRegsUsed(BitVector &used, bool includeReserved);
|
||||||
|
|
||||||
/// FindUnusedReg - Find a unused register of the specified register class
|
|
||||||
/// from the specified set of registers. It return 0 is none is found.
|
|
||||||
unsigned FindUnusedReg(const TargetRegisterClass *RegClass,
|
|
||||||
const BitVector &Candidates) const;
|
|
||||||
|
|
||||||
/// FindUnusedReg - Find a unused register of the specified register class.
|
/// FindUnusedReg - Find a unused register of the specified register class.
|
||||||
/// Exclude callee saved registers if directed. It return 0 is none is found.
|
/// Return 0 if none is found.
|
||||||
unsigned FindUnusedReg(const TargetRegisterClass *RegClass,
|
unsigned FindUnusedReg(const TargetRegisterClass *RegClass) const;
|
||||||
bool ExCalleeSaved = false) const;
|
|
||||||
|
|
||||||
/// setScavengingFrameIndex / getScavengingFrameIndex - accessor and setter of
|
/// setScavengingFrameIndex / getScavengingFrameIndex - accessor and setter of
|
||||||
/// ScavengingFrameIndex.
|
/// ScavengingFrameIndex.
|
||||||
|
@ -248,36 +248,12 @@ static void CreateRegClassMask(const TargetRegisterClass *RC, BitVector &Mask) {
|
|||||||
Mask.set(*I);
|
Mask.set(*I);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RegClass,
|
unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RC) const {
|
||||||
const BitVector &Candidates) const {
|
for (TargetRegisterClass::iterator I = RC->begin(), E = RC->end();
|
||||||
// Mask off the registers which are not in the TargetRegisterClass.
|
I != E; ++I)
|
||||||
BitVector RegsAvailableCopy(NumPhysRegs, false);
|
if (!isAliasUsed(*I))
|
||||||
CreateRegClassMask(RegClass, RegsAvailableCopy);
|
return *I;
|
||||||
RegsAvailableCopy &= RegsAvailable;
|
return 0;
|
||||||
|
|
||||||
// Restrict the search to candidates.
|
|
||||||
RegsAvailableCopy &= Candidates;
|
|
||||||
|
|
||||||
// Returns the first unused (bit is set) register, or 0 is none is found.
|
|
||||||
int Reg = RegsAvailableCopy.find_first();
|
|
||||||
return (Reg == -1) ? 0 : Reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RegClass,
|
|
||||||
bool ExCalleeSaved) const {
|
|
||||||
// Mask off the registers which are not in the TargetRegisterClass.
|
|
||||||
BitVector RegsAvailableCopy(NumPhysRegs, false);
|
|
||||||
CreateRegClassMask(RegClass, RegsAvailableCopy);
|
|
||||||
RegsAvailableCopy &= RegsAvailable;
|
|
||||||
|
|
||||||
// If looking for a non-callee-saved register, mask off all the callee-saved
|
|
||||||
// registers.
|
|
||||||
if (ExCalleeSaved)
|
|
||||||
RegsAvailableCopy &= ~CalleeSavedRegs;
|
|
||||||
|
|
||||||
// Returns the first unused (bit is set) register, or 0 is none is found.
|
|
||||||
int Reg = RegsAvailableCopy.find_first();
|
|
||||||
return (Reg == -1) ? 0 : Reg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// findSurvivorReg - Return the candidate register that is unused for the
|
/// findSurvivorReg - Return the candidate register that is unused for the
|
||||||
|
@ -1006,12 +1006,8 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
|||||||
static
|
static
|
||||||
unsigned findScratchRegister(RegScavenger *RS, const TargetRegisterClass *RC,
|
unsigned findScratchRegister(RegScavenger *RS, const TargetRegisterClass *RC,
|
||||||
ARMFunctionInfo *AFI) {
|
ARMFunctionInfo *AFI) {
|
||||||
unsigned Reg = RS ? RS->FindUnusedReg(RC, true) : (unsigned) ARM::R12;
|
unsigned Reg = RS ? RS->FindUnusedReg(RC) : (unsigned) ARM::R12;
|
||||||
assert(!AFI->isThumb1OnlyFunction());
|
assert(!AFI->isThumb1OnlyFunction());
|
||||||
if (Reg == 0)
|
|
||||||
// Try a already spilled CS register.
|
|
||||||
Reg = RS->FindUnusedReg(RC, AFI->getSpilledCSRegisters());
|
|
||||||
|
|
||||||
return Reg;
|
return Reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,12 +941,8 @@ bool ARMLoadStoreOpt::LoadStoreMultipleOpti(MachineBasicBlock &MBB) {
|
|||||||
// Try to find a free register to use as a new base in case it's needed.
|
// Try to find a free register to use as a new base in case it's needed.
|
||||||
// First advance to the instruction just before the start of the chain.
|
// First advance to the instruction just before the start of the chain.
|
||||||
AdvanceRS(MBB, MemOps);
|
AdvanceRS(MBB, MemOps);
|
||||||
// Find a scratch register. Make sure it's a call clobbered register or
|
// Find a scratch register.
|
||||||
// a spilled callee-saved register.
|
unsigned Scratch = RS->FindUnusedReg(&ARM::GPRRegClass);
|
||||||
unsigned Scratch = RS->FindUnusedReg(&ARM::GPRRegClass, true);
|
|
||||||
if (!Scratch)
|
|
||||||
Scratch = RS->FindUnusedReg(&ARM::GPRRegClass,
|
|
||||||
AFI->getSpilledCSRegisters());
|
|
||||||
// Process the load / store instructions.
|
// Process the load / store instructions.
|
||||||
RS->forward(prior(MBBI));
|
RS->forward(prior(MBBI));
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ static unsigned findScratchRegister(MachineBasicBlock::iterator II,
|
|||||||
const TargetRegisterClass *RC,
|
const TargetRegisterClass *RC,
|
||||||
int SPAdj) {
|
int SPAdj) {
|
||||||
assert(RS && "Register scavenging must be on");
|
assert(RS && "Register scavenging must be on");
|
||||||
unsigned Reg = RS->FindUnusedReg(RC, true);
|
unsigned Reg = RS->FindUnusedReg(RC);
|
||||||
if (Reg == 0)
|
if (Reg == 0)
|
||||||
Reg = RS->scavengeRegister(RC, II, SPAdj);
|
Reg = RS->scavengeRegister(RC, II, SPAdj);
|
||||||
return Reg;
|
return Reg;
|
||||||
|
@ -527,7 +527,7 @@ static
|
|||||||
unsigned findScratchRegister(MachineBasicBlock::iterator II, RegScavenger *RS,
|
unsigned findScratchRegister(MachineBasicBlock::iterator II, RegScavenger *RS,
|
||||||
const TargetRegisterClass *RC, int SPAdj) {
|
const TargetRegisterClass *RC, int SPAdj) {
|
||||||
assert(RS && "Register scavenging must be on");
|
assert(RS && "Register scavenging must be on");
|
||||||
unsigned Reg = RS->FindUnusedReg(RC, true);
|
unsigned Reg = RS->FindUnusedReg(RC);
|
||||||
// FIXME: move ARM callee-saved reg scan to target independent code, then
|
// FIXME: move ARM callee-saved reg scan to target independent code, then
|
||||||
// search for already spilled CS register here.
|
// search for already spilled CS register here.
|
||||||
if (Reg == 0)
|
if (Reg == 0)
|
||||||
|
Reference in New Issue
Block a user