13#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
14#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
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;
233 unsigned PredicateRegForFillSpill = 0;
240 Register EarlyAllocSMESaveBuffer = AArch64::NoRegister;
250 bool SMESaveBufferUsed =
false;
261 EarlyAllocSMESaveBuffer =
Ptr;
265 return EarlyAllocSMESaveBuffer;
276 PredicateRegForFillSpill =
Reg;
279 return PredicateRegForFillSpill;
295 ArgumentStackToRestore = bytes;
300 TailCallReservedStack = bytes;
306 HasCalculatedStackSizeSVE =
true;
322 return CalleeSaveStackHasFreeSpace;
325 CalleeSaveStackHasFreeSpace = s;
335 return OutliningStyle;
339 CalleeSavedStackSize =
Size;
340 HasCalleeSavedStackSize =
true;
349 bool ValidateCalleeSavedStackSize =
false;
355 ValidateCalleeSavedStackSize = HasCalleeSavedStackSize;
358 if (!HasCalleeSavedStackSize || ValidateCalleeSavedStackSize) {
363 int64_t MinOffset = std::numeric_limits<int64_t>::max();
364 int64_t MaxOffset = std::numeric_limits<int64_t>::min();
366 int FrameIdx =
Info.getFrameIdx();
371 MinOffset = std::min<int64_t>(
Offset, MinOffset);
372 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
375 if (SwiftAsyncContextFrameIdx != std::numeric_limits<int>::max()) {
378 MinOffset = std::min<int64_t>(
Offset, MinOffset);
379 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
382 if (StackHazardCSRSlotIndex != std::numeric_limits<int>::max()) {
384 int64_t ObjSize = MFI.
getObjectSize(StackHazardCSRSlotIndex);
385 MinOffset = std::min<int64_t>(
Offset, MinOffset);
386 MaxOffset = std::max<int64_t>(
Offset + ObjSize, MaxOffset);
389 unsigned Size =
alignTo(MaxOffset - MinOffset, 16);
391 "Invalid size calculated for callee saves");
399 assert(HasCalleeSavedStackSize &&
400 "CalleeSavedStackSize has not been calculated");
401 return CalleeSavedStackSize;
406 SVECalleeSavedStackSize =
Size;
407 HasSVECalleeSavedStackSize =
true;
410 assert(HasSVECalleeSavedStackSize &&
411 "SVECalleeSavedStackSize has not been calculated");
412 return SVECalleeSavedStackSize;
416 MinSVECSFrameIndex = Min;
417 MaxSVECSFrameIndex = Max;
425 return NumLocalDynamicTLSAccesses;
428 std::optional<bool>
hasRedZone()
const {
return HasRedZone; }
450 return StackHazardSlotIndex != std::numeric_limits<int>::max();
454 assert(StackHazardSlotIndex == std::numeric_limits<int>::max());
455 StackHazardSlotIndex = Index;
459 assert(StackHazardCSRSlotIndex == std::numeric_limits<int>::max());
460 StackHazardCSRSlotIndex = Index;
469 return JumpTableEntryInfo[Idx].first;
472 return JumpTableEntryInfo[Idx].second;
475 if ((
unsigned)Idx >= JumpTableEntryInfo.size())
476 JumpTableEntryInfo.resize(Idx+1);
477 JumpTableEntryInfo[Idx] = std::make_pair(
Size, PCRelSym);
495 : Kind(Kind), Args(Args.begin(), Args.end()) {
511 LOHRelated.insert_range(Args);
516 size_t InitialSize = LOHContainerSet.size();
517 erase_if(LOHContainerSet, [&](
const auto &
D) {
518 return any_of(
D.getArgs(), [&](
auto *Arg) { return MIs.contains(Arg); });
524 LOHRelated.remove_if([&](
auto *
MI) {
return MIs.
contains(
MI); });
525 return InitialSize - LOHContainerSet.size();
529 return ForwardedMustTailRegParms;
533 return TaggedBasePointerIndex;
538 return TaggedBasePointerOffset;
541 TaggedBasePointerOffset =
Offset;
545 return CalleeSaveBaseToFrameRecordOffset;
548 CalleeSaveBaseToFrameRecordOffset =
Offset;
570 HasSwiftAsyncContext = HasContext;
575 SwiftAsyncContextFrameIdx = FI;
584 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
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
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
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)
MILOHDirective::LOHArgs MILOHArgs
bool hasStackFrame() const
int getStackHazardCSRSlotIndex() const
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
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
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
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.
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(const char *Key, T &Val)
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.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
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)
This class should be specialized by any type that needs to be converted to/from a YAML mapping.