]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/X86/X86MachineFunctionInfo.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / X86 / X86MachineFunctionInfo.h
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
16 #include "llvm/CodeGen/CallingConvLower.h"
17 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/Support/MachineValueType.h"
19
20 namespace llvm {
21
22 /// X86MachineFunctionInfo - This class is derived from MachineFunction and
23 /// contains private X86 target-specific information for each MachineFunction.
24 class X86MachineFunctionInfo : public MachineFunctionInfo {
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   /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
40   /// stack frame in bytes.
41   unsigned CalleeSavedFrameSize = 0;
42
43   /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
44   /// to the space used by the return address).
45   /// Used on windows platform for stdcall & fastcall name decoration
46   unsigned BytesToPopOnReturn = 0;
47
48   /// ReturnAddrIndex - FrameIndex for return slot.
49   int ReturnAddrIndex = 0;
50
51   /// FrameIndex for return slot.
52   int FrameAddrIndex = 0;
53
54   /// TailCallReturnAddrDelta - The number of bytes by which return address
55   /// stack slot is moved as the result of tail call optimization.
56   int TailCallReturnAddrDelta = 0;
57
58   /// SRetReturnReg - Some subtargets require that sret lowering includes
59   /// returning the value of the returned struct in a register. This field
60   /// holds the virtual register into which the sret argument is passed.
61   unsigned SRetReturnReg = 0;
62
63   /// GlobalBaseReg - keeps track of the virtual register initialized for
64   /// use as the global base register. This is used for PIC in some PIC
65   /// relocation models.
66   unsigned GlobalBaseReg = 0;
67
68   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
69   int VarArgsFrameIndex = 0;
70   /// RegSaveFrameIndex - X86-64 vararg func register save area.
71   int RegSaveFrameIndex = 0;
72   /// VarArgsGPOffset - X86-64 vararg func int reg offset.
73   unsigned VarArgsGPOffset = 0;
74   /// VarArgsFPOffset - X86-64 vararg func fp reg offset.
75   unsigned VarArgsFPOffset = 0;
76   /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
77   /// being passed on the stack.
78   unsigned ArgumentStackSize = 0;
79   /// NumLocalDynamics - Number of local-dynamic TLS accesses.
80   unsigned NumLocalDynamics = 0;
81   /// HasPushSequences - Keeps track of whether this function uses sequences
82   /// of pushes to pass function parameters.
83   bool HasPushSequences = false;
84
85   /// True if the function recovers from an SEH exception, and therefore needs
86   /// to spill and restore the frame pointer.
87   bool HasSEHFramePtrSave = false;
88
89   /// The frame index of a stack object containing the original frame pointer
90   /// used to address arguments in a function using a base pointer.
91   int SEHFramePtrSaveIndex = 0;
92
93   /// True if this function has a subset of CSRs that is handled explicitly via
94   /// copies.
95   bool IsSplitCSR = false;
96
97   /// True if this function uses the red zone.
98   bool UsesRedZone = false;
99
100   /// True if this function has WIN_ALLOCA instructions.
101   bool HasWinAlloca = false;
102
103 private:
104   /// ForwardedMustTailRegParms - A list of virtual and physical registers
105   /// that must be forwarded to every musttail call.
106   SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
107
108 public:
109   X86MachineFunctionInfo() = default;
110
111   explicit X86MachineFunctionInfo(MachineFunction &MF) {}
112
113   bool getForceFramePointer() const { return ForceFramePointer;}
114   void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
115
116   bool getHasPushSequences() const { return HasPushSequences; }
117   void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
118
119   bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; }
120   void setRestoreBasePointer(const MachineFunction *MF);
121   int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; }
122
123   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
124   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
125
126   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
127   void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
128
129   int getRAIndex() const { return ReturnAddrIndex; }
130   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
131
132   int getFAIndex() const { return FrameAddrIndex; }
133   void setFAIndex(int Index) { FrameAddrIndex = Index; }
134
135   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
136   void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
137
138   unsigned getSRetReturnReg() const { return SRetReturnReg; }
139   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
140
141   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
142   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
143
144   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
145   void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
146
147   int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
148   void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
149
150   unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
151   void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
152
153   unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
154   void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
155
156   unsigned getArgumentStackSize() const { return ArgumentStackSize; }
157   void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
158
159   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
160   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
161
162   bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; }
163   void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; }
164
165   int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; }
166   void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; }
167
168   SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
169     return ForwardedMustTailRegParms;
170   }
171
172   bool isSplitCSR() const { return IsSplitCSR; }
173   void setIsSplitCSR(bool s) { IsSplitCSR = s; }
174
175   bool getUsesRedZone() const { return UsesRedZone; }
176   void setUsesRedZone(bool V) { UsesRedZone = V; }
177
178   bool hasWinAlloca() const { return HasWinAlloca; }
179   void setHasWinAlloca(bool v) { HasWinAlloca = v; }
180 };
181
182 } // End llvm namespace
183
184 #endif