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_WebAssemblyCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>]>;
29 def SDT_WebAssemblyCallSeqEnd :
30 SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>;
31 def SDT_WebAssemblyCall0 : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
32 def SDT_WebAssemblyCall1 : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>;
33 def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
34 def SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>;
35 def SDT_WebAssemblyWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
38 //===----------------------------------------------------------------------===//
39 // WebAssembly-specific DAG Nodes.
40 //===----------------------------------------------------------------------===//
42 def WebAssemblycallseq_start :
43 SDNode<"ISD::CALLSEQ_START", SDT_WebAssemblyCallSeqStart,
44 [SDNPHasChain, SDNPOutGlue]>;
45 def WebAssemblycallseq_end :
46 SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd,
47 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
48 def WebAssemblycall0 : SDNode<"WebAssemblyISD::CALL0",
50 [SDNPHasChain, SDNPVariadic]>;
51 def WebAssemblycall1 : SDNode<"WebAssemblyISD::CALL1",
53 [SDNPHasChain, SDNPVariadic]>;
54 def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT",
55 SDT_WebAssemblyArgument>;
56 def WebAssemblyreturn : SDNode<"WebAssemblyISD::RETURN",
57 SDT_WebAssemblyReturn, [SDNPHasChain]>;
58 def WebAssemblywrapper : SDNode<"WebAssemblyISD::Wrapper",
59 SDT_WebAssemblyWrapper>;
61 //===----------------------------------------------------------------------===//
62 // WebAssembly-specific Operands.
63 //===----------------------------------------------------------------------===//
66 * TODO(jfb): Add the following.
68 * get_local: read the current value of a local variable
69 * set_local: set the current value of a local variable
72 def global : Operand<iPTR>;
74 //===----------------------------------------------------------------------===//
75 // WebAssembly Instruction Format Definitions.
76 //===----------------------------------------------------------------------===//
78 include "WebAssemblyInstrFormats.td"
80 multiclass ARGUMENT<WebAssemblyRegClass vt> {
81 def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno),
82 [(set vt:$res, (WebAssemblyargument timm:$argno))]>;
84 defm : ARGUMENT<Int32>;
85 defm : ARGUMENT<Int64>;
86 defm : ARGUMENT<Float32>;
87 defm : ARGUMENT<Float64>;
90 def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm),
91 [(set Int32:$res, imm:$imm)]>;
92 def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm),
93 [(set Int64:$res, imm:$imm)]>;
94 def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm),
95 [(set Float32:$res, fpimm:$imm)]>;
96 def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm),
97 [(set Float64:$res, fpimm:$imm)]>;
99 // Special types of immediates.
100 def GLOBAL : I<(outs Int32:$dst), (ins global:$addr),
101 [(set Int32:$dst, (WebAssemblywrapper tglobaladdr:$addr))]>;
103 //===----------------------------------------------------------------------===//
104 // Additional sets of instructions.
105 //===----------------------------------------------------------------------===//
107 include "WebAssemblyInstrMemory.td"
108 include "WebAssemblyInstrCall.td"
109 include "WebAssemblyInstrControl.td"
110 include "WebAssemblyInstrInteger.td"
111 include "WebAssemblyInstrFloat.td"
112 include "WebAssemblyInstrConv.td"
113 include "WebAssemblyInstrAtomics.td"
114 include "WebAssemblyInstrSIMD.td"