The return save offset can be computed at initialization time - do

so and save the value.

llvm-svn: 228996
This commit is contained in:
Eric Christopher 2015-02-13 00:39:27 +00:00
parent 8ec536e3dd
commit f71609b5dd
3 changed files with 19 additions and 17 deletions

View File

@ -36,10 +36,17 @@ static const uint16_t VRRegNo[] = {
PPC::V24, PPC::V25, PPC::V26, PPC::V27, PPC::V28, PPC::V29, PPC::V30, PPC::V31 PPC::V24, PPC::V25, PPC::V26, PPC::V27, PPC::V28, PPC::V29, PPC::V30, PPC::V31
}; };
static unsigned computeReturnSaveOffset(const PPCSubtarget &STI) {
if (STI.isDarwinABI())
return STI.isPPC64() ? 16 : 8;
// SVR4 ABI:
return STI.isPPC64() ? 16 : 4;
}
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) {} Subtarget(STI), ReturnSaveOffset(computeReturnSaveOffset(Subtarget)) {}
// 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(
@ -598,7 +605,7 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
assert((isPPC64 || !isSVR4ABI || !(!FrameSize && (MustSaveLR || HasFP))) && assert((isPPC64 || !isSVR4ABI || !(!FrameSize && (MustSaveLR || HasFP))) &&
"FrameSize must be >0 to save/restore the FP or LR for 32-bit SVR4."); "FrameSize must be >0 to save/restore the FP or LR for 32-bit SVR4.");
int LROffset = PPCFrameLowering::getReturnSaveOffset(isPPC64, isDarwinABI); int LROffset = getReturnSaveOffset();
int FPOffset = 0; int FPOffset = 0;
if (HasFP) { if (HasFP) {
@ -936,7 +943,7 @@ void PPCFrameLowering::emitEpilogue(MachineFunction &MF,
const MCInstrDesc& AddInst = TII.get( isPPC64 ? PPC::ADD8 const MCInstrDesc& AddInst = TII.get( isPPC64 ? PPC::ADD8
: PPC::ADD4 ); : PPC::ADD4 );
int LROffset = PPCFrameLowering::getReturnSaveOffset(isPPC64, isDarwinABI); int LROffset = getReturnSaveOffset();
int FPOffset = 0; int FPOffset = 0;
if (HasFP) { if (HasFP) {

View File

@ -23,6 +23,7 @@ class PPCSubtarget;
class PPCFrameLowering: public TargetFrameLowering { class PPCFrameLowering: public TargetFrameLowering {
const PPCSubtarget &Subtarget; const PPCSubtarget &Subtarget;
const unsigned ReturnSaveOffset;
public: public:
PPCFrameLowering(const PPCSubtarget &STI); PPCFrameLowering(const PPCSubtarget &STI);
@ -67,12 +68,7 @@ public:
/// getReturnSaveOffset - Return the previous frame offset to save the /// getReturnSaveOffset - Return the previous frame offset to save the
/// return address. /// return address.
static unsigned getReturnSaveOffset(bool isPPC64, bool isDarwinABI) { unsigned getReturnSaveOffset() const { return ReturnSaveOffset; }
if (isDarwinABI)
return isPPC64 ? 16 : 8;
// SVR4 ABI:
return isPPC64 ? 16 : 4;
}
/// getTOCSaveOffset - Return the previous frame offset to save the /// getTOCSaveOffset - Return the previous frame offset to save the
/// TOC register -- 64-bit SVR4 ABI only. /// TOC register -- 64-bit SVR4 ABI only.

View File

@ -3472,8 +3472,10 @@ static SDValue EmitTailCallStoreFPAndRetAddr(SelectionDAG &DAG,
if (SPDiff) { if (SPDiff) {
// Calculate the new stack slot for the return address. // Calculate the new stack slot for the return address.
int SlotSize = isPPC64 ? 8 : 4; int SlotSize = isPPC64 ? 8 : 4;
int NewRetAddrLoc = SPDiff + PPCFrameLowering::getReturnSaveOffset(isPPC64, int NewRetAddrLoc = SPDiff +
isDarwinABI); MF.getSubtarget<PPCSubtarget>()
.getFrameLowering()
->getReturnSaveOffset();
int NewRetAddr = MF.getFrameInfo()->CreateFixedObject(SlotSize, int NewRetAddr = MF.getFrameInfo()->CreateFixedObject(SlotSize,
NewRetAddrLoc, true); NewRetAddrLoc, true);
EVT VT = isPPC64 ? MVT::i64 : MVT::i32; EVT VT = isPPC64 ? MVT::i64 : MVT::i32;
@ -5308,7 +5310,6 @@ SDValue
PPCTargetLowering::getReturnAddrFrameIndex(SelectionDAG & DAG) const { PPCTargetLowering::getReturnAddrFrameIndex(SelectionDAG & DAG) const {
MachineFunction &MF = DAG.getMachineFunction(); MachineFunction &MF = DAG.getMachineFunction();
bool isPPC64 = Subtarget.isPPC64(); bool isPPC64 = Subtarget.isPPC64();
bool isDarwinABI = Subtarget.isDarwinABI();
EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
// Get current frame pointer save index. The users of this index will be // Get current frame pointer save index. The users of this index will be
@ -5319,7 +5320,7 @@ PPCTargetLowering::getReturnAddrFrameIndex(SelectionDAG & DAG) const {
// If the frame pointer save index hasn't been defined yet. // If the frame pointer save index hasn't been defined yet.
if (!RASI) { if (!RASI) {
// Find out what the fix offset of the frame pointer save area. // Find out what the fix offset of the frame pointer save area.
int LROffset = PPCFrameLowering::getReturnSaveOffset(isPPC64, isDarwinABI); int LROffset = Subtarget.getFrameLowering()->getReturnSaveOffset();
// Allocate the frame index for frame pointer save area. // Allocate the frame index for frame pointer save area.
RASI = MF.getFrameInfo()->CreateFixedObject(isPPC64? 8 : 4, LROffset, false); RASI = MF.getFrameInfo()->CreateFixedObject(isPPC64? 8 : 4, LROffset, false);
// Save the result. // Save the result.
@ -9699,14 +9700,12 @@ SDValue PPCTargetLowering::LowerRETURNADDR(SDValue Op,
PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>(); PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
FuncInfo->setLRStoreRequired(); FuncInfo->setLRStoreRequired();
bool isPPC64 = Subtarget.isPPC64(); bool isPPC64 = Subtarget.isPPC64();
bool isDarwinABI = Subtarget.isDarwinABI();
if (Depth > 0) { if (Depth > 0) {
SDValue FrameAddr = LowerFRAMEADDR(Op, DAG); SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
SDValue Offset = SDValue Offset =
DAG.getConstant(Subtarget.getFrameLowering()->getReturnSaveOffset(),
DAG.getConstant(PPCFrameLowering::getReturnSaveOffset(isPPC64, isDarwinABI), isPPC64 ? MVT::i64 : MVT::i32);
isPPC64? MVT::i64 : MVT::i32);
return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
DAG.getNode(ISD::ADD, dl, getPointerTy(), DAG.getNode(ISD::ADD, dl, getPointerTy(),
FrameAddr, Offset), FrameAddr, Offset),