LLVM  6.0.0svn
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 class MachineInstr;
27 
28 /// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
29 /// contains private AArch64-specific information for each MachineFunction.
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 
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 
115  return CalleeSaveStackHasFreeSpace;
116  }
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 
151 
152  const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
153 
154  // Shortcuts for LOH related types.
156  MCLOHType Kind;
157 
158  /// Arguments of this directive. Order matters.
160 
161  public:
163 
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 
175 
176  const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
177 
178  /// Add a LOH directive of this @p Kind and this @p 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
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:244
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:235
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
iterator begin() const
Definition: ArrayRef.h:137
const SetOfInstructions & getLOHRelated() 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
MCLOHType
Linker Optimization Hint Type.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:864
iterator end() const
Definition: ArrayRef.h:138
const MILOHContainer & getLOHContainer() const
static bool isValidMCLOHType(unsigned Kind)
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void setCalleeSavedStackSize(unsigned Size)