LLVM API Documentation

MipsMachineFunction.h
Go to the documentation of this file.
00001 //===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- C++ -*-=//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the Mips specific subclass of MachineFunctionInfo.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
00015 #define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
00016 
00017 #include "Mips16HardFloatInfo.h"
00018 #include "llvm/ADT/StringMap.h"
00019 #include "llvm/CodeGen/MachineFrameInfo.h"
00020 #include "llvm/CodeGen/MachineFunction.h"
00021 #include "llvm/CodeGen/MachineMemOperand.h"
00022 #include "llvm/CodeGen/PseudoSourceValue.h"
00023 #include "llvm/IR/GlobalValue.h"
00024 #include "llvm/IR/ValueMap.h"
00025 #include "llvm/Target/TargetFrameLowering.h"
00026 #include "llvm/Target/TargetMachine.h"
00027 #include <map>
00028 #include <string>
00029 #include <utility>
00030 
00031 namespace llvm {
00032 
00033 /// \brief A class derived from PseudoSourceValue that represents a GOT entry
00034 /// resolved by lazy-binding.
00035 class MipsCallEntry : public PseudoSourceValue {
00036 public:
00037   explicit MipsCallEntry(StringRef N);
00038   explicit MipsCallEntry(const GlobalValue *V);
00039   bool isConstant(const MachineFrameInfo *) const override;
00040   bool isAliased(const MachineFrameInfo *) const override;
00041   bool mayAlias(const MachineFrameInfo *) const override;
00042 
00043 private:
00044   void printCustom(raw_ostream &O) const override;
00045 #ifndef NDEBUG
00046   std::string Name;
00047   const GlobalValue *Val;
00048 #endif
00049 };
00050 
00051 /// MipsFunctionInfo - This class is derived from MachineFunction private
00052 /// Mips target-specific information for each MachineFunction.
00053 class MipsFunctionInfo : public MachineFunctionInfo {
00054 public:
00055   MipsFunctionInfo(MachineFunction &MF)
00056       : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0),
00057         VarArgsFrameIndex(0), CallsEhReturn(false), SaveS2(false),
00058         MoveF64ViaSpillFI(-1) {}
00059 
00060   ~MipsFunctionInfo();
00061 
00062   unsigned getSRetReturnReg() const { return SRetReturnReg; }
00063   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
00064 
00065   bool globalBaseRegSet() const;
00066   unsigned getGlobalBaseReg();
00067 
00068   bool mips16SPAliasRegSet() const;
00069   unsigned getMips16SPAliasReg();
00070 
00071   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
00072   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
00073 
00074   bool hasByvalArg() const { return HasByvalArg; }
00075   void setFormalArgInfo(unsigned Size, bool HasByval) {
00076     IncomingArgSize = Size;
00077     HasByvalArg = HasByval;
00078   }
00079 
00080   unsigned getIncomingArgSize() const { return IncomingArgSize; }
00081 
00082   bool callsEhReturn() const { return CallsEhReturn; }
00083   void setCallsEhReturn() { CallsEhReturn = true; }
00084 
00085   void createEhDataRegsFI();
00086   int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
00087   bool isEhDataRegFI(int FI) const;
00088 
00089   /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
00090   /// representing a GOT entry for an external function.
00091   MachinePointerInfo callPtrInfo(StringRef Name);
00092 
00093   /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
00094   /// representing a GOT entry for a global function.
00095   MachinePointerInfo callPtrInfo(const GlobalValue *Val);
00096 
00097   void setSaveS2() { SaveS2 = true; }
00098   bool hasSaveS2() const { return SaveS2; }
00099 
00100   int getMoveF64ViaSpillFI(const TargetRegisterClass *RC);
00101 
00102   std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
00103   StubsNeeded;
00104 
00105 private:
00106   virtual void anchor();
00107 
00108   MachineFunction& MF;
00109   /// SRetReturnReg - Some subtargets require that sret lowering includes
00110   /// returning the value of the returned struct in a register. This field
00111   /// holds the virtual register into which the sret argument is passed.
00112   unsigned SRetReturnReg;
00113 
00114   /// GlobalBaseReg - keeps track of the virtual register initialized for
00115   /// use as the global base register. This is used for PIC in some PIC
00116   /// relocation models.
00117   unsigned GlobalBaseReg;
00118 
00119   /// Mips16SPAliasReg - keeps track of the virtual register initialized for
00120   /// use as an alias for SP for use in load/store of halfword/byte from/to
00121   /// the stack
00122   unsigned Mips16SPAliasReg;
00123 
00124   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
00125   int VarArgsFrameIndex;
00126 
00127   /// True if function has a byval argument.
00128   bool HasByvalArg;
00129 
00130   /// Size of incoming argument area.
00131   unsigned IncomingArgSize;
00132 
00133   /// CallsEhReturn - Whether the function calls llvm.eh.return.
00134   bool CallsEhReturn;
00135 
00136   /// Frame objects for spilling eh data registers.
00137   int EhDataRegFI[4];
00138 
00139   // saveS2
00140   bool SaveS2;
00141 
00142   /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the
00143   /// O32 FPXX ABI is enabled. -1 is used to denote invalid index.
00144   int MoveF64ViaSpillFI;
00145 
00146   /// MipsCallEntry maps.
00147   StringMap<const MipsCallEntry *> ExternalCallEntries;
00148   ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries;
00149 };
00150 
00151 } // end of namespace llvm
00152 
00153 #endif