mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Make the following changes in MipsFrameLowering.cpp:
- Stop emitting instructions needed to initialize the global pointer register. - Stop emitting .cprestore directive. - Do not take into account the $gp save slot when computing stack size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156691 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -136,7 +136,6 @@ void MipsFrameLowering::emitPrologue(MachineFunction &MF) const {
|
|||||||
*static_cast<const MipsInstrInfo*>(MF.getTarget().getInstrInfo());
|
*static_cast<const MipsInstrInfo*>(MF.getTarget().getInstrInfo());
|
||||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
|
DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
|
||||||
bool isPIC = (MF.getTarget().getRelocationModel() == Reloc::PIC_);
|
|
||||||
unsigned SP = STI.isABI_N64() ? Mips::SP_64 : Mips::SP;
|
unsigned SP = STI.isABI_N64() ? Mips::SP_64 : Mips::SP;
|
||||||
unsigned FP = STI.isABI_N64() ? Mips::FP_64 : Mips::FP;
|
unsigned FP = STI.isABI_N64() ? Mips::FP_64 : Mips::FP;
|
||||||
unsigned ZERO = STI.isABI_N64() ? Mips::ZERO_64 : Mips::ZERO;
|
unsigned ZERO = STI.isABI_N64() ? Mips::ZERO_64 : Mips::ZERO;
|
||||||
@@ -144,35 +143,14 @@ void MipsFrameLowering::emitPrologue(MachineFunction &MF) const {
|
|||||||
unsigned ADDiu = STI.isABI_N64() ? Mips::DADDiu : Mips::ADDiu;
|
unsigned ADDiu = STI.isABI_N64() ? Mips::DADDiu : Mips::ADDiu;
|
||||||
|
|
||||||
// First, compute final stack size.
|
// First, compute final stack size.
|
||||||
unsigned RegSize = STI.isGP32bit() ? 4 : 8;
|
|
||||||
unsigned StackAlign = getStackAlignment();
|
unsigned StackAlign = getStackAlignment();
|
||||||
unsigned LocalVarAreaOffset = MipsFI->needGPSaveRestore() ?
|
uint64_t StackSize =
|
||||||
(MFI->getObjectOffset(MipsFI->getGPFI()) + RegSize) :
|
RoundUpToAlignment(MipsFI->getMaxCallFrameSize(), StackAlign) +
|
||||||
MipsFI->getMaxCallFrameSize();
|
|
||||||
uint64_t StackSize = RoundUpToAlignment(LocalVarAreaOffset, StackAlign) +
|
|
||||||
RoundUpToAlignment(MFI->getStackSize(), StackAlign);
|
RoundUpToAlignment(MFI->getStackSize(), StackAlign);
|
||||||
|
|
||||||
// Update stack size
|
// Update stack size
|
||||||
MFI->setStackSize(StackSize);
|
MFI->setStackSize(StackSize);
|
||||||
|
|
||||||
// Emit instructions that set the global base register if the target ABI is
|
|
||||||
// O32.
|
|
||||||
if (isPIC && MipsFI->globalBaseRegSet() && STI.isABI_O32() &&
|
|
||||||
!MipsFI->globalBaseRegFixed()) {
|
|
||||||
// See MipsInstrInfo.td for explanation.
|
|
||||||
MachineBasicBlock *NewEntry = MF.CreateMachineBasicBlock();
|
|
||||||
MF.insert(&MBB, NewEntry);
|
|
||||||
NewEntry->addSuccessor(&MBB);
|
|
||||||
|
|
||||||
// Copy live in registers.
|
|
||||||
for (MachineBasicBlock::livein_iterator R = MBB.livein_begin();
|
|
||||||
R != MBB.livein_end(); ++R)
|
|
||||||
NewEntry->addLiveIn(*R);
|
|
||||||
|
|
||||||
BuildMI(*NewEntry, NewEntry->begin(), dl, TII.get(Mips:: SETGP01),
|
|
||||||
Mips::V0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No need to allocate space on the stack.
|
// No need to allocate space on the stack.
|
||||||
if (StackSize == 0 && !MFI->adjustsStack()) return;
|
if (StackSize == 0 && !MFI->adjustsStack()) return;
|
||||||
|
|
||||||
@@ -251,13 +229,6 @@ void MipsFrameLowering::emitPrologue(MachineFunction &MF) const {
|
|||||||
SrcML = MachineLocation(MachineLocation::VirtualFP);
|
SrcML = MachineLocation(MachineLocation::VirtualFP);
|
||||||
Moves.push_back(MachineMove(SetFPLabel, DstML, SrcML));
|
Moves.push_back(MachineMove(SetFPLabel, DstML, SrcML));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore GP from the saved stack location
|
|
||||||
if (MipsFI->needGPSaveRestore()) {
|
|
||||||
unsigned Offset = MFI->getObjectOffset(MipsFI->getGPFI());
|
|
||||||
BuildMI(MBB, MBBI, dl, TII.get(Mips::CPRESTORE)).addImm(Offset)
|
|
||||||
.addReg(Mips::GP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MipsFrameLowering::emitEpilogue(MachineFunction &MF,
|
void MipsFrameLowering::emitEpilogue(MachineFunction &MF,
|
||||||
|
Reference in New Issue
Block a user