mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
PPCFrameLowering's FramePointerOffset can be computed at initialization
time. Do so. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228998 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
82eeeb5b94
commit
2b4e1b9abf
@ -47,11 +47,25 @@ static unsigned computeTOCSaveOffset(const PPCSubtarget &STI) {
|
||||
return STI.isELFv2ABI() ? 24 : 40;
|
||||
}
|
||||
|
||||
static unsigned computeFramePointerSaveOffset(const PPCSubtarget &STI) {
|
||||
// For the Darwin ABI:
|
||||
// We cannot use the TOC save slot (offset +20) in the PowerPC linkage area
|
||||
// for saving the frame pointer (if needed.) While the published ABI has
|
||||
// not used this slot since at least MacOSX 10.2, there is older code
|
||||
// around that does use it, and that needs to continue to work.
|
||||
if (STI.isDarwinABI())
|
||||
return STI.isPPC64() ? -8U : -4U;
|
||||
|
||||
// SVR4 ABI: First slot in the general register save area.
|
||||
return STI.isPPC64() ? -8U : -4U;
|
||||
}
|
||||
|
||||
PPCFrameLowering::PPCFrameLowering(const PPCSubtarget &STI)
|
||||
: TargetFrameLowering(TargetFrameLowering::StackGrowsDown,
|
||||
(STI.hasQPX() || STI.isBGQ()) ? 32 : 16, 0),
|
||||
Subtarget(STI), ReturnSaveOffset(computeReturnSaveOffset(Subtarget)),
|
||||
TOCSaveOffset(computeTOCSaveOffset(Subtarget)) {}
|
||||
TOCSaveOffset(computeTOCSaveOffset(Subtarget)),
|
||||
FramePointerSaveOffset(computeFramePointerSaveOffset(Subtarget)) {}
|
||||
|
||||
// With the SVR4 ABI, callee-saved registers have fixed offsets on the stack.
|
||||
const PPCFrameLowering::SpillSlot *PPCFrameLowering::getCalleeSavedSpillSlots(
|
||||
@ -620,8 +634,7 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
assert(FPIndex && "No Frame Pointer Save Slot!");
|
||||
FPOffset = FFI->getObjectOffset(FPIndex);
|
||||
} else {
|
||||
FPOffset =
|
||||
PPCFrameLowering::getFramePointerSaveOffset(isPPC64, isDarwinABI);
|
||||
FPOffset = getFramePointerSaveOffset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -958,8 +971,7 @@ void PPCFrameLowering::emitEpilogue(MachineFunction &MF,
|
||||
assert(FPIndex && "No Frame Pointer Save Slot!");
|
||||
FPOffset = FFI->getObjectOffset(FPIndex);
|
||||
} else {
|
||||
FPOffset =
|
||||
PPCFrameLowering::getFramePointerSaveOffset(isPPC64, isDarwinABI);
|
||||
FPOffset = getFramePointerSaveOffset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1159,7 +1171,7 @@ PPCFrameLowering::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
||||
// If the frame pointer save index hasn't been defined yet.
|
||||
if (!FPSI && needsFP(MF)) {
|
||||
// Find out what the fix offset of the frame pointer save area.
|
||||
int FPOffset = getFramePointerSaveOffset(isPPC64, isDarwinABI);
|
||||
int FPOffset = getFramePointerSaveOffset();
|
||||
// Allocate the frame index for frame pointer save area.
|
||||
FPSI = MFI->CreateFixedObject(isPPC64? 8 : 4, FPOffset, true);
|
||||
// Save the result.
|
||||
|
@ -25,6 +25,7 @@ class PPCFrameLowering: public TargetFrameLowering {
|
||||
const PPCSubtarget &Subtarget;
|
||||
const unsigned ReturnSaveOffset;
|
||||
const unsigned TOCSaveOffset;
|
||||
const unsigned FramePointerSaveOffset;
|
||||
|
||||
public:
|
||||
PPCFrameLowering(const PPCSubtarget &STI);
|
||||
@ -77,18 +78,7 @@ public:
|
||||
|
||||
/// getFramePointerSaveOffset - Return the previous frame offset to save the
|
||||
/// frame pointer.
|
||||
static unsigned getFramePointerSaveOffset(bool isPPC64, bool isDarwinABI) {
|
||||
// For the Darwin ABI:
|
||||
// We cannot use the TOC save slot (offset +20) in the PowerPC linkage area
|
||||
// for saving the frame pointer (if needed.) While the published ABI has
|
||||
// not used this slot since at least MacOSX 10.2, there is older code
|
||||
// around that does use it, and that needs to continue to work.
|
||||
if (isDarwinABI)
|
||||
return isPPC64 ? -8U : -4U;
|
||||
|
||||
// SVR4 ABI: First slot in the general register save area.
|
||||
return isPPC64 ? -8U : -4U;
|
||||
}
|
||||
unsigned getFramePointerSaveOffset() const { return FramePointerSaveOffset; }
|
||||
|
||||
/// getBasePointerSaveOffset - Return the previous frame offset to save the
|
||||
/// base pointer.
|
||||
|
@ -3472,10 +3472,9 @@ static SDValue EmitTailCallStoreFPAndRetAddr(SelectionDAG &DAG,
|
||||
if (SPDiff) {
|
||||
// Calculate the new stack slot for the return address.
|
||||
int SlotSize = isPPC64 ? 8 : 4;
|
||||
int NewRetAddrLoc = SPDiff +
|
||||
MF.getSubtarget<PPCSubtarget>()
|
||||
.getFrameLowering()
|
||||
->getReturnSaveOffset();
|
||||
const PPCFrameLowering *FL =
|
||||
MF.getSubtarget<PPCSubtarget>().getFrameLowering();
|
||||
int NewRetAddrLoc = SPDiff + FL->getReturnSaveOffset();
|
||||
int NewRetAddr = MF.getFrameInfo()->CreateFixedObject(SlotSize,
|
||||
NewRetAddrLoc, true);
|
||||
EVT VT = isPPC64 ? MVT::i64 : MVT::i32;
|
||||
@ -3487,8 +3486,7 @@ static SDValue EmitTailCallStoreFPAndRetAddr(SelectionDAG &DAG,
|
||||
// When using the 32/64-bit SVR4 ABI there is no need to move the FP stack
|
||||
// slot as the FP is never overwritten.
|
||||
if (isDarwinABI) {
|
||||
int NewFPLoc =
|
||||
SPDiff + PPCFrameLowering::getFramePointerSaveOffset(isPPC64, isDarwinABI);
|
||||
int NewFPLoc = SPDiff + FL->getFramePointerSaveOffset();
|
||||
int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, NewFPLoc,
|
||||
true);
|
||||
SDValue NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT);
|
||||
@ -5332,7 +5330,6 @@ SDValue
|
||||
PPCTargetLowering::getFramePointerFrameIndex(SelectionDAG & DAG) const {
|
||||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
bool isPPC64 = Subtarget.isPPC64();
|
||||
bool isDarwinABI = Subtarget.isDarwinABI();
|
||||
EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
|
||||
|
||||
// Get current frame pointer save index. The users of this index will be
|
||||
@ -5343,9 +5340,7 @@ PPCTargetLowering::getFramePointerFrameIndex(SelectionDAG & DAG) const {
|
||||
// If the frame pointer save index hasn't been defined yet.
|
||||
if (!FPSI) {
|
||||
// Find out what the fix offset of the frame pointer save area.
|
||||
int FPOffset = PPCFrameLowering::getFramePointerSaveOffset(isPPC64,
|
||||
isDarwinABI);
|
||||
|
||||
int FPOffset = Subtarget.getFrameLowering()->getFramePointerSaveOffset();
|
||||
// Allocate the frame index for frame pointer save area.
|
||||
FPSI = MF.getFrameInfo()->CreateFixedObject(isPPC64? 8 : 4, FPOffset, true);
|
||||
// Save the result.
|
||||
|
Loading…
Reference in New Issue
Block a user