LLVM  8.0.1
AArch64MachineFunctionInfo.h
Go to the documentation of this file.
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/Optional.h"
19 #include "llvm/ADT/SmallPtrSet.h"
20 #include "llvm/ADT/SmallVector.h"
24 #include <cassert>
25 
26 namespace llvm {
27 
28 class MachineInstr;
29 
30 /// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
31 /// contains private AArch64-specific information for each MachineFunction.
33  /// Number of bytes of arguments this function has on the stack. If the callee
34  /// is expected to restore the argument stack this should be a multiple of 16,
35  /// all usable during a tail call.
36  ///
37  /// The alternative would forbid tail call optimisation in some cases: if we
38  /// want to transfer control from a function with 8-bytes of stack-argument
39  /// space to a function with 16-bytes then misalignment of this value would
40  /// make a stack adjustment necessary, which could not be undone by the
41  /// callee.
42  unsigned BytesInStackArgArea = 0;
43 
44  /// The number of bytes to restore to deallocate space for incoming
45  /// arguments. Canonically 0 in the C calling convention, but non-zero when
46  /// callee is expected to pop the args.
47  unsigned ArgumentStackToRestore = 0;
48 
49  /// HasStackFrame - True if this function has a stack frame. Set by
50  /// determineCalleeSaves().
51  bool HasStackFrame = false;
52 
53  /// Amount of stack frame size, not including callee-saved registers.
54  unsigned LocalStackSize;
55 
56  /// Amount of stack frame size used for saving callee-saved registers.
57  unsigned CalleeSavedStackSize;
58 
59  /// Number of TLS accesses using the special (combinable)
60  /// _TLS_MODULE_BASE_ symbol.
61  unsigned NumLocalDynamicTLSAccesses = 0;
62 
63  /// FrameIndex for start of varargs area for arguments passed on the
64  /// stack.
65  int VarArgsStackIndex = 0;
66 
67  /// FrameIndex for start of varargs area for arguments passed in
68  /// general purpose registers.
69  int VarArgsGPRIndex = 0;
70 
71  /// Size of the varargs area for arguments passed in general purpose
72  /// registers.
73  unsigned VarArgsGPRSize = 0;
74 
75  /// FrameIndex for start of varargs area for arguments passed in
76  /// floating-point registers.
77  int VarArgsFPRIndex = 0;
78 
79  /// Size of the varargs area for arguments passed in floating-point
80  /// registers.
81  unsigned VarArgsFPRSize = 0;
82 
83  /// True if this function has a subset of CSRs that is handled explicitly via
84  /// copies.
85  bool IsSplitCSR = false;
86 
87  /// True when the stack gets realigned dynamically because the size of stack
88  /// frame is unknown at compile time. e.g., in case of VLAs.
89  bool StackRealigned = false;
90 
91  /// True when the callee-save stack area has unused gaps that may be used for
92  /// other stack allocations.
93  bool CalleeSaveStackHasFreeSpace = false;
94 
95  /// Has a value when it is known whether or not the function uses a
96  /// redzone, and no value otherwise.
97  /// Initialized during frame lowering, unless the function has the noredzone
98  /// attribute, in which case it is set to false at construction.
99  Optional<bool> HasRedZone;
100 
101  /// ForwardedMustTailRegParms - A list of virtual and physical registers
102  /// that must be forwarded to every musttail call.
103  SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
104 public:
105  AArch64FunctionInfo() = default;
106 
108  (void)MF;
109 
110  // If we already know that the function doesn't have a redzone, set
111  // HasRedZone here.
113  HasRedZone = false;
114  }
115 
116  unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
117  void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; }
118 
119  unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
120  void setArgumentStackToRestore(unsigned bytes) {
121  ArgumentStackToRestore = bytes;
122  }
123 
124  bool hasStackFrame() const { return HasStackFrame; }
125  void setHasStackFrame(bool s) { HasStackFrame = s; }
126 
127  bool isStackRealigned() const { return StackRealigned; }
128  void setStackRealigned(bool s) { StackRealigned = s; }
129 
131  return CalleeSaveStackHasFreeSpace;
132  }
134  CalleeSaveStackHasFreeSpace = s;
135  }
136 
137  bool isSplitCSR() const { return IsSplitCSR; }
138  void setIsSplitCSR(bool s) { IsSplitCSR = s; }
139 
140  void setLocalStackSize(unsigned Size) { LocalStackSize = Size; }
141  unsigned getLocalStackSize() const { return LocalStackSize; }
142 
143  void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
144  unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
145 
146  void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
147  unsigned getNumLocalDynamicTLSAccesses() const {
148  return NumLocalDynamicTLSAccesses;
149  }
150 
151  Optional<bool> hasRedZone() const { return HasRedZone; }
152  void setHasRedZone(bool s) { HasRedZone = s; }
153 
154  int getVarArgsStackIndex() const { return VarArgsStackIndex; }
155  void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
156 
157  int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
158  void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
159 
160  unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
161  void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
162 
163  int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
164  void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
165 
166  unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
167  void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
168 
169  unsigned getJumpTableEntrySize(int Idx) const {
170  auto It = JumpTableEntryInfo.find(Idx);
171  if (It != JumpTableEntryInfo.end())
172  return It->second.first;
173  return 4;
174  }
176  return JumpTableEntryInfo.find(Idx)->second.second;
177  }
178  void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym) {
179  JumpTableEntryInfo[Idx] = std::make_pair(Size, PCRelSym);
180  }
181 
183 
184  const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
185 
186  // Shortcuts for LOH related types.
188  MCLOHType Kind;
189 
190  /// Arguments of this directive. Order matters.
192 
193  public:
195 
197  : Kind(Kind), Args(Args.begin(), Args.end()) {
198  assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
199  }
200 
201  MCLOHType getKind() const { return Kind; }
202  LOHArgs getArgs() const { return Args; }
203  };
204 
207 
208  const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
209 
210  /// Add a LOH directive of this @p Kind and this @p Args.
212  LOHContainerSet.push_back(MILOHDirective(Kind, Args));
213  LOHRelated.insert(Args.begin(), Args.end());
214  }
215 
217  return ForwardedMustTailRegParms;
218  }
219 
220 private:
221  // Hold the lists of LOHs.
222  MILOHContainer LOHContainerSet;
223  SetOfInstructions LOHRelated;
224 
226 };
227 
228 } // end namespace llvm
229 
230 #endif // LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:259
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:250
This class represents lattice values for constants.
Definition: AllocatorList.h:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
iterator begin() const
Definition: ArrayRef.h:137
unsigned getJumpTableEntrySize(int Idx) const
const SetOfInstructions & getLOHRelated() const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:321
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
void setArgumentStackToRestore(unsigned bytes)
AArch64FunctionInfo(MachineFunction &MF)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym)
MCLOHType
Linker Optimization Hint Type.
SmallVectorImpl< ForwardedRegister > & getForwardedMustTailRegParms()
MCSymbol * getJumpTableEntryPCRelSymbol(int Idx) const
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
iterator end() const
Definition: ArrayRef.h:138
const Function & getFunction() const
Return the LLVM function that this machine code represents.
Optional< bool > hasRedZone() const
const MILOHContainer & getLOHContainer() const
static bool isValidMCLOHType(unsigned Kind)
uint32_t Size
Definition: Profile.cpp:47
void setBytesInStackArgArea(unsigned bytes)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void addLOHDirective(MCLOHType Kind, MILOHArgs Args)
Add a LOH directive of this Kind and this Args.
void setCalleeSavedStackSize(unsigned Size)