1 //===-- X86MachineFuctionInfo.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 #include <vector>
21 
22 namespace llvm {
23 
24 /// X86MachineFunctionInfo - This class is derived from MachineFunction and
25 /// contains private X86 target-specific information for each MachineFunction.
26 class X86MachineFunctionInfo : public MachineFunctionInfo {
27   virtual void anchor();
28 
29   /// ForceFramePointer - True if the function is required to use of frame
30   /// pointer for reasons other than it containing dynamic allocation or
31   /// that FP eliminatation is turned off. For example, Cygwin main function
32   /// contains stack pointer re-alignment code which requires FP.
33   bool ForceFramePointer;
34 
35   /// RestoreBasePointerOffset - Non-zero if the function has base pointer
36   /// and makes call to llvm.eh.sjlj.setjmp. When non-zero, the value is a
37   /// displacement from the frame pointer to a slot where the base pointer
38   /// is stashed.
39   signed char RestoreBasePointerOffset;
40 
41   /// CalleeSavedFrameSize - Size of the callee-saved register portion of the
42   /// stack frame in bytes.
43   unsigned CalleeSavedFrameSize;
44 
45   /// BytesToPopOnReturn - Number of bytes function pops on return (in addition
46   /// to the space used by the return address).
47   /// Used on windows platform for stdcall & fastcall name decoration
48   unsigned BytesToPopOnReturn;
49 
50   /// ReturnAddrIndex - FrameIndex for return slot.
51   int ReturnAddrIndex;
52 
53   /// \brief FrameIndex for return slot.
54   int FrameAddrIndex;
55 
56   /// TailCallReturnAddrDelta - The number of bytes by which return address
57   /// stack slot is moved as the result of tail call optimization.
58   int TailCallReturnAddrDelta;
59 
60   /// SRetReturnReg - Some subtargets require that sret lowering includes
61   /// returning the value of the returned struct in a register. This field
62   /// holds the virtual register into which the sret argument is passed.
63   unsigned SRetReturnReg;
64 
65   /// GlobalBaseReg - keeps track of the virtual register initialized for
66   /// use as the global base register. This is used for PIC in some PIC
67   /// relocation models.
68   unsigned GlobalBaseReg;
69 
70   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
71   int VarArgsFrameIndex;
72   /// RegSaveFrameIndex - X86-64 vararg func register save area.
73   int RegSaveFrameIndex;
74   /// VarArgsGPOffset - X86-64 vararg func int reg offset.
75   unsigned VarArgsGPOffset;
76   /// VarArgsFPOffset - X86-64 vararg func fp reg offset.
77   unsigned VarArgsFPOffset;
78   /// ArgumentStackSize - The number of bytes on stack consumed by the arguments
79   /// being passed on the stack.
80   unsigned ArgumentStackSize;
81   /// NumLocalDynamics - Number of local-dynamic TLS accesses.
82   unsigned NumLocalDynamics;
83   /// HasPushSequences - Keeps track of whether this function uses sequences
84   /// of pushes to pass function parameters.
85   bool HasPushSequences;
86 
87 private:
88   /// ForwardedMustTailRegParms - A list of virtual and physical registers
89   /// that must be forwarded to every musttail call.
90   SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
91 
92 public:
X86MachineFunctionInfo()93   X86MachineFunctionInfo() : ForceFramePointer(false),
94                              RestoreBasePointerOffset(0),
95                              CalleeSavedFrameSize(0),
96                              BytesToPopOnReturn(0),
97                              ReturnAddrIndex(0),
98                              FrameAddrIndex(0),
99                              TailCallReturnAddrDelta(0),
100                              SRetReturnReg(0),
101                              GlobalBaseReg(0),
102                              VarArgsFrameIndex(0),
103                              RegSaveFrameIndex(0),
104                              VarArgsGPOffset(0),
105                              VarArgsFPOffset(0),
106                              ArgumentStackSize(0),
107                              NumLocalDynamics(0),
108                              HasPushSequences(false) {}
109 
X86MachineFunctionInfo(MachineFunction & MF)110   explicit X86MachineFunctionInfo(MachineFunction &MF)
111     : ForceFramePointer(false),
112       RestoreBasePointerOffset(0),
113       CalleeSavedFrameSize(0),
114       BytesToPopOnReturn(0),
115       ReturnAddrIndex(0),
116       FrameAddrIndex(0),
117       TailCallReturnAddrDelta(0),
118       SRetReturnReg(0),
119       GlobalBaseReg(0),
120       VarArgsFrameIndex(0),
121       RegSaveFrameIndex(0),
122       VarArgsGPOffset(0),
123       VarArgsFPOffset(0),
124       ArgumentStackSize(0),
125       NumLocalDynamics(0),
126       HasPushSequences(false) {}
127 
getForceFramePointer()128   bool getForceFramePointer() const { return ForceFramePointer;}
setForceFramePointer(bool forceFP)129   void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
130 
getHasPushSequences()131   bool getHasPushSequences() const { return HasPushSequences; }
setHasPushSequences(bool HasPush)132   void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
133 
getRestoreBasePointer()134   bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; }
135   void setRestoreBasePointer(const MachineFunction *MF);
getRestoreBasePointerOffset()136   int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; }
137 
getCalleeSavedFrameSize()138   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
setCalleeSavedFrameSize(unsigned bytes)139   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
140 
getBytesToPopOnReturn()141   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
setBytesToPopOnReturn(unsigned bytes)142   void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}
143 
getRAIndex()144   int getRAIndex() const { return ReturnAddrIndex; }
setRAIndex(int Index)145   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
146 
getFAIndex()147   int getFAIndex() const { return FrameAddrIndex; }
setFAIndex(int Index)148   void setFAIndex(int Index) { FrameAddrIndex = Index; }
149 
getTCReturnAddrDelta()150   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
setTCReturnAddrDelta(int delta)151   void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;}
152 
getSRetReturnReg()153   unsigned getSRetReturnReg() const { return SRetReturnReg; }
setSRetReturnReg(unsigned Reg)154   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
155 
getGlobalBaseReg()156   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
setGlobalBaseReg(unsigned Reg)157   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
158 
getVarArgsFrameIndex()159   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
setVarArgsFrameIndex(int Idx)160   void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
161 
getRegSaveFrameIndex()162   int getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
setRegSaveFrameIndex(int Idx)163   void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; }
164 
getVarArgsGPOffset()165   unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; }
setVarArgsGPOffset(unsigned Offset)166   void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; }
167 
getVarArgsFPOffset()168   unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; }
setVarArgsFPOffset(unsigned Offset)169   void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; }
170 
getArgumentStackSize()171   unsigned getArgumentStackSize() const { return ArgumentStackSize; }
setArgumentStackSize(unsigned size)172   void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
173 
getNumLocalDynamicTLSAccesses()174   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
incNumLocalDynamicTLSAccesses()175   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
176 
getForwardedMustTailRegParms()177   SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
178     return ForwardedMustTailRegParms;
179   }
180 };
181 
182 } // End llvm namespace
183 
184 #endif
185