]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
Merge llvm trunk r321414 to contrib/llvm.
[FreeBSD/FreeBSD.git] / contrib / llvm / 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/CodeGen/SelectionDAGTargetInfo.h"
20 #include "llvm/CodeGen/TargetFrameLowering.h"
21 #include "llvm/Target/TargetMachine.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, const Triple &TT, StringRef CPU,
38                      StringRef FS, const TargetOptions &Options,
39                      Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
40                      CodeGenOpt::Level OP, bool is64bit);
41
42   ~NVPTXTargetMachine() override;
43   const NVPTXSubtarget *getSubtargetImpl(const Function &) const override {
44     return &Subtarget;
45   }
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);
51   }
52
53   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
54
55   // Emission of machine code through MCJIT is not supported.
56   bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &,
57                          bool = true) override {
58     return true;
59   }
60   TargetLoweringObjectFile *getObjFileLowering() const override {
61     return TLOF.get();
62   }
63
64   void adjustPassManager(PassManagerBuilder &) override;
65
66   TargetTransformInfo getTargetTransformInfo(const Function &F) override;
67
68   bool isMachineVerifierClean() const override {
69     return false;
70   }
71 }; // NVPTXTargetMachine.
72
73 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
74   virtual void anchor();
75 public:
76   NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU,
77                        StringRef FS, const TargetOptions &Options,
78                        Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
79                        CodeGenOpt::Level OL, bool JIT);
80 };
81
82 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
83   virtual void anchor();
84 public:
85   NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU,
86                        StringRef FS, const TargetOptions &Options,
87                        Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
88                        CodeGenOpt::Level OL, bool JIT);
89 };
90
91 } // end namespace llvm
92
93 #endif