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 MIPS_MACHINE_FUNCTION_INFO_H 15 #define MIPS_MACHINE_FUNCTION_INFO_H 16 17 #include "MipsSubtarget.h" 18 #include "llvm/ADT/StringMap.h" 19 #include "llvm/ADT/ValueMap.h" 20 #include "llvm/CodeGen/MachineFrameInfo.h" 21 #include "llvm/CodeGen/MachineFunction.h" 22 #include "llvm/CodeGen/MachineMemOperand.h" 23 #include "llvm/CodeGen/PseudoSourceValue.h" 24 #include "llvm/IR/GlobalValue.h" 25 #include "llvm/Target/TargetFrameLowering.h" 26 #include "llvm/Target/TargetMachine.h" 27 #include <utility> 28 29 namespace llvm { 30 31 /// \brief A class derived from PseudoSourceValue that represents a GOT entry 32 /// resolved by lazy-binding. 33 class MipsCallEntry : public PseudoSourceValue { 34 public: 35 explicit MipsCallEntry(const StringRef &N); 36 explicit MipsCallEntry(const GlobalValue *V); 37 virtual bool isConstant(const MachineFrameInfo *) const; 38 virtual bool isAliased(const MachineFrameInfo *) const; 39 virtual bool mayAlias(const MachineFrameInfo *) const; 40 41 private: 42 virtual void printCustom(raw_ostream &O) const; 43 #ifndef NDEBUG 44 std::string Name; 45 const GlobalValue *Val; 46 #endif 47 }; 48 49 /// MipsFunctionInfo - This class is derived from MachineFunction private 50 /// Mips target-specific information for each MachineFunction. 51 class MipsFunctionInfo : public MachineFunctionInfo { 52 public: 53 MipsFunctionInfo(MachineFunction& MF) 54 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0), 55 VarArgsFrameIndex(0), CallsEhReturn(false) 56 {} 57 58 ~MipsFunctionInfo(); 59 60 unsigned getSRetReturnReg() const { return SRetReturnReg; } 61 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } 62 63 bool globalBaseRegSet() const; 64 unsigned getGlobalBaseReg(); 65 66 bool mips16SPAliasRegSet() const; 67 unsigned getMips16SPAliasReg(); 68 69 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 70 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } 71 72 bool hasByvalArg() const { return HasByvalArg; } 73 void setFormalArgInfo(unsigned Size, bool HasByval) { 74 IncomingArgSize = Size; 75 HasByvalArg = HasByval; 76 } 77 78 unsigned getIncomingArgSize() const { return IncomingArgSize; } 79 80 bool callsEhReturn() const { return CallsEhReturn; } 81 void setCallsEhReturn() { CallsEhReturn = true; } 82 83 void createEhDataRegsFI(); 84 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; } 85 bool isEhDataRegFI(int FI) const; 86 87 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object 88 /// representing a GOT entry for an external function. 89 MachinePointerInfo callPtrInfo(const StringRef &Name); 90 91 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object 92 /// representing a GOT entry for a global function. 93 MachinePointerInfo callPtrInfo(const GlobalValue *Val); 94 95 private: 96 virtual void anchor(); 97 98 MachineFunction& MF; 99 /// SRetReturnReg - Some subtargets require that sret lowering includes 100 /// returning the value of the returned struct in a register. This field 101 /// holds the virtual register into which the sret argument is passed. 102 unsigned SRetReturnReg; 103 104 /// GlobalBaseReg - keeps track of the virtual register initialized for 105 /// use as the global base register. This is used for PIC in some PIC 106 /// relocation models. 107 unsigned GlobalBaseReg; 108 109 /// Mips16SPAliasReg - keeps track of the virtual register initialized for 110 /// use as an alias for SP for use in load/store of halfword/byte from/to 111 /// the stack 112 unsigned Mips16SPAliasReg; 113 114 /// VarArgsFrameIndex - FrameIndex for start of varargs area. 115 int VarArgsFrameIndex; 116 117 /// True if function has a byval argument. 118 bool HasByvalArg; 119 120 /// Size of incoming argument area. 121 unsigned IncomingArgSize; 122 123 /// CallsEhReturn - Whether the function calls llvm.eh.return. 124 bool CallsEhReturn; 125 126 /// Frame objects for spilling eh data registers. 127 int EhDataRegFI[4]; 128 129 /// MipsCallEntry maps. 130 StringMap<const MipsCallEntry *> ExternalCallEntries; 131 ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries; 132 }; 133 134 } // end of namespace llvm 135 136 #endif // MIPS_MACHINE_FUNCTION_INFO_H 137