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 19 namespace llvm { 20 21 /// X86MachineFunctionInfo - This class is derived from MachineFunction and 22 /// contains private X86 target-specific information for each MachineFunction. 23 class X86MachineFunctionInfo : public MachineFunctionInfo { 24 virtual void anchor(); 25 26 /// ForceFramePointer - True if the function is required to use of frame 27 /// pointer for reasons other than it containing dynamic allocation or 28 /// that FP eliminatation is turned off. For example, Cygwin main function 29 /// contains stack pointer re-alignment code which requires FP. 30 bool ForceFramePointer = false; 31 32 /// RestoreBasePointerOffset - Non-zero if the function has base pointer 33 /// and makes call to llvm.eh.sjlj.setjmp. When non-zero, the value is a 34 /// displacement from the frame pointer to a slot where the base pointer 35 /// is stashed. 36 signed char RestoreBasePointerOffset = 0; 37 38 /// WinEHXMMSlotInfo - Slot information of XMM registers in the stack frame 39 /// in bytes. 40 DenseMap<int, unsigned> WinEHXMMSlotInfo; 41 42 /// CalleeSavedFrameSize - Size of the callee-saved register portion of the 43 /// stack frame in bytes. 44 unsigned CalleeSavedFrameSize = 0; 45 46 /// BytesToPopOnReturn - Number of bytes function pops on return (in addition 47 /// to the space used by the return address). 48 /// Used on windows platform for stdcall & fastcall name decoration 49 unsigned BytesToPopOnReturn = 0; 50 51 /// ReturnAddrIndex - FrameIndex for return slot. 52 int ReturnAddrIndex = 0; 53 54 /// FrameIndex for return slot. 55 int FrameAddrIndex = 0; 56 57 /// TailCallReturnAddrDelta - The number of bytes by which return address 58 /// stack slot is moved as the result of tail call optimization. 59 int TailCallReturnAddrDelta = 0; 60 61 /// SRetReturnReg - Some subtargets require that sret lowering includes 62 /// returning the value of the returned struct in a register. This field 63 /// holds the virtual register into which the sret argument is passed. 64 unsigned SRetReturnReg = 0; 65 66 /// GlobalBaseReg - keeps track of the virtual register initialized for 67 /// use as the global base register. This is used for PIC in some PIC 68 /// relocation models. 69 unsigned GlobalBaseReg = 0; 70 71 /// VarArgsFrameIndex - FrameIndex for start of varargs area. 72 int VarArgsFrameIndex = 0; 73 /// RegSaveFrameIndex - X86-64 vararg func register save area. 74 int RegSaveFrameIndex = 0; 75 /// VarArgsGPOffset - X86-64 vararg func int reg offset. 76 unsigned VarArgsGPOffset = 0; 77 /// VarArgsFPOffset - X86-64 vararg func fp reg offset. 78 unsigned VarArgsFPOffset = 0; 79 /// ArgumentStackSize - The number of bytes on stack consumed by the arguments 80 /// being passed on the stack. 81 unsigned ArgumentStackSize = 0; 82 /// NumLocalDynamics - Number of local-dynamic TLS accesses. 83 unsigned NumLocalDynamics = 0; 84 /// HasPushSequences - Keeps track of whether this function uses sequences 85 /// of pushes to pass function parameters. 86 bool HasPushSequences = false; 87 88 /// True if the function recovers from an SEH exception, and therefore needs 89 /// to spill and restore the frame pointer. 90 bool HasSEHFramePtrSave = false; 91 92 /// The frame index of a stack object containing the original frame pointer 93 /// used to address arguments in a function using a base pointer. 94 int SEHFramePtrSaveIndex = 0; 95 96 /// True if this function has a subset of CSRs that is handled explicitly via 97 /// copies. 98 bool IsSplitCSR = false; 99 100 /// True if this function uses the red zone. 101 bool UsesRedZone = false; 102 103 /// True if this function has WIN_ALLOCA instructions. 104 bool HasWinAlloca = false; 105 106 private: 107 /// ForwardedMustTailRegParms - A list of virtual and physical registers 108 /// that must be forwarded to every musttail call. 109 SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms; 110 111 public: 112 X86MachineFunctionInfo() = default; 113 114 explicit X86MachineFunctionInfo(MachineFunction &MF) {} 115 116 bool getForceFramePointer() const { return ForceFramePointer;} 117 void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; } 118 119 bool getHasPushSequences() const { return HasPushSequences; } 120 void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; } 121 122 bool getRestoreBasePointer() const { return RestoreBasePointerOffset!=0; } 123 void setRestoreBasePointer(const MachineFunction *MF); 124 int getRestoreBasePointerOffset() const {return RestoreBasePointerOffset; } 125 126 DenseMap<int, unsigned>& getWinEHXMMSlotInfo() { return WinEHXMMSlotInfo; } 127 const DenseMap<int, unsigned>& getWinEHXMMSlotInfo() const { 128 return WinEHXMMSlotInfo; } 129 130 unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; } 131 void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; } 132 133 unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; } 134 void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;} 135 136 int getRAIndex() const { return ReturnAddrIndex; } 137 void setRAIndex(int Index) { ReturnAddrIndex = Index; } 138 139 int getFAIndex() const { return FrameAddrIndex; } 140 void setFAIndex(int Index) { FrameAddrIndex = 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 bool getHasSEHFramePtrSave() const { return HasSEHFramePtrSave; } 170 void setHasSEHFramePtrSave(bool V) { HasSEHFramePtrSave = V; } 171 172 int getSEHFramePtrSaveIndex() const { return SEHFramePtrSaveIndex; } 173 void setSEHFramePtrSaveIndex(int Index) { SEHFramePtrSaveIndex = Index; } 174 175 SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() { 176 return ForwardedMustTailRegParms; 177 } 178 179 bool isSplitCSR() const { return IsSplitCSR; } 180 void setIsSplitCSR(bool s) { IsSplitCSR = s; } 181 182 bool getUsesRedZone() const { return UsesRedZone; } 183 void setUsesRedZone(bool V) { UsesRedZone = V; } 184 185 bool hasWinAlloca() const { return HasWinAlloca; } 186 void setHasWinAlloca(bool v) { HasWinAlloca = v; } 187 }; 188 189 } // End llvm namespace 190 191 #endif 192