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