LLVM  8.0.1
X86MachineFunctionInfo.h
Go to the documentation of this file.
1 //===-- X86MachineFunctionInfo.h - X86 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 X86-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
15 #define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
16 
20 
21 namespace llvm {
22 
23 /// X86MachineFunctionInfo - This class is derived from MachineFunction and
24 /// contains private X86 target-specific information for each MachineFunction.
26  virtual void anchor();
27 
28  /// ForceFramePointer - True if the function is required to use of frame
29  /// pointer for reasons other than it containing dynamic allocation or
30  /// that FP eliminatation is turned off. For example, Cygwin main function
31  /// contains stack pointer re-alignment code which requires FP.
32  bool ForceFramePointer = false;
33 
34  /// RestoreBasePointerOffset - Non-zero if the function has base pointer
35  /// and makes call to llvm.eh.sjlj.setjmp. When non-zero, the value is a
36  /// displacement from the frame pointer to a slot where the base pointer
37  /// is stashed.
38  signed char RestoreBasePointerOffset = 0;
39 
40  /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
41  /// stack frame in bytes.
42  unsigned CalleeSavedFrameSize = 0;
43 
44  /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
45  /// to the space used by the return address).
46  /// Used on windows platform for stdcall & fastcall name decoration
47  unsigned BytesToPopOnReturn = 0;
48 
49  /// ReturnAddrIndex - FrameIndex for return slot.
50  int ReturnAddrIndex = 0;
51 
52  /// FrameIndex for return slot.
53  int FrameAddrIndex = 0;
54 
55  /// TailCallReturnAddrDelta - The number of bytes by which return address
56  /// stack slot is moved as the result of tail call optimization.
57  int TailCallReturnAddrDelta = 0;
58 
59  /// SRetReturnReg - Some subtargets require that sret lowering includes
60  /// returning the value of the returned struct in a register. This field
61  /// holds the virtual register into which the sret argument is passed.
62  unsigned SRetReturnReg = 0;
63 
64  /// GlobalBaseReg - keeps track of the virtual register initialized for
65  /// use as the global base register. This is used for PIC in some PIC
66  /// relocation models.
67  unsigned GlobalBaseReg = 0;
68 
69  /// VarArgsFrameIndex - FrameIndex for start of varargs area.
70  int VarArgsFrameIndex = 0;
71  /// RegSaveFrameIndex - X86-64 vararg func register save area.
72  int RegSaveFrameIndex = 0;
73  /// VarArgsGPOffset - X86-64 vararg func int reg offset.
74  unsigned VarArgsGPOffset = 0;
75  /// VarArgsFPOffset - X86-64 vararg func fp reg offset.
76  unsigned VarArgsFPOffset = 0;
77  /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
78  /// being passed on the stack.
79  unsigned ArgumentStackSize = 0;
80  /// NumLocalDynamics - Number of local-dynamic TLS accesses.
81  unsigned NumLocalDynamics = 0;
82  /// HasPushSequences - Keeps track of whether this function uses sequences
83  /// of pushes to pass function parameters.
84  bool HasPushSequences = false;
85 
86  /// True if the function recovers from an SEH exception, and therefore needs
87  /// to spill and restore the frame pointer.
88  bool HasSEHFramePtrSave = false;
89 
90  /// The frame index of a stack object containing the original frame pointer
91  /// used to address arguments in a function using a base pointer.
92  int SEHFramePtrSaveIndex = 0;
93 
94  /// True if this function has a subset of CSRs that is handled explicitly via
95  /// copies.
96  bool IsSplitCSR = false;
97 
98  /// True if this function uses the red zone.
99  bool UsesRedZone = false;
100 
101  /// True if this function has WIN_ALLOCA instructions.
102  bool HasWinAlloca = false;
103 
104 private:
105  /// ForwardedMustTailRegParms - A list of virtual and physical registers
106  /// that must be forwarded to every musttail call.
107  SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
108 
109 public:
110  X86MachineFunctionInfo() = default;
111 
113 
114  bool getForceFramePointer() const { return ForceFramePointer;}
115  void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
116 
117  bool getHasPushSequences() const { return HasPushSequences; }
118  void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
119 
120  bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; }
121  void setRestoreBasePointer(const MachineFunction *MF);
122  int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; }
123 
124  unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
125  void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
126 
127  unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
128  void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
129 
130  int getRAIndex() const { return ReturnAddrIndex; }
131  void setRAIndex(int Index) { ReturnAddrIndex = Index; }
132 
133  int getFAIndex() const { return FrameAddrIndex; }
134  void setFAIndex(int Index) { FrameAddrIndex = Index; }
135 
136  int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
137  void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
138 
139  unsigned getSRetReturnReg() const { return SRetReturnReg; }
140  void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
141 
142  unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
143  void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
144 
145  int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
146  void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
147 
148  int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
149  void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
150 
151  unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
152  void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
153 
154  unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
155  void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
156 
157  unsigned getArgumentStackSize() const { return ArgumentStackSize; }
158  void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
159 
160  unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
161  void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
162 
163  bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; }
164  void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; }
165 
166  int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; }
167  void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; }
168 
170  return ForwardedMustTailRegParms;
171  }
172 
173  bool isSplitCSR() const { return IsSplitCSR; }
174  void setIsSplitCSR(bool s) { IsSplitCSR = s; }
175 
176  bool getUsesRedZone() const { return UsesRedZone; }
177  void setUsesRedZone(bool V) { UsesRedZone = V; }
178 
179  bool hasWinAlloca() const { return HasWinAlloca; }
180  void setHasWinAlloca(bool v) { HasWinAlloca = v; }
181 };
182 
183 } // End llvm namespace
184 
185 #endif
void setVarArgsFPOffset(unsigned Offset)
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned Reg
void setCalleeSavedFrameSize(unsigned bytes)
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
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 setVarArgsGPOffset(unsigned Offset)
void setBytesToPopOnReturn(unsigned bytes)
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
Definition: STLExtras.h:1167
void setRestoreBasePointer(const MachineFunction *MF)
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
unsigned getNumLocalDynamicTLSAccesses() const
SmallVectorImpl< ForwardedRegister > & getForwardedMustTailRegParms()
void setArgumentStackSize(unsigned size)
X86MachineFunctionInfo(MachineFunction &MF)