diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h | 87 |
1 files changed, 79 insertions, 8 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h index 0009fb7b5520..6ddb3fdb0046 100644 --- a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h +++ b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h @@ -19,6 +19,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/CallingConvLower.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/TargetFrameLowering.h" #include "llvm/IR/Function.h" #include "llvm/MC/MCLinkerOptimizationHint.h" #include <cassert> @@ -51,10 +52,16 @@ class AArch64FunctionInfo final : public MachineFunctionInfo { bool HasStackFrame = false; /// Amount of stack frame size, not including callee-saved registers. - unsigned LocalStackSize; + uint64_t LocalStackSize = 0; + + /// The start and end frame indices for the SVE callee saves. + int MinSVECSFrameIndex = 0; + int MaxSVECSFrameIndex = 0; /// Amount of stack frame size used for saving callee-saved registers. - unsigned CalleeSavedStackSize; + unsigned CalleeSavedStackSize = 0; + unsigned SVECalleeSavedStackSize = 0; + bool HasCalleeSavedStackSize = false; /// Number of TLS accesses using the special (combinable) /// _TLS_MODULE_BASE_ symbol. @@ -117,7 +124,7 @@ class AArch64FunctionInfo final : public MachineFunctionInfo { // Offset from SP-at-entry to the tagged base pointer. // Tagged base pointer is set up to point to the first (lowest address) tagged // stack slot. - unsigned TaggedBasePointerOffset; + unsigned TaggedBasePointerOffset = 0; public: AArch64FunctionInfo() = default; @@ -160,15 +167,79 @@ public: void setCalleeSaveStackHasFreeSpace(bool s) { CalleeSaveStackHasFreeSpace = s; } - bool isSplitCSR() const { return IsSplitCSR; } void setIsSplitCSR(bool s) { IsSplitCSR = s; } - void setLocalStackSize(unsigned Size) { LocalStackSize = Size; } - unsigned getLocalStackSize() const { return LocalStackSize; } + void setLocalStackSize(uint64_t Size) { LocalStackSize = Size; } + uint64_t getLocalStackSize() const { return LocalStackSize; } + + void setCalleeSavedStackSize(unsigned Size) { + CalleeSavedStackSize = Size; + HasCalleeSavedStackSize = true; + } + + // When CalleeSavedStackSize has not been set (for example when + // some MachineIR pass is run in isolation), then recalculate + // the CalleeSavedStackSize directly from the CalleeSavedInfo. + // Note: This information can only be recalculated after PEI + // has assigned offsets to the callee save objects. + unsigned getCalleeSavedStackSize(const MachineFrameInfo &MFI) const { + bool ValidateCalleeSavedStackSize = false; + +#ifndef NDEBUG + // Make sure the calculated size derived from the CalleeSavedInfo + // equals the cached size that was calculated elsewhere (e.g. in + // determineCalleeSaves). + ValidateCalleeSavedStackSize = HasCalleeSavedStackSize; +#endif + + if (!HasCalleeSavedStackSize || ValidateCalleeSavedStackSize) { + assert(MFI.isCalleeSavedInfoValid() && "CalleeSavedInfo not calculated"); + if (MFI.getCalleeSavedInfo().empty()) + return 0; + + int64_t MinOffset = std::numeric_limits<int64_t>::max(); + int64_t MaxOffset = std::numeric_limits<int64_t>::min(); + for (const auto &Info : MFI.getCalleeSavedInfo()) { + int FrameIdx = Info.getFrameIdx(); + if (MFI.getStackID(FrameIdx) != TargetStackID::Default) + continue; + int64_t Offset = MFI.getObjectOffset(FrameIdx); + int64_t ObjSize = MFI.getObjectSize(FrameIdx); + MinOffset = std::min<int64_t>(Offset, MinOffset); + MaxOffset = std::max<int64_t>(Offset + ObjSize, MaxOffset); + } + + unsigned Size = alignTo(MaxOffset - MinOffset, 16); + assert((!HasCalleeSavedStackSize || getCalleeSavedStackSize() == Size) && + "Invalid size calculated for callee saves"); + return Size; + } + + return getCalleeSavedStackSize(); + } + + unsigned getCalleeSavedStackSize() const { + assert(HasCalleeSavedStackSize && + "CalleeSavedStackSize has not been calculated"); + return CalleeSavedStackSize; + } + + // Saves the CalleeSavedStackSize for SVE vectors in 'scalable bytes' + void setSVECalleeSavedStackSize(unsigned Size) { + SVECalleeSavedStackSize = Size; + } + unsigned getSVECalleeSavedStackSize() const { + return SVECalleeSavedStackSize; + } + + void setMinMaxSVECSFrameIndex(int Min, int Max) { + MinSVECSFrameIndex = Min; + MaxSVECSFrameIndex = Max; + } - void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; } - unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; } + int getMinSVECSFrameIndex() const { return MinSVECSFrameIndex; } + int getMaxSVECSFrameIndex() const { return MaxSVECSFrameIndex; } void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; } unsigned getNumLocalDynamicTLSAccesses() const { |