1 //===- MipsMachineFunctionInfo.h - Private data used for Mips ---*- 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 the Mips specific subclass of MachineFunctionInfo. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H 14 #define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H 15 16 #include "Mips16HardFloatInfo.h" 17 #include "llvm/CodeGen/MachineFunction.h" 18 #include "llvm/CodeGen/MachineMemOperand.h" 19 #include <map> 20 21 namespace llvm { 22 23 /// MipsFunctionInfo - This class is derived from MachineFunction private 24 /// Mips target-specific information for each MachineFunction. 25 class MipsFunctionInfo : public MachineFunctionInfo { 26 public: 27 MipsFunctionInfo(MachineFunction &MF) : MF(MF) {} 28 29 ~MipsFunctionInfo() override; 30 31 unsigned getSRetReturnReg() const { return SRetReturnReg; } 32 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } 33 34 bool globalBaseRegSet() const; 35 unsigned getGlobalBaseReg(); 36 37 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 38 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } 39 40 bool hasByvalArg() const { return HasByvalArg; } 41 void setFormalArgInfo(unsigned Size, bool HasByval) { 42 IncomingArgSize = Size; 43 HasByvalArg = HasByval; 44 } 45 46 unsigned getIncomingArgSize() const { return IncomingArgSize; } 47 48 bool callsEhReturn() const { return CallsEhReturn; } 49 void setCallsEhReturn() { CallsEhReturn = true; } 50 51 void createEhDataRegsFI(); 52 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; } 53 bool isEhDataRegFI(int FI) const; 54 55 /// Create a MachinePointerInfo that has an ExternalSymbolPseudoSourceValue 56 /// object representing a GOT entry for an external function. 57 MachinePointerInfo callPtrInfo(const char *ES); 58 59 // Functions with the "interrupt" attribute require special prologues, 60 // epilogues and additional spill slots. 61 bool isISR() const { return IsISR; } 62 void setISR() { IsISR = true; } 63 void createISRRegFI(); 64 int getISRRegFI(unsigned Reg) const { return ISRDataRegFI[Reg]; } 65 bool isISRRegFI(int FI) const; 66 67 /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object 68 /// representing a GOT entry for a global function. 69 MachinePointerInfo callPtrInfo(const GlobalValue *GV); 70 71 void setSaveS2() { SaveS2 = true; } 72 bool hasSaveS2() const { return SaveS2; } 73 74 int getMoveF64ViaSpillFI(const TargetRegisterClass *RC); 75 76 std::map<const char *, const Mips16HardFloatInfo::FuncSignature *> 77 StubsNeeded; 78 79 private: 80 virtual void anchor(); 81 82 MachineFunction& MF; 83 84 /// SRetReturnReg - Some subtargets require that sret lowering includes 85 /// returning the value of the returned struct in a register. This field 86 /// holds the virtual register into which the sret argument is passed. 87 unsigned SRetReturnReg = 0; 88 89 /// GlobalBaseReg - keeps track of the virtual register initialized for 90 /// use as the global base register. This is used for PIC in some PIC 91 /// relocation models. 92 unsigned GlobalBaseReg = 0; 93 94 /// VarArgsFrameIndex - FrameIndex for start of varargs area. 95 int VarArgsFrameIndex = 0; 96 97 /// True if function has a byval argument. 98 bool HasByvalArg; 99 100 /// Size of incoming argument area. 101 unsigned IncomingArgSize; 102 103 /// CallsEhReturn - Whether the function calls llvm.eh.return. 104 bool CallsEhReturn = false; 105 106 /// Frame objects for spilling eh data registers. 107 int EhDataRegFI[4]; 108 109 /// ISR - Whether the function is an Interrupt Service Routine. 110 bool IsISR = false; 111 112 /// Frame objects for spilling C0_STATUS, C0_EPC 113 int ISRDataRegFI[2]; 114 115 // saveS2 116 bool SaveS2 = false; 117 118 /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the 119 /// O32 FPXX ABI is enabled. -1 is used to denote invalid index. 120 int MoveF64ViaSpillFI = -1; 121 }; 122 123 } // end namespace llvm 124 125 #endif // LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H 126