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. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H 14 #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H 15 16 #include "ManagedStringPool.h" 17 #include "NVPTXSubtarget.h" 18 #include "llvm/Target/TargetMachine.h" 19 20 namespace llvm { 21 22 /// NVPTXTargetMachine 23 /// 24 class NVPTXTargetMachine : public LLVMTargetMachine { 25 bool is64bit; 26 // Use 32-bit pointers for accessing const/local/short AS. 27 bool UseShortPointers; 28 std::unique_ptr<TargetLoweringObjectFile> TLOF; 29 NVPTX::DrvInterface drvInterface; 30 NVPTXSubtarget Subtarget; 31 32 // Hold Strings that can be free'd all together with NVPTXTargetMachine 33 ManagedStringPool ManagedStrPool; 34 35 public: 36 NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 37 StringRef FS, const TargetOptions &Options, 38 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 39 CodeGenOpt::Level OP, bool is64bit); 40 41 ~NVPTXTargetMachine() override; getSubtargetImpl(const Function &)42 const NVPTXSubtarget *getSubtargetImpl(const Function &) const override { 43 return &Subtarget; 44 } getSubtargetImpl()45 const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; } is64Bit()46 bool is64Bit() const { return is64bit; } useShortPointers()47 bool useShortPointers() const { return UseShortPointers; } getDrvInterface()48 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; } getManagedStrPool()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 } getObjFileLowering()60 TargetLoweringObjectFile *getObjFileLowering() const override { 61 return TLOF.get(); 62 } 63 64 void adjustPassManager(PassManagerBuilder &) override; 65 void registerPassBuilderCallbacks(PassBuilder &PB, 66 bool DebugPassManager) override; 67 68 TargetTransformInfo getTargetTransformInfo(const Function &F) override; 69 isMachineVerifierClean()70 bool isMachineVerifierClean() const override { 71 return false; 72 } 73 }; // NVPTXTargetMachine. 74 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); 82 }; 83 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); 91 }; 92 93 } // end namespace llvm 94 95 #endif 96