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