* Temporarily suspend LR save/restore optimization as it is not quite correct

* Implement large fixed-size allocas            Entire patch by Nate Begeman.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15345 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman 2004-07-30 15:50:45 +00:00
parent b714fdccdb
commit 4ffddc5228

View File

@ -196,7 +196,7 @@ void PowerPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
unsigned NumBytes = MFI->getStackSize(); unsigned NumBytes = MFI->getStackSize();
// If we have calls, save the LR value on the stack // If we have calls, save the LR value on the stack
if (MFI->hasCalls()) { if (MFI->hasCalls() || true) {
// When we have no frame pointer, we reserve argument space for call sites // When we have no frame pointer, we reserve argument space for call sites
// in the function immediately on entry to the current function. This // in the function immediately on entry to the current function. This
// eliminates the need for add/sub brackets around call sites. // eliminates the need for add/sub brackets around call sites.
@ -254,25 +254,35 @@ void PowerPCRegisterInfo::emitEpilogue(MachineFunction &MF,
// Get the number of bytes allocated from the FrameInfo... // Get the number of bytes allocated from the FrameInfo...
unsigned NumBytes = MFI->getStackSize(); unsigned NumBytes = MFI->getStackSize();
// If we have calls, restore the LR value before we branch to it if (NumBytes == 0 && (MFI->hasCalls() || true)) {
if (MFI->hasCalls()) { // Don't need to adjust the stack pointer, just gotta fix up the LR
// Restore LR
MI = BuildMI(PPC32::LWZ, 2,PPC32::R0).addSImm(NumBytes+8).addReg(PPC32::R1); MI = BuildMI(PPC32::LWZ, 2,PPC32::R0).addSImm(NumBytes+8).addReg(PPC32::R1);
MBB.insert(MBBI, MI); MBB.insert(MBBI, MI);
MI = BuildMI(PPC32::MTLR, 1).addReg(PPC32::R0); MI = BuildMI(PPC32::MTLR, 1).addReg(PPC32::R0);
MBB.insert(MBBI, MI); MBB.insert(MBBI, MI);
} } else if (NumBytes <= 32767-8) {
// We're within range to load the return address and restore the stack
// Do we need to adjust the stack pointer back? // pointer with immediate offsets only.
if (NumBytes == 0) return; if (MFI->hasCalls() || true) {
MI = BuildMI(PPC32::LWZ,2,PPC32::R0).addSImm(NumBytes+8).addReg(PPC32::R1);
// Adjust stack pointer back MBB.insert(MBBI, MI);
if (NumBytes <= 32767) { MI = BuildMI(PPC32::MTLR, 1).addReg(PPC32::R0);
MBB.insert(MBBI, MI);
}
MI = BuildMI(PPC32::ADDI, 2, PPC32::R1).addReg(PPC32::R1).addSImm(NumBytes); MI = BuildMI(PPC32::ADDI, 2, PPC32::R1).addReg(PPC32::R1).addSImm(NumBytes);
MBB.insert(MBBI, MI); MBB.insert(MBBI, MI);
} else { } else {
MI = BuildMI(PPC32::LWZ, 2, PPC32::R1).addSImm(0).addReg(PPC32::R1); MI = BuildMI(PPC32::LWZ, 2, PPC32::R1).addSImm(0).addReg(PPC32::R1);
MBB.insert(MBBI, MI); MBB.insert(MBBI, MI);
// We're not within range to load the return address with an immediate
// offset before restoring the stack pointer, so do it after from its spot
// in the linkage area.
if (MFI->hasCalls() || true) {
MI = BuildMI(PPC32::LWZ, 2, PPC32::R0).addSImm(8).addReg(PPC32::R1);
MBB.insert(MBBI, MI);
MI = BuildMI(PPC32::MTLR, 1).addReg(PPC32::R0);
MBB.insert(MBBI, MI);
}
} }
} }