forked from OSchip/llvm-project
Add a version of FindUnusedReg that restrict search to a specific set of registers.
llvm-svn: 34784
This commit is contained in:
parent
6f059e3e0a
commit
27bc565497
|
@ -78,6 +78,11 @@ public:
|
|||
void setUnused(unsigned Reg) { RegStates.set(Reg); }
|
||||
void setUnused(BitVector Regs) { RegStates |= Regs; }
|
||||
|
||||
/// 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,
|
||||
|
|
|
@ -156,6 +156,21 @@ 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 RegStatesCopy(NumPhysRegs, false);
|
||||
CreateRegClassMask(RegClass, RegStatesCopy);
|
||||
RegStatesCopy &= RegStates;
|
||||
|
||||
// Restrict the search to candidates.
|
||||
RegStatesCopy &= Candidates;
|
||||
|
||||
// Returns the first unused (bit is set) register, or 0 is none is found.
|
||||
int Reg = RegStatesCopy.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.
|
||||
|
|
Loading…
Reference in New Issue