Move the DataLayout to the generic TargetMachine, making it mandatory.
[oota-llvm.git] / lib / Target / NVPTX / NVPTXTargetMachine.h
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;
42   const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
43   bool is64Bit() const { return is64bit; }
44   NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
45   ManagedStringPool *getManagedStrPool() const {
46     return const_cast<ManagedStringPool *>(&ManagedStrPool);
47   }
48
49   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
50
51   // Emission of machine code through MCJIT is not supported.
52   bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_ostream &,
53                          bool = true) override {
54     return true;
55   }
56   TargetLoweringObjectFile *getObjFileLowering() const override {
57     return TLOF.get();
58   }
59
60   TargetIRAnalysis getTargetIRAnalysis() override;
61
62 }; // NVPTXTargetMachine.
63
64 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
65   virtual void anchor();
66 public:
67   NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU,
68                        StringRef FS, const TargetOptions &Options,
69                        Reloc::Model RM, CodeModel::Model CM,
70                        CodeGenOpt::Level OL);
71 };
72
73 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
74   virtual void anchor();
75 public:
76   NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU,
77                        StringRef FS, const TargetOptions &Options,
78                        Reloc::Model RM, CodeModel::Model CM,
79                        CodeGenOpt::Level OL);
80 };
81
82 } // end namespace llvm
83
84 #endif