1 // WebAssemblyInstrInfo.td-Describe the WebAssembly Instructions-*- tablegen -*-
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief WebAssembly Instruction definitions.
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
16 // WebAssembly Instruction Predicate Definitions.
17 //===----------------------------------------------------------------------===//
19 def HasAddr32 : Predicate<"!Subtarget->hasAddr64()">;
20 def HasAddr64 : Predicate<"Subtarget->hasAddr64()">;
21 def HasSIMD128 : Predicate<"Subtarget->hasSIMD128()">,
22 AssemblerPredicate<"FeatureSIMD128", "simd128">;
24 //===----------------------------------------------------------------------===//
25 // WebAssembly-specific DAG Node Types.
26 //===----------------------------------------------------------------------===//
28 def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
29 def SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>;
31 //===----------------------------------------------------------------------===//
32 // WebAssembly-specific DAG Nodes.
33 //===----------------------------------------------------------------------===//
35 def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT",
36 SDT_WebAssemblyArgument>;
37 def WebAssemblyreturn : SDNode<"WebAssemblyISD::RETURN",
38 SDT_WebAssemblyReturn,
39 [SDNPHasChain, SDNPSideEffect]>;
41 //===----------------------------------------------------------------------===//
42 // WebAssembly-specific Operands.
43 //===----------------------------------------------------------------------===//
46 * TODO(jfb): Add the following.
48 * get_local: read the current value of a local variable
49 * set_local: set the current value of a local variable
52 //===----------------------------------------------------------------------===//
53 // WebAssembly Instruction Format Definitions.
54 //===----------------------------------------------------------------------===//
56 include "WebAssemblyInstrFormats.td"
58 multiclass ARGUMENT<WebAssemblyRegClass vt> {
59 def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno),
60 [(set vt:$res, (WebAssemblyargument timm:$argno))]>;
62 defm : ARGUMENT<Int32>;
63 defm : ARGUMENT<Int64>;
64 defm : ARGUMENT<Float32>;
65 defm : ARGUMENT<Float64>;
68 def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm),
69 [(set Int32:$res, imm:$imm)]>;
70 def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm),
71 [(set Int64:$res, imm:$imm)]>;
72 def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm),
73 [(set Float32:$res, fpimm:$imm)]>;
74 def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm),
75 [(set Float64:$res, fpimm:$imm)]>;
77 //===----------------------------------------------------------------------===//
78 // Additional sets of instructions.
79 //===----------------------------------------------------------------------===//
81 include "WebAssemblyInstrMemory.td"
82 include "WebAssemblyInstrCall.td"
83 include "WebAssemblyInstrControl.td"
84 include "WebAssemblyInstrInteger.td"
85 include "WebAssemblyInstrFloat.td"
86 include "WebAssemblyInstrConv.td"
87 include "WebAssemblyInstrAtomics.td"
88 include "WebAssemblyInstrSIMD.td"