WebAssemblySubtarget.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- 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. /// \file
  10. /// This file declares the WebAssembly-specific subclass of
  11. /// TargetSubtarget.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
  15. #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
  16. #include "WebAssemblyFrameLowering.h"
  17. #include "WebAssemblyISelLowering.h"
  18. #include "WebAssemblyInstrInfo.h"
  19. #include "WebAssemblySelectionDAGInfo.h"
  20. #include "llvm/CodeGen/TargetSubtargetInfo.h"
  21. #include <string>
  22. #define GET_SUBTARGETINFO_ENUM
  23. #define GET_SUBTARGETINFO_HEADER
  24. #include "WebAssemblyGenSubtargetInfo.inc"
  25. namespace llvm {
  26. // Defined in WebAssemblyGenSubtargetInfo.inc.
  27. extern const SubtargetFeatureKV
  28. WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures];
  29. class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
  30. enum SIMDEnum {
  31. NoSIMD,
  32. SIMD128,
  33. RelaxedSIMD,
  34. } SIMDLevel = NoSIMD;
  35. bool HasAtomics = false;
  36. bool HasNontrappingFPToInt = false;
  37. bool HasSignExt = false;
  38. bool HasExceptionHandling = false;
  39. bool HasBulkMemory = false;
  40. bool HasMultivalue = false;
  41. bool HasMutableGlobals = false;
  42. bool HasTailCall = false;
  43. bool HasReferenceTypes = false;
  44. bool HasExtendedConst = false;
  45. /// What processor and OS we're targeting.
  46. Triple TargetTriple;
  47. WebAssemblyFrameLowering FrameLowering;
  48. WebAssemblyInstrInfo InstrInfo;
  49. WebAssemblySelectionDAGInfo TSInfo;
  50. WebAssemblyTargetLowering TLInfo;
  51. WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU,
  52. StringRef FS);
  53. public:
  54. /// This constructor initializes the data members to match that
  55. /// of the specified triple.
  56. WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
  57. const std::string &FS, const TargetMachine &TM);
  58. const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override {
  59. return &TSInfo;
  60. }
  61. const WebAssemblyFrameLowering *getFrameLowering() const override {
  62. return &FrameLowering;
  63. }
  64. const WebAssemblyTargetLowering *getTargetLowering() const override {
  65. return &TLInfo;
  66. }
  67. const WebAssemblyInstrInfo *getInstrInfo() const override {
  68. return &InstrInfo;
  69. }
  70. const WebAssemblyRegisterInfo *getRegisterInfo() const override {
  71. return &getInstrInfo()->getRegisterInfo();
  72. }
  73. const Triple &getTargetTriple() const { return TargetTriple; }
  74. bool enableAtomicExpand() const override;
  75. bool enableIndirectBrExpand() const override { return true; }
  76. bool enableMachineScheduler() const override;
  77. bool useAA() const override;
  78. // Predicates used by WebAssemblyInstrInfo.td.
  79. bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
  80. bool hasSIMD128() const { return SIMDLevel >= SIMD128; }
  81. bool hasRelaxedSIMD() const { return SIMDLevel >= RelaxedSIMD; }
  82. bool hasAtomics() const { return HasAtomics; }
  83. bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
  84. bool hasSignExt() const { return HasSignExt; }
  85. bool hasExceptionHandling() const { return HasExceptionHandling; }
  86. bool hasBulkMemory() const { return HasBulkMemory; }
  87. bool hasMultivalue() const { return HasMultivalue; }
  88. bool hasMutableGlobals() const { return HasMutableGlobals; }
  89. bool hasTailCall() const { return HasTailCall; }
  90. bool hasReferenceTypes() const { return HasReferenceTypes; }
  91. /// Parses features string setting specified subtarget options. Definition of
  92. /// function is auto generated by tblgen.
  93. void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
  94. };
  95. } // end namespace llvm
  96. #endif