forked from OSchip/llvm-project
The TOC save offset can be computed at compile time, do so and
propagate changes. llvm-svn: 228997
This commit is contained in:
parent
f71609b5dd
commit
736d39e189
|
@ -43,10 +43,15 @@ static unsigned computeReturnSaveOffset(const PPCSubtarget &STI) {
|
|||
return STI.isPPC64() ? 16 : 4;
|
||||
}
|
||||
|
||||
static unsigned computeTOCSaveOffset(const PPCSubtarget &STI) {
|
||||
return STI.isELFv2ABI() ? 24 : 40;
|
||||
}
|
||||
|
||||
PPCFrameLowering::PPCFrameLowering(const PPCSubtarget &STI)
|
||||
: TargetFrameLowering(TargetFrameLowering::StackGrowsDown,
|
||||
(STI.hasQPX() || STI.isBGQ()) ? 32 : 16, 0),
|
||||
Subtarget(STI), ReturnSaveOffset(computeReturnSaveOffset(Subtarget)) {}
|
||||
Subtarget(STI), ReturnSaveOffset(computeReturnSaveOffset(Subtarget)),
|
||||
TOCSaveOffset(computeTOCSaveOffset(Subtarget)) {}
|
||||
|
||||
// With the SVR4 ABI, callee-saved registers have fixed offsets on the stack.
|
||||
const PPCFrameLowering::SpillSlot *PPCFrameLowering::getCalleeSavedSpillSlots(
|
||||
|
|
|
@ -24,6 +24,7 @@ class PPCSubtarget;
|
|||
class PPCFrameLowering: public TargetFrameLowering {
|
||||
const PPCSubtarget &Subtarget;
|
||||
const unsigned ReturnSaveOffset;
|
||||
const unsigned TOCSaveOffset;
|
||||
|
||||
public:
|
||||
PPCFrameLowering(const PPCSubtarget &STI);
|
||||
|
@ -72,9 +73,7 @@ public:
|
|||
|
||||
/// getTOCSaveOffset - Return the previous frame offset to save the
|
||||
/// TOC register -- 64-bit SVR4 ABI only.
|
||||
static unsigned getTOCSaveOffset(bool isELFv2ABI) {
|
||||
return isELFv2ABI ? 24 : 40;
|
||||
}
|
||||
unsigned getTOCSaveOffset() const { return TOCSaveOffset; }
|
||||
|
||||
/// getFramePointerSaveOffset - Return the previous frame offset to save the
|
||||
/// frame pointer.
|
||||
|
|
|
@ -3900,7 +3900,6 @@ PPCTargetLowering::FinishCall(CallingConv::ID CallConv, SDLoc dl,
|
|||
SmallVectorImpl<SDValue> &InVals,
|
||||
ImmutableCallSite *CS) const {
|
||||
|
||||
bool isELFv2ABI = Subtarget.isELFv2ABI();
|
||||
std::vector<EVT> NodeTys;
|
||||
SmallVector<SDValue, 8> Ops;
|
||||
unsigned CallOpc = PrepareCall(DAG, Callee, InFlag, Chain, CallSeqStart, dl,
|
||||
|
@ -3964,7 +3963,7 @@ PPCTargetLowering::FinishCall(CallingConv::ID CallConv, SDLoc dl,
|
|||
|
||||
EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
|
||||
SDValue StackPtr = DAG.getRegister(PPC::X1, PtrVT);
|
||||
unsigned TOCSaveOffset = PPCFrameLowering::getTOCSaveOffset(isELFv2ABI);
|
||||
unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
|
||||
SDValue TOCOff = DAG.getIntPtrConstant(TOCSaveOffset);
|
||||
SDValue AddTOC = DAG.getNode(ISD::ADD, dl, MVT::i64, StackPtr, TOCOff);
|
||||
|
||||
|
@ -4789,7 +4788,7 @@ PPCTargetLowering::LowerCall_64SVR4(SDValue Chain, SDValue Callee,
|
|||
setUsesTOCBasePtr(DAG);
|
||||
SDValue Val = DAG.getCopyFromReg(Chain, dl, PPC::X2, MVT::i64);
|
||||
// TOC save area offset.
|
||||
unsigned TOCSaveOffset = PPCFrameLowering::getTOCSaveOffset(isELFv2ABI);
|
||||
unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
|
||||
SDValue PtrOff = DAG.getIntPtrConstant(TOCSaveOffset);
|
||||
SDValue AddPtr = DAG.getNode(ISD::ADD, dl, PtrVT, StackPtr, PtrOff);
|
||||
Chain = DAG.getStore(Val.getValue(1), dl, Val, AddPtr,
|
||||
|
|
Loading…
Reference in New Issue