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 /// TailCallReturnAddrDelta - The number of bytes by which return address 54 /// stack slot is moved as the result of tail call optimization. 55 int TailCallReturnAddrDelta; 56 57 /// SRetReturnReg - Some subtargets require that sret lowering includes 58 /// returning the value of the returned struct in a register. This field 59 /// holds the virtual register into which the sret argument is passed. 60 unsigned SRetReturnReg; 61 62 /// GlobalBaseReg - keeps track of the virtual register initialized for 63 /// use as the global base register. This is used for PIC in some PIC 64 /// relocation models. 65 unsigned GlobalBaseReg; 66 67 /// VarArgsFrameIndex - FrameIndex for start of varargs area. 68 int VarArgsFrameIndex; 69 /// RegSaveFrameIndex - X86-64 vararg func register save area. 70 int RegSaveFrameIndex; 71 /// VarArgsGPOffset - X86-64 vararg func int reg offset. 72 unsigned VarArgsGPOffset; 73 /// VarArgsFPOffset - X86-64 vararg func fp reg offset. 74 unsigned VarArgsFPOffset; 75 /// ArgumentStackSize - The number of bytes on stack consumed by the arguments 76 /// being passed on the stack. 77 unsigned ArgumentStackSize; 78 /// NumLocalDynamics - Number of local-dynamic TLS accesses. 79 unsigned NumLocalDynamics; 80 /// HasPushSequences - Keeps track of whether this function uses sequences 81 /// of pushes to pass function parameters. 82 bool HasPushSequences; 83 84 private: 85 /// ForwardedMustTailRegParms - A list of virtual and physical registers 86 /// that must be forwarded to every musttail call. 87 SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms; 88 89 public: 90 X86MachineFunctionInfo() : ForceFramePointer(false), 91 RestoreBasePointerOffset(0), 92 CalleeSavedFrameSize(0), 93 BytesToPopOnReturn(0), 94 ReturnAddrIndex(0), 95 TailCallReturnAddrDelta(0), 96 SRetReturnReg(0), 97 GlobalBaseReg(0), 98 VarArgsFrameIndex(0), 99 RegSaveFrameIndex(0), 100 VarArgsGPOffset(0), 101 VarArgsFPOffset(0), 102 ArgumentStackSize(0), 103 NumLocalDynamics(0), 104 HasPushSequences(false) {} 105 106 explicit X86MachineFunctionInfo(MachineFunction &MF) 107 : ForceFramePointer(false), 108 RestoreBasePointerOffset(0), 109 CalleeSavedFrameSize(0), 110 BytesToPopOnReturn(0), 111 ReturnAddrIndex(0), 112 TailCallReturnAddrDelta(0), 113 SRetReturnReg(0), 114 GlobalBaseReg(0), 115 VarArgsFrameIndex(0), 116 RegSaveFrameIndex(0), 117 VarArgsGPOffset(0), 118 VarArgsFPOffset(0), 119 ArgumentStackSize(0), 120 NumLocalDynamics(0), 121 HasPushSequences(false) {} 122 123 bool getForceFramePointer() const { return ForceFramePointer;} 124 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; } 125 126 bool getHasPushSequences() const { return HasPushSequences; } 127 void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; } 128 129 bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; } 130 void setRestoreBasePointer(const MachineFunction *MF); 131 int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; } 132 133 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; } 134 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; } 135 136 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; } 137 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;} 138 139 int getRAIndex() const { return ReturnAddrIndex; } 140 void setRAIndex(int Index) { ReturnAddrIndex = Index; } 141 142 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; } 143 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;} 144 145 unsigned getSRetReturnReg() const { return SRetReturnReg; } 146 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } 147 148 unsigned getGlobalBaseReg() const { return GlobalBaseReg; } 149 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; } 150 151 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 152 void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; } 153 154 int getRegSaveFrameIndex() const { return RegSaveFrameIndex; } 155 void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; } 156 157 unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; } 158 void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; } 159 160 unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; } 161 void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; } 162 163 unsigned getArgumentStackSize() const { return ArgumentStackSize; } 164 void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; } 165 166 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; } 167 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; } 168 169 SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() { 170 return ForwardedMustTailRegParms; 171 } 172 }; 173 174 } // End llvm namespace 175 176 #endif 177