4794c2ebef60b9dd0a651fcba8dc597e70f3c295
[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 "NVPTXSubtarget.h"
18 #include "ManagedStringPool.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   std::unique_ptr<TargetLoweringObjectFile> TLOF;
29   NVPTXSubtarget Subtarget;
30
31   // Hold Strings that can be free'd all together with NVPTXTargetMachine
32   ManagedStringPool ManagedStrPool;
33
34 public:
35   NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
36                      const TargetOptions &Options, Reloc::Model RM,
37                      CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
38
39   const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
40
41   ManagedStringPool *getManagedStrPool() const {
42     return const_cast<ManagedStringPool *>(&ManagedStrPool);
43   }
44
45   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
46
47   // Emission of machine code through MCJIT is not supported.
48   bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_ostream &,
49                          bool = true) override {
50     return true;
51   }
52   TargetLoweringObjectFile *getObjFileLowering() const override {
53     return TLOF.get();
54   }
55
56   /// \brief Register NVPTX analysis passes with a pass manager.
57   void addAnalysisPasses(PassManagerBase &PM) override;
58
59 }; // NVPTXTargetMachine.
60
61 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
62   virtual void anchor();
63 public:
64   NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU,
65                        StringRef FS, const TargetOptions &Options,
66                        Reloc::Model RM, CodeModel::Model CM,
67                        CodeGenOpt::Level OL);
68 };
69
70 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
71   virtual void anchor();
72 public:
73   NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU,
74                        StringRef FS, const TargetOptions &Options,
75                        Reloc::Model RM, CodeModel::Model CM,
76                        CodeGenOpt::Level OL);
77 };
78
79 } // end namespace llvm
80
81 #endif