mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
In thumb mode, round up stack frame size to multiple of 4 since add/sub
sp, imm instructions implicitly multiply the offset by 4. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33653 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5b91c7f69a
commit
236f677e48
@ -884,11 +884,22 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
||||
unsigned NumBytes = MFI->getStackSize();
|
||||
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
||||
|
||||
if (isThumb) {
|
||||
// Thumb add/sub sp, imm8 instructions implicitly multiply the offset by 4.
|
||||
NumBytes = (NumBytes + 3) & ~3;
|
||||
MFI->setStackSize(NumBytes);
|
||||
}
|
||||
|
||||
// Determine the sizes of each callee-save spill areas and record which frame
|
||||
// belongs to which callee-save spill areas.
|
||||
unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0;
|
||||
int FramePtrSpillFI = 0;
|
||||
if (AFI->hasStackFrame()) {
|
||||
if (!AFI->hasStackFrame()) {
|
||||
if (NumBytes != 0)
|
||||
emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
|
||||
return;
|
||||
}
|
||||
|
||||
if (VARegSaveSize)
|
||||
emitSPUpdate(MBB, MBBI, -VARegSaveSize, isThumb, TII);
|
||||
|
||||
@ -950,10 +961,8 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
||||
movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 2, STI);
|
||||
emitSPUpdate(MBB, MBBI, -DPRCSSize, false, TII);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine starting offsets of spill areas.
|
||||
if (AFI->hasStackFrame()) {
|
||||
unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize);
|
||||
unsigned GPRCS2Offset = DPRCSOffset + DPRCSSize;
|
||||
unsigned GPRCS1Offset = GPRCS2Offset + GPRCS2Size;
|
||||
@ -969,8 +978,6 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
||||
movePastCSLoadStoreOps(MBB, MBBI, ARM::FSTD, 3, STI);
|
||||
emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
|
||||
}
|
||||
} else
|
||||
emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
|
||||
|
||||
AFI->setGPRCalleeSavedArea1Size(GPRCS1Size);
|
||||
AFI->setGPRCalleeSavedArea2Size(GPRCS2Size);
|
||||
@ -1005,7 +1012,12 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
|
||||
bool isThumb = AFI->isThumbFunction();
|
||||
unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize();
|
||||
int NumBytes = (int)MFI->getStackSize();
|
||||
if (AFI->hasStackFrame()) {
|
||||
if (!AFI->hasStackFrame()) {
|
||||
if (NumBytes != 0)
|
||||
emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII);
|
||||
return;
|
||||
}
|
||||
|
||||
// Unwind MBBI to point to first LDR / FLDD.
|
||||
const unsigned *CSRegs = getCalleeSavedRegs();
|
||||
if (MBBI != MBB.begin()) {
|
||||
@ -1054,9 +1066,6 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
|
||||
|
||||
if (VARegSaveSize)
|
||||
emitSPUpdate(MBB, MBBI, VARegSaveSize, isThumb, TII);
|
||||
} else if (NumBytes != 0) {
|
||||
emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned ARMRegisterInfo::getRARegister() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user