mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Transfer regmasks to MRI.
MRI keeps track of which physregs have been used. Make sure it gets updated with all the regmask-clobbered registers. Delete the closePhysRegsUsed() function which isn't necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150830 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dbe266be35
commit
d9f0ff56a1
@ -56,8 +56,13 @@ class MachineRegisterInfo {
|
||||
/// register allocation (though most don't modify this). This is used
|
||||
/// so that the code generator knows which callee save registers to save and
|
||||
/// for other target specific uses.
|
||||
/// This vector only has bits set for registers explicitly used, not their
|
||||
/// aliases.
|
||||
BitVector UsedPhysRegs;
|
||||
|
||||
/// UsedPhysRegMask - Additional used physregs, but including aliases.
|
||||
BitVector UsedPhysRegMask;
|
||||
|
||||
/// ReservedRegs - This is a bit vector of reserved registers. The target
|
||||
/// may change its mind about which registers should be reserved. This
|
||||
/// vector is the frozen set of reserved registers when register allocation
|
||||
@ -296,32 +301,41 @@ public:
|
||||
|
||||
/// isPhysRegUsed - Return true if the specified register is used in this
|
||||
/// function. This only works after register allocation.
|
||||
bool isPhysRegUsed(unsigned Reg) const { return UsedPhysRegs[Reg]; }
|
||||
bool isPhysRegUsed(unsigned Reg) const {
|
||||
return UsedPhysRegs.test(Reg) || UsedPhysRegMask.test(Reg);
|
||||
}
|
||||
|
||||
/// isPhysRegOrOverlapUsed - Return true if Reg or any overlapping register
|
||||
/// is used in this function.
|
||||
bool isPhysRegOrOverlapUsed(unsigned Reg) const {
|
||||
if (UsedPhysRegMask.test(Reg))
|
||||
return true;
|
||||
for (const unsigned *AI = TRI->getOverlaps(Reg); *AI; ++AI)
|
||||
if (isPhysRegUsed(*AI))
|
||||
if (UsedPhysRegs.test(*AI))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// setPhysRegUsed - Mark the specified register used in this function.
|
||||
/// This should only be called during and after register allocation.
|
||||
void setPhysRegUsed(unsigned Reg) { UsedPhysRegs[Reg] = true; }
|
||||
void setPhysRegUsed(unsigned Reg) { UsedPhysRegs.set(Reg); }
|
||||
|
||||
/// addPhysRegsUsed - Mark the specified registers used in this function.
|
||||
/// This should only be called during and after register allocation.
|
||||
void addPhysRegsUsed(const BitVector &Regs) { UsedPhysRegs |= Regs; }
|
||||
|
||||
/// addPhysRegsUsedFromRegMask - Mark any registers not in RegMask as used.
|
||||
/// This corresponds to the bit mask attached to register mask operands.
|
||||
void addPhysRegsUsedFromRegMask(const uint32_t *RegMask) {
|
||||
UsedPhysRegMask.setBitsNotInMask(RegMask);
|
||||
}
|
||||
|
||||
/// setPhysRegUnused - Mark the specified register unused in this function.
|
||||
/// This should only be called during and after register allocation.
|
||||
void setPhysRegUnused(unsigned Reg) { UsedPhysRegs[Reg] = false; }
|
||||
|
||||
/// closePhysRegsUsed - Expand UsedPhysRegs to its transitive closure over
|
||||
/// subregisters. That means that if R is used, so are all subregisters.
|
||||
void closePhysRegsUsed(const TargetRegisterInfo&);
|
||||
void setPhysRegUnused(unsigned Reg) {
|
||||
UsedPhysRegs.reset(Reg);
|
||||
UsedPhysRegMask.reset(Reg);
|
||||
}
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -22,7 +22,8 @@ MachineRegisterInfo::MachineRegisterInfo(const TargetRegisterInfo &TRI)
|
||||
VRegInfo.reserve(256);
|
||||
RegAllocHints.reserve(256);
|
||||
UsedPhysRegs.resize(TRI.getNumRegs());
|
||||
|
||||
UsedPhysRegMask.resize(TRI.getNumRegs());
|
||||
|
||||
// Create the physreg use/def lists.
|
||||
PhysRegUseDefLists = new MachineOperand*[TRI.getNumRegs()];
|
||||
memset(PhysRegUseDefLists, 0, sizeof(MachineOperand*)*TRI.getNumRegs());
|
||||
@ -244,15 +245,6 @@ MachineRegisterInfo::EmitLiveInCopies(MachineBasicBlock *EntryMBB,
|
||||
}
|
||||
}
|
||||
|
||||
void MachineRegisterInfo::closePhysRegsUsed(const TargetRegisterInfo &TRI) {
|
||||
for (int i = UsedPhysRegs.find_first(); i >= 0;
|
||||
i = UsedPhysRegs.find_next(i))
|
||||
for (const unsigned *SS = TRI.getSubRegisters(i);
|
||||
unsigned SubReg = *SS; ++SS)
|
||||
if (SubReg > unsigned(i))
|
||||
UsedPhysRegs.set(SubReg);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void MachineRegisterInfo::dumpUses(unsigned Reg) const {
|
||||
for (use_iterator I = use_begin(Reg), E = use_end(); I != E; ++I)
|
||||
|
@ -1097,9 +1097,6 @@ bool RAFast::runOnMachineFunction(MachineFunction &Fn) {
|
||||
AllocateBasicBlock();
|
||||
}
|
||||
|
||||
// Make sure the set of used physregs is closed under subreg operations.
|
||||
MRI->closePhysRegsUsed(*TRI);
|
||||
|
||||
// Add the clobber lists for all the instructions we skipped earlier.
|
||||
for (SmallPtrSet<const MCInstrDesc*, 4>::const_iterator
|
||||
I = SkippedInstrs.begin(), E = SkippedInstrs.end(); I != E; ++I)
|
||||
|
@ -127,6 +127,11 @@ void VirtRegMap::rewrite(SlotIndexes *Indexes) {
|
||||
for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
|
||||
MOE = MI->operands_end(); MOI != MOE; ++MOI) {
|
||||
MachineOperand &MO = *MOI;
|
||||
|
||||
// Make sure MRI knows about registers clobbered by regmasks.
|
||||
if (MO.isRegMask())
|
||||
MRI->addPhysRegsUsedFromRegMask(MO.getRegMask());
|
||||
|
||||
if (!MO.isReg() || !TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||
continue;
|
||||
unsigned VirtReg = MO.getReg();
|
||||
|
Loading…
Reference in New Issue
Block a user