mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-05 02:07:56 +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. llvm-svn: 79369
This commit is contained in:
parent
a3a49aeee0
commit
9496240bbf
@ -98,15 +98,9 @@ public:
|
||||
/// getRegsUsed - return all registers currently in use in used.
|
||||
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.
|
||||
/// Exclude callee saved registers if directed. It return 0 is none is found.
|
||||
unsigned FindUnusedReg(const TargetRegisterClass *RegClass,
|
||||
bool ExCalleeSaved = false) const;
|
||||
/// Return 0 if none is found.
|
||||
unsigned FindUnusedReg(const TargetRegisterClass *RegClass) const;
|
||||
|
||||
/// setScavengingFrameIndex / getScavengingFrameIndex - accessor and setter of
|
||||
/// ScavengingFrameIndex.
|
||||
|
@ -248,36 +248,12 @@ static void CreateRegClassMask(const TargetRegisterClass *RC, BitVector &Mask) {
|
||||
Mask.set(*I);
|
||||
}
|
||||
|
||||
unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RegClass,
|
||||
const BitVector &Candidates) const {
|
||||
// Mask off the registers which are not in the TargetRegisterClass.
|
||||
BitVector RegsAvailableCopy(NumPhysRegs, false);
|
||||
CreateRegClassMask(RegClass, RegsAvailableCopy);
|
||||
RegsAvailableCopy &= RegsAvailable;
|
||||
|
||||
// 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;
|
||||
unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RC) const {
|
||||
for (TargetRegisterClass::iterator I = RC->begin(), E = RC->end();
|
||||
I != E; ++I)
|
||||
if (!isAliasUsed(*I))
|
||||
return *I;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// findSurvivorReg - Return the candidate register that is unused for the
|
||||
|
@ -1006,12 +1006,8 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||
static
|
||||
unsigned findScratchRegister(RegScavenger *RS, const TargetRegisterClass *RC,
|
||||
ARMFunctionInfo *AFI) {
|
||||
unsigned Reg = RS ? RS->FindUnusedReg(RC, true) : (unsigned) ARM::R12;
|
||||
unsigned Reg = RS ? RS->FindUnusedReg(RC) : (unsigned) ARM::R12;
|
||||
assert(!AFI->isThumb1OnlyFunction());
|
||||
if (Reg == 0)
|
||||
// Try a already spilled CS register.
|
||||
Reg = RS->FindUnusedReg(RC, AFI->getSpilledCSRegisters());
|
||||
|
||||
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.
|
||||
// First advance to the instruction just before the start of the chain.
|
||||
AdvanceRS(MBB, MemOps);
|
||||
// Find a scratch register. Make sure it's a call clobbered register or
|
||||
// a spilled callee-saved register.
|
||||
unsigned Scratch = RS->FindUnusedReg(&ARM::GPRRegClass, true);
|
||||
if (!Scratch)
|
||||
Scratch = RS->FindUnusedReg(&ARM::GPRRegClass,
|
||||
AFI->getSpilledCSRegisters());
|
||||
// Find a scratch register.
|
||||
unsigned Scratch = RS->FindUnusedReg(&ARM::GPRRegClass);
|
||||
// Process the load / store instructions.
|
||||
RS->forward(prior(MBBI));
|
||||
|
||||
|
@ -213,7 +213,7 @@ static unsigned findScratchRegister(MachineBasicBlock::iterator II,
|
||||
const TargetRegisterClass *RC,
|
||||
int SPAdj) {
|
||||
assert(RS && "Register scavenging must be on");
|
||||
unsigned Reg = RS->FindUnusedReg(RC, true);
|
||||
unsigned Reg = RS->FindUnusedReg(RC);
|
||||
if (Reg == 0)
|
||||
Reg = RS->scavengeRegister(RC, II, SPAdj);
|
||||
return Reg;
|
||||
|
@ -527,7 +527,7 @@ static
|
||||
unsigned findScratchRegister(MachineBasicBlock::iterator II, RegScavenger *RS,
|
||||
const TargetRegisterClass *RC, int SPAdj) {
|
||||
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
|
||||
// search for already spilled CS register here.
|
||||
if (Reg == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user