1 //===-- X86MachineFunctionInfo.h - X86 machine function info ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares X86-specific per-machine-function information.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
15 #define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
17 #include "llvm/CodeGen/CallingConvLower.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/Support/MachineValueType.h"
23 /// X86MachineFunctionInfo - This class is derived from MachineFunction and
24 /// contains private X86 target-specific information for each MachineFunction.
25 class X86MachineFunctionInfo
: public MachineFunctionInfo
{
26 virtual void anchor();
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;
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
38 signed char RestoreBasePointerOffset
= 0;
40 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
41 /// stack frame in bytes.
42 unsigned CalleeSavedFrameSize
= 0;
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;
49 /// ReturnAddrIndex - FrameIndex for return slot.
50 int ReturnAddrIndex
= 0;
52 /// FrameIndex for return slot.
53 int FrameAddrIndex
= 0;
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;
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;
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;
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;
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;
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;
94 /// True if this function has a subset of CSRs that is handled explicitly via
96 bool IsSplitCSR
= false;
98 /// True if this function uses the red zone.
99 bool UsesRedZone
= false;
101 /// True if this function has WIN_ALLOCA instructions.
102 bool HasWinAlloca
= false;
105 /// ForwardedMustTailRegParms - A list of virtual and physical registers
106 /// that must be forwarded to every musttail call.
107 SmallVector
<ForwardedRegister
, 1> ForwardedMustTailRegParms
;
110 X86MachineFunctionInfo() = default;
112 explicit X86MachineFunctionInfo(MachineFunction
&MF
) {}
114 bool getForceFramePointer() const { return ForceFramePointer
;}
115 void setForceFramePointer(bool forceFP
) { ForceFramePointer
= forceFP
; }
117 bool getHasPushSequences() const { return HasPushSequences
; }
118 void setHasPushSequences(bool HasPush
) { HasPushSequences
= HasPush
; }
120 bool getRestoreBasePointer() const { return RestoreBasePointerOffset
!=0; }
121 void setRestoreBasePointer(const MachineFunction
*MF
);
122 int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset
; }
124 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize
; }
125 void setCalleeSavedFrameSize(unsigned bytes
) { CalleeSavedFrameSize
= bytes
; }
127 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn
; }
128 void setBytesToPopOnReturn (unsigned bytes
) { BytesToPopOnReturn
= bytes
;}
130 int getRAIndex() const { return ReturnAddrIndex
; }
131 void setRAIndex(int Index
) { ReturnAddrIndex
= Index
; }
133 int getFAIndex() const { return FrameAddrIndex
; }
134 void setFAIndex(int Index
) { FrameAddrIndex
= Index
; }
136 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta
; }
137 void setTCReturnAddrDelta(int delta
) {TailCallReturnAddrDelta
= delta
;}
139 unsigned getSRetReturnReg() const { return SRetReturnReg
; }
140 void setSRetReturnReg(unsigned Reg
) { SRetReturnReg
= Reg
; }
142 unsigned getGlobalBaseReg() const { return GlobalBaseReg
; }
143 void setGlobalBaseReg(unsigned Reg
) { GlobalBaseReg
= Reg
; }
145 int getVarArgsFrameIndex() const { return VarArgsFrameIndex
; }
146 void setVarArgsFrameIndex(int Idx
) { VarArgsFrameIndex
= Idx
; }
148 int getRegSaveFrameIndex() const { return RegSaveFrameIndex
; }
149 void setRegSaveFrameIndex(int Idx
) { RegSaveFrameIndex
= Idx
; }
151 unsigned getVarArgsGPOffset() const { return VarArgsGPOffset
; }
152 void setVarArgsGPOffset(unsigned Offset
) { VarArgsGPOffset
= Offset
; }
154 unsigned getVarArgsFPOffset() const { return VarArgsFPOffset
; }
155 void setVarArgsFPOffset(unsigned Offset
) { VarArgsFPOffset
= Offset
; }
157 unsigned getArgumentStackSize() const { return ArgumentStackSize
; }
158 void setArgumentStackSize(unsigned size
) { ArgumentStackSize
= size
; }
160 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics
; }
161 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics
; }
163 bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave
; }
164 void setHasSEHFramePtrSave(bool V
) { HasSEHFramePtrSave
= V
; }
166 int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex
; }
167 void setSEHFramePtrSaveIndex(int Index
) { SEHFramePtrSaveIndex
= Index
; }
169 SmallVectorImpl
<ForwardedRegister
> &getForwardedMustTailRegParms() {
170 return ForwardedMustTailRegParms
;
173 bool isSplitCSR() const { return IsSplitCSR
; }
174 void setIsSplitCSR(bool s
) { IsSplitCSR
= s
; }
176 bool getUsesRedZone() const { return UsesRedZone
; }
177 void setUsesRedZone(bool V
) { UsesRedZone
= V
; }
179 bool hasWinAlloca() const { return HasWinAlloca
; }
180 void setHasWinAlloca(bool v
) { HasWinAlloca
= v
; }
183 } // End llvm namespace