blob: 521c664ca4ab8bafd6a61b6bbd90e8636c487933 [file] [log] [blame]
JF Bastien5ca0bac2015-07-10 18:23:10 +00001// WebAssemblyInstrMemory.td-WebAssembly Memory codegen support -*- 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//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief WebAssembly Memory operand code-gen constructs.
12///
13//===----------------------------------------------------------------------===//
14
Dan Gohman9c54d3b2015-11-25 18:13:18 +000015// TODO:
JF Bastien73ff6af2015-08-31 22:24:11 +000016// - HasAddr64
JF Bastien73ff6af2015-08-31 22:24:11 +000017// - WebAssemblyTargetLowering having to do with atomics
Dan Gohman4b9d7912015-12-15 22:01:29 +000018// - Each has optional alignment.
JF Bastien73ff6af2015-08-31 22:24:11 +000019
20// WebAssembly has i8/i16/i32/i64/f32/f64 memory types, but doesn't have i8/i16
21// local types. These memory-only types instead zero- or sign-extend into local
22// types when loading, and truncate when storing.
23
Dan Gohman4b9d7912015-12-15 22:01:29 +000024// WebAssembly constant offsets are performed as unsigned with infinite
25// precision, so we need to check for NoUnsignedWrap so that we don't fold an
26// offset for an add that needs wrapping.
Dan Gohmanf225a632016-01-11 22:05:44 +000027def regPlusImm : PatFrag<(ops node:$addr, node:$off),
Dan Gohman4b9d7912015-12-15 22:01:29 +000028 (add node:$addr, node:$off),
29 [{ return N->getFlags()->hasNoUnsignedWrap(); }]>;
30
Dan Gohman3b09d272016-02-22 20:04:02 +000031// Treat an 'or' node as an 'add' if the or'ed bits are known to be zero.
32def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
33 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
34 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
35
36 APInt KnownZero0, KnownOne0;
37 CurDAG->computeKnownBits(N->getOperand(0), KnownZero0, KnownOne0, 0);
38 APInt KnownZero1, KnownOne1;
39 CurDAG->computeKnownBits(N->getOperand(1), KnownZero1, KnownOne1, 0);
40 return (~KnownZero0 & ~KnownZero1) == 0;
41}]>;
42
Dan Gohmanf225a632016-01-11 22:05:44 +000043// GlobalAddresses are conceptually unsigned values, so we can also fold them
44// into immediate values as long as their offsets are non-negative.
45def regPlusGA : PatFrag<(ops node:$addr, node:$off),
46 (add node:$addr, node:$off),
47 [{
48 return N->getFlags()->hasNoUnsignedWrap() ||
49 (N->getOperand(1)->getOpcode() == WebAssemblyISD::Wrapper &&
50 isa<GlobalAddressSDNode>(N->getOperand(1)->getOperand(0)) &&
51 cast<GlobalAddressSDNode>(N->getOperand(1)->getOperand(0))
52 ->getOffset() >= 0);
53}]>;
54
55// We don't need a regPlusES because external symbols never have constant
56// offsets folded into them, so we can just use add.
57
Dan Gohmanfb3e0592015-11-25 19:36:19 +000058let Defs = [ARGUMENTS] in {
59
JF Bastien73ff6af2015-08-31 22:24:11 +000060// Basic load.
Dan Gohmanbb372242016-01-26 03:39:31 +000061def LOAD_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
62 P2Align:$p2align), [],
63 "i32.load\t$dst, ${off}(${addr})${p2align}">;
64def LOAD_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
65 P2Align:$p2align), [],
66 "i64.load\t$dst, ${off}(${addr})${p2align}">;
67def LOAD_F32 : I<(outs F32:$dst), (ins i32imm:$off, I32:$addr,
68 P2Align:$p2align), [],
69 "f32.load\t$dst, ${off}(${addr})${p2align}">;
70def LOAD_F64 : I<(outs F64:$dst), (ins i32imm:$off, I32:$addr,
71 P2Align:$p2align), [],
72 "f64.load\t$dst, ${off}(${addr})${p2align}">;
JF Bastien73ff6af2015-08-31 22:24:11 +000073
Dan Gohman4b9d7912015-12-15 22:01:29 +000074} // Defs = [ARGUMENTS]
75
76// Select loads with no constant offset.
Dan Gohmanbb372242016-01-26 03:39:31 +000077def : Pat<(i32 (load I32:$addr)), (LOAD_I32 0, $addr, 0)>;
78def : Pat<(i64 (load I32:$addr)), (LOAD_I64 0, $addr, 0)>;
79def : Pat<(f32 (load I32:$addr)), (LOAD_F32 0, $addr, 0)>;
80def : Pat<(f64 (load I32:$addr)), (LOAD_F64 0, $addr, 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +000081
82// Select loads with a constant offset.
Dan Gohmanf225a632016-01-11 22:05:44 +000083def : Pat<(i32 (load (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +000084 (LOAD_I32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +000085def : Pat<(i64 (load (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +000086 (LOAD_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +000087def : Pat<(f32 (load (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +000088 (LOAD_F32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +000089def : Pat<(f64 (load (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +000090 (LOAD_F64 imm:$off, $addr, 0)>;
Dan Gohman3b09d272016-02-22 20:04:02 +000091def : Pat<(i32 (load (or_is_add I32:$addr, imm:$off))),
92 (LOAD_I32 imm:$off, $addr, 0)>;
93def : Pat<(i64 (load (or_is_add I32:$addr, imm:$off))),
94 (LOAD_I64 imm:$off, $addr, 0)>;
95def : Pat<(f32 (load (or_is_add I32:$addr, imm:$off))),
96 (LOAD_F32 imm:$off, $addr, 0)>;
97def : Pat<(f64 (load (or_is_add I32:$addr, imm:$off))),
98 (LOAD_F64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +000099def : Pat<(i32 (load (regPlusGA I32:$addr,
100 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000101 (LOAD_I32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000102def : Pat<(i64 (load (regPlusGA I32:$addr,
103 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000104 (LOAD_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000105def : Pat<(f32 (load (regPlusGA I32:$addr,
106 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000107 (LOAD_F32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000108def : Pat<(f64 (load (regPlusGA I32:$addr,
109 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000110 (LOAD_F64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000111def : Pat<(i32 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000112 (LOAD_I32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000113def : Pat<(i64 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000114 (LOAD_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000115def : Pat<(f32 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000116 (LOAD_F32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000117def : Pat<(f64 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000118 (LOAD_F64 texternalsym:$off, $addr, 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000119
120// Select loads with just a constant offset.
Dan Gohmanbb372242016-01-26 03:39:31 +0000121def : Pat<(i32 (load imm:$off)), (LOAD_I32 imm:$off, (CONST_I32 0), 0)>;
122def : Pat<(i64 (load imm:$off)), (LOAD_I64 imm:$off, (CONST_I32 0), 0)>;
123def : Pat<(f32 (load imm:$off)), (LOAD_F32 imm:$off, (CONST_I32 0), 0)>;
124def : Pat<(f64 (load imm:$off)), (LOAD_F64 imm:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000125def : Pat<(i32 (load (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000126 (LOAD_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000127def : Pat<(i64 (load (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000128 (LOAD_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000129def : Pat<(f32 (load (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000130 (LOAD_F32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000131def : Pat<(f64 (load (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000132 (LOAD_F64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000133def : Pat<(i32 (load (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000134 (LOAD_I32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000135def : Pat<(i64 (load (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000136 (LOAD_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000137def : Pat<(f32 (load (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000138 (LOAD_F32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000139def : Pat<(f64 (load (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000140 (LOAD_F64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000141
142let Defs = [ARGUMENTS] in {
143
JF Bastien73ff6af2015-08-31 22:24:11 +0000144// Extending load.
Dan Gohmanbb372242016-01-26 03:39:31 +0000145def LOAD8_S_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
146 P2Align:$p2align), [],
147 "i32.load8_s\t$dst, ${off}(${addr})${p2align}">;
148def LOAD8_U_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
149 P2Align:$p2align), [],
150 "i32.load8_u\t$dst, ${off}(${addr})${p2align}">;
151def LOAD16_S_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
152 P2Align:$p2align), [],
153 "i32.load16_s\t$dst, ${off}(${addr})${p2align}">;
154def LOAD16_U_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
155 P2Align:$p2align), [],
156 "i32.load16_u\t$dst, ${off}(${addr})${p2align}">;
157def LOAD8_S_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
158 P2Align:$p2align), [],
159 "i64.load8_s\t$dst, ${off}(${addr})${p2align}">;
160def LOAD8_U_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
161 P2Align:$p2align), [],
162 "i64.load8_u\t$dst, ${off}(${addr})${p2align}">;
163def LOAD16_S_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
164 P2Align:$p2align), [],
165 "i64.load16_s\t$dst, ${off}(${addr})${p2align}">;
166def LOAD16_U_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
167 P2Align:$p2align), [],
168 "i64.load16_u\t$dst, ${off}(${addr})${p2align}">;
169def LOAD32_S_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
170 P2Align:$p2align), [],
171 "i64.load32_s\t$dst, ${off}(${addr})${p2align}">;
172def LOAD32_U_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
173 P2Align:$p2align), [],
174 "i64.load32_u\t$dst, ${off}(${addr})${p2align}">;
JF Bastien73ff6af2015-08-31 22:24:11 +0000175
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000176} // Defs = [ARGUMENTS]
177
Derek Schuff9d779522015-12-05 00:26:39 +0000178// Select extending loads with no constant offset.
Dan Gohmanbb372242016-01-26 03:39:31 +0000179def : Pat<(i32 (sextloadi8 I32:$addr)), (LOAD8_S_I32 0, $addr, 0)>;
180def : Pat<(i32 (zextloadi8 I32:$addr)), (LOAD8_U_I32 0, $addr, 0)>;
181def : Pat<(i32 (sextloadi16 I32:$addr)), (LOAD16_S_I32 0, $addr, 0)>;
182def : Pat<(i32 (zextloadi16 I32:$addr)), (LOAD16_U_I32 0, $addr, 0)>;
183def : Pat<(i64 (sextloadi8 I32:$addr)), (LOAD8_S_I64 0, $addr, 0)>;
184def : Pat<(i64 (zextloadi8 I32:$addr)), (LOAD8_U_I64 0, $addr, 0)>;
185def : Pat<(i64 (sextloadi16 I32:$addr)), (LOAD16_S_I64 0, $addr, 0)>;
186def : Pat<(i64 (zextloadi16 I32:$addr)), (LOAD16_U_I64 0, $addr, 0)>;
187def : Pat<(i64 (sextloadi32 I32:$addr)), (LOAD32_S_I64 0, $addr, 0)>;
188def : Pat<(i64 (zextloadi32 I32:$addr)), (LOAD32_U_I64 0, $addr, 0)>;
Derek Schuff9d779522015-12-05 00:26:39 +0000189
Dan Gohman4b9d7912015-12-15 22:01:29 +0000190// Select extending loads with a constant offset.
Dan Gohmanf225a632016-01-11 22:05:44 +0000191def : Pat<(i32 (sextloadi8 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000192 (LOAD8_S_I32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000193def : Pat<(i32 (zextloadi8 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000194 (LOAD8_U_I32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000195def : Pat<(i32 (sextloadi16 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000196 (LOAD16_S_I32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000197def : Pat<(i32 (zextloadi16 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000198 (LOAD16_U_I32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000199def : Pat<(i64 (sextloadi8 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000200 (LOAD8_S_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000201def : Pat<(i64 (zextloadi8 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000202 (LOAD8_U_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000203def : Pat<(i64 (sextloadi16 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000204 (LOAD16_S_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000205def : Pat<(i64 (zextloadi16 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000206 (LOAD16_U_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000207def : Pat<(i64 (sextloadi32 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000208 (LOAD32_S_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000209def : Pat<(i64 (zextloadi32 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000210 (LOAD32_U_I64 imm:$off, $addr, 0)>;
Dan Gohman3b09d272016-02-22 20:04:02 +0000211def : Pat<(i32 (sextloadi8 (or_is_add I32:$addr, imm:$off))),
212 (LOAD8_S_I32 imm:$off, $addr, 0)>;
213def : Pat<(i32 (zextloadi8 (or_is_add I32:$addr, imm:$off))),
214 (LOAD8_U_I32 imm:$off, $addr, 0)>;
215def : Pat<(i32 (sextloadi16 (or_is_add I32:$addr, imm:$off))),
216 (LOAD16_S_I32 imm:$off, $addr, 0)>;
217def : Pat<(i32 (zextloadi16 (or_is_add I32:$addr, imm:$off))),
218 (LOAD16_U_I32 imm:$off, $addr, 0)>;
219def : Pat<(i64 (sextloadi8 (or_is_add I32:$addr, imm:$off))),
220 (LOAD8_S_I64 imm:$off, $addr, 0)>;
221def : Pat<(i64 (zextloadi8 (or_is_add I32:$addr, imm:$off))),
222 (LOAD8_U_I64 imm:$off, $addr, 0)>;
223def : Pat<(i64 (sextloadi16 (or_is_add I32:$addr, imm:$off))),
224 (LOAD16_S_I64 imm:$off, $addr, 0)>;
225def : Pat<(i64 (zextloadi16 (or_is_add I32:$addr, imm:$off))),
226 (LOAD16_U_I64 imm:$off, $addr, 0)>;
227def : Pat<(i64 (sextloadi32 (or_is_add I32:$addr, imm:$off))),
228 (LOAD32_S_I64 imm:$off, $addr, 0)>;
229def : Pat<(i64 (zextloadi32 (or_is_add I32:$addr, imm:$off))),
230 (LOAD32_U_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000231def : Pat<(i32 (sextloadi8 (regPlusGA I32:$addr,
232 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000233 (LOAD8_S_I32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000234def : Pat<(i32 (zextloadi8 (regPlusGA I32:$addr,
235 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000236 (LOAD8_U_I32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000237def : Pat<(i32 (sextloadi16 (regPlusGA I32:$addr,
238 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000239 (LOAD16_S_I32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000240def : Pat<(i32 (zextloadi16 (regPlusGA I32:$addr,
241 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000242 (LOAD16_U_I32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000243def : Pat<(i64 (sextloadi8 (regPlusGA I32:$addr,
244 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000245 (LOAD8_S_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000246def : Pat<(i64 (zextloadi8 (regPlusGA I32:$addr,
247 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000248 (LOAD8_U_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000249def : Pat<(i64 (sextloadi16 (regPlusGA I32:$addr,
250 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000251 (LOAD16_S_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000252def : Pat<(i64 (zextloadi16 (regPlusGA I32:$addr,
253 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000254 (LOAD16_U_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000255def : Pat<(i64 (sextloadi32 (regPlusGA I32:$addr,
256 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000257 (LOAD32_S_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000258def : Pat<(i64 (zextloadi32 (regPlusGA I32:$addr,
259 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000260 (LOAD32_U_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000261def : Pat<(i32 (sextloadi8 (add I32:$addr,
262 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000263 (LOAD8_S_I32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000264def : Pat<(i32 (zextloadi8 (add I32:$addr,
265 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000266 (LOAD8_U_I32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000267def : Pat<(i32 (sextloadi16 (add I32:$addr,
268 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000269 (LOAD16_S_I32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000270def : Pat<(i32 (zextloadi16 (add I32:$addr,
271 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000272 (LOAD16_U_I32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000273def : Pat<(i64 (sextloadi8 (add I32:$addr,
274 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000275 (LOAD8_S_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000276def : Pat<(i64 (zextloadi8 (add I32:$addr,
277 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000278 (LOAD8_U_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000279def : Pat<(i64 (sextloadi16 (add I32:$addr,
280 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000281 (LOAD16_S_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000282def : Pat<(i64 (zextloadi16 (add I32:$addr,
283 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000284 (LOAD16_U_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000285def : Pat<(i64 (sextloadi32 (add I32:$addr,
286 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000287 (LOAD32_S_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000288def : Pat<(i64 (zextloadi32 (add I32:$addr,
289 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000290 (LOAD32_U_I64 texternalsym:$off, $addr, 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000291
292// Select extending loads with just a constant offset.
Dan Gohmanbb372242016-01-26 03:39:31 +0000293def : Pat<(i32 (sextloadi8 imm:$off)),
294 (LOAD8_S_I32 imm:$off, (CONST_I32 0), 0)>;
295def : Pat<(i32 (zextloadi8 imm:$off)),
296 (LOAD8_U_I32 imm:$off, (CONST_I32 0), 0)>;
297def : Pat<(i32 (sextloadi16 imm:$off)),
298 (LOAD16_S_I32 imm:$off, (CONST_I32 0), 0)>;
299def : Pat<(i32 (zextloadi16 imm:$off)),
300 (LOAD16_U_I32 imm:$off, (CONST_I32 0), 0)>;
301def : Pat<(i64 (sextloadi8 imm:$off)),
302 (LOAD8_S_I64 imm:$off, (CONST_I32 0), 0)>;
303def : Pat<(i64 (zextloadi8 imm:$off)),
304 (LOAD8_U_I64 imm:$off, (CONST_I32 0), 0)>;
305def : Pat<(i64 (sextloadi16 imm:$off)),
306 (LOAD16_S_I64 imm:$off, (CONST_I32 0), 0)>;
307def : Pat<(i64 (zextloadi16 imm:$off)),
308 (LOAD16_U_I64 imm:$off, (CONST_I32 0), 0)>;
309def : Pat<(i64 (sextloadi32 imm:$off)),
310 (LOAD32_S_I64 imm:$off, (CONST_I32 0), 0)>;
311def : Pat<(i64 (zextloadi32 imm:$off)),
312 (LOAD32_U_I64 imm:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000313def : Pat<(i32 (sextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000314 (LOAD8_S_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000315def : Pat<(i32 (zextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000316 (LOAD8_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000317def : Pat<(i32 (sextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000318 (LOAD16_S_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000319def : Pat<(i32 (zextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000320 (LOAD16_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000321def : Pat<(i64 (sextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000322 (LOAD8_S_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000323def : Pat<(i64 (zextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000324 (LOAD8_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000325def : Pat<(i64 (sextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000326 (LOAD16_S_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000327def : Pat<(i64 (zextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000328 (LOAD16_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000329def : Pat<(i64 (sextloadi32 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000330 (LOAD32_S_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000331def : Pat<(i64 (zextloadi32 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000332 (LOAD32_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000333def : Pat<(i32 (sextloadi8 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000334 (LOAD8_S_I32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000335def : Pat<(i32 (zextloadi8 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000336 (LOAD8_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000337def : Pat<(i32 (sextloadi16 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000338 (LOAD16_S_I32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000339def : Pat<(i32 (zextloadi16 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000340 (LOAD16_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000341def : Pat<(i64 (sextloadi8 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000342 (LOAD8_S_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000343def : Pat<(i64 (zextloadi8 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000344 (LOAD8_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000345def : Pat<(i64 (sextloadi16 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000346 (LOAD16_S_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000347def : Pat<(i64 (zextloadi16 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000348 (LOAD16_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000349def : Pat<(i64 (sextloadi32 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000350 (LOAD32_S_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000351def : Pat<(i64 (zextloadi32 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000352 (LOAD32_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000353
354// Resolve "don't care" extending loads to zero-extending loads. This is
355// somewhat arbitrary, but zero-extending is conceptually simpler.
356
357// Select "don't care" extending loads with no constant offset.
Dan Gohmanbb372242016-01-26 03:39:31 +0000358def : Pat<(i32 (extloadi8 I32:$addr)), (LOAD8_U_I32 0, $addr, 0)>;
359def : Pat<(i32 (extloadi16 I32:$addr)), (LOAD16_U_I32 0, $addr, 0)>;
360def : Pat<(i64 (extloadi8 I32:$addr)), (LOAD8_U_I64 0, $addr, 0)>;
361def : Pat<(i64 (extloadi16 I32:$addr)), (LOAD16_U_I64 0, $addr, 0)>;
362def : Pat<(i64 (extloadi32 I32:$addr)), (LOAD32_U_I64 0, $addr, 0)>;
JF Bastien73ff6af2015-08-31 22:24:11 +0000363
Dan Gohman4b9d7912015-12-15 22:01:29 +0000364// Select "don't care" extending loads with a constant offset.
Dan Gohmanf225a632016-01-11 22:05:44 +0000365def : Pat<(i32 (extloadi8 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000366 (LOAD8_U_I32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000367def : Pat<(i32 (extloadi16 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000368 (LOAD16_U_I32 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000369def : Pat<(i64 (extloadi8 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000370 (LOAD8_U_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000371def : Pat<(i64 (extloadi16 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000372 (LOAD16_U_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000373def : Pat<(i64 (extloadi32 (regPlusImm I32:$addr, imm:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000374 (LOAD32_U_I64 imm:$off, $addr, 0)>;
Dan Gohman3b09d272016-02-22 20:04:02 +0000375def : Pat<(i32 (extloadi8 (or_is_add I32:$addr, imm:$off))),
376 (LOAD8_U_I32 imm:$off, $addr, 0)>;
377def : Pat<(i32 (extloadi16 (or_is_add I32:$addr, imm:$off))),
378 (LOAD16_U_I32 imm:$off, $addr, 0)>;
379def : Pat<(i64 (extloadi8 (or_is_add I32:$addr, imm:$off))),
380 (LOAD8_U_I64 imm:$off, $addr, 0)>;
381def : Pat<(i64 (extloadi16 (or_is_add I32:$addr, imm:$off))),
382 (LOAD16_U_I64 imm:$off, $addr, 0)>;
383def : Pat<(i64 (extloadi32 (or_is_add I32:$addr, imm:$off))),
384 (LOAD32_U_I64 imm:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000385def : Pat<(i32 (extloadi8 (regPlusGA I32:$addr,
386 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000387 (LOAD8_U_I32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000388def : Pat<(i32 (extloadi16 (regPlusGA I32:$addr,
389 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000390 (LOAD16_U_I32 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000391def : Pat<(i64 (extloadi8 (regPlusGA I32:$addr,
392 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000393 (LOAD8_U_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000394def : Pat<(i64 (extloadi16 (regPlusGA I32:$addr,
395 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000396 (LOAD16_U_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000397def : Pat<(i64 (extloadi32 (regPlusGA I32:$addr,
398 (WebAssemblywrapper tglobaladdr:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000399 (LOAD32_U_I64 tglobaladdr:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000400def : Pat<(i32 (extloadi8 (add I32:$addr,
401 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000402 (LOAD8_U_I32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000403def : Pat<(i32 (extloadi16 (add I32:$addr,
404 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000405 (LOAD16_U_I32 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000406def : Pat<(i64 (extloadi8 (add I32:$addr,
407 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000408 (LOAD8_U_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000409def : Pat<(i64 (extloadi16 (add I32:$addr,
410 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000411 (LOAD16_U_I64 texternalsym:$off, $addr, 0)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000412def : Pat<(i64 (extloadi32 (add I32:$addr,
413 (WebAssemblywrapper texternalsym:$off)))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000414 (LOAD32_U_I64 texternalsym:$off, $addr, 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000415
416// Select "don't care" extending loads with just a constant offset.
Dan Gohmanbb372242016-01-26 03:39:31 +0000417def : Pat<(i32 (extloadi8 imm:$off)),
418 (LOAD8_U_I32 imm:$off, (CONST_I32 0), 0)>;
419def : Pat<(i32 (extloadi16 imm:$off)),
420 (LOAD16_U_I32 imm:$off, (CONST_I32 0), 0)>;
421def : Pat<(i64 (extloadi8 imm:$off)),
422 (LOAD8_U_I64 imm:$off, (CONST_I32 0), 0)>;
423def : Pat<(i64 (extloadi16 imm:$off)),
424 (LOAD16_U_I64 imm:$off, (CONST_I32 0), 0)>;
425def : Pat<(i64 (extloadi32 imm:$off)),
426 (LOAD32_U_I64 imm:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000427def : Pat<(i32 (extloadi8 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000428 (LOAD8_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000429def : Pat<(i32 (extloadi16 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000430 (LOAD16_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000431def : Pat<(i64 (extloadi8 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000432 (LOAD8_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000433def : Pat<(i64 (extloadi16 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000434 (LOAD16_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000435def : Pat<(i64 (extloadi32 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000436 (LOAD32_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000437def : Pat<(i32 (extloadi8 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000438 (LOAD8_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000439def : Pat<(i32 (extloadi16 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000440 (LOAD16_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000441def : Pat<(i64 (extloadi8 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000442 (LOAD8_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000443def : Pat<(i64 (extloadi16 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000444 (LOAD16_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000445def : Pat<(i64 (extloadi32 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000446 (LOAD32_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000447
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000448let Defs = [ARGUMENTS] in {
449
JF Bastien73ff6af2015-08-31 22:24:11 +0000450// Basic store.
Dan Gohman7054ac12015-11-23 21:16:35 +0000451// Note that we split the patterns out of the instruction definitions because
452// WebAssembly's stores return their operand value, and tablegen doesn't like
453// instruction definition patterns that don't reference all of the output
454// operands.
JF Bastien73ff6af2015-08-31 22:24:11 +0000455// Note: WebAssembly inverts SelectionDAG's usual operand order.
Dan Gohmanbb372242016-01-26 03:39:31 +0000456def STORE_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
457 P2Align:$p2align, I32:$val), [],
458 "i32.store\t$dst, ${off}(${addr})${p2align}, $val">;
459def STORE_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
460 P2Align:$p2align, I64:$val), [],
461 "i64.store\t$dst, ${off}(${addr})${p2align}, $val">;
462def STORE_F32 : I<(outs F32:$dst), (ins i32imm:$off, I32:$addr,
463 P2Align:$p2align, F32:$val), [],
464 "f32.store\t$dst, ${off}(${addr})${p2align}, $val">;
465def STORE_F64 : I<(outs F64:$dst), (ins i32imm:$off, I32:$addr,
466 P2Align:$p2align, F64:$val), [],
467 "f64.store\t$dst, ${off}(${addr})${p2align}, $val">;
Dan Gohman7054ac12015-11-23 21:16:35 +0000468
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000469} // Defs = [ARGUMENTS]
470
Dan Gohman4b9d7912015-12-15 22:01:29 +0000471// Select stores with no constant offset.
Dan Gohmanbb372242016-01-26 03:39:31 +0000472def : Pat<(store I32:$val, I32:$addr), (STORE_I32 0, I32:$addr, 0, I32:$val)>;
473def : Pat<(store I64:$val, I32:$addr), (STORE_I64 0, I32:$addr, 0, I64:$val)>;
474def : Pat<(store F32:$val, I32:$addr), (STORE_F32 0, I32:$addr, 0, F32:$val)>;
475def : Pat<(store F64:$val, I32:$addr), (STORE_F64 0, I32:$addr, 0, F64:$val)>;
Derek Schuff9d779522015-12-05 00:26:39 +0000476
Dan Gohman4b9d7912015-12-15 22:01:29 +0000477// Select stores with a constant offset.
Dan Gohmanf225a632016-01-11 22:05:44 +0000478def : Pat<(store I32:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000479 (STORE_I32 imm:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000480def : Pat<(store I64:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000481 (STORE_I64 imm:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000482def : Pat<(store F32:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000483 (STORE_F32 imm:$off, I32:$addr, 0, F32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000484def : Pat<(store F64:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000485 (STORE_F64 imm:$off, I32:$addr, 0, F64:$val)>;
Dan Gohman3b09d272016-02-22 20:04:02 +0000486def : Pat<(store I32:$val, (or_is_add I32:$addr, imm:$off)),
487 (STORE_I32 imm:$off, I32:$addr, 0, I32:$val)>;
488def : Pat<(store I64:$val, (or_is_add I32:$addr, imm:$off)),
489 (STORE_I64 imm:$off, I32:$addr, 0, I64:$val)>;
490def : Pat<(store F32:$val, (or_is_add I32:$addr, imm:$off)),
491 (STORE_F32 imm:$off, I32:$addr, 0, F32:$val)>;
492def : Pat<(store F64:$val, (or_is_add I32:$addr, imm:$off)),
493 (STORE_F64 imm:$off, I32:$addr, 0, F64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000494def : Pat<(store I32:$val, (regPlusGA I32:$addr,
495 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000496 (STORE_I32 tglobaladdr:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000497def : Pat<(store I64:$val, (regPlusGA I32:$addr,
498 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000499 (STORE_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000500def : Pat<(store F32:$val, (regPlusGA I32:$addr,
501 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000502 (STORE_F32 tglobaladdr:$off, I32:$addr, 0, F32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000503def : Pat<(store F64:$val, (regPlusGA I32:$addr,
504 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000505 (STORE_F64 tglobaladdr:$off, I32:$addr, 0, F64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000506def : Pat<(store I32:$val, (add I32:$addr,
507 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000508 (STORE_I32 texternalsym:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000509def : Pat<(store I64:$val, (add I32:$addr,
510 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000511 (STORE_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000512def : Pat<(store F32:$val, (add I32:$addr,
513 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000514 (STORE_F32 texternalsym:$off, I32:$addr, 0, F32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000515def : Pat<(store F64:$val, (add I32:$addr,
516 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000517 (STORE_F64 texternalsym:$off, I32:$addr, 0, F64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000518
519// Select stores with just a constant offset.
520def : Pat<(store I32:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000521 (STORE_I32 imm:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000522def : Pat<(store I64:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000523 (STORE_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000524def : Pat<(store F32:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000525 (STORE_F32 imm:$off, (CONST_I32 0), 0, F32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000526def : Pat<(store F64:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000527 (STORE_F64 imm:$off, (CONST_I32 0), 0, F64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000528def : Pat<(store I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000529 (STORE_I32 tglobaladdr:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000530def : Pat<(store I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000531 (STORE_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000532def : Pat<(store F32:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000533 (STORE_F32 tglobaladdr:$off, (CONST_I32 0), 0, F32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000534def : Pat<(store F64:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000535 (STORE_F64 tglobaladdr:$off, (CONST_I32 0), 0, F64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000536def : Pat<(store I32:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000537 (STORE_I32 texternalsym:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000538def : Pat<(store I64:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000539 (STORE_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000540def : Pat<(store F32:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000541 (STORE_F32 texternalsym:$off, (CONST_I32 0), 0, F32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000542def : Pat<(store F64:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000543 (STORE_F64 texternalsym:$off, (CONST_I32 0), 0, F64:$val)>;
JF Bastien73ff6af2015-08-31 22:24:11 +0000544
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000545let Defs = [ARGUMENTS] in {
546
JF Bastien73ff6af2015-08-31 22:24:11 +0000547// Truncating store.
Dan Gohmanbb372242016-01-26 03:39:31 +0000548def STORE8_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
549 P2Align:$p2align, I32:$val), [],
550 "i32.store8\t$dst, ${off}(${addr})${p2align}, $val">;
551def STORE16_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
552 P2Align:$p2align, I32:$val), [],
553 "i32.store16\t$dst, ${off}(${addr})${p2align}, $val">;
554def STORE8_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
555 P2Align:$p2align, I64:$val), [],
556 "i64.store8\t$dst, ${off}(${addr})${p2align}, $val">;
557def STORE16_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
558 P2Align:$p2align, I64:$val), [],
559 "i64.store16\t$dst, ${off}(${addr})${p2align}, $val">;
560def STORE32_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
561 P2Align:$p2align, I64:$val), [],
562 "i64.store32\t$dst, ${off}(${addr})${p2align}, $val">;
Dan Gohman7054ac12015-11-23 21:16:35 +0000563
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000564} // Defs = [ARGUMENTS]
565
Dan Gohman4b9d7912015-12-15 22:01:29 +0000566// Select truncating stores with no constant offset.
Dan Gohman7054ac12015-11-23 21:16:35 +0000567def : Pat<(truncstorei8 I32:$val, I32:$addr),
Dan Gohmanbb372242016-01-26 03:39:31 +0000568 (STORE8_I32 0, I32:$addr, 0, I32:$val)>;
Dan Gohman7054ac12015-11-23 21:16:35 +0000569def : Pat<(truncstorei16 I32:$val, I32:$addr),
Dan Gohmanbb372242016-01-26 03:39:31 +0000570 (STORE16_I32 0, I32:$addr, 0, I32:$val)>;
Dan Gohman7054ac12015-11-23 21:16:35 +0000571def : Pat<(truncstorei8 I64:$val, I32:$addr),
Dan Gohmanbb372242016-01-26 03:39:31 +0000572 (STORE8_I64 0, I32:$addr, 0, I64:$val)>;
Dan Gohman7054ac12015-11-23 21:16:35 +0000573def : Pat<(truncstorei16 I64:$val, I32:$addr),
Dan Gohmanbb372242016-01-26 03:39:31 +0000574 (STORE16_I64 0, I32:$addr, 0, I64:$val)>;
Dan Gohman7054ac12015-11-23 21:16:35 +0000575def : Pat<(truncstorei32 I64:$val, I32:$addr),
Dan Gohmanbb372242016-01-26 03:39:31 +0000576 (STORE32_I64 0, I32:$addr, 0, I64:$val)>;
JF Bastien73ff6af2015-08-31 22:24:11 +0000577
Dan Gohman4b9d7912015-12-15 22:01:29 +0000578// Select truncating stores with a constant offset.
Dan Gohmanf225a632016-01-11 22:05:44 +0000579def : Pat<(truncstorei8 I32:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000580 (STORE8_I32 imm:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000581def : Pat<(truncstorei16 I32:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000582 (STORE16_I32 imm:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000583def : Pat<(truncstorei8 I64:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000584 (STORE8_I64 imm:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000585def : Pat<(truncstorei16 I64:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000586 (STORE16_I64 imm:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000587def : Pat<(truncstorei32 I64:$val, (regPlusImm I32:$addr, imm:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000588 (STORE32_I64 imm:$off, I32:$addr, 0, I64:$val)>;
Dan Gohman3b09d272016-02-22 20:04:02 +0000589def : Pat<(truncstorei8 I32:$val, (or_is_add I32:$addr, imm:$off)),
590 (STORE8_I32 imm:$off, I32:$addr, 0, I32:$val)>;
591def : Pat<(truncstorei16 I32:$val, (or_is_add I32:$addr, imm:$off)),
592 (STORE16_I32 imm:$off, I32:$addr, 0, I32:$val)>;
593def : Pat<(truncstorei8 I64:$val, (or_is_add I32:$addr, imm:$off)),
594 (STORE8_I64 imm:$off, I32:$addr, 0, I64:$val)>;
595def : Pat<(truncstorei16 I64:$val, (or_is_add I32:$addr, imm:$off)),
596 (STORE16_I64 imm:$off, I32:$addr, 0, I64:$val)>;
597def : Pat<(truncstorei32 I64:$val, (or_is_add I32:$addr, imm:$off)),
598 (STORE32_I64 imm:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000599def : Pat<(truncstorei8 I32:$val,
600 (regPlusGA I32:$addr,
601 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000602 (STORE8_I32 tglobaladdr:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000603def : Pat<(truncstorei16 I32:$val,
604 (regPlusGA I32:$addr,
605 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000606 (STORE16_I32 tglobaladdr:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000607def : Pat<(truncstorei8 I64:$val,
608 (regPlusGA I32:$addr,
609 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000610 (STORE8_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000611def : Pat<(truncstorei16 I64:$val,
612 (regPlusGA I32:$addr,
613 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000614 (STORE16_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000615def : Pat<(truncstorei32 I64:$val,
616 (regPlusGA I32:$addr,
617 (WebAssemblywrapper tglobaladdr:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000618 (STORE32_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000619def : Pat<(truncstorei8 I32:$val, (add I32:$addr,
620 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000621 (STORE8_I32 texternalsym:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000622def : Pat<(truncstorei16 I32:$val,
623 (add I32:$addr,
624 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000625 (STORE16_I32 texternalsym:$off, I32:$addr, 0, I32:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000626def : Pat<(truncstorei8 I64:$val,
627 (add I32:$addr,
628 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000629 (STORE8_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000630def : Pat<(truncstorei16 I64:$val,
631 (add I32:$addr,
632 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000633 (STORE16_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
Dan Gohmanf225a632016-01-11 22:05:44 +0000634def : Pat<(truncstorei32 I64:$val,
635 (add I32:$addr,
636 (WebAssemblywrapper texternalsym:$off))),
Dan Gohmanbb372242016-01-26 03:39:31 +0000637 (STORE32_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000638
639// Select truncating stores with just a constant offset.
640def : Pat<(truncstorei8 I32:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000641 (STORE8_I32 imm:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000642def : Pat<(truncstorei16 I32:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000643 (STORE16_I32 imm:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000644def : Pat<(truncstorei8 I64:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000645 (STORE8_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000646def : Pat<(truncstorei16 I64:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000647 (STORE16_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000648def : Pat<(truncstorei32 I64:$val, imm:$off),
Dan Gohmanbb372242016-01-26 03:39:31 +0000649 (STORE32_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000650def : Pat<(truncstorei8 I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000651 (STORE8_I32 tglobaladdr:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000652def : Pat<(truncstorei16 I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000653 (STORE16_I32 tglobaladdr:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000654def : Pat<(truncstorei8 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000655 (STORE8_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000656def : Pat<(truncstorei16 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000657 (STORE16_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000658def : Pat<(truncstorei32 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000659 (STORE32_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000660def : Pat<(truncstorei8 I32:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000661 (STORE8_I32 texternalsym:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000662def : Pat<(truncstorei16 I32:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000663 (STORE16_I32 texternalsym:$off, (CONST_I32 0), 0, I32:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000664def : Pat<(truncstorei8 I64:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000665 (STORE8_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000666def : Pat<(truncstorei16 I64:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000667 (STORE16_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000668def : Pat<(truncstorei32 I64:$val, (WebAssemblywrapper texternalsym:$off)),
Dan Gohmanbb372242016-01-26 03:39:31 +0000669 (STORE32_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
Dan Gohman4b9d7912015-12-15 22:01:29 +0000670
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000671let Defs = [ARGUMENTS] in {
672
Derek Schuff31680dd2016-05-02 17:25:22 +0000673// Current memory size.
674def CURRENT_MEMORY_I32 : I<(outs I32:$dst), (ins),
675 [(set I32:$dst, (int_wasm_current_memory))],
676 "current_memory\t$dst">,
677 Requires<[HasAddr32]>;
678def CURRENT_MEMORY_I64 : I<(outs I64:$dst), (ins),
679 [(set I64:$dst, (int_wasm_current_memory))],
680 "current_memory\t$dst">,
681 Requires<[HasAddr64]>;
Dan Gohmanbaba8c62015-10-02 20:10:26 +0000682
Dan Gohmand7ffb912015-11-05 20:16:59 +0000683// Grow memory.
Dan Gohmanf4333242015-11-13 20:19:11 +0000684def GROW_MEMORY_I32 : I<(outs), (ins I32:$delta),
Dan Gohmanaf29bd42015-11-05 20:42:30 +0000685 [(int_wasm_grow_memory I32:$delta)],
Dan Gohman192dddc2015-11-23 22:37:29 +0000686 "grow_memory\t$delta">,
Dan Gohmand7ffb912015-11-05 20:16:59 +0000687 Requires<[HasAddr32]>;
Dan Gohmanf4333242015-11-13 20:19:11 +0000688def GROW_MEMORY_I64 : I<(outs), (ins I64:$delta),
Dan Gohmanaf29bd42015-11-05 20:42:30 +0000689 [(int_wasm_grow_memory I64:$delta)],
Dan Gohman192dddc2015-11-23 22:37:29 +0000690 "grow_memory\t$delta">,
Dan Gohmand7ffb912015-11-05 20:16:59 +0000691 Requires<[HasAddr64]>;
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000692
693} // Defs = [ARGUMENTS]