1 //===-- RISCVTargetMachine.h - Define TargetMachine for RISCV ---*- 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 RISCV specific subclass of TargetMachine. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETMACHINE_H 15 #define LLVM_LIB_TARGET_RISCV_RISCVTARGETMACHINE_H 16 17 #include "MCTargetDesc/RISCVMCTargetDesc.h" 18 #include "RISCVSubtarget.h" 19 #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 20 #include "llvm/IR/DataLayout.h" 21 #include "llvm/Target/TargetMachine.h" 22 23 namespace llvm { 24 class RISCVTargetMachine : public LLVMTargetMachine { 25 std::unique_ptr<TargetLoweringObjectFile> TLOF; 26 RISCVSubtarget Subtarget; 27 28 public: 29 RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 30 StringRef FS, const TargetOptions &Options, 31 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 32 CodeGenOpt::Level OL, bool JIT); 33 getSubtargetImpl(const Function &)34 const RISCVSubtarget *getSubtargetImpl(const Function &) const override { 35 return &Subtarget; 36 } 37 38 TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 39 getObjFileLowering()40 TargetLoweringObjectFile *getObjFileLowering() const override { 41 return TLOF.get(); 42 } 43 }; 44 } 45 46 #endif 47