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 FeatureRelaxedSIMD : SubtargetFeature<"relaxed-simd", "SIMDLevel", "RelaxedSIMD", 29 "Enable relaxed-simd instructions">; 30 31def FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true", 32 "Enable Atomics">; 33 34def FeatureNontrappingFPToInt : 35 SubtargetFeature<"nontrapping-fptoint", 36 "HasNontrappingFPToInt", "true", 37 "Enable non-trapping float-to-int conversion operators">; 38 39def FeatureSignExt : 40 SubtargetFeature<"sign-ext", 41 "HasSignExt", "true", 42 "Enable sign extension operators">; 43 44def FeatureTailCall : 45 SubtargetFeature<"tail-call", 46 "HasTailCall", "true", 47 "Enable tail call instructions">; 48 49def FeatureExceptionHandling : 50 SubtargetFeature<"exception-handling", "HasExceptionHandling", "true", 51 "Enable Wasm exception handling">; 52 53def FeatureBulkMemory : 54 SubtargetFeature<"bulk-memory", "HasBulkMemory", "true", 55 "Enable bulk memory operations">; 56 57def FeatureMultivalue : 58 SubtargetFeature<"multivalue", 59 "HasMultivalue", "true", 60 "Enable multivalue blocks, instructions, and functions">; 61 62def FeatureMutableGlobals : 63 SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true", 64 "Enable mutable globals">; 65 66def FeatureReferenceTypes : 67 SubtargetFeature<"reference-types", "HasReferenceTypes", "true", 68 "Enable reference types">; 69 70def FeatureExtendedConst : 71 SubtargetFeature<"extended-const", "HasExtendedConst", "true", 72 "Enable extended const expressions">; 73 74def FeatureMultiMemory : 75 SubtargetFeature<"multimemory", "HasMultiMemory", "true", 76 "Enable multiple memories">; 77 78//===----------------------------------------------------------------------===// 79// Architectures. 80//===----------------------------------------------------------------------===// 81 82//===----------------------------------------------------------------------===// 83// Register File Description 84//===----------------------------------------------------------------------===// 85 86include "WebAssemblyRegisterInfo.td" 87 88//===----------------------------------------------------------------------===// 89// Instruction Descriptions 90//===----------------------------------------------------------------------===// 91 92include "WebAssemblyInstrInfo.td" 93 94def WebAssemblyInstrInfo : InstrInfo; 95 96//===----------------------------------------------------------------------===// 97// WebAssembly Processors supported. 98//===----------------------------------------------------------------------===// 99 100// Minimal Viable Product. 101def : ProcessorModel<"mvp", NoSchedModel, []>; 102 103// Generic processor: latest stable version. 104// 105// This includes features that have achieved phase 4 of the standards process, 106// and that are expected to work for most users in the current time, with 107// consideration given to available support in relevant engines and tools, and 108// the importance of the features. 109def : ProcessorModel<"generic", NoSchedModel, 110 [FeatureSignExt, FeatureMutableGlobals]>; 111 112// Latest and greatest experimental version of WebAssembly. Bugs included! 113def : ProcessorModel<"bleeding-edge", NoSchedModel, 114 [FeatureSIMD128, FeatureAtomics, 115 FeatureNontrappingFPToInt, FeatureSignExt, 116 FeatureMutableGlobals, FeatureBulkMemory, 117 FeatureTailCall]>; 118 119//===----------------------------------------------------------------------===// 120// Target Declaration 121//===----------------------------------------------------------------------===// 122 123def WebAssemblyAsmParser : AsmParser { 124 // The physical register names are not in the binary format or asm text 125 let ShouldEmitMatchRegisterName = 0; 126} 127 128def WebAssemblyAsmWriter : AsmWriter { 129 string AsmWriterClassName = "InstPrinter"; 130 int PassSubtarget = 0; 131 int Variant = 0; 132 bit isMCAsmWriter = 1; 133} 134 135def WebAssembly : Target { 136 let InstructionSet = WebAssemblyInstrInfo; 137 let AssemblyParsers = [WebAssemblyAsmParser]; 138 let AssemblyWriters = [WebAssemblyAsmWriter]; 139} 140