• 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 NVPTX_TARGETMACHINE_H
15 #define NVPTX_TARGETMACHINE_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   NVPTXSubtarget Subtarget;
29 
30   // Hold Strings that can be free'd all together with NVPTXTargetMachine
31   ManagedStringPool ManagedStrPool;
32 
33 public:
34   NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
35                      const TargetOptions &Options, Reloc::Model RM,
36                      CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
37 
getFrameLowering()38   const TargetFrameLowering *getFrameLowering() const override {
39     return getSubtargetImpl()->getFrameLowering();
40   }
getInstrInfo()41   const NVPTXInstrInfo *getInstrInfo() const override {
42     return getSubtargetImpl()->getInstrInfo();
43   }
getDataLayout()44   const DataLayout *getDataLayout() const override {
45     return getSubtargetImpl()->getDataLayout();
46   }
getSubtargetImpl()47   const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
getRegisterInfo()48   const NVPTXRegisterInfo *getRegisterInfo() const override {
49     return getSubtargetImpl()->getRegisterInfo();
50   }
51 
getTargetLowering()52   const NVPTXTargetLowering *getTargetLowering() const override {
53     return getSubtargetImpl()->getTargetLowering();
54   }
55 
getSelectionDAGInfo()56   const TargetSelectionDAGInfo *getSelectionDAGInfo() const override {
57     return getSubtargetImpl()->getSelectionDAGInfo();
58   }
59 
getManagedStrPool()60   ManagedStringPool *getManagedStrPool() const {
61     return const_cast<ManagedStringPool *>(&ManagedStrPool);
62   }
63 
64   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
65 
66   // Emission of machine code through JITCodeEmitter is not supported.
67   bool addPassesToEmitMachineCode(PassManagerBase &, JITCodeEmitter &,
68                                   bool = true) override {
69     return true;
70   }
71 
72   // Emission of machine code through MCJIT is not supported.
73   bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_ostream &,
74                          bool = true) override {
75     return true;
76   }
77 
78 }; // NVPTXTargetMachine.
79 
80 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
81   virtual void anchor();
82 public:
83   NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU,
84                        StringRef FS, const TargetOptions &Options,
85                        Reloc::Model RM, CodeModel::Model CM,
86                        CodeGenOpt::Level OL);
87 };
88 
89 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
90   virtual void anchor();
91 public:
92   NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU,
93                        StringRef FS, const TargetOptions &Options,
94                        Reloc::Model RM, CodeModel::Model CM,
95                        CodeGenOpt::Level OL);
96 };
97 
98 } // end namespace llvm
99 
100 #endif
101