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 FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true", 260b57cec5SDimitry Andric "Enable Atomics">; 270b57cec5SDimitry Andric 28*0fca6ea1SDimitry Andricdef FeatureBulkMemory : 29*0fca6ea1SDimitry Andric SubtargetFeature<"bulk-memory", "HasBulkMemory", "true", 30*0fca6ea1SDimitry Andric "Enable bulk memory operations">; 310b57cec5SDimitry Andric 320b57cec5SDimitry Andricdef FeatureExceptionHandling : 330b57cec5SDimitry Andric SubtargetFeature<"exception-handling", "HasExceptionHandling", "true", 340b57cec5SDimitry Andric "Enable Wasm exception handling">; 350b57cec5SDimitry Andric 36*0fca6ea1SDimitry Andricdef FeatureExtendedConst : 37*0fca6ea1SDimitry Andric SubtargetFeature<"extended-const", "HasExtendedConst", "true", 38*0fca6ea1SDimitry Andric "Enable extended const expressions">; 39*0fca6ea1SDimitry Andric 40*0fca6ea1SDimitry Andricdef FeatureHalfPrecision : 41*0fca6ea1SDimitry Andric SubtargetFeature<"half-precision", "HasHalfPrecision", "true", 42*0fca6ea1SDimitry Andric "Enable half precision instructions">; 43*0fca6ea1SDimitry Andric 44*0fca6ea1SDimitry Andricdef FeatureMultiMemory : 45*0fca6ea1SDimitry Andric SubtargetFeature<"multimemory", "HasMultiMemory", "true", 46*0fca6ea1SDimitry Andric "Enable multiple memories">; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andricdef FeatureMultivalue : 490b57cec5SDimitry Andric SubtargetFeature<"multivalue", 500b57cec5SDimitry Andric "HasMultivalue", "true", 510b57cec5SDimitry Andric "Enable multivalue blocks, instructions, and functions">; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andricdef FeatureMutableGlobals : 540b57cec5SDimitry Andric SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true", 550b57cec5SDimitry Andric "Enable mutable globals">; 560b57cec5SDimitry Andric 57*0fca6ea1SDimitry Andricdef FeatureNontrappingFPToInt : 58*0fca6ea1SDimitry Andric SubtargetFeature<"nontrapping-fptoint", 59*0fca6ea1SDimitry Andric "HasNontrappingFPToInt", "true", 60*0fca6ea1SDimitry Andric "Enable non-trapping float-to-int conversion operators">; 61*0fca6ea1SDimitry Andric 625ffd83dbSDimitry Andricdef FeatureReferenceTypes : 635ffd83dbSDimitry Andric SubtargetFeature<"reference-types", "HasReferenceTypes", "true", 645ffd83dbSDimitry Andric "Enable reference types">; 655ffd83dbSDimitry Andric 66*0fca6ea1SDimitry Andricdef FeatureRelaxedSIMD : 67*0fca6ea1SDimitry Andric SubtargetFeature<"relaxed-simd", "SIMDLevel", "RelaxedSIMD", 68*0fca6ea1SDimitry Andric "Enable relaxed-simd instructions">; 6981ad6265SDimitry Andric 70*0fca6ea1SDimitry Andricdef FeatureSignExt : 71*0fca6ea1SDimitry Andric SubtargetFeature<"sign-ext", "HasSignExt", "true", 72*0fca6ea1SDimitry Andric "Enable sign extension operators">; 73*0fca6ea1SDimitry Andric 74*0fca6ea1SDimitry Andricdef FeatureSIMD128 : SubtargetFeature<"simd128", "SIMDLevel", "SIMD128", 75*0fca6ea1SDimitry Andric "Enable 128-bit SIMD">; 76*0fca6ea1SDimitry Andric 77*0fca6ea1SDimitry Andricdef FeatureTailCall : 78*0fca6ea1SDimitry Andric SubtargetFeature<"tail-call", "HasTailCall", "true", 79*0fca6ea1SDimitry Andric "Enable tail call instructions">; 805f757f3fSDimitry Andric 810b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 820b57cec5SDimitry Andric// Architectures. 830b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 860b57cec5SDimitry Andric// Register File Description 870b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 880b57cec5SDimitry Andric 890b57cec5SDimitry Andricinclude "WebAssemblyRegisterInfo.td" 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 920b57cec5SDimitry Andric// Instruction Descriptions 930b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 940b57cec5SDimitry Andric 950b57cec5SDimitry Andricinclude "WebAssemblyInstrInfo.td" 960b57cec5SDimitry Andric 970b57cec5SDimitry Andricdef WebAssemblyInstrInfo : InstrInfo; 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1000b57cec5SDimitry Andric// WebAssembly Processors supported. 1010b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric// Minimal Viable Product. 1040b57cec5SDimitry Andricdef : ProcessorModel<"mvp", NoSchedModel, []>; 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric// Generic processor: latest stable version. 107bdd1243dSDimitry Andric// 108bdd1243dSDimitry Andric// This includes features that have achieved phase 4 of the standards process, 109bdd1243dSDimitry Andric// and that are expected to work for most users in the current time, with 110bdd1243dSDimitry Andric// consideration given to available support in relevant engines and tools, and 111bdd1243dSDimitry Andric// the importance of the features. 112bdd1243dSDimitry Andricdef : ProcessorModel<"generic", NoSchedModel, 113*0fca6ea1SDimitry Andric [FeatureMultivalue, FeatureMutableGlobals, 114*0fca6ea1SDimitry Andric FeatureReferenceTypes, FeatureSignExt]>; 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric// Latest and greatest experimental version of WebAssembly. Bugs included! 1170b57cec5SDimitry Andricdef : ProcessorModel<"bleeding-edge", NoSchedModel, 118*0fca6ea1SDimitry Andric [FeatureAtomics, FeatureBulkMemory, 119*0fca6ea1SDimitry Andric FeatureExceptionHandling, FeatureExtendedConst, 120*0fca6ea1SDimitry Andric FeatureHalfPrecision, FeatureMultiMemory, 121*0fca6ea1SDimitry Andric FeatureMultivalue, FeatureMutableGlobals, 122*0fca6ea1SDimitry Andric FeatureNontrappingFPToInt, FeatureRelaxedSIMD, 123*0fca6ea1SDimitry Andric FeatureReferenceTypes, FeatureSIMD128, FeatureSignExt, 1245ffd83dbSDimitry Andric FeatureTailCall]>; 1250b57cec5SDimitry Andric 1260b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1270b57cec5SDimitry Andric// Target Declaration 1280b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andricdef WebAssemblyAsmParser : AsmParser { 1310b57cec5SDimitry Andric // The physical register names are not in the binary format or asm text 1320b57cec5SDimitry Andric let ShouldEmitMatchRegisterName = 0; 1330b57cec5SDimitry Andric} 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andricdef WebAssemblyAsmWriter : AsmWriter { 1360b57cec5SDimitry Andric string AsmWriterClassName = "InstPrinter"; 1370b57cec5SDimitry Andric int PassSubtarget = 0; 1380b57cec5SDimitry Andric int Variant = 0; 1390b57cec5SDimitry Andric bit isMCAsmWriter = 1; 1400b57cec5SDimitry Andric} 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andricdef WebAssembly : Target { 1430b57cec5SDimitry Andric let InstructionSet = WebAssemblyInstrInfo; 1440b57cec5SDimitry Andric let AssemblyParsers = [WebAssemblyAsmParser]; 1450b57cec5SDimitry Andric let AssemblyWriters = [WebAssemblyAsmWriter]; 1460b57cec5SDimitry Andric} 147