xref: /freebsd/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssembly.td (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric//- WebAssembly.td - Describe the WebAssembly Target Machine --*- tablegen -*-//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric///
90b57cec5SDimitry Andric/// \file
100b57cec5SDimitry Andric/// This is a target description file for the WebAssembly architecture,
110b57cec5SDimitry Andric/// which is also known as "wasm".
120b57cec5SDimitry Andric///
130b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
140b57cec5SDimitry Andric
150b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
160b57cec5SDimitry Andric// Target-independent interfaces which we are implementing
170b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
180b57cec5SDimitry Andric
190b57cec5SDimitry Andricinclude "llvm/Target/Target.td"
200b57cec5SDimitry Andric
210b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
220b57cec5SDimitry Andric// WebAssembly Subtarget features.
230b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
240b57cec5SDimitry Andric
250b57cec5SDimitry Andricdef FeatureSIMD128 : SubtargetFeature<"simd128", "SIMDLevel", "SIMD128",
260b57cec5SDimitry Andric                                      "Enable 128-bit SIMD">;
270b57cec5SDimitry Andric
28349cc55cSDimitry Andricdef FeatureRelaxedSIMD : SubtargetFeature<"relaxed-simd", "SIMDLevel", "RelaxedSIMD",
29349cc55cSDimitry Andric                                      "Enable relaxed-simd instructions">;
30349cc55cSDimitry Andric
310b57cec5SDimitry Andricdef FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true",
320b57cec5SDimitry Andric                                      "Enable Atomics">;
330b57cec5SDimitry Andric
340b57cec5SDimitry Andricdef FeatureNontrappingFPToInt :
350b57cec5SDimitry Andric      SubtargetFeature<"nontrapping-fptoint",
360b57cec5SDimitry Andric                       "HasNontrappingFPToInt", "true",
370b57cec5SDimitry Andric                       "Enable non-trapping float-to-int conversion operators">;
380b57cec5SDimitry Andric
390b57cec5SDimitry Andricdef FeatureSignExt :
400b57cec5SDimitry Andric      SubtargetFeature<"sign-ext",
410b57cec5SDimitry Andric                       "HasSignExt", "true",
420b57cec5SDimitry Andric                       "Enable sign extension operators">;
430b57cec5SDimitry Andric
440b57cec5SDimitry Andricdef FeatureTailCall :
450b57cec5SDimitry Andric      SubtargetFeature<"tail-call",
460b57cec5SDimitry Andric                       "HasTailCall", "true",
470b57cec5SDimitry Andric                       "Enable tail call instructions">;
480b57cec5SDimitry Andric
490b57cec5SDimitry Andricdef FeatureExceptionHandling :
500b57cec5SDimitry Andric      SubtargetFeature<"exception-handling", "HasExceptionHandling", "true",
510b57cec5SDimitry Andric                       "Enable Wasm exception handling">;
520b57cec5SDimitry Andric
530b57cec5SDimitry Andricdef FeatureBulkMemory :
540b57cec5SDimitry Andric      SubtargetFeature<"bulk-memory", "HasBulkMemory", "true",
550b57cec5SDimitry Andric                       "Enable bulk memory operations">;
560b57cec5SDimitry Andric
570b57cec5SDimitry Andricdef FeatureMultivalue :
580b57cec5SDimitry Andric      SubtargetFeature<"multivalue",
590b57cec5SDimitry Andric                       "HasMultivalue", "true",
600b57cec5SDimitry Andric                       "Enable multivalue blocks, instructions, and functions">;
610b57cec5SDimitry Andric
620b57cec5SDimitry Andricdef FeatureMutableGlobals :
630b57cec5SDimitry Andric      SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true",
640b57cec5SDimitry Andric                       "Enable mutable globals">;
650b57cec5SDimitry Andric
665ffd83dbSDimitry Andricdef FeatureReferenceTypes :
675ffd83dbSDimitry Andric      SubtargetFeature<"reference-types", "HasReferenceTypes", "true",
685ffd83dbSDimitry Andric                       "Enable reference types">;
695ffd83dbSDimitry Andric
7081ad6265SDimitry Andricdef FeatureExtendedConst :
7181ad6265SDimitry Andric      SubtargetFeature<"extended-const", "HasExtendedConst", "true",
7281ad6265SDimitry Andric                       "Enable extended const expressions">;
7381ad6265SDimitry Andric
74*5f757f3fSDimitry Andricdef FeatureMultiMemory :
75*5f757f3fSDimitry Andric      SubtargetFeature<"multimemory", "HasMultiMemory", "true",
76*5f757f3fSDimitry Andric                       "Enable multiple memories">;
77*5f757f3fSDimitry Andric
780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
790b57cec5SDimitry Andric// Architectures.
800b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
810b57cec5SDimitry Andric
820b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
830b57cec5SDimitry Andric// Register File Description
840b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
850b57cec5SDimitry Andric
860b57cec5SDimitry Andricinclude "WebAssemblyRegisterInfo.td"
870b57cec5SDimitry Andric
880b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
890b57cec5SDimitry Andric// Instruction Descriptions
900b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
910b57cec5SDimitry Andric
920b57cec5SDimitry Andricinclude "WebAssemblyInstrInfo.td"
930b57cec5SDimitry Andric
940b57cec5SDimitry Andricdef WebAssemblyInstrInfo : InstrInfo;
950b57cec5SDimitry Andric
960b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
970b57cec5SDimitry Andric// WebAssembly Processors supported.
980b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
990b57cec5SDimitry Andric
1000b57cec5SDimitry Andric// Minimal Viable Product.
1010b57cec5SDimitry Andricdef : ProcessorModel<"mvp", NoSchedModel, []>;
1020b57cec5SDimitry Andric
1030b57cec5SDimitry Andric// Generic processor: latest stable version.
104bdd1243dSDimitry Andric//
105bdd1243dSDimitry Andric// This includes features that have achieved phase 4 of the standards process,
106bdd1243dSDimitry Andric// and that are expected to work for most users in the current time, with
107bdd1243dSDimitry Andric// consideration given to available support in relevant engines and tools, and
108bdd1243dSDimitry Andric// the importance of the features.
109bdd1243dSDimitry Andricdef : ProcessorModel<"generic", NoSchedModel,
110bdd1243dSDimitry Andric                      [FeatureSignExt, FeatureMutableGlobals]>;
1110b57cec5SDimitry Andric
1120b57cec5SDimitry Andric// Latest and greatest experimental version of WebAssembly. Bugs included!
1130b57cec5SDimitry Andricdef : ProcessorModel<"bleeding-edge", NoSchedModel,
1140b57cec5SDimitry Andric                      [FeatureSIMD128, FeatureAtomics,
1150b57cec5SDimitry Andric                       FeatureNontrappingFPToInt, FeatureSignExt,
1165ffd83dbSDimitry Andric                       FeatureMutableGlobals, FeatureBulkMemory,
1175ffd83dbSDimitry Andric                       FeatureTailCall]>;
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1200b57cec5SDimitry Andric// Target Declaration
1210b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1220b57cec5SDimitry Andric
1230b57cec5SDimitry Andricdef WebAssemblyAsmParser : AsmParser {
1240b57cec5SDimitry Andric  // The physical register names are not in the binary format or asm text
1250b57cec5SDimitry Andric  let ShouldEmitMatchRegisterName = 0;
1260b57cec5SDimitry Andric}
1270b57cec5SDimitry Andric
1280b57cec5SDimitry Andricdef WebAssemblyAsmWriter : AsmWriter {
1290b57cec5SDimitry Andric  string AsmWriterClassName  = "InstPrinter";
1300b57cec5SDimitry Andric  int PassSubtarget = 0;
1310b57cec5SDimitry Andric  int Variant = 0;
1320b57cec5SDimitry Andric  bit isMCAsmWriter = 1;
1330b57cec5SDimitry Andric}
1340b57cec5SDimitry Andric
1350b57cec5SDimitry Andricdef WebAssembly : Target {
1360b57cec5SDimitry Andric  let InstructionSet = WebAssemblyInstrInfo;
1370b57cec5SDimitry Andric  let AssemblyParsers  = [WebAssemblyAsmParser];
1380b57cec5SDimitry Andric  let AssemblyWriters = [WebAssemblyAsmWriter];
1390b57cec5SDimitry Andric}
140