mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Some simpliciations to the spill/reload interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5067 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8ed9eb5ca3
commit
b167c04e62
@ -126,14 +126,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Moves value from memory into that register
|
/// Moves value from memory into that register
|
||||||
MachineBasicBlock::iterator
|
unsigned reloadVirtReg(MachineBasicBlock &MBB,
|
||||||
moveUseToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
MachineBasicBlock::iterator &I, unsigned VirtReg);
|
||||||
unsigned VirtReg, unsigned &PhysReg);
|
|
||||||
|
|
||||||
/// Saves reg value on the stack (maps virtual register to stack value)
|
/// Saves reg value on the stack (maps virtual register to stack value)
|
||||||
MachineBasicBlock::iterator
|
void spillVirtReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I,
|
||||||
saveVirtRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
unsigned VirtReg, unsigned PhysReg);
|
||||||
unsigned VirtReg, unsigned PhysReg);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -178,35 +176,31 @@ unsigned RegAllocSimple::getFreeReg(unsigned virtualReg) {
|
|||||||
return getFreeReg(virtualReg);
|
return getFreeReg(virtualReg);
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineBasicBlock::iterator
|
unsigned RegAllocSimple::reloadVirtReg(MachineBasicBlock &MBB,
|
||||||
RegAllocSimple::moveUseToReg (MachineBasicBlock &MBB,
|
MachineBasicBlock::iterator &I,
|
||||||
MachineBasicBlock::iterator I,
|
unsigned VirtReg) {
|
||||||
unsigned VirtReg, unsigned &PhysReg)
|
|
||||||
{
|
|
||||||
const TargetRegisterClass* regClass = MF->getRegClass(VirtReg);
|
const TargetRegisterClass* regClass = MF->getRegClass(VirtReg);
|
||||||
unsigned stackOffset = getStackSpaceFor(VirtReg, regClass);
|
unsigned stackOffset = getStackSpaceFor(VirtReg, regClass);
|
||||||
PhysReg = getFreeReg(VirtReg);
|
unsigned PhysReg = getFreeReg(VirtReg);
|
||||||
|
|
||||||
// Add move instruction(s)
|
// Add move instruction(s)
|
||||||
++NumReloaded;
|
++NumReloaded;
|
||||||
return RegInfo->loadRegOffset2Reg(MBB, I, PhysReg,
|
I = RegInfo->loadRegOffset2Reg(MBB, I, PhysReg, RegInfo->getFramePointer(),
|
||||||
RegInfo->getFramePointer(),
|
-stackOffset, regClass->getDataSize());
|
||||||
-stackOffset, regClass->getDataSize());
|
return PhysReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineBasicBlock::iterator
|
void RegAllocSimple::spillVirtReg(MachineBasicBlock &MBB,
|
||||||
RegAllocSimple::saveVirtRegToStack (MachineBasicBlock &MBB,
|
MachineBasicBlock::iterator &I,
|
||||||
MachineBasicBlock::iterator I,
|
unsigned VirtReg, unsigned PhysReg)
|
||||||
unsigned VirtReg, unsigned PhysReg)
|
|
||||||
{
|
{
|
||||||
const TargetRegisterClass* regClass = MF->getRegClass(VirtReg);
|
const TargetRegisterClass* regClass = MF->getRegClass(VirtReg);
|
||||||
unsigned stackOffset = getStackSpaceFor(VirtReg, regClass);
|
unsigned stackOffset = getStackSpaceFor(VirtReg, regClass);
|
||||||
|
|
||||||
// Add move instruction(s)
|
// Add move instruction(s)
|
||||||
++NumSpilled;
|
++NumSpilled;
|
||||||
return RegInfo->storeReg2RegOffset(MBB, I, PhysReg,
|
I = RegInfo->storeReg2RegOffset(MBB, I, PhysReg, RegInfo->getFramePointer(),
|
||||||
RegInfo->getFramePointer(),
|
-stackOffset, regClass->getDataSize());
|
||||||
-stackOffset, regClass->getDataSize());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -322,11 +316,13 @@ void RegAllocSimple::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
} else {
|
} else {
|
||||||
physReg = getFreeReg(virtualReg);
|
physReg = getFreeReg(virtualReg);
|
||||||
}
|
}
|
||||||
I = --saveVirtRegToStack(MBB, ++I, virtualReg, physReg);
|
++I;
|
||||||
|
spillVirtReg(MBB, I, virtualReg, physReg);
|
||||||
|
--I;
|
||||||
} else {
|
} else {
|
||||||
I = moveUseToReg(MBB, I, virtualReg, physReg);
|
physReg = reloadVirtReg(MBB, I, virtualReg);
|
||||||
|
Virt2PhysRegMap[virtualReg] = physReg;
|
||||||
}
|
}
|
||||||
Virt2PhysRegMap[virtualReg] = physReg;
|
|
||||||
}
|
}
|
||||||
MI->SetMachineOperandReg(i, physReg);
|
MI->SetMachineOperandReg(i, physReg);
|
||||||
DEBUG(std::cerr << "virt: " << virtualReg <<
|
DEBUG(std::cerr << "virt: " << virtualReg <<
|
||||||
|
Loading…
x
Reference in New Issue
Block a user