1 //===-- NVPTXTargetMachine.h - Define TargetMachine for NVPTX ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the NVPTX specific subclass of TargetMachine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
17 #include "ManagedStringPool.h"
18 #include "NVPTXSubtarget.h"
19 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
20 #include "llvm/Target/TargetFrameLowering.h"
21 #include "llvm/Target/TargetMachine.h"
25 /// NVPTXTargetMachine
27 class NVPTXTargetMachine : public LLVMTargetMachine {
29 std::unique_ptr<TargetLoweringObjectFile> TLOF;
30 NVPTX::DrvInterface drvInterface;
31 NVPTXSubtarget Subtarget;
33 // Hold Strings that can be free'd all together with NVPTXTargetMachine
34 ManagedStringPool ManagedStrPool;
37 NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
38 StringRef FS, const TargetOptions &Options,
39 Optional<Reloc::Model> RM, CodeModel::Model CM,
40 CodeGenOpt::Level OP, bool is64bit);
42 ~NVPTXTargetMachine() override;
43 const NVPTXSubtarget *getSubtargetImpl(const Function &) const override {
46 const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
47 bool is64Bit() const { return is64bit; }
48 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
49 ManagedStringPool *getManagedStrPool() const {
50 return const_cast<ManagedStringPool *>(&ManagedStrPool);
53 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
55 // Emission of machine code through MCJIT is not supported.
56 bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &,
57 bool = true) override {
60 TargetLoweringObjectFile *getObjFileLowering() const override {
64 void addEarlyAsPossiblePasses(PassManagerBase &PM) override;
65 TargetIRAnalysis getTargetIRAnalysis() override;
67 }; // NVPTXTargetMachine.
69 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
70 virtual void anchor();
72 NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU,
73 StringRef FS, const TargetOptions &Options,
74 Optional<Reloc::Model> RM, CodeModel::Model CM,
75 CodeGenOpt::Level OL);
78 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
79 virtual void anchor();
81 NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU,
82 StringRef FS, const TargetOptions &Options,
83 Optional<Reloc::Model> RM, CodeModel::Model CM,
84 CodeGenOpt::Level OL);
87 } // end namespace llvm