1 //===-- X86MachineFunctionInfo.h - X86 machine function info ----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file declares X86-specific per-machine-function information.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
14 #define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
16 #include "llvm/CodeGen/CallingConvLower.h"
17 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/Support/MachineValueType.h"
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();
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;
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
37 signed char RestoreBasePointerOffset
= 0;
39 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
40 /// stack frame in bytes.
41 unsigned CalleeSavedFrameSize
= 0;
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;
48 /// ReturnAddrIndex - FrameIndex for return slot.
49 int ReturnAddrIndex
= 0;
51 /// FrameIndex for return slot.
52 int FrameAddrIndex
= 0;
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;
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;
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;
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;
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;
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;
93 /// True if this function has a subset of CSRs that is handled explicitly via
95 bool IsSplitCSR
= false;
97 /// True if this function uses the red zone.
98 bool UsesRedZone
= false;
100 /// True if this function has WIN_ALLOCA instructions.
101 bool HasWinAlloca
= false;
104 /// ForwardedMustTailRegParms - A list of virtual and physical registers
105 /// that must be forwarded to every musttail call.
106 SmallVector
<ForwardedRegister
, 1> ForwardedMustTailRegParms
;
109 X86MachineFunctionInfo() = default;
111 explicit X86MachineFunctionInfo(MachineFunction
&MF
) {}
113 bool getForceFramePointer() const { return ForceFramePointer
;}
114 void setForceFramePointer(bool forceFP
) { ForceFramePointer
= forceFP
; }
116 bool getHasPushSequences() const { return HasPushSequences
; }
117 void setHasPushSequences(bool HasPush
) { HasPushSequences
= HasPush
; }
119 bool getRestoreBasePointer() const { return RestoreBasePointerOffset
!=0; }
120 void setRestoreBasePointer(const MachineFunction
*MF
);
121 int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset
; }
123 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize
; }
124 void setCalleeSavedFrameSize(unsigned bytes
) { CalleeSavedFrameSize
= bytes
; }
126 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn
; }
127 void setBytesToPopOnReturn (unsigned bytes
) { BytesToPopOnReturn
= bytes
;}
129 int getRAIndex() const { return ReturnAddrIndex
; }
130 void setRAIndex(int Index
) { ReturnAddrIndex
= Index
; }
132 int getFAIndex() const { return FrameAddrIndex
; }
133 void setFAIndex(int Index
) { FrameAddrIndex
= Index
; }
135 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta
; }
136 void setTCReturnAddrDelta(int delta
) {TailCallReturnAddrDelta
= delta
;}
138 unsigned getSRetReturnReg() const { return SRetReturnReg
; }
139 void setSRetReturnReg(unsigned Reg
) { SRetReturnReg
= Reg
; }
141 unsigned getGlobalBaseReg() const { return GlobalBaseReg
; }
142 void setGlobalBaseReg(unsigned Reg
) { GlobalBaseReg
= Reg
; }
144 int getVarArgsFrameIndex() const { return VarArgsFrameIndex
; }
145 void setVarArgsFrameIndex(int Idx
) { VarArgsFrameIndex
= Idx
; }
147 int getRegSaveFrameIndex() const { return RegSaveFrameIndex
; }
148 void setRegSaveFrameIndex(int Idx
) { RegSaveFrameIndex
= Idx
; }
150 unsigned getVarArgsGPOffset() const { return VarArgsGPOffset
; }
151 void setVarArgsGPOffset(unsigned Offset
) { VarArgsGPOffset
= Offset
; }
153 unsigned getVarArgsFPOffset() const { return VarArgsFPOffset
; }
154 void setVarArgsFPOffset(unsigned Offset
) { VarArgsFPOffset
= Offset
; }
156 unsigned getArgumentStackSize() const { return ArgumentStackSize
; }
157 void setArgumentStackSize(unsigned size
) { ArgumentStackSize
= size
; }
159 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics
; }
160 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics
; }
162 bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave
; }
163 void setHasSEHFramePtrSave(bool V
) { HasSEHFramePtrSave
= V
; }
165 int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex
; }
166 void setSEHFramePtrSaveIndex(int Index
) { SEHFramePtrSaveIndex
= Index
; }
168 SmallVectorImpl
<ForwardedRegister
> &getForwardedMustTailRegParms() {
169 return ForwardedMustTailRegParms
;
172 bool isSplitCSR() const { return IsSplitCSR
; }
173 void setIsSplitCSR(bool s
) { IsSplitCSR
= s
; }
175 bool getUsesRedZone() const { return UsesRedZone
; }
176 void setUsesRedZone(bool V
) { UsesRedZone
= V
; }
178 bool hasWinAlloca() const { return HasWinAlloca
; }
179 void setHasWinAlloca(bool v
) { HasWinAlloca
= v
; }
182 } // End llvm namespace