WebAssembly.td 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //- WebAssembly.td - Describe the WebAssembly Target Machine --*- tablegen -*-//
  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 is a target description file for the WebAssembly architecture,
  11. /// which is also known as "wasm".
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. //===----------------------------------------------------------------------===//
  15. // Target-independent interfaces which we are implementing
  16. //===----------------------------------------------------------------------===//
  17. include "llvm/Target/Target.td"
  18. //===----------------------------------------------------------------------===//
  19. // WebAssembly Subtarget features.
  20. //===----------------------------------------------------------------------===//
  21. def FeatureSIMD128 : SubtargetFeature<"simd128", "SIMDLevel", "SIMD128",
  22. "Enable 128-bit SIMD">;
  23. def FeatureRelaxedSIMD : SubtargetFeature<"relaxed-simd", "SIMDLevel", "RelaxedSIMD",
  24. "Enable relaxed-simd instructions">;
  25. def FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true",
  26. "Enable Atomics">;
  27. def FeatureNontrappingFPToInt :
  28. SubtargetFeature<"nontrapping-fptoint",
  29. "HasNontrappingFPToInt", "true",
  30. "Enable non-trapping float-to-int conversion operators">;
  31. def FeatureSignExt :
  32. SubtargetFeature<"sign-ext",
  33. "HasSignExt", "true",
  34. "Enable sign extension operators">;
  35. def FeatureTailCall :
  36. SubtargetFeature<"tail-call",
  37. "HasTailCall", "true",
  38. "Enable tail call instructions">;
  39. def FeatureExceptionHandling :
  40. SubtargetFeature<"exception-handling", "HasExceptionHandling", "true",
  41. "Enable Wasm exception handling">;
  42. def FeatureBulkMemory :
  43. SubtargetFeature<"bulk-memory", "HasBulkMemory", "true",
  44. "Enable bulk memory operations">;
  45. def FeatureMultivalue :
  46. SubtargetFeature<"multivalue",
  47. "HasMultivalue", "true",
  48. "Enable multivalue blocks, instructions, and functions">;
  49. def FeatureMutableGlobals :
  50. SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true",
  51. "Enable mutable globals">;
  52. def FeatureReferenceTypes :
  53. SubtargetFeature<"reference-types", "HasReferenceTypes", "true",
  54. "Enable reference types">;
  55. def FeatureExtendedConst :
  56. SubtargetFeature<"extended-const", "HasExtendedConst", "true",
  57. "Enable extended const expressions">;
  58. //===----------------------------------------------------------------------===//
  59. // Architectures.
  60. //===----------------------------------------------------------------------===//
  61. //===----------------------------------------------------------------------===//
  62. // Register File Description
  63. //===----------------------------------------------------------------------===//
  64. include "WebAssemblyRegisterInfo.td"
  65. //===----------------------------------------------------------------------===//
  66. // Instruction Descriptions
  67. //===----------------------------------------------------------------------===//
  68. include "WebAssemblyInstrInfo.td"
  69. def WebAssemblyInstrInfo : InstrInfo;
  70. //===----------------------------------------------------------------------===//
  71. // WebAssembly Processors supported.
  72. //===----------------------------------------------------------------------===//
  73. // Minimal Viable Product.
  74. def : ProcessorModel<"mvp", NoSchedModel, []>;
  75. // Generic processor: latest stable version.
  76. //
  77. // This includes features that have achieved phase 4 of the standards process,
  78. // and that are expected to work for most users in the current time, with
  79. // consideration given to available support in relevant engines and tools, and
  80. // the importance of the features.
  81. def : ProcessorModel<"generic", NoSchedModel,
  82. [FeatureSignExt, FeatureMutableGlobals]>;
  83. // Latest and greatest experimental version of WebAssembly. Bugs included!
  84. def : ProcessorModel<"bleeding-edge", NoSchedModel,
  85. [FeatureSIMD128, FeatureAtomics,
  86. FeatureNontrappingFPToInt, FeatureSignExt,
  87. FeatureMutableGlobals, FeatureBulkMemory,
  88. FeatureTailCall]>;
  89. //===----------------------------------------------------------------------===//
  90. // Target Declaration
  91. //===----------------------------------------------------------------------===//
  92. def WebAssemblyAsmParser : AsmParser {
  93. // The physical register names are not in the binary format or asm text
  94. let ShouldEmitMatchRegisterName = 0;
  95. }
  96. def WebAssemblyAsmWriter : AsmWriter {
  97. string AsmWriterClassName = "InstPrinter";
  98. int PassSubtarget = 0;
  99. int Variant = 0;
  100. bit isMCAsmWriter = 1;
  101. }
  102. def WebAssembly : Target {
  103. let InstructionSet = WebAssemblyInstrInfo;
  104. let AssemblyParsers = [WebAssemblyAsmParser];
  105. let AssemblyWriters = [WebAssemblyAsmWriter];
  106. }