forked from OSchip/llvm-project
Some simpliciations to the spill/reload interface
llvm-svn: 5067
This commit is contained in:
parent
4e560ee65b
commit
bc1e6700eb
|
@ -126,13 +126,11 @@ namespace {
|
|||
}
|
||||
|
||||
/// Moves value from memory into that register
|
||||
MachineBasicBlock::iterator
|
||||
moveUseToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
||||
unsigned VirtReg, unsigned &PhysReg);
|
||||
unsigned reloadVirtReg(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator &I, unsigned VirtReg);
|
||||
|
||||
/// Saves reg value on the stack (maps virtual register to stack value)
|
||||
MachineBasicBlock::iterator
|
||||
saveVirtRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
||||
void spillVirtReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I,
|
||||
unsigned VirtReg, unsigned PhysReg);
|
||||
};
|
||||
|
||||
|
@ -178,25 +176,22 @@ unsigned RegAllocSimple::getFreeReg(unsigned virtualReg) {
|
|||
return getFreeReg(virtualReg);
|
||||
}
|
||||
|
||||
MachineBasicBlock::iterator
|
||||
RegAllocSimple::moveUseToReg (MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I,
|
||||
unsigned VirtReg, unsigned &PhysReg)
|
||||
{
|
||||
unsigned RegAllocSimple::reloadVirtReg(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator &I,
|
||||
unsigned VirtReg) {
|
||||
const TargetRegisterClass* regClass = MF->getRegClass(VirtReg);
|
||||
unsigned stackOffset = getStackSpaceFor(VirtReg, regClass);
|
||||
PhysReg = getFreeReg(VirtReg);
|
||||
unsigned PhysReg = getFreeReg(VirtReg);
|
||||
|
||||
// Add move instruction(s)
|
||||
++NumReloaded;
|
||||
return RegInfo->loadRegOffset2Reg(MBB, I, PhysReg,
|
||||
RegInfo->getFramePointer(),
|
||||
I = RegInfo->loadRegOffset2Reg(MBB, I, PhysReg, RegInfo->getFramePointer(),
|
||||
-stackOffset, regClass->getDataSize());
|
||||
return PhysReg;
|
||||
}
|
||||
|
||||
MachineBasicBlock::iterator
|
||||
RegAllocSimple::saveVirtRegToStack (MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I,
|
||||
void RegAllocSimple::spillVirtReg(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator &I,
|
||||
unsigned VirtReg, unsigned PhysReg)
|
||||
{
|
||||
const TargetRegisterClass* regClass = MF->getRegClass(VirtReg);
|
||||
|
@ -204,8 +199,7 @@ RegAllocSimple::saveVirtRegToStack (MachineBasicBlock &MBB,
|
|||
|
||||
// Add move instruction(s)
|
||||
++NumSpilled;
|
||||
return RegInfo->storeReg2RegOffset(MBB, I, PhysReg,
|
||||
RegInfo->getFramePointer(),
|
||||
I = RegInfo->storeReg2RegOffset(MBB, I, PhysReg, RegInfo->getFramePointer(),
|
||||
-stackOffset, regClass->getDataSize());
|
||||
}
|
||||
|
||||
|
@ -322,12 +316,14 @@ void RegAllocSimple::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||
} else {
|
||||
physReg = getFreeReg(virtualReg);
|
||||
}
|
||||
I = --saveVirtRegToStack(MBB, ++I, virtualReg, physReg);
|
||||
++I;
|
||||
spillVirtReg(MBB, I, virtualReg, physReg);
|
||||
--I;
|
||||
} else {
|
||||
I = moveUseToReg(MBB, I, virtualReg, physReg);
|
||||
}
|
||||
physReg = reloadVirtReg(MBB, I, virtualReg);
|
||||
Virt2PhysRegMap[virtualReg] = physReg;
|
||||
}
|
||||
}
|
||||
MI->SetMachineOperandReg(i, physReg);
|
||||
DEBUG(std::cerr << "virt: " << virtualReg <<
|
||||
", phys: " << op.getAllocatedRegNum() << "\n");
|
||||
|
|
Loading…
Reference in New Issue