1 // WebAssemblyInstrMemory.td-WebAssembly Memory codegen support -*- tablegen -*-
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// WebAssembly Memory operand code-gen constructs.
12 //===----------------------------------------------------------------------===//
15 // - WebAssemblyTargetLowering having to do with atomics
16 // - Each has optional alignment.
18 // WebAssembly has i8/i16/i32/i64/f32/f64 memory types, but doesn't have i8/i16
19 // local types. These memory-only types instead zero- or sign-extend into local
20 // types when loading, and truncate when storing.
22 // WebAssembly constant offsets are performed as unsigned with infinite
23 // precision, so we need to check for NoUnsignedWrap so that we don't fold an
24 // offset for an add that needs wrapping.
25 def regPlusImm : PatFrag<(ops node:$addr, node:$off),
26 (add node:$addr, node:$off),
27 [{ return N->getFlags().hasNoUnsignedWrap(); }]>;
29 // Treat an 'or' node as an 'add' if the or'ed bits are known to be zero.
30 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
31 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
32 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
34 KnownBits Known0 = CurDAG->computeKnownBits(N->getOperand(0), 0);
35 KnownBits Known1 = CurDAG->computeKnownBits(N->getOperand(1), 0);
36 return (~Known0.Zero & ~Known1.Zero) == 0;
39 // We don't need a regPlusES because external symbols never have constant
40 // offsets folded into them, so we can just use add.
42 // Defines atomic and non-atomic loads, regular and extending.
43 multiclass WebAssemblyLoad<WebAssemblyRegClass rc, string Name, int Opcode,
44 list<Predicate> reqs = []> {
45 let mayLoad = 1, UseNamedOperandTable = 1 in {
46 defm "_A32": I<(outs rc:$dst),
47 (ins P2Align:$p2align, offset32_op:$off, I32:$addr),
48 (outs), (ins P2Align:$p2align, offset32_op:$off),
49 [], !strconcat(Name, "\t$dst, ${off}(${addr})${p2align}"),
50 !strconcat(Name, "\t${off}${p2align}"), Opcode, "false">,
52 defm "_A64": I<(outs rc:$dst),
53 (ins P2Align:$p2align, offset64_op:$off, I64:$addr),
54 (outs), (ins P2Align:$p2align, offset64_op:$off),
55 [], !strconcat(Name, "\t$dst, ${off}(${addr})${p2align}"),
56 !strconcat(Name, "\t${off}${p2align}"), Opcode, "true">,
62 // FIXME: When we can break syntax compatibility, reorder the fields in the
63 // asmstrings to match the binary encoding.
64 defm LOAD_I32 : WebAssemblyLoad<I32, "i32.load", 0x28, []>;
65 defm LOAD_I64 : WebAssemblyLoad<I64, "i64.load", 0x29, []>;
66 defm LOAD_F32 : WebAssemblyLoad<F32, "f32.load", 0x2a, []>;
67 defm LOAD_F64 : WebAssemblyLoad<F64, "f64.load", 0x2b, []>;
69 // Select loads with no constant offset.
70 multiclass LoadPatNoOffset<ValueType ty, SDPatternOperator kind, string inst> {
71 def : Pat<(ty (kind I32:$addr)), (!cast<NI>(inst # "_A32") 0, 0, I32:$addr)>,
72 Requires<[HasAddr32]>;
73 def : Pat<(ty (kind (i64 I64:$addr))), (!cast<NI>(inst # "_A64") 0, 0, I64:$addr)>,
74 Requires<[HasAddr64]>;
77 defm : LoadPatNoOffset<i32, load, "LOAD_I32">;
78 defm : LoadPatNoOffset<i64, load, "LOAD_I64">;
79 defm : LoadPatNoOffset<f32, load, "LOAD_F32">;
80 defm : LoadPatNoOffset<f64, load, "LOAD_F64">;
82 // Select loads with a constant offset.
84 // Pattern with address + immediate offset
85 multiclass LoadPatImmOff<ValueType ty, SDPatternOperator kind, PatFrag operand,
87 def : Pat<(ty (kind (operand I32:$addr, imm:$off))),
88 (!cast<NI>(inst # "_A32") 0, imm:$off, I32:$addr)>,
89 Requires<[HasAddr32]>;
90 def : Pat<(ty (kind (operand I64:$addr, imm:$off))),
91 (!cast<NI>(inst # "_A64") 0, imm:$off, I64:$addr)>,
92 Requires<[HasAddr64]>;
95 defm : LoadPatImmOff<i32, load, regPlusImm, "LOAD_I32">;
96 defm : LoadPatImmOff<i64, load, regPlusImm, "LOAD_I64">;
97 defm : LoadPatImmOff<f32, load, regPlusImm, "LOAD_F32">;
98 defm : LoadPatImmOff<f64, load, regPlusImm, "LOAD_F64">;
99 defm : LoadPatImmOff<i32, load, or_is_add, "LOAD_I32">;
100 defm : LoadPatImmOff<i64, load, or_is_add, "LOAD_I64">;
101 defm : LoadPatImmOff<f32, load, or_is_add, "LOAD_F32">;
102 defm : LoadPatImmOff<f64, load, or_is_add, "LOAD_F64">;
104 // Select loads with just a constant offset.
105 multiclass LoadPatOffsetOnly<ValueType ty, SDPatternOperator kind, string inst> {
106 def : Pat<(ty (kind imm:$off)),
107 (!cast<NI>(inst # "_A32") 0, imm:$off, (CONST_I32 0))>,
108 Requires<[HasAddr32]>;
109 def : Pat<(ty (kind imm:$off)),
110 (!cast<NI>(inst # "_A64") 0, imm:$off, (CONST_I64 0))>,
111 Requires<[HasAddr64]>;
114 defm : LoadPatOffsetOnly<i32, load, "LOAD_I32">;
115 defm : LoadPatOffsetOnly<i64, load, "LOAD_I64">;
116 defm : LoadPatOffsetOnly<f32, load, "LOAD_F32">;
117 defm : LoadPatOffsetOnly<f64, load, "LOAD_F64">;
119 multiclass LoadPatGlobalAddrOffOnly<ValueType ty, SDPatternOperator kind, string inst> {
120 def : Pat<(ty (kind (WebAssemblyWrapper tglobaladdr:$off))),
121 (!cast<NI>(inst # "_A32") 0, tglobaladdr:$off, (CONST_I32 0))>,
122 Requires<[IsNotPIC, HasAddr32]>;
123 def : Pat<(ty (kind (WebAssemblyWrapper tglobaladdr:$off))),
124 (!cast<NI>(inst # "_A64") 0, tglobaladdr:$off, (CONST_I64 0))>,
125 Requires<[IsNotPIC, HasAddr64]>;
128 defm : LoadPatGlobalAddrOffOnly<i32, load, "LOAD_I32">;
129 defm : LoadPatGlobalAddrOffOnly<i64, load, "LOAD_I64">;
130 defm : LoadPatGlobalAddrOffOnly<f32, load, "LOAD_F32">;
131 defm : LoadPatGlobalAddrOffOnly<f64, load, "LOAD_F64">;
134 defm LOAD8_S_I32 : WebAssemblyLoad<I32, "i32.load8_s", 0x2c, []>;
135 defm LOAD8_U_I32 : WebAssemblyLoad<I32, "i32.load8_u", 0x2d, []>;
136 defm LOAD16_S_I32 : WebAssemblyLoad<I32, "i32.load16_s", 0x2e, []>;
137 defm LOAD16_U_I32 : WebAssemblyLoad<I32, "i32.load16_u", 0x2f, []>;
138 defm LOAD8_S_I64 : WebAssemblyLoad<I64, "i64.load8_s", 0x30, []>;
139 defm LOAD8_U_I64 : WebAssemblyLoad<I64, "i64.load8_u", 0x31, []>;
140 defm LOAD16_S_I64 : WebAssemblyLoad<I64, "i64.load16_s", 0x32, []>;
141 defm LOAD16_U_I64 : WebAssemblyLoad<I64, "i64.load16_u", 0x33, []>;
142 defm LOAD32_S_I64 : WebAssemblyLoad<I64, "i64.load32_s", 0x34, []>;
143 defm LOAD32_U_I64 : WebAssemblyLoad<I64, "i64.load32_u", 0x35, []>;
145 // Select extending loads with no constant offset.
146 defm : LoadPatNoOffset<i32, sextloadi8, "LOAD8_S_I32">;
147 defm : LoadPatNoOffset<i32, zextloadi8, "LOAD8_U_I32">;
148 defm : LoadPatNoOffset<i32, sextloadi16, "LOAD16_S_I32">;
149 defm : LoadPatNoOffset<i32, zextloadi16, "LOAD16_U_I32">;
150 defm : LoadPatNoOffset<i64, sextloadi8, "LOAD8_S_I64">;
151 defm : LoadPatNoOffset<i64, zextloadi8, "LOAD8_U_I64">;
152 defm : LoadPatNoOffset<i64, sextloadi16, "LOAD16_S_I64">;
153 defm : LoadPatNoOffset<i64, zextloadi16, "LOAD16_U_I64">;
154 defm : LoadPatNoOffset<i64, sextloadi32, "LOAD32_S_I64">;
155 defm : LoadPatNoOffset<i64, zextloadi32, "LOAD32_U_I64">;
157 // Select extending loads with a constant offset.
158 defm : LoadPatImmOff<i32, sextloadi8, regPlusImm, "LOAD8_S_I32">;
159 defm : LoadPatImmOff<i32, zextloadi8, regPlusImm, "LOAD8_U_I32">;
160 defm : LoadPatImmOff<i32, sextloadi16, regPlusImm, "LOAD16_S_I32">;
161 defm : LoadPatImmOff<i32, zextloadi16, regPlusImm, "LOAD16_U_I32">;
162 defm : LoadPatImmOff<i64, sextloadi8, regPlusImm, "LOAD8_S_I64">;
163 defm : LoadPatImmOff<i64, zextloadi8, regPlusImm, "LOAD8_U_I64">;
164 defm : LoadPatImmOff<i64, sextloadi16, regPlusImm, "LOAD16_S_I64">;
165 defm : LoadPatImmOff<i64, zextloadi16, regPlusImm, "LOAD16_U_I64">;
166 defm : LoadPatImmOff<i64, sextloadi32, regPlusImm, "LOAD32_S_I64">;
167 defm : LoadPatImmOff<i64, zextloadi32, regPlusImm, "LOAD32_U_I64">;
169 defm : LoadPatImmOff<i32, sextloadi8, or_is_add, "LOAD8_S_I32">;
170 defm : LoadPatImmOff<i32, zextloadi8, or_is_add, "LOAD8_U_I32">;
171 defm : LoadPatImmOff<i32, sextloadi16, or_is_add, "LOAD16_S_I32">;
172 defm : LoadPatImmOff<i32, zextloadi16, or_is_add, "LOAD16_U_I32">;
173 defm : LoadPatImmOff<i64, sextloadi8, or_is_add, "LOAD8_S_I64">;
174 defm : LoadPatImmOff<i64, zextloadi8, or_is_add, "LOAD8_U_I64">;
175 defm : LoadPatImmOff<i64, sextloadi16, or_is_add, "LOAD16_S_I64">;
176 defm : LoadPatImmOff<i64, zextloadi16, or_is_add, "LOAD16_U_I64">;
177 defm : LoadPatImmOff<i64, sextloadi32, or_is_add, "LOAD32_S_I64">;
178 defm : LoadPatImmOff<i64, zextloadi32, or_is_add, "LOAD32_U_I64">;
180 // Select extending loads with just a constant offset.
181 defm : LoadPatOffsetOnly<i32, sextloadi8, "LOAD8_S_I32">;
182 defm : LoadPatOffsetOnly<i32, zextloadi8, "LOAD8_U_I32">;
183 defm : LoadPatOffsetOnly<i32, sextloadi16, "LOAD16_S_I32">;
184 defm : LoadPatOffsetOnly<i32, zextloadi16, "LOAD16_U_I32">;
186 defm : LoadPatOffsetOnly<i64, sextloadi8, "LOAD8_S_I64">;
187 defm : LoadPatOffsetOnly<i64, zextloadi8, "LOAD8_U_I64">;
188 defm : LoadPatOffsetOnly<i64, sextloadi16, "LOAD16_S_I64">;
189 defm : LoadPatOffsetOnly<i64, zextloadi16, "LOAD16_U_I64">;
190 defm : LoadPatOffsetOnly<i64, sextloadi32, "LOAD32_S_I64">;
191 defm : LoadPatOffsetOnly<i64, zextloadi32, "LOAD32_U_I64">;
193 defm : LoadPatGlobalAddrOffOnly<i32, sextloadi8, "LOAD8_S_I32">;
194 defm : LoadPatGlobalAddrOffOnly<i32, zextloadi8, "LOAD8_U_I32">;
195 defm : LoadPatGlobalAddrOffOnly<i32, sextloadi16, "LOAD16_S_I32">;
196 defm : LoadPatGlobalAddrOffOnly<i32, zextloadi16, "LOAD16_U_I32">;
197 defm : LoadPatGlobalAddrOffOnly<i64, sextloadi8, "LOAD8_S_I64">;
198 defm : LoadPatGlobalAddrOffOnly<i64, zextloadi8, "LOAD8_U_I64">;
199 defm : LoadPatGlobalAddrOffOnly<i64, sextloadi16, "LOAD16_S_I64">;
200 defm : LoadPatGlobalAddrOffOnly<i64, zextloadi16, "LOAD16_U_I64">;
201 defm : LoadPatGlobalAddrOffOnly<i64, sextloadi32, "LOAD32_S_I64">;
202 defm : LoadPatGlobalAddrOffOnly<i64, zextloadi32, "LOAD32_U_I64">;
204 // Resolve "don't care" extending loads to zero-extending loads. This is
205 // somewhat arbitrary, but zero-extending is conceptually simpler.
207 // Select "don't care" extending loads with no constant offset.
208 defm : LoadPatNoOffset<i32, extloadi8, "LOAD8_U_I32">;
209 defm : LoadPatNoOffset<i32, extloadi16, "LOAD16_U_I32">;
210 defm : LoadPatNoOffset<i64, extloadi8, "LOAD8_U_I64">;
211 defm : LoadPatNoOffset<i64, extloadi16, "LOAD16_U_I64">;
212 defm : LoadPatNoOffset<i64, extloadi32, "LOAD32_U_I64">;
214 // Select "don't care" extending loads with a constant offset.
215 defm : LoadPatImmOff<i32, extloadi8, regPlusImm, "LOAD8_U_I32">;
216 defm : LoadPatImmOff<i32, extloadi16, regPlusImm, "LOAD16_U_I32">;
217 defm : LoadPatImmOff<i64, extloadi8, regPlusImm, "LOAD8_U_I64">;
218 defm : LoadPatImmOff<i64, extloadi16, regPlusImm, "LOAD16_U_I64">;
219 defm : LoadPatImmOff<i64, extloadi32, regPlusImm, "LOAD32_U_I64">;
220 defm : LoadPatImmOff<i32, extloadi8, or_is_add, "LOAD8_U_I32">;
221 defm : LoadPatImmOff<i32, extloadi16, or_is_add, "LOAD16_U_I32">;
222 defm : LoadPatImmOff<i64, extloadi8, or_is_add, "LOAD8_U_I64">;
223 defm : LoadPatImmOff<i64, extloadi16, or_is_add, "LOAD16_U_I64">;
224 defm : LoadPatImmOff<i64, extloadi32, or_is_add, "LOAD32_U_I64">;
226 // Select "don't care" extending loads with just a constant offset.
227 defm : LoadPatOffsetOnly<i32, extloadi8, "LOAD8_U_I32">;
228 defm : LoadPatOffsetOnly<i32, extloadi16, "LOAD16_U_I32">;
229 defm : LoadPatOffsetOnly<i64, extloadi8, "LOAD8_U_I64">;
230 defm : LoadPatOffsetOnly<i64, extloadi16, "LOAD16_U_I64">;
231 defm : LoadPatOffsetOnly<i64, extloadi32, "LOAD32_U_I64">;
232 defm : LoadPatGlobalAddrOffOnly<i32, extloadi8, "LOAD8_U_I32">;
233 defm : LoadPatGlobalAddrOffOnly<i32, extloadi16, "LOAD16_U_I32">;
234 defm : LoadPatGlobalAddrOffOnly<i64, extloadi8, "LOAD8_U_I64">;
235 defm : LoadPatGlobalAddrOffOnly<i64, extloadi16, "LOAD16_U_I64">;
236 defm : LoadPatGlobalAddrOffOnly<i64, extloadi32, "LOAD32_U_I64">;
238 // Defines atomic and non-atomic stores, regular and truncating
239 multiclass WebAssemblyStore<WebAssemblyRegClass rc, string Name, int Opcode,
240 list<Predicate> reqs = []> {
241 let mayStore = 1, UseNamedOperandTable = 1 in
242 defm "_A32" : I<(outs),
243 (ins P2Align:$p2align, offset32_op:$off, I32:$addr, rc:$val),
245 (ins P2Align:$p2align, offset32_op:$off), [],
246 !strconcat(Name, "\t${off}(${addr})${p2align}, $val"),
247 !strconcat(Name, "\t${off}${p2align}"), Opcode, "false">,
249 let mayStore = 1, UseNamedOperandTable = 1 in
250 defm "_A64" : I<(outs),
251 (ins P2Align:$p2align, offset64_op:$off, I64:$addr, rc:$val),
253 (ins P2Align:$p2align, offset64_op:$off), [],
254 !strconcat(Name, "\t${off}(${addr})${p2align}, $val"),
255 !strconcat(Name, "\t${off}${p2align}"), Opcode, "true">,
260 // Note: WebAssembly inverts SelectionDAG's usual operand order.
261 defm STORE_I32 : WebAssemblyStore<I32, "i32.store", 0x36>;
262 defm STORE_I64 : WebAssemblyStore<I64, "i64.store", 0x37>;
263 defm STORE_F32 : WebAssemblyStore<F32, "f32.store", 0x38>;
264 defm STORE_F64 : WebAssemblyStore<F64, "f64.store", 0x39>;
266 // Select stores with no constant offset.
267 multiclass StorePatNoOffset<ValueType ty, PatFrag node, string inst> {
268 def : Pat<(node ty:$val, I32:$addr),
269 (!cast<NI>(inst # "_A32") 0, 0, I32:$addr, ty:$val)>,
270 Requires<[HasAddr32]>;
271 def : Pat<(node ty:$val, I64:$addr),
272 (!cast<NI>(inst # "_A64") 0, 0, I64:$addr, ty:$val)>,
273 Requires<[HasAddr64]>;
276 defm : StorePatNoOffset<i32, store, "STORE_I32">;
277 defm : StorePatNoOffset<i64, store, "STORE_I64">;
278 defm : StorePatNoOffset<f32, store, "STORE_F32">;
279 defm : StorePatNoOffset<f64, store, "STORE_F64">;
281 // Select stores with a constant offset.
282 multiclass StorePatImmOff<ValueType ty, PatFrag kind, PatFrag operand,
284 def : Pat<(kind ty:$val, (operand I32:$addr, imm:$off)),
285 (!cast<NI>(inst # "_A32") 0, imm:$off, I32:$addr, ty:$val)>,
286 Requires<[HasAddr32]>;
287 def : Pat<(kind ty:$val, (operand I64:$addr, imm:$off)),
288 (!cast<NI>(inst # "_A64") 0, imm:$off, I64:$addr, ty:$val)>,
289 Requires<[HasAddr64]>;
292 defm : StorePatImmOff<i32, store, regPlusImm, "STORE_I32">;
293 defm : StorePatImmOff<i64, store, regPlusImm, "STORE_I64">;
294 defm : StorePatImmOff<f32, store, regPlusImm, "STORE_F32">;
295 defm : StorePatImmOff<f64, store, regPlusImm, "STORE_F64">;
296 defm : StorePatImmOff<i32, store, or_is_add, "STORE_I32">;
297 defm : StorePatImmOff<i64, store, or_is_add, "STORE_I64">;
298 defm : StorePatImmOff<f32, store, or_is_add, "STORE_F32">;
299 defm : StorePatImmOff<f64, store, or_is_add, "STORE_F64">;
301 // Select stores with just a constant offset.
302 multiclass StorePatOffsetOnly<ValueType ty, PatFrag kind, string inst> {
303 def : Pat<(kind ty:$val, imm:$off),
304 (!cast<NI>(inst # "_A32") 0, imm:$off, (CONST_I32 0), ty:$val)>,
305 Requires<[HasAddr32]>;
306 def : Pat<(kind ty:$val, imm:$off),
307 (!cast<NI>(inst # "_A64") 0, imm:$off, (CONST_I64 0), ty:$val)>,
308 Requires<[HasAddr64]>;
310 defm : StorePatOffsetOnly<i32, store, "STORE_I32">;
311 defm : StorePatOffsetOnly<i64, store, "STORE_I64">;
312 defm : StorePatOffsetOnly<f32, store, "STORE_F32">;
313 defm : StorePatOffsetOnly<f64, store, "STORE_F64">;
315 multiclass StorePatGlobalAddrOffOnly<ValueType ty, PatFrag kind, string inst> {
316 def : Pat<(kind ty:$val, (WebAssemblyWrapper tglobaladdr:$off)),
317 (!cast<NI>(inst # "_A32") 0, tglobaladdr:$off, (CONST_I32 0),
319 Requires<[IsNotPIC, HasAddr32]>;
320 def : Pat<(kind ty:$val, (WebAssemblyWrapper tglobaladdr:$off)),
321 (!cast<NI>(inst # "_A64") 0, tglobaladdr:$off, (CONST_I64 0),
323 Requires<[IsNotPIC, HasAddr64]>;
325 defm : StorePatGlobalAddrOffOnly<i32, store, "STORE_I32">;
326 defm : StorePatGlobalAddrOffOnly<i64, store, "STORE_I64">;
327 defm : StorePatGlobalAddrOffOnly<f32, store, "STORE_F32">;
328 defm : StorePatGlobalAddrOffOnly<f64, store, "STORE_F64">;
331 defm STORE8_I32 : WebAssemblyStore<I32, "i32.store8", 0x3a>;
332 defm STORE16_I32 : WebAssemblyStore<I32, "i32.store16", 0x3b>;
333 defm STORE8_I64 : WebAssemblyStore<I64, "i64.store8", 0x3c>;
334 defm STORE16_I64 : WebAssemblyStore<I64, "i64.store16", 0x3d>;
335 defm STORE32_I64 : WebAssemblyStore<I64, "i64.store32", 0x3e>;
337 // Select truncating stores with no constant offset.
338 defm : StorePatNoOffset<i32, truncstorei8, "STORE8_I32">;
339 defm : StorePatNoOffset<i32, truncstorei16, "STORE16_I32">;
340 defm : StorePatNoOffset<i64, truncstorei8, "STORE8_I64">;
341 defm : StorePatNoOffset<i64, truncstorei16, "STORE16_I64">;
342 defm : StorePatNoOffset<i64, truncstorei32, "STORE32_I64">;
344 // Select truncating stores with a constant offset.
345 defm : StorePatImmOff<i32, truncstorei8, regPlusImm, "STORE8_I32">;
346 defm : StorePatImmOff<i32, truncstorei16, regPlusImm, "STORE16_I32">;
347 defm : StorePatImmOff<i64, truncstorei8, regPlusImm, "STORE8_I64">;
348 defm : StorePatImmOff<i64, truncstorei16, regPlusImm, "STORE16_I64">;
349 defm : StorePatImmOff<i64, truncstorei32, regPlusImm, "STORE32_I64">;
350 defm : StorePatImmOff<i32, truncstorei8, or_is_add, "STORE8_I32">;
351 defm : StorePatImmOff<i32, truncstorei16, or_is_add, "STORE16_I32">;
352 defm : StorePatImmOff<i64, truncstorei8, or_is_add, "STORE8_I64">;
353 defm : StorePatImmOff<i64, truncstorei16, or_is_add, "STORE16_I64">;
354 defm : StorePatImmOff<i64, truncstorei32, or_is_add, "STORE32_I64">;
356 // Select truncating stores with just a constant offset.
357 defm : StorePatOffsetOnly<i32, truncstorei8, "STORE8_I32">;
358 defm : StorePatOffsetOnly<i32, truncstorei16, "STORE16_I32">;
359 defm : StorePatOffsetOnly<i64, truncstorei8, "STORE8_I64">;
360 defm : StorePatOffsetOnly<i64, truncstorei16, "STORE16_I64">;
361 defm : StorePatOffsetOnly<i64, truncstorei32, "STORE32_I64">;
362 defm : StorePatGlobalAddrOffOnly<i32, truncstorei8, "STORE8_I32">;
363 defm : StorePatGlobalAddrOffOnly<i32, truncstorei16, "STORE16_I32">;
364 defm : StorePatGlobalAddrOffOnly<i64, truncstorei8, "STORE8_I64">;
365 defm : StorePatGlobalAddrOffOnly<i64, truncstorei16, "STORE16_I64">;
366 defm : StorePatGlobalAddrOffOnly<i64, truncstorei32, "STORE32_I64">;
368 multiclass MemoryOps<WebAssemblyRegClass rc, string B> {
369 // Current memory size.
370 defm MEMORY_SIZE_A#B : I<(outs rc:$dst), (ins i32imm:$flags),
371 (outs), (ins i32imm:$flags),
373 (int_wasm_memory_size (i32 imm:$flags)))],
374 "memory.size\t$dst, $flags", "memory.size\t$flags",
378 defm MEMORY_GROW_A#B : I<(outs rc:$dst), (ins i32imm:$flags, rc:$delta),
379 (outs), (ins i32imm:$flags),
381 (int_wasm_memory_grow (i32 imm:$flags),
383 "memory.grow\t$dst, $flags, $delta",
384 "memory.grow\t$flags", 0x40>;
387 defm : MemoryOps<I32, "32">;
388 defm : MemoryOps<I64, "64">;