blob: b0b8a9b996a37b0604fa7e61c1ad05b4df6b6b88 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//- WebAssembly.td - Describe the WebAssembly Target Machine --*- tablegen -*-//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Gohman10e730a2015-06-29 23:51:55 +00006//
7//===----------------------------------------------------------------------===//
Dan Gohmanad664b32015-12-08 03:33:51 +00008///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This is a target description file for the WebAssembly architecture,
Dan Gohmanad664b32015-12-08 03:33:51 +000011/// which is also known as "wasm".
12///
Dan Gohman10e730a2015-06-29 23:51:55 +000013//===----------------------------------------------------------------------===//
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
Thomas Lively64a39a12019-01-10 22:32:11 +000025def FeatureSIMD128 : SubtargetFeature<"simd128", "SIMDLevel", "SIMD128",
JF Bastien03855df2015-07-01 23:41:25 +000026 "Enable 128-bit SIMD">;
Thomas Lively64a39a12019-01-10 22:32:11 +000027
28def FeatureUnimplementedSIMD128 :
29 SubtargetFeature<"unimplemented-simd128",
30 "SIMDLevel", "UnimplementedSIMD128",
31 "Enable 128-bit SIMD not yet implemented in engines",
32 [FeatureSIMD128]>;
33
Derek Schuff18ba1922017-08-30 18:07:45 +000034def FeatureAtomics : SubtargetFeature<"atomics", "HasAtomics", "true",
35 "Enable Atomics">;
Thomas Livelyeafe8ef2019-05-23 17:26:47 +000036
Dan Gohmancdd48b82017-11-28 01:13:40 +000037def FeatureNontrappingFPToInt :
38 SubtargetFeature<"nontrapping-fptoint",
39 "HasNontrappingFPToInt", "true",
40 "Enable non-trapping float-to-int conversion operators">;
Dan Gohman10e730a2015-06-29 23:51:55 +000041
Dan Gohman5d2b9352018-01-19 17:16:24 +000042def FeatureSignExt :
43 SubtargetFeature<"sign-ext",
44 "HasSignExt", "true",
45 "Enable sign extension operators">;
46
Thomas Livelyeafe8ef2019-05-23 17:26:47 +000047def FeatureTailCall :
48 SubtargetFeature<"tail-call",
49 "HasTailCall", "true",
50 "Enable tail call instructions">;
51
Heejin Ahn9386bde2018-02-24 00:40:50 +000052def FeatureExceptionHandling :
53 SubtargetFeature<"exception-handling", "HasExceptionHandling", "true",
54 "Enable Wasm exception handling">;
55
Thomas Lively88058d42019-01-31 21:02:19 +000056def FeatureBulkMemory :
57 SubtargetFeature<"bulk-memory", "HasBulkMemory", "true",
58 "Enable bulk memory operations">;
59
Thomas Livelyeafe8ef2019-05-23 17:26:47 +000060def FeatureMultivalue :
61 SubtargetFeature<"multivalue",
62 "HasMultivalue", "true",
63 "Enable multivalue blocks, instructions, and functions">;
64
Thomas Lively5f0c4c62019-03-29 22:00:18 +000065def FeatureMutableGlobals :
66 SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true",
67 "Enable mutable globals">;
68
Dan Gohman10e730a2015-06-29 23:51:55 +000069//===----------------------------------------------------------------------===//
70// Architectures.
71//===----------------------------------------------------------------------===//
72
73//===----------------------------------------------------------------------===//
74// Register File Description
75//===----------------------------------------------------------------------===//
76
77include "WebAssemblyRegisterInfo.td"
78
79//===----------------------------------------------------------------------===//
80// Instruction Descriptions
81//===----------------------------------------------------------------------===//
82
83include "WebAssemblyInstrInfo.td"
84
85def WebAssemblyInstrInfo : InstrInfo;
86
87//===----------------------------------------------------------------------===//
88// WebAssembly Processors supported.
89//===----------------------------------------------------------------------===//
90
JF Bastien03855df2015-07-01 23:41:25 +000091// Minimal Viable Product.
92def : ProcessorModel<"mvp", NoSchedModel, []>;
93
JF Bastien088c47e2015-07-27 23:25:54 +000094// Generic processor: latest stable version.
95def : ProcessorModel<"generic", NoSchedModel, []>;
96
JF Bastien03855df2015-07-01 23:41:25 +000097// Latest and greatest experimental version of WebAssembly. Bugs included!
Derek Schuff18ba1922017-08-30 18:07:45 +000098def : ProcessorModel<"bleeding-edge", NoSchedModel,
Thomas Lively936734b2018-11-10 00:11:14 +000099 [FeatureSIMD128, FeatureAtomics,
Thomas Lively9e275142019-04-12 20:39:53 +0000100 FeatureNontrappingFPToInt, FeatureSignExt,
101 FeatureMutableGlobals]>;
Dan Gohman10e730a2015-06-29 23:51:55 +0000102
103//===----------------------------------------------------------------------===//
104// Target Declaration
105//===----------------------------------------------------------------------===//
106
Derek Schuffe4825972018-03-20 20:06:35 +0000107def WebAssemblyAsmParser : AsmParser {
108 // The physical register names are not in the binary format or asm text
109 let ShouldEmitMatchRegisterName = 0;
110}
Reid Kleckner440219d52018-03-21 21:46:47 +0000111
Sam Clegg16c16822018-05-10 22:16:44 +0000112def WebAssemblyAsmWriter : AsmWriter {
113 string AsmWriterClassName = "InstPrinter";
114 int PassSubtarget = 0;
115 int Variant = 0;
116 bit isMCAsmWriter = 1;
117}
118
Reid Kleckner440219d52018-03-21 21:46:47 +0000119def WebAssembly : Target {
120 let InstructionSet = WebAssemblyInstrInfo;
121 let AssemblyParsers = [WebAssemblyAsmParser];
Sam Clegg16c16822018-05-10 22:16:44 +0000122 let AssemblyWriters = [WebAssemblyAsmWriter];
Reid Kleckner440219d52018-03-21 21:46:47 +0000123}