mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
The base pointer save offset can be computed at initialization time,
do so and fix up the calls. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229169 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f7f32530e0
commit
40ccb77781
@ -16,6 +16,7 @@
|
|||||||
#include "PPCInstrInfo.h"
|
#include "PPCInstrInfo.h"
|
||||||
#include "PPCMachineFunctionInfo.h"
|
#include "PPCMachineFunctionInfo.h"
|
||||||
#include "PPCSubtarget.h"
|
#include "PPCSubtarget.h"
|
||||||
|
#include "PPCTargetMachine.h"
|
||||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
@ -68,13 +69,26 @@ static unsigned computeLinkageSize(const PPCSubtarget &STI) {
|
|||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned computeBasePointerSaveOffset(const PPCSubtarget &STI) {
|
||||||
|
if (STI.isDarwinABI())
|
||||||
|
return STI.isPPC64() ? -16U : -8U;
|
||||||
|
|
||||||
|
// SVR4 ABI: First slot in the general register save area.
|
||||||
|
return STI.isPPC64()
|
||||||
|
? -16U
|
||||||
|
: (STI.getTargetMachine().getRelocationModel() == Reloc::PIC_)
|
||||||
|
? -12U
|
||||||
|
: -8U;
|
||||||
|
}
|
||||||
|
|
||||||
PPCFrameLowering::PPCFrameLowering(const PPCSubtarget &STI)
|
PPCFrameLowering::PPCFrameLowering(const PPCSubtarget &STI)
|
||||||
: TargetFrameLowering(TargetFrameLowering::StackGrowsDown,
|
: TargetFrameLowering(TargetFrameLowering::StackGrowsDown,
|
||||||
(STI.hasQPX() || STI.isBGQ()) ? 32 : 16, 0),
|
(STI.hasQPX() || STI.isBGQ()) ? 32 : 16, 0),
|
||||||
Subtarget(STI), ReturnSaveOffset(computeReturnSaveOffset(Subtarget)),
|
Subtarget(STI), ReturnSaveOffset(computeReturnSaveOffset(Subtarget)),
|
||||||
TOCSaveOffset(computeTOCSaveOffset(Subtarget)),
|
TOCSaveOffset(computeTOCSaveOffset(Subtarget)),
|
||||||
FramePointerSaveOffset(computeFramePointerSaveOffset(Subtarget)),
|
FramePointerSaveOffset(computeFramePointerSaveOffset(Subtarget)),
|
||||||
LinkageSize(computeLinkageSize(Subtarget)) {}
|
LinkageSize(computeLinkageSize(Subtarget)),
|
||||||
|
BasePointerSaveOffset(computeBasePointerSaveOffset(STI)) {}
|
||||||
|
|
||||||
// With the SVR4 ABI, callee-saved registers have fixed offsets on the stack.
|
// With the SVR4 ABI, callee-saved registers have fixed offsets on the stack.
|
||||||
const PPCFrameLowering::SpillSlot *PPCFrameLowering::getCalleeSavedSpillSlots(
|
const PPCFrameLowering::SpillSlot *PPCFrameLowering::getCalleeSavedSpillSlots(
|
||||||
@ -557,7 +571,6 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
|
|||||||
DebugLoc dl;
|
DebugLoc dl;
|
||||||
bool needsCFI = MMI.hasDebugInfo() ||
|
bool needsCFI = MMI.hasDebugInfo() ||
|
||||||
MF.getFunction()->needsUnwindTableEntry();
|
MF.getFunction()->needsUnwindTableEntry();
|
||||||
bool isPIC = MF.getTarget().getRelocationModel() == Reloc::PIC_;
|
|
||||||
|
|
||||||
// Get processor type.
|
// Get processor type.
|
||||||
bool isPPC64 = Subtarget.isPPC64();
|
bool isPPC64 = Subtarget.isPPC64();
|
||||||
@ -653,10 +666,7 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
|
|||||||
assert(BPIndex && "No Base Pointer Save Slot!");
|
assert(BPIndex && "No Base Pointer Save Slot!");
|
||||||
BPOffset = FFI->getObjectOffset(BPIndex);
|
BPOffset = FFI->getObjectOffset(BPIndex);
|
||||||
} else {
|
} else {
|
||||||
BPOffset =
|
BPOffset = getBasePointerSaveOffset();
|
||||||
PPCFrameLowering::getBasePointerSaveOffset(isPPC64,
|
|
||||||
isDarwinABI,
|
|
||||||
isPIC);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,9 +948,7 @@ void PPCFrameLowering::emitEpilogue(MachineFunction &MF,
|
|||||||
// Get processor type.
|
// Get processor type.
|
||||||
bool isPPC64 = Subtarget.isPPC64();
|
bool isPPC64 = Subtarget.isPPC64();
|
||||||
// Get the ABI.
|
// Get the ABI.
|
||||||
bool isDarwinABI = Subtarget.isDarwinABI();
|
|
||||||
bool isSVR4ABI = Subtarget.isSVR4ABI();
|
bool isSVR4ABI = Subtarget.isSVR4ABI();
|
||||||
bool isPIC = MF.getTarget().getRelocationModel() == Reloc::PIC_;
|
|
||||||
|
|
||||||
// Check if the link register (LR) has been saved.
|
// Check if the link register (LR) has been saved.
|
||||||
PPCFunctionInfo *FI = MF.getInfo<PPCFunctionInfo>();
|
PPCFunctionInfo *FI = MF.getInfo<PPCFunctionInfo>();
|
||||||
@ -990,10 +998,7 @@ void PPCFrameLowering::emitEpilogue(MachineFunction &MF,
|
|||||||
assert(BPIndex && "No Base Pointer Save Slot!");
|
assert(BPIndex && "No Base Pointer Save Slot!");
|
||||||
BPOffset = FFI->getObjectOffset(BPIndex);
|
BPOffset = FFI->getObjectOffset(BPIndex);
|
||||||
} else {
|
} else {
|
||||||
BPOffset =
|
BPOffset = getBasePointerSaveOffset();
|
||||||
PPCFrameLowering::getBasePointerSaveOffset(isPPC64,
|
|
||||||
isDarwinABI,
|
|
||||||
isPIC);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,7 +1177,6 @@ PPCFrameLowering::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
|||||||
int FPSI = FI->getFramePointerSaveIndex();
|
int FPSI = FI->getFramePointerSaveIndex();
|
||||||
bool isPPC64 = Subtarget.isPPC64();
|
bool isPPC64 = Subtarget.isPPC64();
|
||||||
bool isDarwinABI = Subtarget.isDarwinABI();
|
bool isDarwinABI = Subtarget.isDarwinABI();
|
||||||
bool isPIC = MF.getTarget().getRelocationModel() == Reloc::PIC_;
|
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
|
|
||||||
// If the frame pointer save index hasn't been defined yet.
|
// If the frame pointer save index hasn't been defined yet.
|
||||||
@ -1187,7 +1191,7 @@ PPCFrameLowering::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
|||||||
|
|
||||||
int BPSI = FI->getBasePointerSaveIndex();
|
int BPSI = FI->getBasePointerSaveIndex();
|
||||||
if (!BPSI && RegInfo->hasBasePointer(MF)) {
|
if (!BPSI && RegInfo->hasBasePointer(MF)) {
|
||||||
int BPOffset = getBasePointerSaveOffset(isPPC64, isDarwinABI, isPIC);
|
int BPOffset = getBasePointerSaveOffset();
|
||||||
// Allocate the frame index for the base pointer save area.
|
// Allocate the frame index for the base pointer save area.
|
||||||
BPSI = MFI->CreateFixedObject(isPPC64? 8 : 4, BPOffset, true);
|
BPSI = MFI->CreateFixedObject(isPPC64? 8 : 4, BPOffset, true);
|
||||||
// Save the result.
|
// Save the result.
|
||||||
|
@ -27,6 +27,7 @@ class PPCFrameLowering: public TargetFrameLowering {
|
|||||||
const unsigned TOCSaveOffset;
|
const unsigned TOCSaveOffset;
|
||||||
const unsigned FramePointerSaveOffset;
|
const unsigned FramePointerSaveOffset;
|
||||||
const unsigned LinkageSize;
|
const unsigned LinkageSize;
|
||||||
|
const unsigned BasePointerSaveOffset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PPCFrameLowering(const PPCSubtarget &STI);
|
PPCFrameLowering(const PPCSubtarget &STI);
|
||||||
@ -83,15 +84,7 @@ public:
|
|||||||
|
|
||||||
/// getBasePointerSaveOffset - Return the previous frame offset to save the
|
/// getBasePointerSaveOffset - Return the previous frame offset to save the
|
||||||
/// base pointer.
|
/// base pointer.
|
||||||
static unsigned getBasePointerSaveOffset(bool isPPC64,
|
unsigned getBasePointerSaveOffset() const { return BasePointerSaveOffset; }
|
||||||
bool isDarwinABI,
|
|
||||||
bool isPIC) {
|
|
||||||
if (isDarwinABI)
|
|
||||||
return isPPC64 ? -16U : -8U;
|
|
||||||
|
|
||||||
// SVR4 ABI: First slot in the general register save area.
|
|
||||||
return isPPC64 ? -16U : isPIC ? -12U : -8U;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getLinkageSize - Return the size of the PowerPC ABI linkage area.
|
/// getLinkageSize - Return the size of the PowerPC ABI linkage area.
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user