1 //===-- MipsTargetMachine.h - Define TargetMachine 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 TargetMachine. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H 15 #define LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H 16 17 #include "MCTargetDesc/MipsABIInfo.h" 18 #include "MipsSubtarget.h" 19 #include "llvm/CodeGen/BasicTTIImpl.h" 20 #include "llvm/CodeGen/Passes.h" 21 #include "llvm/CodeGen/SelectionDAGISel.h" 22 #include "llvm/Target/TargetFrameLowering.h" 23 #include "llvm/Target/TargetMachine.h" 24 25 namespace llvm { 26 class formatted_raw_ostream; 27 class MipsRegisterInfo; 28 29 class MipsTargetMachine : public LLVMTargetMachine { 30 bool isLittle; 31 std::unique_ptr<TargetLoweringObjectFile> TLOF; 32 // Selected ABI 33 MipsABIInfo ABI; 34 MipsSubtarget *Subtarget; 35 MipsSubtarget DefaultSubtarget; 36 MipsSubtarget NoMips16Subtarget; 37 MipsSubtarget Mips16Subtarget; 38 39 mutable StringMap<std::unique_ptr<MipsSubtarget>> SubtargetMap; 40 41 public: 42 MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 43 StringRef FS, const TargetOptions &Options, Reloc::Model RM, 44 CodeModel::Model CM, CodeGenOpt::Level OL, bool isLittle); 45 ~MipsTargetMachine() override; 46 47 TargetIRAnalysis getTargetIRAnalysis() override; 48 getSubtargetImpl()49 const MipsSubtarget *getSubtargetImpl() const { 50 if (Subtarget) 51 return Subtarget; 52 return &DefaultSubtarget; 53 } 54 55 const MipsSubtarget *getSubtargetImpl(const Function &F) const override; 56 57 /// \brief Reset the subtarget for the Mips target. 58 void resetSubtarget(MachineFunction *MF); 59 60 // Pass Pipeline Configuration 61 TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 62 getObjFileLowering()63 TargetLoweringObjectFile *getObjFileLowering() const override { 64 return TLOF.get(); 65 } 66 isLittleEndian()67 bool isLittleEndian() const { return isLittle; } getABI()68 const MipsABIInfo &getABI() const { return ABI; } 69 }; 70 71 /// MipsebTargetMachine - Mips32/64 big endian target machine. 72 /// 73 class MipsebTargetMachine : public MipsTargetMachine { 74 virtual void anchor(); 75 public: 76 MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 77 StringRef FS, const TargetOptions &Options, 78 Reloc::Model RM, CodeModel::Model CM, 79 CodeGenOpt::Level OL); 80 }; 81 82 /// MipselTargetMachine - Mips32/64 little endian target machine. 83 /// 84 class MipselTargetMachine : public MipsTargetMachine { 85 virtual void anchor(); 86 public: 87 MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 88 StringRef FS, const TargetOptions &Options, 89 Reloc::Model RM, CodeModel::Model CM, 90 CodeGenOpt::Level OL); 91 }; 92 93 } // End llvm namespace 94 95 #endif 96