xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
10b57cec5SDimitry Andric //=- AArch64MachineFunctionInfo.h - AArch64 machine function info -*- C++ -*-=//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file declares AArch64-specific per-machine-function information.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "llvm/ADT/ArrayRef.h"
170b57cec5SDimitry Andric #include "llvm/ADT/Optional.h"
180b57cec5SDimitry Andric #include "llvm/ADT/SmallPtrSet.h"
190b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h"
200b57cec5SDimitry Andric #include "llvm/CodeGen/CallingConvLower.h"
215ffd83dbSDimitry Andric #include "llvm/CodeGen/MIRYamlMapping.h"
220b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h"
238bcb0991SDimitry Andric #include "llvm/IR/Function.h"
240b57cec5SDimitry Andric #include "llvm/MC/MCLinkerOptimizationHint.h"
250b57cec5SDimitry Andric #include <cassert>
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric namespace llvm {
280b57cec5SDimitry Andric 
295ffd83dbSDimitry Andric namespace yaml {
305ffd83dbSDimitry Andric struct AArch64FunctionInfo;
315ffd83dbSDimitry Andric } // end namespace yaml
325ffd83dbSDimitry Andric 
330b57cec5SDimitry Andric class MachineInstr;
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric /// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
360b57cec5SDimitry Andric /// contains private AArch64-specific information for each MachineFunction.
370b57cec5SDimitry Andric class AArch64FunctionInfo final : public MachineFunctionInfo {
38*e8d8bef9SDimitry Andric   /// Backreference to the machine function.
39*e8d8bef9SDimitry Andric   MachineFunction &MF;
40*e8d8bef9SDimitry Andric 
410b57cec5SDimitry Andric   /// Number of bytes of arguments this function has on the stack. If the callee
420b57cec5SDimitry Andric   /// is expected to restore the argument stack this should be a multiple of 16,
430b57cec5SDimitry Andric   /// all usable during a tail call.
440b57cec5SDimitry Andric   ///
450b57cec5SDimitry Andric   /// The alternative would forbid tail call optimisation in some cases: if we
460b57cec5SDimitry Andric   /// want to transfer control from a function with 8-bytes of stack-argument
470b57cec5SDimitry Andric   /// space to a function with 16-bytes then misalignment of this value would
480b57cec5SDimitry Andric   /// make a stack adjustment necessary, which could not be undone by the
490b57cec5SDimitry Andric   /// callee.
500b57cec5SDimitry Andric   unsigned BytesInStackArgArea = 0;
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric   /// The number of bytes to restore to deallocate space for incoming
530b57cec5SDimitry Andric   /// arguments. Canonically 0 in the C calling convention, but non-zero when
540b57cec5SDimitry Andric   /// callee is expected to pop the args.
550b57cec5SDimitry Andric   unsigned ArgumentStackToRestore = 0;
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric   /// HasStackFrame - True if this function has a stack frame. Set by
580b57cec5SDimitry Andric   /// determineCalleeSaves().
590b57cec5SDimitry Andric   bool HasStackFrame = false;
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   /// Amount of stack frame size, not including callee-saved registers.
62480093f4SDimitry Andric   uint64_t LocalStackSize = 0;
63480093f4SDimitry Andric 
64480093f4SDimitry Andric   /// The start and end frame indices for the SVE callee saves.
65480093f4SDimitry Andric   int MinSVECSFrameIndex = 0;
66480093f4SDimitry Andric   int MaxSVECSFrameIndex = 0;
670b57cec5SDimitry Andric 
680b57cec5SDimitry Andric   /// Amount of stack frame size used for saving callee-saved registers.
69480093f4SDimitry Andric   unsigned CalleeSavedStackSize = 0;
70480093f4SDimitry Andric   unsigned SVECalleeSavedStackSize = 0;
71480093f4SDimitry Andric   bool HasCalleeSavedStackSize = false;
720b57cec5SDimitry Andric 
730b57cec5SDimitry Andric   /// Number of TLS accesses using the special (combinable)
740b57cec5SDimitry Andric   /// _TLS_MODULE_BASE_ symbol.
750b57cec5SDimitry Andric   unsigned NumLocalDynamicTLSAccesses = 0;
760b57cec5SDimitry Andric 
770b57cec5SDimitry Andric   /// FrameIndex for start of varargs area for arguments passed on the
780b57cec5SDimitry Andric   /// stack.
790b57cec5SDimitry Andric   int VarArgsStackIndex = 0;
800b57cec5SDimitry Andric 
810b57cec5SDimitry Andric   /// FrameIndex for start of varargs area for arguments passed in
820b57cec5SDimitry Andric   /// general purpose registers.
830b57cec5SDimitry Andric   int VarArgsGPRIndex = 0;
840b57cec5SDimitry Andric 
850b57cec5SDimitry Andric   /// Size of the varargs area for arguments passed in general purpose
860b57cec5SDimitry Andric   /// registers.
870b57cec5SDimitry Andric   unsigned VarArgsGPRSize = 0;
880b57cec5SDimitry Andric 
890b57cec5SDimitry Andric   /// FrameIndex for start of varargs area for arguments passed in
900b57cec5SDimitry Andric   /// floating-point registers.
910b57cec5SDimitry Andric   int VarArgsFPRIndex = 0;
920b57cec5SDimitry Andric 
930b57cec5SDimitry Andric   /// Size of the varargs area for arguments passed in floating-point
940b57cec5SDimitry Andric   /// registers.
950b57cec5SDimitry Andric   unsigned VarArgsFPRSize = 0;
960b57cec5SDimitry Andric 
970b57cec5SDimitry Andric   /// True if this function has a subset of CSRs that is handled explicitly via
980b57cec5SDimitry Andric   /// copies.
990b57cec5SDimitry Andric   bool IsSplitCSR = false;
1000b57cec5SDimitry Andric 
1010b57cec5SDimitry Andric   /// True when the stack gets realigned dynamically because the size of stack
1020b57cec5SDimitry Andric   /// frame is unknown at compile time. e.g., in case of VLAs.
1030b57cec5SDimitry Andric   bool StackRealigned = false;
1040b57cec5SDimitry Andric 
1050b57cec5SDimitry Andric   /// True when the callee-save stack area has unused gaps that may be used for
1060b57cec5SDimitry Andric   /// other stack allocations.
1070b57cec5SDimitry Andric   bool CalleeSaveStackHasFreeSpace = false;
1080b57cec5SDimitry Andric 
1090b57cec5SDimitry Andric   /// SRetReturnReg - sret lowering includes returning the value of the
1100b57cec5SDimitry Andric   /// returned struct in a register. This field holds the virtual register into
1110b57cec5SDimitry Andric   /// which the sret argument is passed.
1120b57cec5SDimitry Andric   unsigned SRetReturnReg = 0;
1138bcb0991SDimitry Andric   /// SVE stack size (for predicates and data vectors) are maintained here
1148bcb0991SDimitry Andric   /// rather than in FrameInfo, as the placement and Stack IDs are target
1158bcb0991SDimitry Andric   /// specific.
1168bcb0991SDimitry Andric   uint64_t StackSizeSVE = 0;
1178bcb0991SDimitry Andric 
1188bcb0991SDimitry Andric   /// HasCalculatedStackSizeSVE indicates whether StackSizeSVE is valid.
1198bcb0991SDimitry Andric   bool HasCalculatedStackSizeSVE = false;
1200b57cec5SDimitry Andric 
1210b57cec5SDimitry Andric   /// Has a value when it is known whether or not the function uses a
1220b57cec5SDimitry Andric   /// redzone, and no value otherwise.
1230b57cec5SDimitry Andric   /// Initialized during frame lowering, unless the function has the noredzone
1240b57cec5SDimitry Andric   /// attribute, in which case it is set to false at construction.
1250b57cec5SDimitry Andric   Optional<bool> HasRedZone;
1260b57cec5SDimitry Andric 
1270b57cec5SDimitry Andric   /// ForwardedMustTailRegParms - A list of virtual and physical registers
1280b57cec5SDimitry Andric   /// that must be forwarded to every musttail call.
1290b57cec5SDimitry Andric   SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
1300b57cec5SDimitry Andric 
131*e8d8bef9SDimitry Andric   /// FrameIndex for the tagged base pointer.
132*e8d8bef9SDimitry Andric   Optional<int> TaggedBasePointerIndex;
133*e8d8bef9SDimitry Andric 
134*e8d8bef9SDimitry Andric   /// Offset from SP-at-entry to the tagged base pointer.
135*e8d8bef9SDimitry Andric   /// Tagged base pointer is set up to point to the first (lowest address)
136*e8d8bef9SDimitry Andric   /// tagged stack slot.
137*e8d8bef9SDimitry Andric   unsigned TaggedBasePointerOffset;
1380b57cec5SDimitry Andric 
1395ffd83dbSDimitry Andric   /// OutliningStyle denotes, if a function was outined, how it was outlined,
1405ffd83dbSDimitry Andric   /// e.g. Tail Call, Thunk, or Function if none apply.
1415ffd83dbSDimitry Andric   Optional<std::string> OutliningStyle;
1425ffd83dbSDimitry Andric 
143*e8d8bef9SDimitry Andric   // Offset from SP-after-callee-saved-spills (i.e. SP-at-entry minus
144*e8d8bef9SDimitry Andric   // CalleeSavedStackSize) to the address of the frame record.
145*e8d8bef9SDimitry Andric   int CalleeSaveBaseToFrameRecordOffset = 0;
146*e8d8bef9SDimitry Andric 
147*e8d8bef9SDimitry Andric   /// SignReturnAddress is true if PAC-RET is enabled for the function with
148*e8d8bef9SDimitry Andric   /// defaults being sign non-leaf functions only, with the B key.
149*e8d8bef9SDimitry Andric   bool SignReturnAddress = false;
150*e8d8bef9SDimitry Andric 
151*e8d8bef9SDimitry Andric   /// SignReturnAddressAll modifies the default PAC-RET mode to signing leaf
152*e8d8bef9SDimitry Andric   /// functions as well.
153*e8d8bef9SDimitry Andric   bool SignReturnAddressAll = false;
154*e8d8bef9SDimitry Andric 
155*e8d8bef9SDimitry Andric   /// SignWithBKey modifies the default PAC-RET mode to signing with the B key.
156*e8d8bef9SDimitry Andric   bool SignWithBKey = false;
157*e8d8bef9SDimitry Andric 
158*e8d8bef9SDimitry Andric   /// BranchTargetEnforcement enables placing BTI instructions at potential
159*e8d8bef9SDimitry Andric   /// indirect branch destinations.
160*e8d8bef9SDimitry Andric   bool BranchTargetEnforcement = false;
161*e8d8bef9SDimitry Andric 
1620b57cec5SDimitry Andric public:
163*e8d8bef9SDimitry Andric   explicit AArch64FunctionInfo(MachineFunction &MF);
1640b57cec5SDimitry Andric 
1655ffd83dbSDimitry Andric   void initializeBaseYamlFields(const yaml::AArch64FunctionInfo &YamlMFI);
1660b57cec5SDimitry Andric 
1670b57cec5SDimitry Andric   unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
1680b57cec5SDimitry Andric   void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; }
1690b57cec5SDimitry Andric 
1700b57cec5SDimitry Andric   unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
1710b57cec5SDimitry Andric   void setArgumentStackToRestore(unsigned bytes) {
1720b57cec5SDimitry Andric     ArgumentStackToRestore = bytes;
1730b57cec5SDimitry Andric   }
1740b57cec5SDimitry Andric 
1758bcb0991SDimitry Andric   bool hasCalculatedStackSizeSVE() const { return HasCalculatedStackSizeSVE; }
1768bcb0991SDimitry Andric 
1778bcb0991SDimitry Andric   void setStackSizeSVE(uint64_t S) {
1788bcb0991SDimitry Andric     HasCalculatedStackSizeSVE = true;
1798bcb0991SDimitry Andric     StackSizeSVE = S;
1808bcb0991SDimitry Andric   }
1818bcb0991SDimitry Andric 
1828bcb0991SDimitry Andric   uint64_t getStackSizeSVE() const { return StackSizeSVE; }
1838bcb0991SDimitry Andric 
1840b57cec5SDimitry Andric   bool hasStackFrame() const { return HasStackFrame; }
1850b57cec5SDimitry Andric   void setHasStackFrame(bool s) { HasStackFrame = s; }
1860b57cec5SDimitry Andric 
1870b57cec5SDimitry Andric   bool isStackRealigned() const { return StackRealigned; }
1880b57cec5SDimitry Andric   void setStackRealigned(bool s) { StackRealigned = s; }
1890b57cec5SDimitry Andric 
1900b57cec5SDimitry Andric   bool hasCalleeSaveStackFreeSpace() const {
1910b57cec5SDimitry Andric     return CalleeSaveStackHasFreeSpace;
1920b57cec5SDimitry Andric   }
1930b57cec5SDimitry Andric   void setCalleeSaveStackHasFreeSpace(bool s) {
1940b57cec5SDimitry Andric     CalleeSaveStackHasFreeSpace = s;
1950b57cec5SDimitry Andric   }
1960b57cec5SDimitry Andric   bool isSplitCSR() const { return IsSplitCSR; }
1970b57cec5SDimitry Andric   void setIsSplitCSR(bool s) { IsSplitCSR = s; }
1980b57cec5SDimitry Andric 
199480093f4SDimitry Andric   void setLocalStackSize(uint64_t Size) { LocalStackSize = Size; }
200480093f4SDimitry Andric   uint64_t getLocalStackSize() const { return LocalStackSize; }
2010b57cec5SDimitry Andric 
2025ffd83dbSDimitry Andric   void setOutliningStyle(std::string Style) { OutliningStyle = Style; }
2035ffd83dbSDimitry Andric   Optional<std::string> getOutliningStyle() const { return OutliningStyle; }
2045ffd83dbSDimitry Andric 
205480093f4SDimitry Andric   void setCalleeSavedStackSize(unsigned Size) {
206480093f4SDimitry Andric     CalleeSavedStackSize = Size;
207480093f4SDimitry Andric     HasCalleeSavedStackSize = true;
208480093f4SDimitry Andric   }
209480093f4SDimitry Andric 
210480093f4SDimitry Andric   // When CalleeSavedStackSize has not been set (for example when
211480093f4SDimitry Andric   // some MachineIR pass is run in isolation), then recalculate
212480093f4SDimitry Andric   // the CalleeSavedStackSize directly from the CalleeSavedInfo.
213480093f4SDimitry Andric   // Note: This information can only be recalculated after PEI
214480093f4SDimitry Andric   // has assigned offsets to the callee save objects.
215480093f4SDimitry Andric   unsigned getCalleeSavedStackSize(const MachineFrameInfo &MFI) const {
216480093f4SDimitry Andric     bool ValidateCalleeSavedStackSize = false;
217480093f4SDimitry Andric 
218480093f4SDimitry Andric #ifndef NDEBUG
219480093f4SDimitry Andric     // Make sure the calculated size derived from the CalleeSavedInfo
220480093f4SDimitry Andric     // equals the cached size that was calculated elsewhere (e.g. in
221480093f4SDimitry Andric     // determineCalleeSaves).
222480093f4SDimitry Andric     ValidateCalleeSavedStackSize = HasCalleeSavedStackSize;
223480093f4SDimitry Andric #endif
224480093f4SDimitry Andric 
225480093f4SDimitry Andric     if (!HasCalleeSavedStackSize || ValidateCalleeSavedStackSize) {
226480093f4SDimitry Andric       assert(MFI.isCalleeSavedInfoValid() && "CalleeSavedInfo not calculated");
227480093f4SDimitry Andric       if (MFI.getCalleeSavedInfo().empty())
228480093f4SDimitry Andric         return 0;
229480093f4SDimitry Andric 
230480093f4SDimitry Andric       int64_t MinOffset = std::numeric_limits<int64_t>::max();
231480093f4SDimitry Andric       int64_t MaxOffset = std::numeric_limits<int64_t>::min();
232480093f4SDimitry Andric       for (const auto &Info : MFI.getCalleeSavedInfo()) {
233480093f4SDimitry Andric         int FrameIdx = Info.getFrameIdx();
234480093f4SDimitry Andric         if (MFI.getStackID(FrameIdx) != TargetStackID::Default)
235480093f4SDimitry Andric           continue;
236480093f4SDimitry Andric         int64_t Offset = MFI.getObjectOffset(FrameIdx);
237480093f4SDimitry Andric         int64_t ObjSize = MFI.getObjectSize(FrameIdx);
238480093f4SDimitry Andric         MinOffset = std::min<int64_t>(Offset, MinOffset);
239480093f4SDimitry Andric         MaxOffset = std::max<int64_t>(Offset + ObjSize, MaxOffset);
240480093f4SDimitry Andric       }
241480093f4SDimitry Andric 
242480093f4SDimitry Andric       unsigned Size = alignTo(MaxOffset - MinOffset, 16);
243480093f4SDimitry Andric       assert((!HasCalleeSavedStackSize || getCalleeSavedStackSize() == Size) &&
244480093f4SDimitry Andric              "Invalid size calculated for callee saves");
245480093f4SDimitry Andric       return Size;
246480093f4SDimitry Andric     }
247480093f4SDimitry Andric 
248480093f4SDimitry Andric     return getCalleeSavedStackSize();
249480093f4SDimitry Andric   }
250480093f4SDimitry Andric 
251480093f4SDimitry Andric   unsigned getCalleeSavedStackSize() const {
252480093f4SDimitry Andric     assert(HasCalleeSavedStackSize &&
253480093f4SDimitry Andric            "CalleeSavedStackSize has not been calculated");
254480093f4SDimitry Andric     return CalleeSavedStackSize;
255480093f4SDimitry Andric   }
256480093f4SDimitry Andric 
257480093f4SDimitry Andric   // Saves the CalleeSavedStackSize for SVE vectors in 'scalable bytes'
258480093f4SDimitry Andric   void setSVECalleeSavedStackSize(unsigned Size) {
259480093f4SDimitry Andric     SVECalleeSavedStackSize = Size;
260480093f4SDimitry Andric   }
261480093f4SDimitry Andric   unsigned getSVECalleeSavedStackSize() const {
262480093f4SDimitry Andric     return SVECalleeSavedStackSize;
263480093f4SDimitry Andric   }
264480093f4SDimitry Andric 
265480093f4SDimitry Andric   void setMinMaxSVECSFrameIndex(int Min, int Max) {
266480093f4SDimitry Andric     MinSVECSFrameIndex = Min;
267480093f4SDimitry Andric     MaxSVECSFrameIndex = Max;
268480093f4SDimitry Andric   }
269480093f4SDimitry Andric 
270480093f4SDimitry Andric   int getMinSVECSFrameIndex() const { return MinSVECSFrameIndex; }
271480093f4SDimitry Andric   int getMaxSVECSFrameIndex() const { return MaxSVECSFrameIndex; }
2720b57cec5SDimitry Andric 
2730b57cec5SDimitry Andric   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
2740b57cec5SDimitry Andric   unsigned getNumLocalDynamicTLSAccesses() const {
2750b57cec5SDimitry Andric     return NumLocalDynamicTLSAccesses;
2760b57cec5SDimitry Andric   }
2770b57cec5SDimitry Andric 
2780b57cec5SDimitry Andric   Optional<bool> hasRedZone() const { return HasRedZone; }
2790b57cec5SDimitry Andric   void setHasRedZone(bool s) { HasRedZone = s; }
2800b57cec5SDimitry Andric 
2810b57cec5SDimitry Andric   int getVarArgsStackIndex() const { return VarArgsStackIndex; }
2820b57cec5SDimitry Andric   void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
2830b57cec5SDimitry Andric 
2840b57cec5SDimitry Andric   int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
2850b57cec5SDimitry Andric   void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
2860b57cec5SDimitry Andric 
2870b57cec5SDimitry Andric   unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
2880b57cec5SDimitry Andric   void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
2890b57cec5SDimitry Andric 
2900b57cec5SDimitry Andric   int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
2910b57cec5SDimitry Andric   void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
2920b57cec5SDimitry Andric 
2930b57cec5SDimitry Andric   unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
2940b57cec5SDimitry Andric   void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
2950b57cec5SDimitry Andric 
2960b57cec5SDimitry Andric   unsigned getSRetReturnReg() const { return SRetReturnReg; }
2970b57cec5SDimitry Andric   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
2980b57cec5SDimitry Andric 
2990b57cec5SDimitry Andric   unsigned getJumpTableEntrySize(int Idx) const {
300*e8d8bef9SDimitry Andric     return JumpTableEntryInfo[Idx].first;
3010b57cec5SDimitry Andric   }
3020b57cec5SDimitry Andric   MCSymbol *getJumpTableEntryPCRelSymbol(int Idx) const {
303*e8d8bef9SDimitry Andric     return JumpTableEntryInfo[Idx].second;
3040b57cec5SDimitry Andric   }
3050b57cec5SDimitry Andric   void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym) {
306*e8d8bef9SDimitry Andric     if ((unsigned)Idx >= JumpTableEntryInfo.size())
307*e8d8bef9SDimitry Andric       JumpTableEntryInfo.resize(Idx+1);
3080b57cec5SDimitry Andric     JumpTableEntryInfo[Idx] = std::make_pair(Size, PCRelSym);
3090b57cec5SDimitry Andric   }
3100b57cec5SDimitry Andric 
3110b57cec5SDimitry Andric   using SetOfInstructions = SmallPtrSet<const MachineInstr *, 16>;
3120b57cec5SDimitry Andric 
3130b57cec5SDimitry Andric   const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
3140b57cec5SDimitry Andric 
3150b57cec5SDimitry Andric   // Shortcuts for LOH related types.
3160b57cec5SDimitry Andric   class MILOHDirective {
3170b57cec5SDimitry Andric     MCLOHType Kind;
3180b57cec5SDimitry Andric 
3190b57cec5SDimitry Andric     /// Arguments of this directive. Order matters.
3200b57cec5SDimitry Andric     SmallVector<const MachineInstr *, 3> Args;
3210b57cec5SDimitry Andric 
3220b57cec5SDimitry Andric   public:
3230b57cec5SDimitry Andric     using LOHArgs = ArrayRef<const MachineInstr *>;
3240b57cec5SDimitry Andric 
3250b57cec5SDimitry Andric     MILOHDirective(MCLOHType Kind, LOHArgs Args)
3260b57cec5SDimitry Andric         : Kind(Kind), Args(Args.begin(), Args.end()) {
3270b57cec5SDimitry Andric       assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
3280b57cec5SDimitry Andric     }
3290b57cec5SDimitry Andric 
3300b57cec5SDimitry Andric     MCLOHType getKind() const { return Kind; }
3310b57cec5SDimitry Andric     LOHArgs getArgs() const { return Args; }
3320b57cec5SDimitry Andric   };
3330b57cec5SDimitry Andric 
3340b57cec5SDimitry Andric   using MILOHArgs = MILOHDirective::LOHArgs;
3350b57cec5SDimitry Andric   using MILOHContainer = SmallVector<MILOHDirective, 32>;
3360b57cec5SDimitry Andric 
3370b57cec5SDimitry Andric   const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
3380b57cec5SDimitry Andric 
3390b57cec5SDimitry Andric   /// Add a LOH directive of this @p Kind and this @p Args.
3400b57cec5SDimitry Andric   void addLOHDirective(MCLOHType Kind, MILOHArgs Args) {
3410b57cec5SDimitry Andric     LOHContainerSet.push_back(MILOHDirective(Kind, Args));
3420b57cec5SDimitry Andric     LOHRelated.insert(Args.begin(), Args.end());
3430b57cec5SDimitry Andric   }
3440b57cec5SDimitry Andric 
3450b57cec5SDimitry Andric   SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
3460b57cec5SDimitry Andric     return ForwardedMustTailRegParms;
3470b57cec5SDimitry Andric   }
3480b57cec5SDimitry Andric 
349*e8d8bef9SDimitry Andric   Optional<int> getTaggedBasePointerIndex() const {
350*e8d8bef9SDimitry Andric     return TaggedBasePointerIndex;
351*e8d8bef9SDimitry Andric   }
352*e8d8bef9SDimitry Andric   void setTaggedBasePointerIndex(int Index) { TaggedBasePointerIndex = Index; }
353*e8d8bef9SDimitry Andric 
3540b57cec5SDimitry Andric   unsigned getTaggedBasePointerOffset() const {
3550b57cec5SDimitry Andric     return TaggedBasePointerOffset;
3560b57cec5SDimitry Andric   }
3570b57cec5SDimitry Andric   void setTaggedBasePointerOffset(unsigned Offset) {
3580b57cec5SDimitry Andric     TaggedBasePointerOffset = Offset;
3590b57cec5SDimitry Andric   }
3600b57cec5SDimitry Andric 
361*e8d8bef9SDimitry Andric   int getCalleeSaveBaseToFrameRecordOffset() const {
362*e8d8bef9SDimitry Andric     return CalleeSaveBaseToFrameRecordOffset;
363*e8d8bef9SDimitry Andric   }
364*e8d8bef9SDimitry Andric   void setCalleeSaveBaseToFrameRecordOffset(int Offset) {
365*e8d8bef9SDimitry Andric     CalleeSaveBaseToFrameRecordOffset = Offset;
366*e8d8bef9SDimitry Andric   }
367*e8d8bef9SDimitry Andric 
368*e8d8bef9SDimitry Andric   bool shouldSignReturnAddress() const;
369*e8d8bef9SDimitry Andric   bool shouldSignReturnAddress(bool SpillsLR) const;
370*e8d8bef9SDimitry Andric 
371*e8d8bef9SDimitry Andric   bool shouldSignWithBKey() const { return SignWithBKey; }
372*e8d8bef9SDimitry Andric 
373*e8d8bef9SDimitry Andric   bool branchTargetEnforcement() const { return BranchTargetEnforcement; }
374*e8d8bef9SDimitry Andric 
3750b57cec5SDimitry Andric private:
3760b57cec5SDimitry Andric   // Hold the lists of LOHs.
3770b57cec5SDimitry Andric   MILOHContainer LOHContainerSet;
3780b57cec5SDimitry Andric   SetOfInstructions LOHRelated;
3790b57cec5SDimitry Andric 
380*e8d8bef9SDimitry Andric   SmallVector<std::pair<unsigned, MCSymbol *>, 2> JumpTableEntryInfo;
3810b57cec5SDimitry Andric };
3820b57cec5SDimitry Andric 
3835ffd83dbSDimitry Andric namespace yaml {
3845ffd83dbSDimitry Andric struct AArch64FunctionInfo final : public yaml::MachineFunctionInfo {
3855ffd83dbSDimitry Andric   Optional<bool> HasRedZone;
3865ffd83dbSDimitry Andric 
3875ffd83dbSDimitry Andric   AArch64FunctionInfo() = default;
3885ffd83dbSDimitry Andric   AArch64FunctionInfo(const llvm::AArch64FunctionInfo &MFI);
3895ffd83dbSDimitry Andric 
3905ffd83dbSDimitry Andric   void mappingImpl(yaml::IO &YamlIO) override;
3915ffd83dbSDimitry Andric   ~AArch64FunctionInfo() = default;
3925ffd83dbSDimitry Andric };
3935ffd83dbSDimitry Andric 
3945ffd83dbSDimitry Andric template <> struct MappingTraits<AArch64FunctionInfo> {
3955ffd83dbSDimitry Andric   static void mapping(IO &YamlIO, AArch64FunctionInfo &MFI) {
3965ffd83dbSDimitry Andric     YamlIO.mapOptional("hasRedZone", MFI.HasRedZone);
3975ffd83dbSDimitry Andric   }
3985ffd83dbSDimitry Andric };
3995ffd83dbSDimitry Andric 
4005ffd83dbSDimitry Andric } // end namespace yaml
4015ffd83dbSDimitry Andric 
4020b57cec5SDimitry Andric } // end namespace llvm
4030b57cec5SDimitry Andric 
4040b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
405