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;
79 bool HasExplicitWinCFIRanges =
false;
85 unsigned CalleeSavedStackSize = 0;
86 unsigned ZPRCalleeSavedStackSize = 0;
87 unsigned PPRCalleeSavedStackSize = 0;
88 bool HasCalleeSavedStackSize =
false;
89 bool HasSVECalleeSavedStackSize =
false;
93 unsigned NumLocalDynamicTLSAccesses = 0;
97 int VarArgsStackIndex = 0;
100 unsigned VarArgsStackOffset = 0;
104 int VarArgsGPRIndex = 0;
108 unsigned VarArgsGPRSize = 0;
112 int VarArgsFPRIndex = 0;
116 unsigned VarArgsFPRSize = 0;
121 int StackHazardSlotIndex = std::numeric_limits<int>::max();
122 int StackHazardCSRSlotIndex = std::numeric_limits<int>::max();
126 bool IsSplitCSR =
false;
130 bool StackRealigned =
false;
134 bool CalleeSaveStackHasFreeSpace =
false;
149 bool SplitSVEObjects =
false;
152 bool HasCalculatedStackSizeSVE =
false;
158 std::optional<bool> HasRedZone;
165 std::optional<int> TaggedBasePointerIndex;
170 unsigned TaggedBasePointerOffset;
174 std::optional<std::string> OutliningStyle;
178 int CalleeSaveBaseToFrameRecordOffset = 0;
184 bool SignWithBKey =
false;
189 bool HasELFSignedGOT =
false;
197 enum class SignReturnAddressHardeningKind { None, LoadReturnAddress };
199 SignReturnAddressHardeningKind SignReturnAddressHardening =
200 SignReturnAddressHardeningKind::None;
204 bool BranchTargetEnforcement =
false;
210 bool BranchProtectionPAuthLR =
false;
215 bool HasSwiftAsyncContext =
false;
221 bool HasWinCallToCalleePopFunction =
false;
224 int SwiftAsyncContextFrameIdx = std::numeric_limits<int>::max();
226 bool IsMTETagged =
false;
230 bool IsSVECC =
false;
233 bool HasStreamingModeChanges =
false;
236 mutable std::optional<bool> NeedsDwarfUnwindInfo;
239 mutable std::optional<bool> NeedsAsyncDwarfUnwindInfo;
241 int64_t StackProbeSize = 0;
249 unsigned PredicateRegForFillSpill = 0;
267 EarlyAllocSMESaveBuffer = Ptr;
271 return EarlyAllocSMESaveBuffer;
275 PredicateRegForFillSpill =
Reg;
278 return PredicateRegForFillSpill;
294 ArgumentStackToRestore = bytes;
299 TailCallReservedStack = bytes;
304 "expected SVE stack sizes to be aligned to 16-bytes");
307 HasCalculatedStackSizeSVE =
true;
330 HasExplicitWinCFIRanges =
Value;
336 return CalleeSaveStackHasFreeSpace;
339 CalleeSaveStackHasFreeSpace = s;
349 return OutliningStyle;
353 CalleeSavedStackSize =
Size;
354 HasCalleeSavedStackSize =
true;
363 bool ValidateCalleeSavedStackSize =
false;
369 ValidateCalleeSavedStackSize = HasCalleeSavedStackSize;
372 if (!HasCalleeSavedStackSize || ValidateCalleeSavedStackSize) {
377 int64_t MinOffset = std::numeric_limits<int64_t>::max();
378 int64_t MaxOffset = std::numeric_limits<int64_t>::min();
380 int FrameIdx = Info.getFrameIdx();
385 MinOffset = std::min<int64_t>(
Offset, MinOffset);
386 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
389 if (SwiftAsyncContextFrameIdx != std::numeric_limits<int>::max()) {
392 MinOffset = std::min<int64_t>(
Offset, MinOffset);
393 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
396 if (StackHazardCSRSlotIndex != std::numeric_limits<int>::max()) {
398 int64_t ObjSize = MFI.
getObjectSize(StackHazardCSRSlotIndex);
399 MinOffset = std::min<int64_t>(
Offset, MinOffset);
400 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
403 unsigned Size =
alignTo(MaxOffset - MinOffset, 16);
405 "Invalid size calculated for callee saves");
413 assert(HasCalleeSavedStackSize &&
414 "CalleeSavedStackSize has not been calculated");
415 return CalleeSavedStackSize;
421 "expected SVE callee-save sizes to be aligned to 16-bytes");
422 ZPRCalleeSavedStackSize = ZPR;
423 PPRCalleeSavedStackSize = PPR;
424 HasSVECalleeSavedStackSize =
true;
427 assert(HasSVECalleeSavedStackSize &&
428 "ZPRCalleeSavedStackSize has not been calculated");
429 return ZPRCalleeSavedStackSize;
432 assert(HasSVECalleeSavedStackSize &&
433 "PPRCalleeSavedStackSize has not been calculated");
434 return PPRCalleeSavedStackSize;
439 "ZPRs and PPRs are split. Use get[ZPR|PPR]CalleeSavedStackSize()");
445 return NumLocalDynamicTLSAccesses;
452 std::optional<bool>
hasRedZone()
const {
return HasRedZone; }
474 return StackHazardSlotIndex != std::numeric_limits<int>::max();
478 assert(StackHazardSlotIndex == std::numeric_limits<int>::max());
479 StackHazardSlotIndex = Index;
483 assert(StackHazardCSRSlotIndex == std::numeric_limits<int>::max());
484 StackHazardCSRSlotIndex = Index;
502 return JumpTableEntryInfo[Idx].first;
505 return JumpTableEntryInfo[Idx].second;
508 if ((
unsigned)Idx >= JumpTableEntryInfo.size())
509 JumpTableEntryInfo.resize(Idx+1);
510 JumpTableEntryInfo[Idx] = std::make_pair(
Size, PCRelSym);
528 : Kind(Kind), Args(Args.begin(), Args.end()) {
544 LOHRelated.insert_range(Args);
549 size_t InitialSize = LOHContainerSet.size();
550 erase_if(LOHContainerSet, [&](
const auto &
D) {
551 return any_of(
D.getArgs(), [&](
auto *Arg) { return MIs.contains(Arg); });
557 LOHRelated.remove_if([&](
auto *
MI) {
return MIs.
contains(
MI); });
558 return InitialSize - LOHContainerSet.size();
562 return ForwardedMustTailRegParms;
566 return TaggedBasePointerIndex;
571 return TaggedBasePointerOffset;
574 TaggedBasePointerOffset =
Offset;
578 return CalleeSaveBaseToFrameRecordOffset;
581 CalleeSaveBaseToFrameRecordOffset =
Offset;
590 return SignCondition;
605 return SignReturnAddressHardening != SignReturnAddressHardeningKind::None;
613 HasSwiftAsyncContext = HasContext;
618 HasWinCallToCalleePopFunction = Has;
621 return HasWinCallToCalleePopFunction;
625 SwiftAsyncContextFrameIdx = FI;
634 HasStreamingModeChanges = HasChanges;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Promote Memory to Register
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 setHasExplicitWinCFIRanges(bool Value)
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)
bool hasWinCallToCalleePopFunction() const
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
bool hasExplicitWinCFIRanges() 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)
bool shouldHardenSignReturnAddress() const
void setHasWinCallToCalleePopFunction(bool Has)
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
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...
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.
LLVM Value Representation.
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
bool HasExplicitWinCFIRanges
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.