blob: d73e66ea985d1c5d3e86cbc83836b8e796a7d0d0 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001// WebAssemblyInstrInfo.td-Describe the WebAssembly Instructions-*- tablegen -*-
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
JF Bastien5ca0bac2015-07-10 18:23:10 +00009///
10/// \file
11/// \brief WebAssembly Instruction definitions.
12///
Dan Gohman10e730a2015-06-29 23:51:55 +000013//===----------------------------------------------------------------------===//
14
15//===----------------------------------------------------------------------===//
16// WebAssembly Instruction Predicate Definitions.
17//===----------------------------------------------------------------------===//
18
JF Bastien03855df2015-07-01 23:41:25 +000019def HasAddr32 : Predicate<"!Subtarget->hasAddr64()">;
20def HasAddr64 : Predicate<"Subtarget->hasAddr64()">;
21def HasSIMD128 : Predicate<"Subtarget->hasSIMD128()">,
22 AssemblerPredicate<"FeatureSIMD128", "simd128">;
23
Dan Gohman10e730a2015-06-29 23:51:55 +000024//===----------------------------------------------------------------------===//
25// WebAssembly-specific DAG Node Types.
26//===----------------------------------------------------------------------===//
27
JF Bastienaf111db2015-08-24 22:16:48 +000028def SDT_WebAssemblyCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>]>;
29def SDT_WebAssemblyCallSeqEnd :
30 SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>;
31def SDT_WebAssemblyCall : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>;
JF Bastien600aee92015-07-31 17:53:38 +000032def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
JF Bastien4a2d5602015-07-31 21:04:18 +000033def SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>;
JF Bastienaf111db2015-08-24 22:16:48 +000034def SDT_WebAssemblyWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
35 SDTCisPtrTy<0>]>;
JF Bastien600aee92015-07-31 17:53:38 +000036
Dan Gohman10e730a2015-06-29 23:51:55 +000037//===----------------------------------------------------------------------===//
38// WebAssembly-specific DAG Nodes.
39//===----------------------------------------------------------------------===//
40
JF Bastienaf111db2015-08-24 22:16:48 +000041def WebAssemblycallseq_start :
42 SDNode<"ISD::CALLSEQ_START", SDT_WebAssemblyCallSeqStart,
43 [SDNPHasChain, SDNPOutGlue]>;
44def WebAssemblycallseq_end :
45 SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd,
46 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
47def WebAssemblycall : SDNode<"WebAssemblyISD::CALL",
48 SDT_WebAssemblyCall,
49 [SDNPHasChain, SDNPVariadic]>;
JF Bastien600aee92015-07-31 17:53:38 +000050def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT",
51 SDT_WebAssemblyArgument>;
52def WebAssemblyreturn : SDNode<"WebAssemblyISD::RETURN",
JF Bastienaf111db2015-08-24 22:16:48 +000053 SDT_WebAssemblyReturn, [SDNPHasChain]>;
54def WebAssemblywrapper : SDNode<"WebAssemblyISD::Wrapper",
55 SDT_WebAssemblyWrapper>;
JF Bastien600aee92015-07-31 17:53:38 +000056
Dan Gohman10e730a2015-06-29 23:51:55 +000057//===----------------------------------------------------------------------===//
58// WebAssembly-specific Operands.
59//===----------------------------------------------------------------------===//
60
JF Bastien5ca0bac2015-07-10 18:23:10 +000061/*
62 * TODO(jfb): Add the following.
63 *
64 * get_local: read the current value of a local variable
65 * set_local: set the current value of a local variable
66*/
67
JF Bastienaf111db2015-08-24 22:16:48 +000068def global : Operand<iPTR>;
69
Dan Gohman10e730a2015-06-29 23:51:55 +000070//===----------------------------------------------------------------------===//
71// WebAssembly Instruction Format Definitions.
72//===----------------------------------------------------------------------===//
73
74include "WebAssemblyInstrFormats.td"
75
JF Bastien8f9aea02015-08-01 04:48:44 +000076multiclass ARGUMENT<WebAssemblyRegClass vt> {
77 def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno),
78 [(set vt:$res, (WebAssemblyargument timm:$argno))]>;
79}
80defm : ARGUMENT<Int32>;
81defm : ARGUMENT<Int64>;
82defm : ARGUMENT<Float32>;
83defm : ARGUMENT<Float64>;
JF Bastien600aee92015-07-31 17:53:38 +000084
JF Bastien4a642252015-08-10 22:36:48 +000085
86def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm),
87 [(set Int32:$res, imm:$imm)]>;
88def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm),
89 [(set Int64:$res, imm:$imm)]>;
90def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm),
91 [(set Float32:$res, fpimm:$imm)]>;
92def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm),
93 [(set Float64:$res, fpimm:$imm)]>;
94
JF Bastienaf111db2015-08-24 22:16:48 +000095// Special types of immediates.
96def GLOBAL : I<(outs Int32:$dst), (ins global:$addr),
97 [(set Int32:$dst, (WebAssemblywrapper tglobaladdr:$addr))]>;
98
Dan Gohman10e730a2015-06-29 23:51:55 +000099//===----------------------------------------------------------------------===//
100// Additional sets of instructions.
101//===----------------------------------------------------------------------===//
102
JF Bastien5ca0bac2015-07-10 18:23:10 +0000103include "WebAssemblyInstrMemory.td"
104include "WebAssemblyInstrCall.td"
JF Bastien600aee92015-07-31 17:53:38 +0000105include "WebAssemblyInstrControl.td"
JF Bastien5ca0bac2015-07-10 18:23:10 +0000106include "WebAssemblyInstrInteger.td"
107include "WebAssemblyInstrFloat.td"
108include "WebAssemblyInstrConv.td"
Dan Gohman10e730a2015-06-29 23:51:55 +0000109include "WebAssemblyInstrAtomics.td"
110include "WebAssemblyInstrSIMD.td"