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