mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
Register allocator is responsible for spilling callee saved regs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5092 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5b9cd61946
commit
6c6cf873f3
@ -117,14 +117,6 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF,
|
|||||||
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
|
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
|
||||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
|
|
||||||
// PUSH all callee-save registers
|
|
||||||
const unsigned* regs = getCalleeSaveRegs();
|
|
||||||
while (*regs) {
|
|
||||||
MachineInstr *MI = BuildMI(X86::PUSHr32, 1).addReg(*regs);
|
|
||||||
MBBI = ++MBB.insert(MBBI, MI);
|
|
||||||
++regs;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUSH ebp
|
// PUSH ebp
|
||||||
MachineInstr *MI = BuildMI(X86::PUSHr32, 1).addReg(X86::EBP);
|
MachineInstr *MI = BuildMI(X86::PUSHr32, 1).addReg(X86::EBP);
|
||||||
MBBI = ++MBB.insert(MBBI, MI);
|
MBBI = ++MBB.insert(MBBI, MI);
|
||||||
@ -144,15 +136,7 @@ void X86RegisterInfo::emitEpilogue(MachineBasicBlock &MBB,
|
|||||||
assert((*MBBI)->getOpcode() == X86::RET &&
|
assert((*MBBI)->getOpcode() == X86::RET &&
|
||||||
"Can only insert epilog into returning blocks");
|
"Can only insert epilog into returning blocks");
|
||||||
|
|
||||||
// insert LEAVE
|
// insert LEAVE: mov ESP, EBP; pop EBP
|
||||||
MBBI = ++MBB.insert(MBBI, BuildMI(X86::LEAVE, 0));
|
MBBI = ++MBB.insert(MBBI, BuildMI(X86::MOVrr32, 1,X86::ESP).addReg(X86::EBP));
|
||||||
|
MBBI = ++MBB.insert(MBBI, BuildMI(X86::POPr32, 1).addReg(X86::EBP));
|
||||||
// POP all callee-save registers in REVERSE ORDER
|
|
||||||
static const unsigned regs[] = { X86::EBX, X86::EDI, X86::ESI,
|
|
||||||
MRegisterInfo::NoRegister };
|
|
||||||
unsigned idx = 0;
|
|
||||||
while (regs[idx]) {
|
|
||||||
MachineInstr *MI = BuildMI(X86::POPr32, 0, regs[idx++]);
|
|
||||||
MBBI = ++(MBB.insert(MBBI, MI));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user