/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
Line | Count | Source |
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 | 456k | explicit AArch64FunctionInfo(MachineFunction &MF) { |
97 | 456k | (void)MF; |
98 | 456k | } |
99 | | |
100 | 223k | unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; } |
101 | 297k | void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; } |
102 | | |
103 | 440k | unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; } |
104 | 21 | void setArgumentStackToRestore(unsigned bytes) { |
105 | 21 | ArgumentStackToRestore = bytes; |
106 | 21 | } |
107 | | |
108 | 1.35M | bool hasStackFrame() const { return HasStackFrame; } |
109 | 321k | void setHasStackFrame(bool s) { HasStackFrame = s; } |
110 | | |
111 | 273k | bool isStackRealigned() const { return StackRealigned; } |
112 | 21 | void setStackRealigned(bool s) { StackRealigned = s; } |
113 | | |
114 | 50.0k | bool hasCalleeSaveStackFreeSpace() const { |
115 | 50.0k | return CalleeSaveStackHasFreeSpace; |
116 | 50.0k | } |
117 | 983 | void setCalleeSaveStackHasFreeSpace(bool s) { |
118 | 983 | CalleeSaveStackHasFreeSpace = s; |
119 | 983 | } |
120 | | |
121 | 117 | bool isSplitCSR() const { return IsSplitCSR; } |
122 | 6 | void setIsSplitCSR(bool s) { IsSplitCSR = s; } |
123 | | |
124 | 456k | void setLocalStackSize(unsigned Size) { LocalStackSize = Size; } |
125 | 1.37M | unsigned getLocalStackSize() const { return LocalStackSize; } |
126 | | |
127 | 572k | void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; } |
128 | 4.05M | unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; } |
129 | | |
130 | 8 | void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; } |
131 | 9.30k | unsigned getNumLocalDynamicTLSAccesses() const { |
132 | 9.30k | return NumLocalDynamicTLSAccesses; |
133 | 9.30k | } |
134 | | |
135 | 141 | int getVarArgsStackIndex() const { return VarArgsStackIndex; } |
136 | 194 | void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; } |
137 | | |
138 | 11 | int getVarArgsGPRIndex() const { return VarArgsGPRIndex; } |
139 | 19 | void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; } |
140 | | |
141 | 130 | unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; } |
142 | 19 | void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; } |
143 | | |
144 | 4 | int getVarArgsFPRIndex() const { return VarArgsFPRIndex; } |
145 | 6 | void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; } |
146 | | |
147 | 5 | unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; } |
148 | 6 | void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; } |
149 | | |
150 | | using SetOfInstructions = SmallPtrSet<const MachineInstr *, 16>; |
151 | | |
152 | 24.1M | 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 | 1.23M | : Kind(Kind), Args(Args.begin(), Args.end()) { |
166 | 1.23M | assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!"); |
167 | 1.23M | } |
168 | | |
169 | 1.23M | MCLOHType getKind() const { return Kind; } |
170 | 1.23M | LOHArgs getArgs() const { return Args; } |
171 | | }; |
172 | | |
173 | | using MILOHArgs = MILOHDirective::LOHArgs; |
174 | | using MILOHContainer = SmallVector<MILOHDirective, 32>; |
175 | | |
176 | 261k | const MILOHContainer &getLOHContainer() const { return LOHContainerSet; } |
177 | | |
178 | | /// Add a LOH directive of this @p Kind and this @p Args. |
179 | 1.23M | void addLOHDirective(MCLOHType Kind, MILOHArgs Args) { |
180 | 1.23M | LOHContainerSet.push_back(MILOHDirective(Kind, Args)); |
181 | 1.23M | LOHRelated.insert(Args.begin(), Args.end()); |
182 | 1.23M | } |
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 |