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//===----------------------------------------------------------------------===//
16// Target-independent interfaces which we are implementing
17//===----------------------------------------------------------------------===//
18
19include "llvm/Target/Target.td"
20
21//===----------------------------------------------------------------------===//
22// WebAssembly Subtarget features.
23//===----------------------------------------------------------------------===//
24
25def FeatureSIMD128 : SubtargetFeature<"simd128", "SIMDLevel", "SIMD128",
26                                      "Enable 128-bit SIMD">;
27
28def FeatureUnimplementedSIMD128 :
29      SubtargetFeature<"unimplemented-simd128",
30                       "SIMDLevel", "UnimplementedSIMD128",
31                       "Enable 128-bit SIMD not yet implemented in engines",
32                       [FeatureSIMD128]>;
33
34def FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true",
35                                      "Enable Atomics">;
36def FeatureNontrappingFPToInt :
37      SubtargetFeature<"nontrapping-fptoint",
38                       "HasNontrappingFPToInt", "true",
39                       "Enable non-trapping float-to-int conversion operators">;
40
41def FeatureSignExt :
42      SubtargetFeature<"sign-ext",
43                       "HasSignExt", "true",
44                       "Enable sign extension operators">;
45
46def FeatureExceptionHandling :
47      SubtargetFeature<"exception-handling", "HasExceptionHandling", "true",
48                       "Enable Wasm exception handling">;
49
50def FeatureBulkMemory :
51      SubtargetFeature<"bulk-memory", "HasBulkMemory", "true",
52                       "Enable bulk memory operations">;
53
54def FeatureMutableGlobals :
55      SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true",
56                       "Enable mutable globals">;
57
58//===----------------------------------------------------------------------===//
59// Architectures.
60//===----------------------------------------------------------------------===//
61
62//===----------------------------------------------------------------------===//
63// Register File Description
64//===----------------------------------------------------------------------===//
65
66include "WebAssemblyRegisterInfo.td"
67
68//===----------------------------------------------------------------------===//
69// Instruction Descriptions
70//===----------------------------------------------------------------------===//
71
72include "WebAssemblyInstrInfo.td"
73
74def WebAssemblyInstrInfo : InstrInfo;
75
76//===----------------------------------------------------------------------===//
77// WebAssembly Processors supported.
78//===----------------------------------------------------------------------===//
79
80// Minimal Viable Product.
81def : ProcessorModel<"mvp", NoSchedModel, []>;
82
83// Generic processor: latest stable version.
84def : ProcessorModel<"generic", NoSchedModel, []>;
85
86// Latest and greatest experimental version of WebAssembly. Bugs included!
87def : ProcessorModel<"bleeding-edge", NoSchedModel,
88                      [FeatureSIMD128, FeatureAtomics,
89                       FeatureNontrappingFPToInt, FeatureSignExt,
90                       FeatureMutableGlobals]>;
91
92//===----------------------------------------------------------------------===//
93// Target Declaration
94//===----------------------------------------------------------------------===//
95
96def WebAssemblyAsmParser : AsmParser {
97  // The physical register names are not in the binary format or asm text
98  let ShouldEmitMatchRegisterName = 0;
99}
100
101def WebAssemblyAsmWriter : AsmWriter {
102  string AsmWriterClassName  = "InstPrinter";
103  int PassSubtarget = 0;
104  int Variant = 0;
105  bit isMCAsmWriter = 1;
106}
107
108def WebAssembly : Target {
109  let InstructionSet = WebAssemblyInstrInfo;
110  let AssemblyParsers  = [WebAssemblyAsmParser];
111  let AssemblyWriters = [WebAssemblyAsmWriter];
112}
113