13#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
14#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
34struct AArch64FunctionInfo;
37class AArch64Subtarget;
57 unsigned BytesInStackArgArea = 0;
62 unsigned ArgumentStackToRestore = 0;
68 unsigned TailCallReservedStack = 0;
72 bool HasStackFrame =
false;
78 int MinSVECSFrameIndex = 0;
79 int MaxSVECSFrameIndex = 0;
82 unsigned CalleeSavedStackSize = 0;
83 unsigned SVECalleeSavedStackSize = 0;
84 bool HasCalleeSavedStackSize =
false;
85 bool HasSVECalleeSavedStackSize =
false;
89 unsigned NumLocalDynamicTLSAccesses = 0;
93 int VarArgsStackIndex = 0;
96 unsigned VarArgsStackOffset = 0;
100 int VarArgsGPRIndex = 0;
104 unsigned VarArgsGPRSize = 0;
108 int VarArgsFPRIndex = 0;
112 unsigned VarArgsFPRSize = 0;
117 int StackHazardSlotIndex = std::numeric_limits<int>::max();
118 int StackHazardCSRSlotIndex = std::numeric_limits<int>::max();
122 bool IsSplitCSR =
false;
126 bool StackRealigned =
false;
130 bool CalleeSaveStackHasFreeSpace =
false;
143 bool HasCalculatedStackSizeSVE =
false;
149 std::optional<bool> HasRedZone;
156 std::optional<int> TaggedBasePointerIndex;
161 unsigned TaggedBasePointerOffset;
165 std::optional<std::string> OutliningStyle;
169 int CalleeSaveBaseToFrameRecordOffset = 0;
173 bool SignReturnAddress =
false;
177 bool SignReturnAddressAll =
false;
180 bool SignWithBKey =
false;
185 bool HasELFSignedGOT =
false;
194 bool BranchTargetEnforcement =
false;
200 bool BranchProtectionPAuthLR =
false;
205 bool HasSwiftAsyncContext =
false;
208 int SwiftAsyncContextFrameIdx = std::numeric_limits<int>::max();
210 bool IsMTETagged =
false;
214 bool IsSVECC =
false;
217 bool HasStreamingModeChanges =
false;
220 mutable std::optional<bool> NeedsDwarfUnwindInfo;
223 mutable std::optional<bool> NeedsAsyncDwarfUnwindInfo;
225 int64_t StackProbeSize = 0;
232 bool PStateSMRegUsed =
false;
236 unsigned PredicateRegForFillSpill = 0;
249 bool SMESaveBufferUsed =
false;
267 PredicateRegForFillSpill =
Reg;
270 return PredicateRegForFillSpill;
289 ArgumentStackToRestore = bytes;
294 TailCallReservedStack = bytes;
300 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;
400 SVECalleeSavedStackSize =
Size;
401 HasSVECalleeSavedStackSize =
true;
404 assert(HasSVECalleeSavedStackSize &&
405 "SVECalleeSavedStackSize has not been calculated");
406 return SVECalleeSavedStackSize;
410 MinSVECSFrameIndex = Min;
411 MaxSVECSFrameIndex = Max;
419 return NumLocalDynamicTLSAccesses;
422 std::optional<bool>
hasRedZone()
const {
return HasRedZone; }
444 return StackHazardSlotIndex != std::numeric_limits<int>::max();
448 assert(StackHazardSlotIndex == std::numeric_limits<int>::max());
449 StackHazardSlotIndex =
Index;
453 assert(StackHazardCSRSlotIndex == std::numeric_limits<int>::max());
454 StackHazardCSRSlotIndex =
Index;
463 return JumpTableEntryInfo[
Idx].first;
466 return JumpTableEntryInfo[
Idx].second;
469 if ((
unsigned)
Idx >= JumpTableEntryInfo.size())
470 JumpTableEntryInfo.resize(
Idx+1);
471 JumpTableEntryInfo[
Idx] = std::make_pair(
Size, PCRelSym);
489 : Kind(Kind), Args(Args.begin(), Args.end()) {
510 size_t InitialSize = LOHContainerSet.
size();
511 erase_if(LOHContainerSet, [&](
const auto &
D) {
512 return any_of(
D.getArgs(), [&](
auto *Arg) { return MIs.contains(Arg); });
519 return InitialSize - LOHContainerSet.
size();
523 return ForwardedMustTailRegParms;
527 return TaggedBasePointerIndex;
532 return TaggedBasePointerOffset;
535 TaggedBasePointerOffset =
Offset;
539 return CalleeSaveBaseToFrameRecordOffset;
542 CalleeSaveBaseToFrameRecordOffset =
Offset;
564 HasSwiftAsyncContext = HasContext;
569 SwiftAsyncContextFrameIdx = FI;
578 HasStreamingModeChanges = HasChanges;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Analysis containing CSE Info
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
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.
void setPStateSMRegUsed(bool Used=true)
bool needsShadowCallStackPrologueEpilogue(MachineFunction &MF) const
bool branchTargetEnforcement() const
void setHasStackFrame(bool s)
void setSwiftAsyncContextFrameIdx(int FI)
unsigned getTailCallReservedStack() const
unsigned getCalleeSavedStackSize(const MachineFrameInfo &MFI) const
unsigned getVarArgsFPRSize() const
void setCalleeSaveBaseToFrameRecordOffset(int Offset)
void setVarArgsStackOffset(unsigned Offset)
bool hasStackProbing() const
void setVarArgsStackIndex(int Index)
unsigned getArgumentStackToRestore() const
TPIDR2Object & getTPIDR2Obj()
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()
int getMaxSVECSFrameIndex() const
void setIsSplitCSR(bool s)
int getVarArgsFPRIndex() const
bool hasStreamingModeChanges() const
bool shouldSignReturnAddress(const MachineFunction &MF) 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)
uint64_t getStackSizeSVE() const
void setHasSwiftAsyncContext(bool HasContext)
bool branchProtectionPAuthLR() const
void setPStateSMReg(Register Reg)
void setHasRedZone(bool s)
bool hasStackFrame() const
int getStackHazardCSRSlotIndex() const
void setVarArgsFPRSize(unsigned Size)
std::optional< int > getTaggedBasePointerIndex() const
unsigned getVarArgsStackOffset() const
SMEAttrs getSMEFnAttrs() const
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
void setStackSizeSVE(uint64_t S)
MCSymbol * getJumpTableEntryPCRelSymbol(int Idx) const
bool isStackRealigned() const
Register getPStateSMReg() 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
void setSMESaveBufferUsed(bool Used=true)
void setSRetReturnReg(unsigned Reg)
void setStackHazardCSRSlotIndex(int Index)
void setSMESaveBufferAddr(Register Reg)
int getSwiftAsyncContextFrameIdx() const
unsigned getPredicateRegForFillSpill() const
bool hasCalculatedStackSizeSVE() const
void setSVECalleeSavedStackSize(unsigned Size)
std::optional< std::string > getOutliningStyle() const
unsigned getBytesInStackArgArea() const
Register getSMESaveBufferAddr() const
void initializeBaseYamlFields(const yaml::AArch64FunctionInfo &YamlMFI)
const MILOHContainer & getLOHContainer() const
void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym)
unsigned isSMESaveBufferUsed() const
unsigned getSVECalleeSavedStackSize() const
int getMinSVECSFrameIndex() 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
void setArgumentStackToRestore(unsigned bytes)
void setMinMaxSVECSFrameIndex(int Min, int Max)
void setHasStreamingModeChanges(bool HasChanges)
unsigned getCalleeSavedStackSize() const
bool hasCalleeSaveStackFreeSpace() const
bool shouldSignWithBKey() const
unsigned isPStateSMRegUsed() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Allocate memory in an ever growing pool, as if by bump-pointer.
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.
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 remove_if(UnaryPredicate P)
Remove elements that match the given predicate.
void insert_range(Range &&R)
bool contains(ConstPtrType Ptr) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
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.
MCLOHType
Linker Optimization Hint Type.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
std::optional< bool > HasRedZone
std::optional< uint64_t > StackSizeSVE
~AArch64FunctionInfo()=default
AArch64FunctionInfo()=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)