1 //===-- X86MachineFunctionInfo.h - X86 machine function info ----*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file declares X86-specific per-machine-function information. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H 14 #define LLVM_LIB_TARGET_X86_X86MACHINEFUNCTIONINFO_H 15 16 #include "llvm/CodeGen/CallingConvLower.h" 17 #include "llvm/CodeGen/MachineFunction.h" 18 #include "llvm/Support/MachineValueType.h" 19 20 namespace llvm { 21 22 /// X86MachineFunctionInfo - This class is derived from MachineFunction and 23 /// contains private X86 target-specific information for each MachineFunction. 24 class X86MachineFunctionInfo : public MachineFunctionInfo { 25 virtual void anchor(); 26 27 /// ForceFramePointer - True if the function is required to use of frame 28 /// pointer for reasons other than it containing dynamic allocation or 29 /// that FP eliminatation is turned off. For example, Cygwin main function 30 /// contains stack pointer re-alignment code which requires FP. 31 bool ForceFramePointer = false; 32 33 /// RestoreBasePointerOffset - Non-zero if the function has base pointer 34 /// and makes call to llvm.eh.sjlj.setjmp. When non-zero, the value is a 35 /// displacement from the frame pointer to a slot where the base pointer 36 /// is stashed. 37 signed char RestoreBasePointerOffset = 0; 38 39 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the 40 /// stack frame in bytes. 41 unsigned CalleeSavedFrameSize = 0; 42 43 /// CalleeSavedXMMFrameSize - Size of the callee-saved XMM register portion 44 /// of the stack frame in bytes. 45 unsigned CalleeSavedXMMFrameSize = 0; 46 47 /// CalleeSavedXMMFrameOrigin - Origin slot of the callee-saved XMM register 48 /// portion of the stack frame. 49 int CalleeSavedXMMFrameOrigin = 0; 50 51 /// BytesToPopOnReturn - Number of bytes function pops on return (in addition 52 /// to the space used by the return address). 53 /// Used on windows platform for stdcall & fastcall name decoration 54 unsigned BytesToPopOnReturn = 0; 55 56 /// ReturnAddrIndex - FrameIndex for return slot. 57 int ReturnAddrIndex = 0; 58 59 /// FrameIndex for return slot. 60 int FrameAddrIndex = 0; 61 62 /// TailCallReturnAddrDelta - The number of bytes by which return address 63 /// stack slot is moved as the result of tail call optimization. 64 int TailCallReturnAddrDelta = 0; 65 66 /// SRetReturnReg - Some subtargets require that sret lowering includes 67 /// returning the value of the returned struct in a register. This field 68 /// holds the virtual register into which the sret argument is passed. 69 unsigned SRetReturnReg = 0; 70 71 /// GlobalBaseReg - keeps track of the virtual register initialized for 72 /// use as the global base register. This is used for PIC in some PIC 73 /// relocation models. 74 unsigned GlobalBaseReg = 0; 75 76 /// VarArgsFrameIndex - FrameIndex for start of varargs area. 77 int VarArgsFrameIndex = 0; 78 /// RegSaveFrameIndex - X86-64 vararg func register save area. 79 int RegSaveFrameIndex = 0; 80 /// VarArgsGPOffset - X86-64 vararg func int reg offset. 81 unsigned VarArgsGPOffset = 0; 82 /// VarArgsFPOffset - X86-64 vararg func fp reg offset. 83 unsigned VarArgsFPOffset = 0; 84 /// ArgumentStackSize - The number of bytes on stack consumed by the arguments 85 /// being passed on the stack. 86 unsigned ArgumentStackSize = 0; 87 /// NumLocalDynamics - Number of local-dynamic TLS accesses. 88 unsigned NumLocalDynamics = 0; 89 /// HasPushSequences - Keeps track of whether this function uses sequences 90 /// of pushes to pass function parameters. 91 bool HasPushSequences = false; 92 93 /// True if the function recovers from an SEH exception, and therefore needs 94 /// to spill and restore the frame pointer. 95 bool HasSEHFramePtrSave = false; 96 97 /// The frame index of a stack object containing the original frame pointer 98 /// used to address arguments in a function using a base pointer. 99 int SEHFramePtrSaveIndex = 0; 100 101 /// True if this function has a subset of CSRs that is handled explicitly via 102 /// copies. 103 bool IsSplitCSR = false; 104 105 /// True if this function uses the red zone. 106 bool UsesRedZone = false; 107 108 /// True if this function has WIN_ALLOCA instructions. 109 bool HasWinAlloca = false; 110 111 private: 112 /// ForwardedMustTailRegParms - A list of virtual and physical registers 113 /// that must be forwarded to every musttail call. 114 SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms; 115 116 public: 117 X86MachineFunctionInfo() = default; 118 119 explicit X86MachineFunctionInfo(MachineFunction &MF) {} 120 121 bool getForceFramePointer() const { return ForceFramePointer;} 122 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; } 123 124 bool getHasPushSequences() const { return HasPushSequences; } 125 void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; } 126 127 bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; } 128 void setRestoreBasePointer(const MachineFunction *MF); 129 int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; } 130 131 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; } 132 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; } 133 134 unsigned getCalleeSavedXMMFrameInfo(int &origin) const 135 { origin = CalleeSavedXMMFrameOrigin; return CalleeSavedXMMFrameSize; } 136 void setCalleeSavedXMMFrameInfo(unsigned size, int origin) 137 { CalleeSavedXMMFrameSize = size; CalleeSavedXMMFrameOrigin = origin; } 138 139 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; } 140 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;} 141 142 int getRAIndex() const { return ReturnAddrIndex; } 143 void setRAIndex(int Index) { ReturnAddrIndex = Index; } 144 145 int getFAIndex() const { return FrameAddrIndex; } 146 void setFAIndex(int Index) { FrameAddrIndex = Index; } 147 148 int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; } 149 void setTCReturnAddrDelta(int delta) {TailCallReturnAddrDelta = delta;} 150 151 unsigned getSRetReturnReg() const { return SRetReturnReg; } 152 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } 153 154 unsigned getGlobalBaseReg() const { return GlobalBaseReg; } 155 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; } 156 157 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 158 void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; } 159 160 int getRegSaveFrameIndex() const { return RegSaveFrameIndex; } 161 void setRegSaveFrameIndex(int Idx) { RegSaveFrameIndex = Idx; } 162 163 unsigned getVarArgsGPOffset() const { return VarArgsGPOffset; } 164 void setVarArgsGPOffset(unsigned Offset) { VarArgsGPOffset = Offset; } 165 166 unsigned getVarArgsFPOffset() const { return VarArgsFPOffset; } 167 void setVarArgsFPOffset(unsigned Offset) { VarArgsFPOffset = Offset; } 168 169 unsigned getArgumentStackSize() const { return ArgumentStackSize; } 170 void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; } 171 172 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; } 173 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; } 174 175 bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; } 176 void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; } 177 178 int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; } 179 void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; } 180 181 SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() { 182 return ForwardedMustTailRegParms; 183 } 184 185 bool isSplitCSR() const { return IsSplitCSR; } 186 void setIsSplitCSR(bool s) { IsSplitCSR = s; } 187 188 bool getUsesRedZone() const { return UsesRedZone; } 189 void setUsesRedZone(bool V) { UsesRedZone = V; } 190 191 bool hasWinAlloca() const { return HasWinAlloca; } 192 void setHasWinAlloca(bool v) { HasWinAlloca = v; } 193 }; 194 195 } // End llvm namespace 196 197 #endif 198