mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-26 02:22:29 +00:00
Fixed a bug where moves due to phis were being neglected.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5019 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -253,7 +253,7 @@ bool RegAllocSimple::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
if (targetReg.isVirtualRegister()) {
|
if (targetReg.isVirtualRegister()) {
|
||||||
physReg = getFreeReg(virtualReg);
|
physReg = getFreeReg(virtualReg);
|
||||||
} else {
|
} else {
|
||||||
physReg = targetReg.getAllocatedRegNum();
|
physReg = virtualReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the register class of the target register: should be the
|
// Find the register class of the target register: should be the
|
||||||
@@ -293,29 +293,25 @@ bool RegAllocSimple::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
++opI;
|
++opI;
|
||||||
|
|
||||||
|
|
||||||
// insert the move just before the return/branch
|
// Retrieve the constant value from this op, move it to target
|
||||||
if (MII.isReturn(opMI->getOpcode()) || MII.isBranch(opMI->getOpcode()))
|
// register of the phi
|
||||||
|
if (opVal.getType() == MachineOperand::MO_SignExtendedImmed ||
|
||||||
|
opVal.getType() == MachineOperand::MO_UnextendedImmed)
|
||||||
{
|
{
|
||||||
// Retrieve the constant value from this op, move it to target
|
opI = RegInfo->moveImm2Reg(opBlock, opI, physReg,
|
||||||
// register of the phi
|
(unsigned) opVal.getImmedValue(),
|
||||||
if (opVal.getType() == MachineOperand::MO_SignExtendedImmed ||
|
dataSize);
|
||||||
opVal.getType() == MachineOperand::MO_UnextendedImmed)
|
saveVirtRegToStack(opBlock, opI, virtualReg, physReg);
|
||||||
{
|
} else {
|
||||||
opI = RegInfo->moveImm2Reg(opBlock, opI, physReg,
|
// Allocate a physical register and add a move in the BB
|
||||||
(unsigned) opVal.getImmedValue(),
|
unsigned opVirtualReg = (unsigned) opVal.getAllocatedRegNum();
|
||||||
dataSize);
|
unsigned opPhysReg; // = getFreeReg(opVirtualReg);
|
||||||
saveVirtRegToStack(opBlock, opI, virtualReg, physReg);
|
opI = moveUseToReg(opBlock, opI, opVirtualReg, physReg);
|
||||||
} else {
|
//opI = RegInfo->moveReg2Reg(opBlock, opI, physReg, opPhysReg,
|
||||||
// Allocate a physical register and add a move in the BB
|
// dataSize);
|
||||||
unsigned opVirtualReg = (unsigned) opVal.getAllocatedRegNum();
|
// Save that register value to the stack of the TARGET REG
|
||||||
unsigned opPhysReg; // = getFreeReg(opVirtualReg);
|
saveVirtRegToStack(opBlock, opI, virtualReg, physReg);
|
||||||
opI = moveUseToReg(opBlock, opI, opVirtualReg, opPhysReg);
|
}
|
||||||
opI = RegInfo->moveReg2Reg(opBlock, opI, physReg, opPhysReg,
|
|
||||||
dataSize);
|
|
||||||
// Save that register value to the stack of the TARGET REG
|
|
||||||
saveVirtRegToStack(opBlock, opI, virtualReg, opPhysReg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// make regs available to other instructions
|
// make regs available to other instructions
|
||||||
clearAllRegs();
|
clearAllRegs();
|
||||||
|
|||||||
Reference in New Issue
Block a user