mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Use a spilled free callee-saved register as scratch register.
llvm-svn: 34785
This commit is contained in:
parent
0aa68b9246
commit
07dcde8ba2
@ -313,6 +313,7 @@ ARMRegisterInfo::getCalleeSavedRegClasses() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitVector ARMRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
BitVector ARMRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
||||||
|
// FIXME: avoid re-calculating this everytime.
|
||||||
BitVector Reserved(getNumRegs());
|
BitVector Reserved(getNumRegs());
|
||||||
Reserved.set(ARM::SP);
|
Reserved.set(ARM::SP);
|
||||||
Reserved.set(ARM::PC);
|
Reserved.set(ARM::PC);
|
||||||
@ -619,6 +620,20 @@ static void emitThumbConstant(MachineBasicBlock &MBB,
|
|||||||
.addReg(DestReg, false, false, true);
|
.addReg(DestReg, false, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// findScratchRegister - Find a 'free' ARM register. If register scavenger
|
||||||
|
/// is not being used, R12 is available. Otherwise, try for a call-clobbered
|
||||||
|
/// register first and then a spilled callee-saved register if that fails.
|
||||||
|
static
|
||||||
|
unsigned findScratchRegister(RegScavenger *RS, const TargetRegisterClass *RC,
|
||||||
|
ARMFunctionInfo *AFI) {
|
||||||
|
unsigned Reg = RS ? RS->FindUnusedReg(RC, true) : (unsigned) ARM::R12;
|
||||||
|
if (Reg == 0)
|
||||||
|
// Try a already spilled CS register.
|
||||||
|
Reg = RS->FindUnusedReg(RC, AFI->getSpilledCSRegisters());
|
||||||
|
|
||||||
|
return Reg;
|
||||||
|
}
|
||||||
|
|
||||||
void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||||
RegScavenger *RS) const{
|
RegScavenger *RS) const{
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
@ -902,9 +917,8 @@ void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
|||||||
// If the offset we have is too large to fit into the instruction, we need
|
// If the offset we have is too large to fit into the instruction, we need
|
||||||
// to form it with a series of ADDri's. Do this by taking 8-bit chunks
|
// to form it with a series of ADDri's. Do this by taking 8-bit chunks
|
||||||
// out of 'Offset'.
|
// out of 'Offset'.
|
||||||
unsigned ScratchReg = RS
|
unsigned ScratchReg = findScratchRegister(RS, &ARM::GPRRegClass, AFI);
|
||||||
? RS->FindUnusedReg(&ARM::GPRRegClass, true) : (unsigned)ARM::R12;
|
assert(ScratchReg && "Unable to find a free register!");
|
||||||
assert(ScratchReg != 0 && "Unable to find a free call-clobbered register!");
|
|
||||||
emitARMRegPlusImmediate(MBB, II, ScratchReg, FrameReg,
|
emitARMRegPlusImmediate(MBB, II, ScratchReg, FrameReg,
|
||||||
isSub ? -Offset : Offset, TII);
|
isSub ? -Offset : Offset, TII);
|
||||||
MI.getOperand(i).ChangeToRegister(ScratchReg, false, false, true);
|
MI.getOperand(i).ChangeToRegister(ScratchReg, false, false, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user