• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- X86MachineFunctionInfo.h - X86 machine function info ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares X86-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
15 #define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H
16 
17 #include "llvm/CodeGen/CallingConvLower.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/CodeGen/MachineValueType.h"
20 
21 namespace llvm {
22 
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();
27 
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;
33 
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
37   /// is stashed.
38   signed char RestoreBasePointerOffset = 0;
39 
40   /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
41   /// stack frame in bytes.
42   unsigned CalleeSavedFrameSize = 0;
43 
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;
48 
49   /// ReturnAddrIndex - FrameIndex for return slot.
50   int ReturnAddrIndex = 0;
51 
52   /// \brief FrameIndex for return slot.
53   int FrameAddrIndex = 0;
54 
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;
58 
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;
63 
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;
68 
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;
85 
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;
89 
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;
93 
94   /// True if this function has a subset of CSRs that is handled explicitly via
95   /// copies.
96   bool IsSplitCSR = false;
97 
98   /// True if this function uses the red zone.
99   bool UsesRedZone = false;
100 
101   /// True if this function has WIN_ALLOCA instructions.
102   bool HasWinAlloca = false;
103 
104 private:
105   /// ForwardedMustTailRegParms - A list of virtual and physical registers
106   /// that must be forwarded to every musttail call.
107   SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
108 
109 public:
110   X86MachineFunctionInfo() = default;
111 
X86MachineFunctionInfo(MachineFunction & MF)112   explicit X86MachineFunctionInfo(MachineFunction &MF) {}
113 
getForceFramePointer()114   bool getForceFramePointer() const { return ForceFramePointer;}
setForceFramePointer(bool forceFP)115   void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
116 
getHasPushSequences()117   bool getHasPushSequences() const { return HasPushSequences; }
setHasPushSequences(bool HasPush)118   void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
119 
getRestoreBasePointer()120   bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; }
121   void setRestoreBasePointer(const MachineFunction *MF);
getRestoreBasePointerOffset()122   int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; }
123 
getCalleeSavedFrameSize()124   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
setCalleeSavedFrameSize(unsigned bytes)125   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
126 
getBytesToPopOnReturn()127   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
setBytesToPopOnReturn(unsigned bytes)128   void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
129 
getRAIndex()130   int getRAIndex() const { return ReturnAddrIndex; }
setRAIndex(int Index)131   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
132 
getFAIndex()133   int getFAIndex() const { return FrameAddrIndex; }
setFAIndex(int Index)134   void setFAIndex(int Index) { FrameAddrIndex = Index; }
135 
getTCReturnAddrDelta()136   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
setTCReturnAddrDelta(int delta)137   void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
138 
getSRetReturnReg()139   unsigned getSRetReturnReg() const { return SRetReturnReg; }
setSRetReturnReg(unsigned Reg)140   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
141 
getGlobalBaseReg()142   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
setGlobalBaseReg(unsigned Reg)143   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
144 
getVarArgsFrameIndex()145   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
setVarArgsFrameIndex(int Idx)146   void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
147 
getRegSaveFrameIndex()148   int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
setRegSaveFrameIndex(int Idx)149   void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
150 
getVarArgsGPOffset()151   unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
setVarArgsGPOffset(unsigned Offset)152   void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
153 
getVarArgsFPOffset()154   unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
setVarArgsFPOffset(unsigned Offset)155   void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
156 
getArgumentStackSize()157   unsigned getArgumentStackSize() const { return ArgumentStackSize; }
setArgumentStackSize(unsigned size)158   void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
159 
getNumLocalDynamicTLSAccesses()160   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
incNumLocalDynamicTLSAccesses()161   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
162 
getHasSEHFramePtrSave()163   bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; }
setHasSEHFramePtrSave(bool V)164   void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; }
165 
getSEHFramePtrSaveIndex()166   int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; }
setSEHFramePtrSaveIndex(int Index)167   void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; }
168 
getForwardedMustTailRegParms()169   SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
170     return ForwardedMustTailRegParms;
171   }
172 
isSplitCSR()173   bool isSplitCSR() const { return IsSplitCSR; }
setIsSplitCSR(bool s)174   void setIsSplitCSR(bool s) { IsSplitCSR = s; }
175 
getUsesRedZone()176   bool getUsesRedZone() const { return UsesRedZone; }
setUsesRedZone(bool V)177   void setUsesRedZone(bool V) { UsesRedZone = V; }
178 
hasWinAlloca()179   bool hasWinAlloca() const { return HasWinAlloca; }
setHasWinAlloca(bool v)180   void setHasWinAlloca(bool v) { HasWinAlloca = v; }
181 };
182 
183 } // End llvm namespace
184 
185 #endif
186