]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
Upgrade Unbound to 1.6.2. More to follow.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AArch64 / AArch64MachineFunctionInfo.h
1 //=- AArch64MachineFunctionInfo.h - AArch64 machine function info -*- C++ -*-=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares AArch64-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
15 #define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
16
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallPtrSet.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/MC/MCLinkerOptimizationHint.h"
22 #include <cassert>
23
24 namespace llvm {
25
26 class MachineInstr;
27
28 /// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
29 /// contains private AArch64-specific information for each MachineFunction.
30 class AArch64FunctionInfo final : public MachineFunctionInfo {
31   /// Number of bytes of arguments this function has on the stack. If the callee
32   /// is expected to restore the argument stack this should be a multiple of 16,
33   /// all usable during a tail call.
34   ///
35   /// The alternative would forbid tail call optimisation in some cases: if we
36   /// want to transfer control from a function with 8-bytes of stack-argument
37   /// space to a function with 16-bytes then misalignment of this value would
38   /// make a stack adjustment necessary, which could not be undone by the
39   /// callee.
40   unsigned BytesInStackArgArea = 0;
41
42   /// The number of bytes to restore to deallocate space for incoming
43   /// arguments. Canonically 0 in the C calling convention, but non-zero when
44   /// callee is expected to pop the args.
45   unsigned ArgumentStackToRestore = 0;
46
47   /// HasStackFrame - True if this function has a stack frame. Set by
48   /// determineCalleeSaves().
49   bool HasStackFrame = false;
50
51   /// \brief Amount of stack frame size, not including callee-saved registers.
52   unsigned LocalStackSize;
53
54   /// \brief Amount of stack frame size used for saving callee-saved registers.
55   unsigned CalleeSavedStackSize;
56
57   /// \brief Number of TLS accesses using the special (combinable)
58   /// _TLS_MODULE_BASE_ symbol.
59   unsigned NumLocalDynamicTLSAccesses = 0;
60
61   /// \brief FrameIndex for start of varargs area for arguments passed on the
62   /// stack.
63   int VarArgsStackIndex = 0;
64
65   /// \brief FrameIndex for start of varargs area for arguments passed in
66   /// general purpose registers.
67   int VarArgsGPRIndex = 0;
68
69   /// \brief Size of the varargs area for arguments passed in general purpose
70   /// registers.
71   unsigned VarArgsGPRSize = 0;
72
73   /// \brief FrameIndex for start of varargs area for arguments passed in
74   /// floating-point registers.
75   int VarArgsFPRIndex = 0;
76
77   /// \brief Size of the varargs area for arguments passed in floating-point
78   /// registers.
79   unsigned VarArgsFPRSize = 0;
80
81   /// True if this function has a subset of CSRs that is handled explicitly via
82   /// copies.
83   bool IsSplitCSR = false;
84
85   /// True when the stack gets realigned dynamically because the size of stack
86   /// frame is unknown at compile time. e.g., in case of VLAs.
87   bool StackRealigned = false;
88
89   /// True when the callee-save stack area has unused gaps that may be used for
90   /// other stack allocations.
91   bool CalleeSaveStackHasFreeSpace = false;
92
93 public:
94   AArch64FunctionInfo() = default;
95
96   explicit AArch64FunctionInfo(MachineFunction &MF) {
97     (void)MF;
98   }
99
100   unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
101   void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; }
102
103   unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
104   void setArgumentStackToRestore(unsigned bytes) {
105     ArgumentStackToRestore = bytes;
106   }
107
108   bool hasStackFrame() const { return HasStackFrame; }
109   void setHasStackFrame(bool s) { HasStackFrame = s; }
110
111   bool isStackRealigned() const { return StackRealigned; }
112   void setStackRealigned(bool s) { StackRealigned = s; }
113
114   bool hasCalleeSaveStackFreeSpace() const {
115     return CalleeSaveStackHasFreeSpace;
116   }
117   void setCalleeSaveStackHasFreeSpace(bool s) {
118     CalleeSaveStackHasFreeSpace = s;
119   }
120
121   bool isSplitCSR() const { return IsSplitCSR; }
122   void setIsSplitCSR(bool s) { IsSplitCSR = s; }
123
124   void setLocalStackSize(unsigned Size) { LocalStackSize = Size; }
125   unsigned getLocalStackSize() const { return LocalStackSize; }
126
127   void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
128   unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
129
130   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
131   unsigned getNumLocalDynamicTLSAccesses() const {
132     return NumLocalDynamicTLSAccesses;
133   }
134
135   int getVarArgsStackIndex() const { return VarArgsStackIndex; }
136   void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
137
138   int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
139   void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
140
141   unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
142   void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
143
144   int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
145   void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
146
147   unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
148   void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
149
150   using SetOfInstructions = SmallPtrSet<const MachineInstr *, 16>;
151
152   const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
153
154   // Shortcuts for LOH related types.
155   class MILOHDirective {
156     MCLOHType Kind;
157
158     /// Arguments of this directive. Order matters.
159     SmallVector<const MachineInstr *, 3> Args;
160
161   public:
162     using LOHArgs = ArrayRef<const MachineInstr *>;
163
164     MILOHDirective(MCLOHType Kind, LOHArgs Args)
165         : Kind(Kind), Args(Args.begin(), Args.end()) {
166       assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
167     }
168
169     MCLOHType getKind() const { return Kind; }
170     LOHArgs getArgs() const { return Args; }
171   };
172
173   using MILOHArgs = MILOHDirective::LOHArgs;
174   using MILOHContainer = SmallVector<MILOHDirective, 32>;
175
176   const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
177
178   /// Add a LOH directive of this @p Kind and this @p Args.
179   void addLOHDirective(MCLOHType Kind, MILOHArgs Args) {
180     LOHContainerSet.push_back(MILOHDirective(Kind, Args));
181     LOHRelated.insert(Args.begin(), Args.end());
182   }
183
184 private:
185   // Hold the lists of LOHs.
186   MILOHContainer LOHContainerSet;
187   SetOfInstructions LOHRelated;
188 };
189
190 } // end namespace llvm
191
192 #endif // LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H