• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- NVPTXTargetMachine.h - Define TargetMachine for NVPTX ---*- 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 NVPTX specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
16 
17 #include "ManagedStringPool.h"
18 #include "NVPTXSubtarget.h"
19 #include "llvm/Target/TargetFrameLowering.h"
20 #include "llvm/Target/TargetMachine.h"
21 #include "llvm/Target/TargetSelectionDAGInfo.h"
22 
23 namespace llvm {
24 
25 /// NVPTXTargetMachine
26 ///
27 class NVPTXTargetMachine : public LLVMTargetMachine {
28   bool is64bit;
29   std::unique_ptr<TargetLoweringObjectFile> TLOF;
30   NVPTX::DrvInterface drvInterface;
31   NVPTXSubtarget Subtarget;
32 
33   // Hold Strings that can be free'd all together with NVPTXTargetMachine
34   ManagedStringPool ManagedStrPool;
35 
36 public:
37   NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
38                      const TargetOptions &Options, Reloc::Model RM,
39                      CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
40 
41   ~NVPTXTargetMachine() override;
getSubtargetImpl(const Function &)42   const NVPTXSubtarget *getSubtargetImpl(const Function &) const override {
43     return &Subtarget;
44   }
getSubtargetImpl()45   const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
is64Bit()46   bool is64Bit() const { return is64bit; }
getDrvInterface()47   NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
getManagedStrPool()48   ManagedStringPool *getManagedStrPool() const {
49     return const_cast<ManagedStringPool *>(&ManagedStrPool);
50   }
51 
52   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
53 
54   // Emission of machine code through MCJIT is not supported.
55   bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &,
56                          bool = true) override {
57     return true;
58   }
getObjFileLowering()59   TargetLoweringObjectFile *getObjFileLowering() const override {
60     return TLOF.get();
61   }
62 
63   TargetIRAnalysis getTargetIRAnalysis() override;
64 
65 }; // NVPTXTargetMachine.
66 
67 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
68   virtual void anchor();
69 public:
70   NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU,
71                        StringRef FS, const TargetOptions &Options,
72                        Reloc::Model RM, CodeModel::Model CM,
73                        CodeGenOpt::Level OL);
74 };
75 
76 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
77   virtual void anchor();
78 public:
79   NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU,
80                        StringRef FS, const TargetOptions &Options,
81                        Reloc::Model RM, CodeModel::Model CM,
82                        CodeGenOpt::Level OL);
83 };
84 
85 } // end namespace llvm
86 
87 #endif
88