NVPTXTargetMachine.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
  13. #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
  14. #include "ManagedStringPool.h"
  15. #include "NVPTXSubtarget.h"
  16. #include "llvm/Target/TargetMachine.h"
  17. #include <utility>
  18. namespace llvm {
  19. /// NVPTXTargetMachine
  20. ///
  21. class NVPTXTargetMachine : public LLVMTargetMachine {
  22. bool is64bit;
  23. // Use 32-bit pointers for accessing const/local/short AS.
  24. bool UseShortPointers;
  25. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  26. NVPTX::DrvInterface drvInterface;
  27. NVPTXSubtarget Subtarget;
  28. // Hold Strings that can be free'd all together with NVPTXTargetMachine
  29. ManagedStringPool ManagedStrPool;
  30. public:
  31. NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  32. StringRef FS, const TargetOptions &Options,
  33. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  34. CodeGenOpt::Level OP, bool is64bit);
  35. ~NVPTXTargetMachine() override;
  36. const NVPTXSubtarget *getSubtargetImpl(const Function &) const override {
  37. return &Subtarget;
  38. }
  39. const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
  40. bool is64Bit() const { return is64bit; }
  41. bool useShortPointers() const { return UseShortPointers; }
  42. NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
  43. ManagedStringPool *getManagedStrPool() const {
  44. return const_cast<ManagedStringPool *>(&ManagedStrPool);
  45. }
  46. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  47. // Emission of machine code through MCJIT is not supported.
  48. bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &,
  49. bool = true) override {
  50. return true;
  51. }
  52. TargetLoweringObjectFile *getObjFileLowering() const override {
  53. return TLOF.get();
  54. }
  55. void adjustPassManager(PassManagerBuilder &) override;
  56. void registerPassBuilderCallbacks(PassBuilder &PB) override;
  57. TargetTransformInfo getTargetTransformInfo(const Function &F) override;
  58. bool isMachineVerifierClean() const override {
  59. return false;
  60. }
  61. std::pair<const Value *, unsigned>
  62. getPredicatedAddrSpace(const Value *V) const override;
  63. }; // NVPTXTargetMachine.
  64. class NVPTXTargetMachine32 : public NVPTXTargetMachine {
  65. virtual void anchor();
  66. public:
  67. NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU,
  68. StringRef FS, const TargetOptions &Options,
  69. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  70. CodeGenOpt::Level OL, bool JIT);
  71. };
  72. class NVPTXTargetMachine64 : public NVPTXTargetMachine {
  73. virtual void anchor();
  74. public:
  75. NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU,
  76. StringRef FS, const TargetOptions &Options,
  77. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  78. CodeGenOpt::Level OL, bool JIT);
  79. };
  80. } // end namespace llvm
  81. #endif