1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Fix reversed logic in getRegsUsed. Rename RegStates to RegsAvailable to

hopefully forestall similar errors.

llvm-svn: 35362
This commit is contained in:
Dale Johannesen 2007-03-26 22:23:54 +00:00
parent 16700ef424
commit 3ad8ab7b61
2 changed files with 23 additions and 23 deletions

View File

@ -47,10 +47,10 @@ class RegScavenger {
///
const TargetRegisterClass *ScavengedRC;
/// RegStates - The current state of all the physical registers immediately
/// RegsAvailable - The current state of all the physical registers immediately
/// before MBBI. One bit per physical register. If bit is set that means it's
/// available, unset means the register is currently being used.
BitVector RegStates;
BitVector RegsAvailable;
public:
RegScavenger()
@ -88,18 +88,18 @@ public:
/// isUsed / isUsed - Test if a register is currently being used.
///
bool isUsed(unsigned Reg) const { return !RegStates[Reg]; }
bool isUnused(unsigned Reg) const { return RegStates[Reg]; }
bool isUsed(unsigned Reg) const { return !RegsAvailable[Reg]; }
bool isUnused(unsigned Reg) const { return RegsAvailable[Reg]; }
/// getRegsUsed - return all registers currently in use in used.
void getRegsUsed(BitVector &used, bool includeReserved);
/// setUsed / setUnused - Mark the state of one or a number of registers.
///
void setUsed(unsigned Reg) { RegStates.reset(Reg); }
void setUsed(BitVector Regs) { RegStates &= ~Regs; }
void setUnused(unsigned Reg) { RegStates.set(Reg); }
void setUnused(BitVector Regs) { RegStates |= Regs; }
void setUsed(unsigned Reg) { RegsAvailable.reset(Reg); }
void setUsed(BitVector Regs) { RegsAvailable &= ~Regs; }
void setUnused(unsigned Reg) { RegsAvailable.set(Reg); }
void setUnused(BitVector Regs) { RegsAvailable |= Regs; }
/// FindUnusedReg - Find a unused register of the specified register class
/// from the specified set of registers. It return 0 is none is found.

View File

@ -36,7 +36,7 @@ void RegScavenger::enterBasicBlock(MachineBasicBlock *mbb) {
if (!MBB) {
NumPhysRegs = RegInfo->getNumRegs();
RegStates.resize(NumPhysRegs);
RegsAvailable.resize(NumPhysRegs);
// Create reserved registers bitvector.
ReservedRegs = RegInfo->getReservedRegs(MF);
@ -54,10 +54,10 @@ void RegScavenger::enterBasicBlock(MachineBasicBlock *mbb) {
ScavengedRC = NULL;
// All registers started out unused.
RegStates.set();
RegsAvailable.set();
// Reserved registers are always used.
RegStates ^= ReservedRegs;
RegsAvailable ^= ReservedRegs;
// Live-in registers are in use.
if (!MBB->livein_empty())
@ -182,9 +182,9 @@ void RegScavenger::backward() {
void RegScavenger::getRegsUsed(BitVector &used, bool includeReserved) {
if (includeReserved)
used = RegStates;
used = ~RegsAvailable;
else
used = RegStates & ~ReservedRegs;
used = ~RegsAvailable & ~ReservedRegs;
}
/// CreateRegClassMask - Set the bits that represent the registers in the
@ -198,32 +198,32 @@ static void CreateRegClassMask(const TargetRegisterClass *RC, BitVector &Mask) {
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;
BitVector RegsAvailableCopy(NumPhysRegs, false);
CreateRegClassMask(RegClass, RegsAvailableCopy);
RegsAvailableCopy &= RegsAvailable;
// Restrict the search to candidates.
RegStatesCopy &= Candidates;
RegsAvailableCopy &= Candidates;
// Returns the first unused (bit is set) register, or 0 is none is found.
int Reg = RegStatesCopy.find_first();
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 RegStatesCopy(NumPhysRegs, false);
CreateRegClassMask(RegClass, RegStatesCopy);
RegStatesCopy &= RegStates;
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)
RegStatesCopy &= ~CalleeSavedRegs;
RegsAvailableCopy &= ~CalleeSavedRegs;
// Returns the first unused (bit is set) register, or 0 is none is found.
int Reg = RegStatesCopy.find_first();
int Reg = RegsAvailableCopy.find_first();
return (Reg == -1) ? 0 : Reg;
}