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