If stack realignment is used - incoming args will use EBP as base register and locals - ESP

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50162 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2008-04-23 18:21:02 +00:00
parent b51dce3013
commit 8e91ec5e29

View File

@ -281,16 +281,28 @@ bool X86RegisterInfo::hasReservedCallFrame(MachineFunction &MF) const {
int int
X86RegisterInfo::getFrameIndexOffset(MachineFunction &MF, int FI) const { X86RegisterInfo::getFrameIndexOffset(MachineFunction &MF, int FI) const {
int Offset = MF.getFrameInfo()->getObjectOffset(FI) + SlotSize; int Offset = MF.getFrameInfo()->getObjectOffset(FI) + SlotSize;
if (!hasFP(MF))
return Offset + MF.getFrameInfo()->getStackSize();
// Skip the saved EBP if (needsStackRealignment(MF)) {
Offset += SlotSize; if (FI < 0)
// Skip the saved EBP
Offset += SlotSize;
else
return Offset + MF.getFrameInfo()->getStackSize();
// FIXME: Support tail calls
} else {
if (!hasFP(MF))
return Offset + MF.getFrameInfo()->getStackSize();
// Skip the saved EBP
Offset += SlotSize;
// Skip the RETADDR move area
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
if (TailCallReturnAddrDelta < 0) Offset -= TailCallReturnAddrDelta;
}
// Skip the RETADDR move area
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
if (TailCallReturnAddrDelta < 0) Offset -= TailCallReturnAddrDelta;
return Offset; return Offset;
} }
@ -360,9 +372,16 @@ void X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
} }
int FrameIndex = MI.getOperand(i).getIndex(); int FrameIndex = MI.getOperand(i).getIndex();
unsigned BasePtr;
if (needsStackRealignment(MF))
BasePtr = (FrameIndex < 0 ? FramePtr : StackPtr);
else
BasePtr = (hasFP(MF) ? FramePtr : StackPtr);
// This must be part of a four operand memory reference. Replace the // This must be part of a four operand memory reference. Replace the
// FrameIndex with base register with EBP. Add an offset to the offset. // FrameIndex with base register with EBP. Add an offset to the offset.
MI.getOperand(i).ChangeToRegister(hasFP(MF) ? FramePtr : StackPtr, false); MI.getOperand(i).ChangeToRegister(BasePtr, false);
// Now add the frame object offset to the offset from EBP. // Now add the frame object offset to the offset from EBP.
int64_t Offset = getFrameIndexOffset(MF, FrameIndex) + int64_t Offset = getFrameIndexOffset(MF, FrameIndex) +