Recommit r373598 "[yaml2obj/obj2yaml] - Add support for SHT_LLVM_ADDRSIG sections."
[llvm-complete.git] / lib / Target / NVPTX / NVPTXTargetMachine.h
blobd84600c74e292bccf411260671e87448d6a65bdb
1 //===-- NVPTXTargetMachine.h - Define TargetMachine for NVPTX ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the NVPTX specific subclass of TargetMachine.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
14 #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
16 #include "ManagedStringPool.h"
17 #include "NVPTXSubtarget.h"
18 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
19 #include "llvm/CodeGen/TargetFrameLowering.h"
20 #include "llvm/Target/TargetMachine.h"
22 namespace llvm {
24 /// NVPTXTargetMachine
25 ///
26 class NVPTXTargetMachine : public LLVMTargetMachine {
27 bool is64bit;
28 // Use 32-bit pointers for accessing const/local/short AS.
29 bool UseShortPointers;
30 std::unique_ptr<TargetLoweringObjectFile> TLOF;
31 NVPTX::DrvInterface drvInterface;
32 NVPTXSubtarget Subtarget;
34 // Hold Strings that can be free'd all together with NVPTXTargetMachine
35 ManagedStringPool ManagedStrPool;
37 public:
38 NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
39 StringRef FS, const TargetOptions &Options,
40 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
41 CodeGenOpt::Level OP, bool is64bit);
43 ~NVPTXTargetMachine() override;
44 const NVPTXSubtarget *getSubtargetImpl(const Function &) const override {
45 return &Subtarget;
47 const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
48 bool is64Bit() const { return is64bit; }
49 bool useShortPointers() const { return UseShortPointers; }
50 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
51 ManagedStringPool *getManagedStrPool() const {
52 return const_cast<ManagedStringPool *>(&ManagedStrPool);
55 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
57 // Emission of machine code through MCJIT is not supported.
58 bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &,
59 bool = true) override {
60 return true;
62 TargetLoweringObjectFile *getObjFileLowering() const override {
63 return TLOF.get();
66 void adjustPassManager(PassManagerBuilder &) override;
68 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
70 bool isMachineVerifierClean() const override {
71 return false;
73 }; // NVPTXTargetMachine.
75 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
76 virtual void anchor();
77 public:
78 NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU,
79 StringRef FS, const TargetOptions &Options,
80 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
81 CodeGenOpt::Level OL, bool JIT);
84 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
85 virtual void anchor();
86 public:
87 NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU,
88 StringRef FS, const TargetOptions &Options,
89 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
90 CodeGenOpt::Level OL, bool JIT);
93 } // end namespace llvm
95 #endif