1 //- WebAssembly.td - Describe the WebAssembly Target Machine --*- tablegen -*-//
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
7 //===----------------------------------------------------------------------===//
10 /// This is a target description file for the WebAssembly architecture,
11 /// which is also known as "wasm".
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
16 // Target-independent interfaces which we are implementing
17 //===----------------------------------------------------------------------===//
19 include "llvm/Target/Target.td"
21 //===----------------------------------------------------------------------===//
22 // WebAssembly Subtarget features.
23 //===----------------------------------------------------------------------===//
25 def FeatureSIMD128 : SubtargetFeature<"simd128", "SIMDLevel", "SIMD128",
26 "Enable 128-bit SIMD">;
28 def FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true",
31 def FeatureNontrappingFPToInt :
32 SubtargetFeature<"nontrapping-fptoint",
33 "HasNontrappingFPToInt", "true",
34 "Enable non-trapping float-to-int conversion operators">;
37 SubtargetFeature<"sign-ext",
39 "Enable sign extension operators">;
42 SubtargetFeature<"tail-call",
43 "HasTailCall", "true",
44 "Enable tail call instructions">;
46 def FeatureExceptionHandling :
47 SubtargetFeature<"exception-handling", "HasExceptionHandling", "true",
48 "Enable Wasm exception handling">;
50 def FeatureBulkMemory :
51 SubtargetFeature<"bulk-memory", "HasBulkMemory", "true",
52 "Enable bulk memory operations">;
54 def FeatureMultivalue :
55 SubtargetFeature<"multivalue",
56 "HasMultivalue", "true",
57 "Enable multivalue blocks, instructions, and functions">;
59 def FeatureMutableGlobals :
60 SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true",
61 "Enable mutable globals">;
63 def FeatureReferenceTypes :
64 SubtargetFeature<"reference-types", "HasReferenceTypes", "true",
65 "Enable reference types">;
67 //===----------------------------------------------------------------------===//
69 //===----------------------------------------------------------------------===//
71 //===----------------------------------------------------------------------===//
72 // Register File Description
73 //===----------------------------------------------------------------------===//
75 include "WebAssemblyRegisterInfo.td"
77 //===----------------------------------------------------------------------===//
78 // Instruction Descriptions
79 //===----------------------------------------------------------------------===//
81 include "WebAssemblyInstrInfo.td"
83 def WebAssemblyInstrInfo : InstrInfo;
85 //===----------------------------------------------------------------------===//
86 // WebAssembly Processors supported.
87 //===----------------------------------------------------------------------===//
89 // Minimal Viable Product.
90 def : ProcessorModel<"mvp", NoSchedModel, []>;
92 // Generic processor: latest stable version.
93 def : ProcessorModel<"generic", NoSchedModel, []>;
95 // Latest and greatest experimental version of WebAssembly. Bugs included!
96 def : ProcessorModel<"bleeding-edge", NoSchedModel,
97 [FeatureSIMD128, FeatureAtomics,
98 FeatureNontrappingFPToInt, FeatureSignExt,
99 FeatureMutableGlobals, FeatureBulkMemory,
102 //===----------------------------------------------------------------------===//
103 // Target Declaration
104 //===----------------------------------------------------------------------===//
106 def WebAssemblyAsmParser : AsmParser {
107 // The physical register names are not in the binary format or asm text
108 let ShouldEmitMatchRegisterName = 0;
111 def WebAssemblyAsmWriter : AsmWriter {
112 string AsmWriterClassName = "InstPrinter";
113 int PassSubtarget = 0;
115 bit isMCAsmWriter = 1;
118 def WebAssembly : Target {
119 let InstructionSet = WebAssemblyInstrInfo;
120 let AssemblyParsers = [WebAssemblyAsmParser];
121 let AssemblyWriters = [WebAssemblyAsmWriter];