diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2019-07-12 21:13:55 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2019-07-12 21:13:55 +0000 |
commit | 32452487ae999eeed03065e3799976944eb936b5 (patch) | |
tree | acff7776dea5d43a3a326f6b22403ca502db1975 | |
parent | a205ebb09cc50e29e8d7edae6910de25baf69509 (diff) | |
download | bcm5719-llvm-32452487ae999eeed03065e3799976944eb936b5.tar.gz bcm5719-llvm-32452487ae999eeed03065e3799976944eb936b5.zip |
Factor out resolveFrameOffsetReference (NFC).
Split AArch64FrameLowering::resolveFrameIndexReference in two parts
* Finding frame offset for the index.
* Finding base register and offset to that register.
The second part will be used to implement a virtual frame pointer in
armv8.5 MTE stack instrumentation lowering.
Reviewers: pcc, vitalybuka, hctim, ostannard
Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64171
llvm-svn: 365958
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64FrameLowering.cpp | 35 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64FrameLowering.h | 3 |
2 files changed, 26 insertions, 12 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp index 3239cf05381..fed0fc7f624 100644 --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp @@ -1508,27 +1508,28 @@ int AArch64FrameLowering::getNonLocalFrameIndexReference( return getSEHFrameIndexOffset(MF, FI); } -static int getFPOffset(const MachineFunction &MF, int FI) { - const auto &MFI = MF.getFrameInfo(); +static int getFPOffset(const MachineFunction &MF, int ObjectOffset) { const auto *AFI = MF.getInfo<AArch64FunctionInfo>(); const auto &Subtarget = MF.getSubtarget<AArch64Subtarget>(); bool IsWin64 = Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv()); unsigned FixedObject = IsWin64 ? alignTo(AFI->getVarArgsGPRSize(), 16) : 0; - return MFI.getObjectOffset(FI) + FixedObject + 16; + return ObjectOffset + FixedObject + 16; } -static int getStackOffset(const MachineFunction &MF, int FI) { +static int getStackOffset(const MachineFunction &MF, int ObjectOffset) { const auto &MFI = MF.getFrameInfo(); - return MFI.getObjectOffset(FI) + MFI.getStackSize(); + return ObjectOffset + MFI.getStackSize(); } int AArch64FrameLowering::getSEHFrameIndexOffset(const MachineFunction &MF, int FI) const { const auto *RegInfo = static_cast<const AArch64RegisterInfo *>( MF.getSubtarget().getRegisterInfo()); - return RegInfo->getLocalAddressRegister(MF) == AArch64::FP ? - getFPOffset(MF, FI) : getStackOffset(MF, FI); + int ObjectOffset = MF.getFrameInfo().getObjectOffset(FI); + return RegInfo->getLocalAddressRegister(MF) == AArch64::FP + ? getFPOffset(MF, ObjectOffset) + : getStackOffset(MF, ObjectOffset); } int AArch64FrameLowering::resolveFrameIndexReference(const MachineFunction &MF, @@ -1536,15 +1537,25 @@ int AArch64FrameLowering::resolveFrameIndexReference(const MachineFunction &MF, bool PreferFP, bool ForSimm) const { const auto &MFI = MF.getFrameInfo(); + int ObjectOffset = MFI.getObjectOffset(FI); + bool isFixed = MFI.isFixedObjectIndex(FI); + return resolveFrameOffsetReference(MF, ObjectOffset, isFixed, FrameReg, + PreferFP, ForSimm); +} + +int AArch64FrameLowering::resolveFrameOffsetReference( + const MachineFunction &MF, int ObjectOffset, bool isFixed, + unsigned &FrameReg, bool PreferFP, bool ForSimm) const { + const auto &MFI = MF.getFrameInfo(); const auto *RegInfo = static_cast<const AArch64RegisterInfo *>( MF.getSubtarget().getRegisterInfo()); const auto *AFI = MF.getInfo<AArch64FunctionInfo>(); const auto &Subtarget = MF.getSubtarget<AArch64Subtarget>(); - int FPOffset = getFPOffset(MF, FI); - int Offset = getStackOffset(MF, FI); - bool isFixed = MFI.isFixedObjectIndex(FI); - bool isCSR = !isFixed && MFI.getObjectOffset(FI) >= - -((int)AFI->getCalleeSavedStackSize()); + + int FPOffset = getFPOffset(MF, ObjectOffset); + int Offset = getStackOffset(MF, ObjectOffset); + bool isCSR = + !isFixed && ObjectOffset >= -((int)AFI->getCalleeSavedStackSize()); // Use frame pointer to reference fixed objects. Use it for locals if // there are VLAs or a dynamically realigned SP (and thus the SP isn't diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.h b/llvm/lib/Target/AArch64/AArch64FrameLowering.h index efbe35f67af..6dbd34b2189 100644 --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.h +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.h @@ -42,6 +42,9 @@ public: int resolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, bool PreferFP, bool ForSimm) const; + int resolveFrameOffsetReference(const MachineFunction &MF, int ObjectOffset, + bool isFixed, unsigned &FrameReg, + bool PreferFP, bool ForSimm) const; bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector<CalleeSavedInfo> &CSI, |