| Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | //- WebAssembly.td - Describe the WebAssembly Target Machine --*- tablegen -*-// |
| 2 | // |
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
| Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| Dan Gohman | ad664b3 | 2015-12-08 03:33:51 +0000 | [diff] [blame] | 8 | /// |
| 9 | /// \file |
| Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 10 | /// This is a target description file for the WebAssembly architecture, |
| Dan Gohman | ad664b3 | 2015-12-08 03:33:51 +0000 | [diff] [blame] | 11 | /// which is also known as "wasm". |
| 12 | /// |
| Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | // Target-independent interfaces which we are implementing |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
| 19 | include "llvm/Target/Target.td" |
| 20 | |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | // WebAssembly Subtarget features. |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | |
| Thomas Lively | 64a39a1 | 2019-01-10 22:32:11 +0000 | [diff] [blame] | 25 | def FeatureSIMD128 : SubtargetFeature<"simd128", "SIMDLevel", "SIMD128", |
| JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 26 | "Enable 128-bit SIMD">; |
| Thomas Lively | 64a39a1 | 2019-01-10 22:32:11 +0000 | [diff] [blame] | 27 | |
| 28 | def FeatureUnimplementedSIMD128 : |
| 29 | SubtargetFeature<"unimplemented-simd128", |
| 30 | "SIMDLevel", "UnimplementedSIMD128", |
| 31 | "Enable 128-bit SIMD not yet implemented in engines", |
| 32 | [FeatureSIMD128]>; |
| 33 | |
| Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame] | 34 | def FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true", |
| 35 | "Enable Atomics">; |
| Thomas Lively | eafe8ef | 2019-05-23 17:26:47 +0000 | [diff] [blame] | 36 | |
| Dan Gohman | cdd48b8 | 2017-11-28 01:13:40 +0000 | [diff] [blame] | 37 | def FeatureNontrappingFPToInt : |
| 38 | SubtargetFeature<"nontrapping-fptoint", |
| 39 | "HasNontrappingFPToInt", "true", |
| 40 | "Enable non-trapping float-to-int conversion operators">; |
| Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 41 | |
| Dan Gohman | 5d2b935 | 2018-01-19 17:16:24 +0000 | [diff] [blame] | 42 | def FeatureSignExt : |
| 43 | SubtargetFeature<"sign-ext", |
| 44 | "HasSignExt", "true", |
| 45 | "Enable sign extension operators">; |
| 46 | |
| Thomas Lively | eafe8ef | 2019-05-23 17:26:47 +0000 | [diff] [blame] | 47 | def FeatureTailCall : |
| 48 | SubtargetFeature<"tail-call", |
| 49 | "HasTailCall", "true", |
| 50 | "Enable tail call instructions">; |
| 51 | |
| Heejin Ahn | 9386bde | 2018-02-24 00:40:50 +0000 | [diff] [blame] | 52 | def FeatureExceptionHandling : |
| 53 | SubtargetFeature<"exception-handling", "HasExceptionHandling", "true", |
| 54 | "Enable Wasm exception handling">; |
| 55 | |
| Thomas Lively | 88058d4 | 2019-01-31 21:02:19 +0000 | [diff] [blame] | 56 | def FeatureBulkMemory : |
| 57 | SubtargetFeature<"bulk-memory", "HasBulkMemory", "true", |
| 58 | "Enable bulk memory operations">; |
| 59 | |
| Thomas Lively | eafe8ef | 2019-05-23 17:26:47 +0000 | [diff] [blame] | 60 | def FeatureMultivalue : |
| 61 | SubtargetFeature<"multivalue", |
| 62 | "HasMultivalue", "true", |
| 63 | "Enable multivalue blocks, instructions, and functions">; |
| 64 | |
| Thomas Lively | 5f0c4c6 | 2019-03-29 22:00:18 +0000 | [diff] [blame] | 65 | def FeatureMutableGlobals : |
| 66 | SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true", |
| 67 | "Enable mutable globals">; |
| 68 | |
| Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 69 | //===----------------------------------------------------------------------===// |
| 70 | // Architectures. |
| 71 | //===----------------------------------------------------------------------===// |
| 72 | |
| 73 | //===----------------------------------------------------------------------===// |
| 74 | // Register File Description |
| 75 | //===----------------------------------------------------------------------===// |
| 76 | |
| 77 | include "WebAssemblyRegisterInfo.td" |
| 78 | |
| 79 | //===----------------------------------------------------------------------===// |
| 80 | // Instruction Descriptions |
| 81 | //===----------------------------------------------------------------------===// |
| 82 | |
| 83 | include "WebAssemblyInstrInfo.td" |
| 84 | |
| 85 | def WebAssemblyInstrInfo : InstrInfo; |
| 86 | |
| 87 | //===----------------------------------------------------------------------===// |
| 88 | // WebAssembly Processors supported. |
| 89 | //===----------------------------------------------------------------------===// |
| 90 | |
| JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 91 | // Minimal Viable Product. |
| 92 | def : ProcessorModel<"mvp", NoSchedModel, []>; |
| 93 | |
| JF Bastien | 088c47e | 2015-07-27 23:25:54 +0000 | [diff] [blame] | 94 | // Generic processor: latest stable version. |
| 95 | def : ProcessorModel<"generic", NoSchedModel, []>; |
| 96 | |
| JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 97 | // Latest and greatest experimental version of WebAssembly. Bugs included! |
| Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame] | 98 | def : ProcessorModel<"bleeding-edge", NoSchedModel, |
| Thomas Lively | 936734b | 2018-11-10 00:11:14 +0000 | [diff] [blame] | 99 | [FeatureSIMD128, FeatureAtomics, |
| Thomas Lively | 9e27514 | 2019-04-12 20:39:53 +0000 | [diff] [blame] | 100 | FeatureNontrappingFPToInt, FeatureSignExt, |
| 101 | FeatureMutableGlobals]>; |
| Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 102 | |
| 103 | //===----------------------------------------------------------------------===// |
| 104 | // Target Declaration |
| 105 | //===----------------------------------------------------------------------===// |
| 106 | |
| Derek Schuff | e482597 | 2018-03-20 20:06:35 +0000 | [diff] [blame] | 107 | def WebAssemblyAsmParser : AsmParser { |
| 108 | // The physical register names are not in the binary format or asm text |
| 109 | let ShouldEmitMatchRegisterName = 0; |
| 110 | } |
| Reid Kleckner | 440219d5 | 2018-03-21 21:46:47 +0000 | [diff] [blame] | 111 | |
| Sam Clegg | 16c1682 | 2018-05-10 22:16:44 +0000 | [diff] [blame] | 112 | def WebAssemblyAsmWriter : AsmWriter { |
| 113 | string AsmWriterClassName = "InstPrinter"; |
| 114 | int PassSubtarget = 0; |
| 115 | int Variant = 0; |
| 116 | bit isMCAsmWriter = 1; |
| 117 | } |
| 118 | |
| Reid Kleckner | 440219d5 | 2018-03-21 21:46:47 +0000 | [diff] [blame] | 119 | def WebAssembly : Target { |
| 120 | let InstructionSet = WebAssemblyInstrInfo; |
| 121 | let AssemblyParsers = [WebAssemblyAsmParser]; |
| Sam Clegg | 16c1682 | 2018-05-10 22:16:44 +0000 | [diff] [blame] | 122 | let AssemblyWriters = [WebAssemblyAsmWriter]; |
| Reid Kleckner | 440219d5 | 2018-03-21 21:46:47 +0000 | [diff] [blame] | 123 | } |