1 //===-- NVPTXTargetMachine.h - Define TargetMachine for NVPTX ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the NVPTX specific subclass of TargetMachine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
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"
25 /// NVPTXTargetMachine
27 class NVPTXTargetMachine : public LLVMTargetMachine {
29 std::unique_ptr<TargetLoweringObjectFile> TLOF;
30 const DataLayout DL; // Calculates type size & alignment
31 NVPTX::DrvInterface drvInterface;
32 NVPTXSubtarget Subtarget;
34 // Hold Strings that can be free'd all together with NVPTXTargetMachine
35 ManagedStringPool ManagedStrPool;
38 NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
39 const TargetOptions &Options, Reloc::Model RM,
40 CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
42 ~NVPTXTargetMachine() override;
43 const DataLayout *getDataLayout() const override { return &DL; }
44 const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
45 bool is64Bit() const { return is64bit; }
46 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
47 ManagedStringPool *getManagedStrPool() const {
48 return const_cast<ManagedStringPool *>(&ManagedStrPool);
51 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
53 // Emission of machine code through MCJIT is not supported.
54 bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_ostream &,
55 bool = true) override {
58 TargetLoweringObjectFile *getObjFileLowering() const override {
62 TargetIRAnalysis getTargetIRAnalysis() override;
64 }; // NVPTXTargetMachine.
66 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
67 virtual void anchor();
69 NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU,
70 StringRef FS, const TargetOptions &Options,
71 Reloc::Model RM, CodeModel::Model CM,
72 CodeGenOpt::Level OL);
75 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
76 virtual void anchor();
78 NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU,
79 StringRef FS, const TargetOptions &Options,
80 Reloc::Model RM, CodeModel::Model CM,
81 CodeGenOpt::Level OL);
84 } // end namespace llvm