13#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
14#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
61 unsigned BytesInStackArgArea = 0;
66 unsigned ArgumentStackToRestore = 0;
72 unsigned TailCallReservedStack = 0;
76 bool HasStackFrame =
false;
82 unsigned CalleeSavedStackSize = 0;
83 unsigned ZPRCalleeSavedStackSize = 0;
84 unsigned PPRCalleeSavedStackSize = 0;
85 bool HasCalleeSavedStackSize =
false;
86 bool HasSVECalleeSavedStackSize =
false;
90 unsigned NumLocalDynamicTLSAccesses = 0;
94 int VarArgsStackIndex = 0;
97 unsigned VarArgsStackOffset = 0;
101 int VarArgsGPRIndex = 0;
105 unsigned VarArgsGPRSize = 0;
109 int VarArgsFPRIndex = 0;
113 unsigned VarArgsFPRSize = 0;
118 int StackHazardSlotIndex = std::numeric_limits<int>::max();
119 int StackHazardCSRSlotIndex = std::numeric_limits<int>::max();
123 bool IsSplitCSR =
false;
127 bool StackRealigned =
false;
131 bool CalleeSaveStackHasFreeSpace =
false;
146 bool SplitSVEObjects =
false;
149 bool HasCalculatedStackSizeSVE =
false;
155 std::optional<bool> HasRedZone;
162 std::optional<int> TaggedBasePointerIndex;
167 unsigned TaggedBasePointerOffset;
171 std::optional<std::string> OutliningStyle;
175 int CalleeSaveBaseToFrameRecordOffset = 0;
181 bool SignWithBKey =
false;
186 bool HasELFSignedGOT =
false;
195 bool BranchTargetEnforcement =
false;
201 bool BranchProtectionPAuthLR =
false;
206 bool HasSwiftAsyncContext =
false;
209 int SwiftAsyncContextFrameIdx = std::numeric_limits<int>::max();
211 bool IsMTETagged =
false;
215 bool IsSVECC =
false;
218 bool HasStreamingModeChanges =
false;
221 mutable std::optional<bool> NeedsDwarfUnwindInfo;
224 mutable std::optional<bool> NeedsAsyncDwarfUnwindInfo;
226 int64_t StackProbeSize = 0;
234 unsigned PredicateRegForFillSpill = 0;
241 Register EarlyAllocSMESaveBuffer = AArch64::NoRegister;
252 EarlyAllocSMESaveBuffer = Ptr;
256 return EarlyAllocSMESaveBuffer;
260 PredicateRegForFillSpill =
Reg;
263 return PredicateRegForFillSpill;
279 ArgumentStackToRestore = bytes;
284 TailCallReservedStack = bytes;
289 "expected SVE stack sizes to be aligned to 16-bytes");
292 HasCalculatedStackSizeSVE =
true;
316 return CalleeSaveStackHasFreeSpace;
319 CalleeSaveStackHasFreeSpace = s;
329 return OutliningStyle;
333 CalleeSavedStackSize =
Size;
334 HasCalleeSavedStackSize =
true;
343 bool ValidateCalleeSavedStackSize =
false;
349 ValidateCalleeSavedStackSize = HasCalleeSavedStackSize;
352 if (!HasCalleeSavedStackSize || ValidateCalleeSavedStackSize) {
357 int64_t MinOffset = std::numeric_limits<int64_t>::max();
358 int64_t MaxOffset = std::numeric_limits<int64_t>::min();
360 int FrameIdx = Info.getFrameIdx();
365 MinOffset = std::min<int64_t>(
Offset, MinOffset);
366 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
369 if (SwiftAsyncContextFrameIdx != std::numeric_limits<int>::max()) {
372 MinOffset = std::min<int64_t>(
Offset, MinOffset);
373 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
376 if (StackHazardCSRSlotIndex != std::numeric_limits<int>::max()) {
378 int64_t ObjSize = MFI.
getObjectSize(StackHazardCSRSlotIndex);
379 MinOffset = std::min<int64_t>(
Offset, MinOffset);
380 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
383 unsigned Size =
alignTo(MaxOffset - MinOffset, 16);
385 "Invalid size calculated for callee saves");
393 assert(HasCalleeSavedStackSize &&
394 "CalleeSavedStackSize has not been calculated");
395 return CalleeSavedStackSize;
401 "expected SVE callee-save sizes to be aligned to 16-bytes");
402 ZPRCalleeSavedStackSize = ZPR;
403 PPRCalleeSavedStackSize = PPR;
404 HasSVECalleeSavedStackSize =
true;
407 assert(HasSVECalleeSavedStackSize &&
408 "ZPRCalleeSavedStackSize has not been calculated");
409 return ZPRCalleeSavedStackSize;
412 assert(HasSVECalleeSavedStackSize &&
413 "PPRCalleeSavedStackSize has not been calculated");
414 return PPRCalleeSavedStackSize;
419 "ZPRs and PPRs are split. Use get[ZPR|PPR]CalleeSavedStackSize()");
425 return NumLocalDynamicTLSAccesses;
432 std::optional<bool>
hasRedZone()
const {
return HasRedZone; }
454 return StackHazardSlotIndex != std::numeric_limits<int>::max();
458 assert(StackHazardSlotIndex == std::numeric_limits<int>::max());
459 StackHazardSlotIndex = Index;
463 assert(StackHazardCSRSlotIndex == std::numeric_limits<int>::max());
464 StackHazardCSRSlotIndex = Index;
482 return JumpTableEntryInfo[Idx].first;
485 return JumpTableEntryInfo[Idx].second;
488 if ((
unsigned)Idx >= JumpTableEntryInfo.size())
489 JumpTableEntryInfo.resize(Idx+1);
490 JumpTableEntryInfo[Idx] = std::make_pair(
Size, PCRelSym);
508 : Kind(Kind), Args(Args.begin(), Args.end()) {
524 LOHRelated.insert_range(Args);
529 size_t InitialSize = LOHContainerSet.size();
530 erase_if(LOHContainerSet, [&](
const auto &
D) {
531 return any_of(
D.getArgs(), [&](
auto *Arg) { return MIs.contains(Arg); });
537 LOHRelated.remove_if([&](
auto *
MI) {
return MIs.
contains(
MI); });
538 return InitialSize - LOHContainerSet.size();
542 return ForwardedMustTailRegParms;
546 return TaggedBasePointerIndex;
551 return TaggedBasePointerOffset;
554 TaggedBasePointerOffset =
Offset;
558 return CalleeSaveBaseToFrameRecordOffset;
561 CalleeSaveBaseToFrameRecordOffset =
Offset;
570 return SignCondition;
589 HasSwiftAsyncContext = HasContext;
594 SwiftAsyncContextFrameIdx = FI;
603 HasStreamingModeChanges = HasChanges;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
MILOHDirective(MCLOHType Kind, LOHArgs Args)
MCLOHType getKind() const
ArrayRef< const MachineInstr * > LOHArgs
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
void addLOHDirective(MCLOHType Kind, MILOHArgs Args)
Add a LOH directive of this Kind and this Args.
bool needsShadowCallStackPrologueEpilogue(MachineFunction &MF) const
bool branchTargetEnforcement() const
unsigned getPPRCalleeSavedStackSize() const
void setHasStackFrame(bool s)
void setSwiftAsyncContextFrameIdx(int FI)
unsigned getTailCallReservedStack() const
unsigned getCalleeSavedStackSize(const MachineFrameInfo &MFI) const
Register getEarlyAllocSMESaveBuffer() const
unsigned getVarArgsFPRSize() const
void setCalleeSaveBaseToFrameRecordOffset(int Offset)
void setVarArgsStackOffset(unsigned Offset)
bool hasStackProbing() const
void setVarArgsStackIndex(int Index)
void setEarlyAllocSMESaveBuffer(Register Ptr)
unsigned getArgumentStackToRestore() const
void setTailCallReservedStack(unsigned bytes)
SmallVector< MILOHDirective, 32 > MILOHContainer
void setLocalStackSize(uint64_t Size)
void setCalleeSaveStackHasFreeSpace(bool s)
int getCalleeSaveBaseToFrameRecordOffset() const
bool hasELFSignedGOT() const
SmallVectorImpl< ForwardedRegister > & getForwardedMustTailRegParms()
void setIsSplitCSR(bool s)
int getVarArgsFPRIndex() const
SignReturnAddress getSignReturnAddressCondition() const
bool hasStreamingModeChanges() const
void setPredicateRegForFillSpill(unsigned Reg)
void setOutliningStyle(const std::string &Style)
void incNumLocalDynamicTLSAccesses()
const SetOfInstructions & getLOHRelated() const
void setBytesInStackArgArea(unsigned bytes)
int getVarArgsStackIndex() const
void setVarArgsGPRIndex(int Index)
int getStackHazardSlotIndex() const
unsigned getTaggedBasePointerOffset() const
void setCalleeSavedStackSize(unsigned Size)
int getVarArgsGPRIndex() const
int64_t getStackProbeSize() const
void setSigningInstrLabel(MCSymbol *Label)
void setHasSwiftAsyncContext(bool HasContext)
void setSplitSVEObjects(bool s)
bool branchProtectionPAuthLR() const
void setPStateSMReg(Register Reg)
void setHasRedZone(bool s)
MILOHDirective::LOHArgs MILOHArgs
bool hasStackFrame() const
int getStackHazardCSRSlotIndex() const
void setStackSizeSVE(uint64_t ZPR, uint64_t PPR)
void setVarArgsFPRSize(unsigned Size)
std::optional< int > getTaggedBasePointerIndex() const
unsigned getVarArgsStackOffset() const
SMEAttrs getSMEFnAttrs() const
AArch64FunctionInfo(const Function &F, const AArch64Subtarget *STI)
uint64_t getLocalStackSize() const
void setStackRealigned(bool s)
unsigned getJumpTableEntrySize(int Idx) const
bool needsDwarfUnwindInfo(const MachineFunction &MF) const
size_t clearLinkerOptimizationHints(const SmallPtrSetImpl< MachineInstr * > &MIs)
unsigned getVarArgsGPRSize() const
unsigned getSRetReturnReg() const
MCSymbol * getJumpTableEntryPCRelSymbol(int Idx) const
bool isStackRealigned() const
Register getPStateSMReg() const
uint64_t getStackSizePPR() const
unsigned getNumLocalDynamicTLSAccesses() const
SmallPtrSet< const MachineInstr *, 16 > SetOfInstructions
bool hasSwiftAsyncContext() const
bool hasStackHazardSlotIndex() const
void setTaggedBasePointerOffset(unsigned Offset)
void setStackHazardSlotIndex(int Index)
std::optional< bool > hasRedZone() const
unsigned getZPRCalleeSavedStackSize() const
void setSRetReturnReg(unsigned Reg)
static bool shouldSignReturnAddress(SignReturnAddress Condition, bool IsLRSpilled)
void setStackHazardCSRSlotIndex(int Index)
int getSwiftAsyncContextFrameIdx() const
unsigned getPredicateRegForFillSpill() const
void setSVECalleeSavedStackSize(unsigned ZPR, unsigned PPR)
bool hasCalculatedStackSizeSVE() const
std::optional< std::string > getOutliningStyle() const
unsigned getBytesInStackArgArea() const
uint64_t getStackSizeZPR() const
void initializeBaseYamlFields(const yaml::AArch64FunctionInfo &YamlMFI)
const MILOHContainer & getLOHContainer() const
void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym)
bool hasSVEStackSize() const
bool isStackHazardIncludedInCalleeSaveArea() const
unsigned getSVECalleeSavedStackSize() const
bool hasSplitSVEObjects() const
bool needsAsyncDwarfUnwindInfo(const MachineFunction &MF) const
void setVarArgsFPRIndex(int Index)
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
void setVarArgsGPRSize(unsigned Size)
void setTaggedBasePointerIndex(int Index)
MCSymbol * getSigningInstrLabel() const
bool hasSVE_AAPCS(const MachineFunction &MF) const
void setArgumentStackToRestore(unsigned bytes)
void setHasStreamingModeChanges(bool HasChanges)
unsigned getCalleeSavedStackSize() const
bool hasCalleeSaveStackFreeSpace() const
bool shouldSignWithBKey() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
static constexpr unsigned NoRegister
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
uint8_t getStackID(int ObjectIdx) const
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
SMEAttrs is a utility class to parse the SME ACLE attributes on functions.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void mapOptional(StringRef Key, T &Val)
@ AArch64_SVE_VectorCall
Used between AArch64 SVE functions.
This is an optimization pass for GlobalISel generic memory operations.
SignReturnAddress
Condition of signing the return address in a function.
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
static bool isValidMCLOHType(unsigned Kind)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
MCLOHType
Linker Optimization Hint Type.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
This struct is a compact representation of a valid (non-zero power of two) alignment.
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
std::optional< bool > HasRedZone
std::optional< uint64_t > StackSizePPR
AArch64FunctionInfo()=default
std::optional< bool > HasStreamingModeChanges
std::optional< bool > HasStackFrame
std::optional< uint64_t > StackSizeZPR
~AArch64FunctionInfo() override=default
void mappingImpl(yaml::IO &YamlIO) override
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
static void mapping(IO &YamlIO, AArch64FunctionInfo &MFI)
This class should be specialized by any type that needs to be converted to/from a YAML mapping.