mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
Clean up scavengeRegister() a bit to prefer available regs, which allows
the simplification of frame index register scavenging to not have to check for available registers directly and instead just let scavengeRegister() handle it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -885,21 +885,7 @@ void PEI::scavengeFrameVirtualRegs(MachineFunction &Fn) {
|
|||||||
// Scavenge a new scratch register
|
// Scavenge a new scratch register
|
||||||
CurrentVirtReg = Reg;
|
CurrentVirtReg = Reg;
|
||||||
const TargetRegisterClass *RC = Fn.getRegInfo().getRegClass(Reg);
|
const TargetRegisterClass *RC = Fn.getRegInfo().getRegClass(Reg);
|
||||||
const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo();
|
CurrentScratchReg = RS->scavengeRegister(RC, I, SPAdj);
|
||||||
BitVector Candidates(TRI->getNumRegs());
|
|
||||||
RS->getRegsAvailable(RC, Candidates);
|
|
||||||
|
|
||||||
// If there are any registers available, use the one that's
|
|
||||||
// unused for the longest after this instruction. That increases
|
|
||||||
// the ability to reuse the value.
|
|
||||||
if (Candidates.any()) {
|
|
||||||
MachineBasicBlock::iterator UMI;
|
|
||||||
CurrentScratchReg = RS->findSurvivorReg(I, Candidates, 25, UMI);
|
|
||||||
} else {
|
|
||||||
// No register is "free". Scavenge a register.
|
|
||||||
CurrentScratchReg = RS->scavengeRegister(RC, I, SPAdj);
|
|
||||||
}
|
|
||||||
|
|
||||||
PrevValue = Value;
|
PrevValue = Value;
|
||||||
}
|
}
|
||||||
// replace this reference to the virtual register with the
|
// replace this reference to the virtual register with the
|
||||||
|
@@ -339,13 +339,16 @@ unsigned RegScavenger::scavengeRegister(const TargetRegisterClass *RC,
|
|||||||
Candidates.reset(MO.getReg());
|
Candidates.reset(MO.getReg());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to find a register that's unused if there is one, as then we won't
|
||||||
|
// have to spill.
|
||||||
|
if ((Candidates & RegsAvailable).any())
|
||||||
|
Candidates &= RegsAvailable;
|
||||||
|
|
||||||
// Find the register whose use is furthest away.
|
// Find the register whose use is furthest away.
|
||||||
MachineBasicBlock::iterator UseMI;
|
MachineBasicBlock::iterator UseMI;
|
||||||
unsigned SReg = findSurvivorReg(I, Candidates, 25, UseMI);
|
unsigned SReg = findSurvivorReg(I, Candidates, 25, UseMI);
|
||||||
|
|
||||||
// If we found an unused register there is no reason to spill it. We have
|
// If we found an unused register there is no reason to spill it.
|
||||||
// probably found a callee-saved register that has been saved in the
|
|
||||||
// prologue, but happens to be unused at this point.
|
|
||||||
if (!isAliasUsed(SReg))
|
if (!isAliasUsed(SReg))
|
||||||
return SReg;
|
return SReg;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user