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