NVPTXSubtarget.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //=====-- NVPTXSubtarget.h - Define Subtarget for the 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 TargetSubtarget.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
  13. #define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
  14. #include "NVPTX.h"
  15. #include "NVPTXFrameLowering.h"
  16. #include "NVPTXISelLowering.h"
  17. #include "NVPTXInstrInfo.h"
  18. #include "NVPTXRegisterInfo.h"
  19. #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
  20. #include "llvm/CodeGen/TargetSubtargetInfo.h"
  21. #include "llvm/IR/DataLayout.h"
  22. #include <string>
  23. #define GET_SUBTARGETINFO_HEADER
  24. #include "NVPTXGenSubtargetInfo.inc"
  25. namespace llvm {
  26. class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
  27. virtual void anchor();
  28. std::string TargetName;
  29. // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
  30. unsigned PTXVersion;
  31. // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
  32. unsigned int SmVersion;
  33. const NVPTXTargetMachine &TM;
  34. NVPTXInstrInfo InstrInfo;
  35. NVPTXTargetLowering TLInfo;
  36. SelectionDAGTargetInfo TSInfo;
  37. // NVPTX does not have any call stack frame, but need a NVPTX specific
  38. // FrameLowering class because TargetFrameLowering is abstract.
  39. NVPTXFrameLowering FrameLowering;
  40. public:
  41. /// This constructor initializes the data members to match that
  42. /// of the specified module.
  43. ///
  44. NVPTXSubtarget(const Triple &TT, const std::string &CPU,
  45. const std::string &FS, const NVPTXTargetMachine &TM);
  46. const TargetFrameLowering *getFrameLowering() const override {
  47. return &FrameLowering;
  48. }
  49. const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
  50. const NVPTXRegisterInfo *getRegisterInfo() const override {
  51. return &InstrInfo.getRegisterInfo();
  52. }
  53. const NVPTXTargetLowering *getTargetLowering() const override {
  54. return &TLInfo;
  55. }
  56. const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
  57. return &TSInfo;
  58. }
  59. bool hasAtomAddF64() const { return SmVersion >= 60; }
  60. bool hasAtomScope() const { return SmVersion >= 60; }
  61. bool hasAtomBitwise64() const { return SmVersion >= 32; }
  62. bool hasAtomMinMax64() const { return SmVersion >= 32; }
  63. bool hasLDG() const { return SmVersion >= 32; }
  64. inline bool hasHWROT32() const { return SmVersion >= 32; }
  65. bool hasImageHandles() const;
  66. bool hasFP16Math() const { return SmVersion >= 53; }
  67. bool allowFP16Math() const;
  68. unsigned int getSmVersion() const { return SmVersion; }
  69. std::string getTargetName() const { return TargetName; }
  70. unsigned getPTXVersion() const { return PTXVersion; }
  71. NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
  72. void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
  73. };
  74. } // End llvm namespace
  75. #endif