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/CodeGen/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 /// \brief 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;
102 /// ForwardedMustTailRegParms - A list of virtual and physical registers
103 /// that must be forwarded to every musttail call.
104 SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
107 X86MachineFunctionInfo() = default;
109 explicit X86MachineFunctionInfo(MachineFunction &MF) {}
111 bool getForceFramePointer() const { return ForceFramePointer;}
112 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
114 bool getHasPushSequences() const { return HasPushSequences; }
115 void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
117 bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; }
118 void setRestoreBasePointer(const MachineFunction *MF);
119 int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; }
121 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
122 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
124 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
125 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
127 int getRAIndex() const { return ReturnAddrIndex; }
128 void setRAIndex(int Index) { ReturnAddrIndex = Index; }
130 int getFAIndex() const { return FrameAddrIndex; }
131 void setFAIndex(int Index) { FrameAddrIndex = Index; }
133 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
134 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
136 unsigned getSRetReturnReg() const { return SRetReturnReg; }
137 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
139 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
140 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
142 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
143 void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
145 int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
146 void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
148 unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
149 void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
151 unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
152 void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
154 unsigned getArgumentStackSize() const { return ArgumentStackSize; }
155 void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
157 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
158 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
160 bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; }
161 void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; }
163 int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; }
164 void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; }
166 SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
167 return ForwardedMustTailRegParms;
170 bool isSplitCSR() const { return IsSplitCSR; }
171 void setIsSplitCSR(bool s) { IsSplitCSR = s; }
173 bool getUsesRedZone() const { return UsesRedZone; }
174 void setUsesRedZone(bool V) { UsesRedZone = V; }
177 } // End llvm namespace