blob: 409c8525f93706f5f4619ba690aafe83a6bd071b [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>]>;
Dan Gohmanf71abef2015-09-09 16:13:47 +000031def SDT_WebAssemblyCall0 : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
32def SDT_WebAssemblyCall1 : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>;
JF Bastien600aee92015-07-31 17:53:38 +000033def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
JF Bastien4a2d5602015-07-31 21:04:18 +000034def SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>;
JF Bastienaf111db2015-08-24 22:16:48 +000035def SDT_WebAssemblyWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
36 SDTCisPtrTy<0>]>;
JF Bastien600aee92015-07-31 17:53:38 +000037
Dan Gohman10e730a2015-06-29 23:51:55 +000038//===----------------------------------------------------------------------===//
39// WebAssembly-specific DAG Nodes.
40//===----------------------------------------------------------------------===//
41
JF Bastienaf111db2015-08-24 22:16:48 +000042def WebAssemblycallseq_start :
43 SDNode<"ISD::CALLSEQ_START", SDT_WebAssemblyCallSeqStart,
44 [SDNPHasChain, SDNPOutGlue]>;
45def WebAssemblycallseq_end :
46 SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd,
47 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
Dan Gohmanf71abef2015-09-09 16:13:47 +000048def WebAssemblycall0 : SDNode<"WebAssemblyISD::CALL0",
49 SDT_WebAssemblyCall0,
50 [SDNPHasChain, SDNPVariadic]>;
51def WebAssemblycall1 : SDNode<"WebAssemblyISD::CALL1",
52 SDT_WebAssemblyCall1,
53 [SDNPHasChain, SDNPVariadic]>;
JF Bastien600aee92015-07-31 17:53:38 +000054def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT",
55 SDT_WebAssemblyArgument>;
56def WebAssemblyreturn : SDNode<"WebAssemblyISD::RETURN",
JF Bastienaf111db2015-08-24 22:16:48 +000057 SDT_WebAssemblyReturn, [SDNPHasChain]>;
58def WebAssemblywrapper : SDNode<"WebAssemblyISD::Wrapper",
59 SDT_WebAssemblyWrapper>;
JF Bastien600aee92015-07-31 17:53:38 +000060
Dan Gohman10e730a2015-06-29 23:51:55 +000061//===----------------------------------------------------------------------===//
62// WebAssembly-specific Operands.
63//===----------------------------------------------------------------------===//
64
JF Bastien5ca0bac2015-07-10 18:23:10 +000065/*
66 * TODO(jfb): Add the following.
67 *
68 * get_local: read the current value of a local variable
69 * set_local: set the current value of a local variable
70*/
71
JF Bastienaf111db2015-08-24 22:16:48 +000072def global : Operand<iPTR>;
73
Dan Gohman10e730a2015-06-29 23:51:55 +000074//===----------------------------------------------------------------------===//
75// WebAssembly Instruction Format Definitions.
76//===----------------------------------------------------------------------===//
77
78include "WebAssemblyInstrFormats.td"
79
JF Bastien8f9aea02015-08-01 04:48:44 +000080multiclass ARGUMENT<WebAssemblyRegClass vt> {
81 def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno),
82 [(set vt:$res, (WebAssemblyargument timm:$argno))]>;
83}
84defm : ARGUMENT<Int32>;
85defm : ARGUMENT<Int64>;
86defm : ARGUMENT<Float32>;
87defm : ARGUMENT<Float64>;
JF Bastien600aee92015-07-31 17:53:38 +000088
JF Bastien4a642252015-08-10 22:36:48 +000089
90def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm),
91 [(set Int32:$res, imm:$imm)]>;
92def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm),
93 [(set Int64:$res, imm:$imm)]>;
94def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm),
95 [(set Float32:$res, fpimm:$imm)]>;
96def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm),
97 [(set Float64:$res, fpimm:$imm)]>;
98
JF Bastienaf111db2015-08-24 22:16:48 +000099// Special types of immediates.
100def GLOBAL : I<(outs Int32:$dst), (ins global:$addr),
101 [(set Int32:$dst, (WebAssemblywrapper tglobaladdr:$addr))]>;
102
Dan Gohman10e730a2015-06-29 23:51:55 +0000103//===----------------------------------------------------------------------===//
104// Additional sets of instructions.
105//===----------------------------------------------------------------------===//
106
JF Bastien5ca0bac2015-07-10 18:23:10 +0000107include "WebAssemblyInstrMemory.td"
108include "WebAssemblyInstrCall.td"
JF Bastien600aee92015-07-31 17:53:38 +0000109include "WebAssemblyInstrControl.td"
JF Bastien5ca0bac2015-07-10 18:23:10 +0000110include "WebAssemblyInstrInteger.td"
111include "WebAssemblyInstrFloat.td"
112include "WebAssemblyInstrConv.td"
Dan Gohman10e730a2015-06-29 23:51:55 +0000113include "WebAssemblyInstrAtomics.td"
114include "WebAssemblyInstrSIMD.td"