LLVM  4.0.0
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/SmallPtrSet.h"
19 #include "llvm/ADT/SmallVector.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.
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 
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 
113  return CalleeSaveStackHasFreeSpace;
114  }
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 
149 
150  const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
151 
152  // Shortcuts for LOH related types.
154  MCLOHType Kind;
155 
156  /// Arguments of this directive. Order matters.
158 
159  public:
161 
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 
173 
174  const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
175 
176  /// Add a LOH directive of this @p Kind and this @p 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
SmallVector< MILOHDirective, 32 > MILOHContainer
void push_back(const T &Elt)
Definition: SmallVector.h:211
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:241
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
iterator end() const
Definition: ArrayRef.h:130
const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:233
const MILOHContainer & getLOHContainer() const
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
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
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:368
MCLOHType
Linker Optimization Hint Type.
iterator begin() const
Definition: ArrayRef.h:129
const SetOfInstructions & getLOHRelated() const
unsigned getNumLocalDynamicTLSAccesses() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
static bool isValidMCLOHType(unsigned Kind)
void setBytesInStackArgArea(unsigned bytes)
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void addLOHDirective(MCLOHType Kind, MILOHArgs Args)
Add a LOH directive of this Kind and this Args.
SmallPtrSet< const MachineInstr *, 16 > SetOfInstructions
void setCalleeSavedStackSize(unsigned Size)