xref: /aosp_15_r20/external/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker// WebAssemblyInstrMemory.td-WebAssembly Memory codegen support -*- tablegen -*-
2*9880d681SAndroid Build Coastguard Worker//
3*9880d681SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker//
5*9880d681SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker//
8*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker///
10*9880d681SAndroid Build Coastguard Worker/// \file
11*9880d681SAndroid Build Coastguard Worker/// \brief WebAssembly Memory operand code-gen constructs.
12*9880d681SAndroid Build Coastguard Worker///
13*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker// TODO:
16*9880d681SAndroid Build Coastguard Worker//  - HasAddr64
17*9880d681SAndroid Build Coastguard Worker//  - WebAssemblyTargetLowering having to do with atomics
18*9880d681SAndroid Build Coastguard Worker//  - Each has optional alignment.
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker// WebAssembly has i8/i16/i32/i64/f32/f64 memory types, but doesn't have i8/i16
21*9880d681SAndroid Build Coastguard Worker// local types. These memory-only types instead zero- or sign-extend into local
22*9880d681SAndroid Build Coastguard Worker// types when loading, and truncate when storing.
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker// WebAssembly constant offsets are performed as unsigned with infinite
25*9880d681SAndroid Build Coastguard Worker// precision, so we need to check for NoUnsignedWrap so that we don't fold an
26*9880d681SAndroid Build Coastguard Worker// offset for an add that needs wrapping.
27*9880d681SAndroid Build Coastguard Workerdef regPlusImm : PatFrag<(ops node:$addr, node:$off),
28*9880d681SAndroid Build Coastguard Worker                         (add node:$addr, node:$off),
29*9880d681SAndroid Build Coastguard Worker                         [{ return N->getFlags()->hasNoUnsignedWrap(); }]>;
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker// Treat an 'or' node as an 'add' if the or'ed bits are known to be zero.
32*9880d681SAndroid Build Coastguard Workerdef or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
33*9880d681SAndroid Build Coastguard Worker  if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
34*9880d681SAndroid Build Coastguard Worker    return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker  APInt KnownZero0, KnownOne0;
37*9880d681SAndroid Build Coastguard Worker  CurDAG->computeKnownBits(N->getOperand(0), KnownZero0, KnownOne0, 0);
38*9880d681SAndroid Build Coastguard Worker  APInt KnownZero1, KnownOne1;
39*9880d681SAndroid Build Coastguard Worker  CurDAG->computeKnownBits(N->getOperand(1), KnownZero1, KnownOne1, 0);
40*9880d681SAndroid Build Coastguard Worker  return (~KnownZero0 & ~KnownZero1) == 0;
41*9880d681SAndroid Build Coastguard Worker}]>;
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker// GlobalAddresses are conceptually unsigned values, so we can also fold them
44*9880d681SAndroid Build Coastguard Worker// into immediate values as long as their offsets are non-negative.
45*9880d681SAndroid Build Coastguard Workerdef regPlusGA : PatFrag<(ops node:$addr, node:$off),
46*9880d681SAndroid Build Coastguard Worker                        (add node:$addr, node:$off),
47*9880d681SAndroid Build Coastguard Worker                        [{
48*9880d681SAndroid Build Coastguard Worker  return N->getFlags()->hasNoUnsignedWrap() ||
49*9880d681SAndroid Build Coastguard Worker         (N->getOperand(1)->getOpcode() == WebAssemblyISD::Wrapper &&
50*9880d681SAndroid Build Coastguard Worker          isa<GlobalAddressSDNode>(N->getOperand(1)->getOperand(0)) &&
51*9880d681SAndroid Build Coastguard Worker          cast<GlobalAddressSDNode>(N->getOperand(1)->getOperand(0))
52*9880d681SAndroid Build Coastguard Worker             ->getOffset() >= 0);
53*9880d681SAndroid Build Coastguard Worker}]>;
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker// We don't need a regPlusES because external symbols never have constant
56*9880d681SAndroid Build Coastguard Worker// offsets folded into them, so we can just use add.
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Workerlet Defs = [ARGUMENTS] in {
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker// Basic load.
61*9880d681SAndroid Build Coastguard Workerdef LOAD_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
62*9880d681SAndroid Build Coastguard Worker                                   P2Align:$p2align), [],
63*9880d681SAndroid Build Coastguard Worker                 "i32.load\t$dst, ${off}(${addr})${p2align}">;
64*9880d681SAndroid Build Coastguard Workerdef LOAD_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
65*9880d681SAndroid Build Coastguard Worker                                   P2Align:$p2align), [],
66*9880d681SAndroid Build Coastguard Worker                 "i64.load\t$dst, ${off}(${addr})${p2align}">;
67*9880d681SAndroid Build Coastguard Workerdef LOAD_F32 : I<(outs F32:$dst), (ins i32imm:$off, I32:$addr,
68*9880d681SAndroid Build Coastguard Worker                                   P2Align:$p2align), [],
69*9880d681SAndroid Build Coastguard Worker                 "f32.load\t$dst, ${off}(${addr})${p2align}">;
70*9880d681SAndroid Build Coastguard Workerdef LOAD_F64 : I<(outs F64:$dst), (ins i32imm:$off, I32:$addr,
71*9880d681SAndroid Build Coastguard Worker                                   P2Align:$p2align), [],
72*9880d681SAndroid Build Coastguard Worker                 "f64.load\t$dst, ${off}(${addr})${p2align}">;
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Worker} // Defs = [ARGUMENTS]
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Worker// Select loads with no constant offset.
77*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load I32:$addr)), (LOAD_I32 0, $addr, 0)>;
78*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load I32:$addr)), (LOAD_I64 0, $addr, 0)>;
79*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load I32:$addr)), (LOAD_F32 0, $addr, 0)>;
80*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load I32:$addr)), (LOAD_F64 0, $addr, 0)>;
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Worker// Select loads with a constant offset.
83*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load (regPlusImm I32:$addr, imm:$off))),
84*9880d681SAndroid Build Coastguard Worker          (LOAD_I32 imm:$off, $addr, 0)>;
85*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load (regPlusImm I32:$addr, imm:$off))),
86*9880d681SAndroid Build Coastguard Worker          (LOAD_I64 imm:$off, $addr, 0)>;
87*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load (regPlusImm I32:$addr, imm:$off))),
88*9880d681SAndroid Build Coastguard Worker          (LOAD_F32 imm:$off, $addr, 0)>;
89*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load (regPlusImm I32:$addr, imm:$off))),
90*9880d681SAndroid Build Coastguard Worker          (LOAD_F64 imm:$off, $addr, 0)>;
91*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load (or_is_add I32:$addr, imm:$off))),
92*9880d681SAndroid Build Coastguard Worker          (LOAD_I32 imm:$off, $addr, 0)>;
93*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load (or_is_add I32:$addr, imm:$off))),
94*9880d681SAndroid Build Coastguard Worker          (LOAD_I64 imm:$off, $addr, 0)>;
95*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load (or_is_add I32:$addr, imm:$off))),
96*9880d681SAndroid Build Coastguard Worker          (LOAD_F32 imm:$off, $addr, 0)>;
97*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load (or_is_add I32:$addr, imm:$off))),
98*9880d681SAndroid Build Coastguard Worker          (LOAD_F64 imm:$off, $addr, 0)>;
99*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load (regPlusGA I32:$addr,
100*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper tglobaladdr:$off)))),
101*9880d681SAndroid Build Coastguard Worker          (LOAD_I32 tglobaladdr:$off, $addr, 0)>;
102*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load (regPlusGA I32:$addr,
103*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper tglobaladdr:$off)))),
104*9880d681SAndroid Build Coastguard Worker          (LOAD_I64 tglobaladdr:$off, $addr, 0)>;
105*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load (regPlusGA I32:$addr,
106*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper tglobaladdr:$off)))),
107*9880d681SAndroid Build Coastguard Worker          (LOAD_F32 tglobaladdr:$off, $addr, 0)>;
108*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load (regPlusGA I32:$addr,
109*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper tglobaladdr:$off)))),
110*9880d681SAndroid Build Coastguard Worker          (LOAD_F64 tglobaladdr:$off, $addr, 0)>;
111*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
112*9880d681SAndroid Build Coastguard Worker          (LOAD_I32 texternalsym:$off, $addr, 0)>;
113*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
114*9880d681SAndroid Build Coastguard Worker          (LOAD_I64 texternalsym:$off, $addr, 0)>;
115*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
116*9880d681SAndroid Build Coastguard Worker          (LOAD_F32 texternalsym:$off, $addr, 0)>;
117*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
118*9880d681SAndroid Build Coastguard Worker          (LOAD_F64 texternalsym:$off, $addr, 0)>;
119*9880d681SAndroid Build Coastguard Worker
120*9880d681SAndroid Build Coastguard Worker// Select loads with just a constant offset.
121*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load imm:$off)), (LOAD_I32 imm:$off, (CONST_I32 0), 0)>;
122*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load imm:$off)), (LOAD_I64 imm:$off, (CONST_I32 0), 0)>;
123*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load imm:$off)), (LOAD_F32 imm:$off, (CONST_I32 0), 0)>;
124*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load imm:$off)), (LOAD_F64 imm:$off, (CONST_I32 0), 0)>;
125*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load (WebAssemblywrapper tglobaladdr:$off))),
126*9880d681SAndroid Build Coastguard Worker          (LOAD_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
127*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load (WebAssemblywrapper tglobaladdr:$off))),
128*9880d681SAndroid Build Coastguard Worker          (LOAD_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
129*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load (WebAssemblywrapper tglobaladdr:$off))),
130*9880d681SAndroid Build Coastguard Worker          (LOAD_F32 tglobaladdr:$off, (CONST_I32 0), 0)>;
131*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load (WebAssemblywrapper tglobaladdr:$off))),
132*9880d681SAndroid Build Coastguard Worker          (LOAD_F64 tglobaladdr:$off, (CONST_I32 0), 0)>;
133*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (load (WebAssemblywrapper texternalsym:$off))),
134*9880d681SAndroid Build Coastguard Worker          (LOAD_I32 texternalsym:$off, (CONST_I32 0), 0)>;
135*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (load (WebAssemblywrapper texternalsym:$off))),
136*9880d681SAndroid Build Coastguard Worker          (LOAD_I64 texternalsym:$off, (CONST_I32 0), 0)>;
137*9880d681SAndroid Build Coastguard Workerdef : Pat<(f32 (load (WebAssemblywrapper texternalsym:$off))),
138*9880d681SAndroid Build Coastguard Worker          (LOAD_F32 texternalsym:$off, (CONST_I32 0), 0)>;
139*9880d681SAndroid Build Coastguard Workerdef : Pat<(f64 (load (WebAssemblywrapper texternalsym:$off))),
140*9880d681SAndroid Build Coastguard Worker          (LOAD_F64 texternalsym:$off, (CONST_I32 0), 0)>;
141*9880d681SAndroid Build Coastguard Worker
142*9880d681SAndroid Build Coastguard Workerlet Defs = [ARGUMENTS] in {
143*9880d681SAndroid Build Coastguard Worker
144*9880d681SAndroid Build Coastguard Worker// Extending load.
145*9880d681SAndroid Build Coastguard Workerdef LOAD8_S_I32  : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
146*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
147*9880d681SAndroid Build Coastguard Worker                     "i32.load8_s\t$dst, ${off}(${addr})${p2align}">;
148*9880d681SAndroid Build Coastguard Workerdef LOAD8_U_I32  : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
149*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
150*9880d681SAndroid Build Coastguard Worker                     "i32.load8_u\t$dst, ${off}(${addr})${p2align}">;
151*9880d681SAndroid Build Coastguard Workerdef LOAD16_S_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
152*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
153*9880d681SAndroid Build Coastguard Worker                     "i32.load16_s\t$dst, ${off}(${addr})${p2align}">;
154*9880d681SAndroid Build Coastguard Workerdef LOAD16_U_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
155*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
156*9880d681SAndroid Build Coastguard Worker                     "i32.load16_u\t$dst, ${off}(${addr})${p2align}">;
157*9880d681SAndroid Build Coastguard Workerdef LOAD8_S_I64  : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
158*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
159*9880d681SAndroid Build Coastguard Worker                     "i64.load8_s\t$dst, ${off}(${addr})${p2align}">;
160*9880d681SAndroid Build Coastguard Workerdef LOAD8_U_I64  : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
161*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
162*9880d681SAndroid Build Coastguard Worker                     "i64.load8_u\t$dst, ${off}(${addr})${p2align}">;
163*9880d681SAndroid Build Coastguard Workerdef LOAD16_S_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
164*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
165*9880d681SAndroid Build Coastguard Worker                     "i64.load16_s\t$dst, ${off}(${addr})${p2align}">;
166*9880d681SAndroid Build Coastguard Workerdef LOAD16_U_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
167*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
168*9880d681SAndroid Build Coastguard Worker                     "i64.load16_u\t$dst, ${off}(${addr})${p2align}">;
169*9880d681SAndroid Build Coastguard Workerdef LOAD32_S_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
170*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
171*9880d681SAndroid Build Coastguard Worker                     "i64.load32_s\t$dst, ${off}(${addr})${p2align}">;
172*9880d681SAndroid Build Coastguard Workerdef LOAD32_U_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
173*9880d681SAndroid Build Coastguard Worker                                       P2Align:$p2align), [],
174*9880d681SAndroid Build Coastguard Worker                     "i64.load32_u\t$dst, ${off}(${addr})${p2align}">;
175*9880d681SAndroid Build Coastguard Worker
176*9880d681SAndroid Build Coastguard Worker} // Defs = [ARGUMENTS]
177*9880d681SAndroid Build Coastguard Worker
178*9880d681SAndroid Build Coastguard Worker// Select extending loads with no constant offset.
179*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 I32:$addr)), (LOAD8_S_I32 0, $addr, 0)>;
180*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 I32:$addr)), (LOAD8_U_I32 0, $addr, 0)>;
181*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 I32:$addr)), (LOAD16_S_I32 0, $addr, 0)>;
182*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 I32:$addr)), (LOAD16_U_I32 0, $addr, 0)>;
183*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 I32:$addr)), (LOAD8_S_I64 0, $addr, 0)>;
184*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 I32:$addr)), (LOAD8_U_I64 0, $addr, 0)>;
185*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 I32:$addr)), (LOAD16_S_I64 0, $addr, 0)>;
186*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 I32:$addr)), (LOAD16_U_I64 0, $addr, 0)>;
187*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 I32:$addr)), (LOAD32_S_I64 0, $addr, 0)>;
188*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 I32:$addr)), (LOAD32_U_I64 0, $addr, 0)>;
189*9880d681SAndroid Build Coastguard Worker
190*9880d681SAndroid Build Coastguard Worker// Select extending loads with a constant offset.
191*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 (regPlusImm I32:$addr, imm:$off))),
192*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I32 imm:$off, $addr, 0)>;
193*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 (regPlusImm I32:$addr, imm:$off))),
194*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 imm:$off, $addr, 0)>;
195*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 (regPlusImm I32:$addr, imm:$off))),
196*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I32 imm:$off, $addr, 0)>;
197*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 (regPlusImm I32:$addr, imm:$off))),
198*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 imm:$off, $addr, 0)>;
199*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 (regPlusImm I32:$addr, imm:$off))),
200*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I64 imm:$off, $addr, 0)>;
201*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 (regPlusImm I32:$addr, imm:$off))),
202*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 imm:$off, $addr, 0)>;
203*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 (regPlusImm I32:$addr, imm:$off))),
204*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I64 imm:$off, $addr, 0)>;
205*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 (regPlusImm I32:$addr, imm:$off))),
206*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 imm:$off, $addr, 0)>;
207*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 (regPlusImm I32:$addr, imm:$off))),
208*9880d681SAndroid Build Coastguard Worker          (LOAD32_S_I64 imm:$off, $addr, 0)>;
209*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 (regPlusImm I32:$addr, imm:$off))),
210*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 imm:$off, $addr, 0)>;
211*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 (or_is_add I32:$addr, imm:$off))),
212*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I32 imm:$off, $addr, 0)>;
213*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 (or_is_add I32:$addr, imm:$off))),
214*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 imm:$off, $addr, 0)>;
215*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 (or_is_add I32:$addr, imm:$off))),
216*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I32 imm:$off, $addr, 0)>;
217*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 (or_is_add I32:$addr, imm:$off))),
218*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 imm:$off, $addr, 0)>;
219*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 (or_is_add I32:$addr, imm:$off))),
220*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I64 imm:$off, $addr, 0)>;
221*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 (or_is_add I32:$addr, imm:$off))),
222*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 imm:$off, $addr, 0)>;
223*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 (or_is_add I32:$addr, imm:$off))),
224*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I64 imm:$off, $addr, 0)>;
225*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 (or_is_add I32:$addr, imm:$off))),
226*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 imm:$off, $addr, 0)>;
227*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 (or_is_add I32:$addr, imm:$off))),
228*9880d681SAndroid Build Coastguard Worker          (LOAD32_S_I64 imm:$off, $addr, 0)>;
229*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 (or_is_add I32:$addr, imm:$off))),
230*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 imm:$off, $addr, 0)>;
231*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 (regPlusGA I32:$addr,
232*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off)))),
233*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I32 tglobaladdr:$off, $addr, 0)>;
234*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 (regPlusGA I32:$addr,
235*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off)))),
236*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 tglobaladdr:$off, $addr, 0)>;
237*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 (regPlusGA I32:$addr,
238*9880d681SAndroid Build Coastguard Worker                                       (WebAssemblywrapper tglobaladdr:$off)))),
239*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I32 tglobaladdr:$off, $addr, 0)>;
240*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 (regPlusGA I32:$addr,
241*9880d681SAndroid Build Coastguard Worker                                       (WebAssemblywrapper tglobaladdr:$off)))),
242*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 tglobaladdr:$off, $addr, 0)>;
243*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 (regPlusGA I32:$addr,
244*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off)))),
245*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I64 tglobaladdr:$off, $addr, 0)>;
246*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 (regPlusGA I32:$addr,
247*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off)))),
248*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 tglobaladdr:$off, $addr, 0)>;
249*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 (regPlusGA I32:$addr,
250*9880d681SAndroid Build Coastguard Worker                                       (WebAssemblywrapper tglobaladdr:$off)))),
251*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I64 tglobaladdr:$off, $addr, 0)>;
252*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 (regPlusGA I32:$addr,
253*9880d681SAndroid Build Coastguard Worker                                       (WebAssemblywrapper tglobaladdr:$off)))),
254*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 tglobaladdr:$off, $addr, 0)>;
255*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 (regPlusGA I32:$addr,
256*9880d681SAndroid Build Coastguard Worker                                       (WebAssemblywrapper tglobaladdr:$off)))),
257*9880d681SAndroid Build Coastguard Worker          (LOAD32_S_I64 tglobaladdr:$off, $addr, 0)>;
258*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 (regPlusGA I32:$addr,
259*9880d681SAndroid Build Coastguard Worker                                       (WebAssemblywrapper tglobaladdr:$off)))),
260*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 tglobaladdr:$off, $addr, 0)>;
261*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 (add I32:$addr,
262*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off)))),
263*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I32 texternalsym:$off, $addr, 0)>;
264*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 (add I32:$addr,
265*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off)))),
266*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 texternalsym:$off, $addr, 0)>;
267*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 (add I32:$addr,
268*9880d681SAndroid Build Coastguard Worker                                 (WebAssemblywrapper texternalsym:$off)))),
269*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I32 texternalsym:$off, $addr, 0)>;
270*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 (add I32:$addr,
271*9880d681SAndroid Build Coastguard Worker                                 (WebAssemblywrapper texternalsym:$off)))),
272*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 texternalsym:$off, $addr, 0)>;
273*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 (add I32:$addr,
274*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off)))),
275*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I64 texternalsym:$off, $addr, 0)>;
276*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 (add I32:$addr,
277*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off)))),
278*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 texternalsym:$off, $addr, 0)>;
279*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 (add I32:$addr,
280*9880d681SAndroid Build Coastguard Worker                                 (WebAssemblywrapper texternalsym:$off)))),
281*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I64 texternalsym:$off, $addr, 0)>;
282*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 (add I32:$addr,
283*9880d681SAndroid Build Coastguard Worker                                 (WebAssemblywrapper texternalsym:$off)))),
284*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 texternalsym:$off, $addr, 0)>;
285*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 (add I32:$addr,
286*9880d681SAndroid Build Coastguard Worker                                 (WebAssemblywrapper texternalsym:$off)))),
287*9880d681SAndroid Build Coastguard Worker          (LOAD32_S_I64 texternalsym:$off, $addr, 0)>;
288*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 (add I32:$addr,
289*9880d681SAndroid Build Coastguard Worker                                 (WebAssemblywrapper texternalsym:$off)))),
290*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 texternalsym:$off, $addr, 0)>;
291*9880d681SAndroid Build Coastguard Worker
292*9880d681SAndroid Build Coastguard Worker// Select extending loads with just a constant offset.
293*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 imm:$off)),
294*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I32 imm:$off, (CONST_I32 0), 0)>;
295*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 imm:$off)),
296*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 imm:$off, (CONST_I32 0), 0)>;
297*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 imm:$off)),
298*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I32 imm:$off, (CONST_I32 0), 0)>;
299*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 imm:$off)),
300*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 imm:$off, (CONST_I32 0), 0)>;
301*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 imm:$off)),
302*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I64 imm:$off, (CONST_I32 0), 0)>;
303*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 imm:$off)),
304*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 imm:$off, (CONST_I32 0), 0)>;
305*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 imm:$off)),
306*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I64 imm:$off, (CONST_I32 0), 0)>;
307*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 imm:$off)),
308*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 imm:$off, (CONST_I32 0), 0)>;
309*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 imm:$off)),
310*9880d681SAndroid Build Coastguard Worker          (LOAD32_S_I64 imm:$off, (CONST_I32 0), 0)>;
311*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 imm:$off)),
312*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 imm:$off, (CONST_I32 0), 0)>;
313*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
314*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
315*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
316*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
317*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
318*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
319*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
320*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
321*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
322*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
323*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
324*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
325*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
326*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
327*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
328*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
329*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 (WebAssemblywrapper tglobaladdr:$off))),
330*9880d681SAndroid Build Coastguard Worker          (LOAD32_S_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
331*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 (WebAssemblywrapper tglobaladdr:$off))),
332*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
333*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi8 (WebAssemblywrapper texternalsym:$off))),
334*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I32 texternalsym:$off, (CONST_I32 0), 0)>;
335*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi8 (WebAssemblywrapper texternalsym:$off))),
336*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
337*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (sextloadi16 (WebAssemblywrapper texternalsym:$off))),
338*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I32 texternalsym:$off, (CONST_I32 0), 0)>;
339*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (zextloadi16 (WebAssemblywrapper texternalsym:$off))),
340*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
341*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi8 (WebAssemblywrapper texternalsym:$off))),
342*9880d681SAndroid Build Coastguard Worker          (LOAD8_S_I64 texternalsym:$off, (CONST_I32 0), 0)>;
343*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi8 (WebAssemblywrapper texternalsym:$off))),
344*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
345*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi16 (WebAssemblywrapper texternalsym:$off))),
346*9880d681SAndroid Build Coastguard Worker          (LOAD16_S_I64 texternalsym:$off, (CONST_I32 0), 0)>;
347*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi16 (WebAssemblywrapper texternalsym:$off))),
348*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
349*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (sextloadi32 (WebAssemblywrapper texternalsym:$off))),
350*9880d681SAndroid Build Coastguard Worker          (LOAD32_S_I64 texternalsym:$off, (CONST_I32 0), 0)>;
351*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (zextloadi32 (WebAssemblywrapper texternalsym:$off))),
352*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
353*9880d681SAndroid Build Coastguard Worker
354*9880d681SAndroid Build Coastguard Worker// Resolve "don't care" extending loads to zero-extending loads. This is
355*9880d681SAndroid Build Coastguard Worker// somewhat arbitrary, but zero-extending is conceptually simpler.
356*9880d681SAndroid Build Coastguard Worker
357*9880d681SAndroid Build Coastguard Worker// Select "don't care" extending loads with no constant offset.
358*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 I32:$addr)),  (LOAD8_U_I32 0, $addr, 0)>;
359*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 I32:$addr)), (LOAD16_U_I32 0, $addr, 0)>;
360*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 I32:$addr)),  (LOAD8_U_I64 0, $addr, 0)>;
361*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 I32:$addr)), (LOAD16_U_I64 0, $addr, 0)>;
362*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 I32:$addr)), (LOAD32_U_I64 0, $addr, 0)>;
363*9880d681SAndroid Build Coastguard Worker
364*9880d681SAndroid Build Coastguard Worker// Select "don't care" extending loads with a constant offset.
365*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 (regPlusImm I32:$addr, imm:$off))),
366*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 imm:$off, $addr, 0)>;
367*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 (regPlusImm I32:$addr, imm:$off))),
368*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 imm:$off, $addr, 0)>;
369*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 (regPlusImm I32:$addr, imm:$off))),
370*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 imm:$off, $addr, 0)>;
371*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 (regPlusImm I32:$addr, imm:$off))),
372*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 imm:$off, $addr, 0)>;
373*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 (regPlusImm I32:$addr, imm:$off))),
374*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 imm:$off, $addr, 0)>;
375*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 (or_is_add I32:$addr, imm:$off))),
376*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 imm:$off, $addr, 0)>;
377*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 (or_is_add I32:$addr, imm:$off))),
378*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 imm:$off, $addr, 0)>;
379*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 (or_is_add I32:$addr, imm:$off))),
380*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 imm:$off, $addr, 0)>;
381*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 (or_is_add I32:$addr, imm:$off))),
382*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 imm:$off, $addr, 0)>;
383*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 (or_is_add I32:$addr, imm:$off))),
384*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 imm:$off, $addr, 0)>;
385*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 (regPlusGA I32:$addr,
386*9880d681SAndroid Build Coastguard Worker                                     (WebAssemblywrapper tglobaladdr:$off)))),
387*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 tglobaladdr:$off, $addr, 0)>;
388*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 (regPlusGA I32:$addr,
389*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off)))),
390*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 tglobaladdr:$off, $addr, 0)>;
391*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 (regPlusGA I32:$addr,
392*9880d681SAndroid Build Coastguard Worker                                     (WebAssemblywrapper tglobaladdr:$off)))),
393*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 tglobaladdr:$off, $addr, 0)>;
394*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 (regPlusGA I32:$addr,
395*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off)))),
396*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 tglobaladdr:$off, $addr, 0)>;
397*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 (regPlusGA I32:$addr,
398*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off)))),
399*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 tglobaladdr:$off, $addr, 0)>;
400*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 (add I32:$addr,
401*9880d681SAndroid Build Coastguard Worker                               (WebAssemblywrapper texternalsym:$off)))),
402*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 texternalsym:$off, $addr, 0)>;
403*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 (add I32:$addr,
404*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off)))),
405*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 texternalsym:$off, $addr, 0)>;
406*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 (add I32:$addr,
407*9880d681SAndroid Build Coastguard Worker                               (WebAssemblywrapper texternalsym:$off)))),
408*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 texternalsym:$off, $addr, 0)>;
409*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 (add I32:$addr,
410*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off)))),
411*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 texternalsym:$off, $addr, 0)>;
412*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 (add I32:$addr,
413*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off)))),
414*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 texternalsym:$off, $addr, 0)>;
415*9880d681SAndroid Build Coastguard Worker
416*9880d681SAndroid Build Coastguard Worker// Select "don't care" extending loads with just a constant offset.
417*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 imm:$off)),
418*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 imm:$off, (CONST_I32 0), 0)>;
419*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 imm:$off)),
420*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 imm:$off, (CONST_I32 0), 0)>;
421*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 imm:$off)),
422*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 imm:$off, (CONST_I32 0), 0)>;
423*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 imm:$off)),
424*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 imm:$off, (CONST_I32 0), 0)>;
425*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 imm:$off)),
426*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 imm:$off, (CONST_I32 0), 0)>;
427*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 (WebAssemblywrapper tglobaladdr:$off))),
428*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
429*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 (WebAssemblywrapper tglobaladdr:$off))),
430*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 tglobaladdr:$off, (CONST_I32 0), 0)>;
431*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 (WebAssemblywrapper tglobaladdr:$off))),
432*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
433*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 (WebAssemblywrapper tglobaladdr:$off))),
434*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
435*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 (WebAssemblywrapper tglobaladdr:$off))),
436*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
437*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi8 (WebAssemblywrapper texternalsym:$off))),
438*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
439*9880d681SAndroid Build Coastguard Workerdef : Pat<(i32 (extloadi16 (WebAssemblywrapper texternalsym:$off))),
440*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I32 texternalsym:$off, (CONST_I32 0), 0)>;
441*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi8 (WebAssemblywrapper texternalsym:$off))),
442*9880d681SAndroid Build Coastguard Worker          (LOAD8_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
443*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi16 (WebAssemblywrapper texternalsym:$off))),
444*9880d681SAndroid Build Coastguard Worker          (LOAD16_U_I64 texternalsym:$off, (CONST_I32 0), 0)>;
445*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (extloadi32 (WebAssemblywrapper texternalsym:$off))),
446*9880d681SAndroid Build Coastguard Worker          (LOAD32_U_I64 tglobaladdr:$off, (CONST_I32 0), 0)>;
447*9880d681SAndroid Build Coastguard Worker
448*9880d681SAndroid Build Coastguard Workerlet Defs = [ARGUMENTS] in {
449*9880d681SAndroid Build Coastguard Worker
450*9880d681SAndroid Build Coastguard Worker// Basic store.
451*9880d681SAndroid Build Coastguard Worker// Note that we split the patterns out of the instruction definitions because
452*9880d681SAndroid Build Coastguard Worker// WebAssembly's stores return their operand value, and tablegen doesn't like
453*9880d681SAndroid Build Coastguard Worker// instruction definition patterns that don't reference all of the output
454*9880d681SAndroid Build Coastguard Worker// operands.
455*9880d681SAndroid Build Coastguard Worker// Note: WebAssembly inverts SelectionDAG's usual operand order.
456*9880d681SAndroid Build Coastguard Workerdef STORE_I32  : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
457*9880d681SAndroid Build Coastguard Worker                                     P2Align:$p2align, I32:$val), [],
458*9880d681SAndroid Build Coastguard Worker                   "i32.store\t$dst, ${off}(${addr})${p2align}, $val">;
459*9880d681SAndroid Build Coastguard Workerdef STORE_I64  : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
460*9880d681SAndroid Build Coastguard Worker                                     P2Align:$p2align, I64:$val), [],
461*9880d681SAndroid Build Coastguard Worker                   "i64.store\t$dst, ${off}(${addr})${p2align}, $val">;
462*9880d681SAndroid Build Coastguard Workerdef STORE_F32  : I<(outs F32:$dst), (ins i32imm:$off, I32:$addr,
463*9880d681SAndroid Build Coastguard Worker                                     P2Align:$p2align, F32:$val), [],
464*9880d681SAndroid Build Coastguard Worker                   "f32.store\t$dst, ${off}(${addr})${p2align}, $val">;
465*9880d681SAndroid Build Coastguard Workerdef STORE_F64  : I<(outs F64:$dst), (ins i32imm:$off, I32:$addr,
466*9880d681SAndroid Build Coastguard Worker                                     P2Align:$p2align, F64:$val), [],
467*9880d681SAndroid Build Coastguard Worker                   "f64.store\t$dst, ${off}(${addr})${p2align}, $val">;
468*9880d681SAndroid Build Coastguard Worker
469*9880d681SAndroid Build Coastguard Worker} // Defs = [ARGUMENTS]
470*9880d681SAndroid Build Coastguard Worker
471*9880d681SAndroid Build Coastguard Worker// Select stores with no constant offset.
472*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, I32:$addr), (STORE_I32 0, I32:$addr, 0, I32:$val)>;
473*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, I32:$addr), (STORE_I64 0, I32:$addr, 0, I64:$val)>;
474*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, I32:$addr), (STORE_F32 0, I32:$addr, 0, F32:$val)>;
475*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, I32:$addr), (STORE_F64 0, I32:$addr, 0, F64:$val)>;
476*9880d681SAndroid Build Coastguard Worker
477*9880d681SAndroid Build Coastguard Worker// Select stores with a constant offset.
478*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, (regPlusImm I32:$addr, imm:$off)),
479*9880d681SAndroid Build Coastguard Worker          (STORE_I32 imm:$off, I32:$addr, 0, I32:$val)>;
480*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, (regPlusImm I32:$addr, imm:$off)),
481*9880d681SAndroid Build Coastguard Worker          (STORE_I64 imm:$off, I32:$addr, 0, I64:$val)>;
482*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, (regPlusImm I32:$addr, imm:$off)),
483*9880d681SAndroid Build Coastguard Worker          (STORE_F32 imm:$off, I32:$addr, 0, F32:$val)>;
484*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, (regPlusImm I32:$addr, imm:$off)),
485*9880d681SAndroid Build Coastguard Worker          (STORE_F64 imm:$off, I32:$addr, 0, F64:$val)>;
486*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, (or_is_add I32:$addr, imm:$off)),
487*9880d681SAndroid Build Coastguard Worker          (STORE_I32 imm:$off, I32:$addr, 0, I32:$val)>;
488*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, (or_is_add I32:$addr, imm:$off)),
489*9880d681SAndroid Build Coastguard Worker          (STORE_I64 imm:$off, I32:$addr, 0, I64:$val)>;
490*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, (or_is_add I32:$addr, imm:$off)),
491*9880d681SAndroid Build Coastguard Worker          (STORE_F32 imm:$off, I32:$addr, 0, F32:$val)>;
492*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, (or_is_add I32:$addr, imm:$off)),
493*9880d681SAndroid Build Coastguard Worker          (STORE_F64 imm:$off, I32:$addr, 0, F64:$val)>;
494*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, (regPlusGA I32:$addr,
495*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off))),
496*9880d681SAndroid Build Coastguard Worker          (STORE_I32 tglobaladdr:$off, I32:$addr, 0, I32:$val)>;
497*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, (regPlusGA I32:$addr,
498*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off))),
499*9880d681SAndroid Build Coastguard Worker          (STORE_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
500*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, (regPlusGA I32:$addr,
501*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off))),
502*9880d681SAndroid Build Coastguard Worker          (STORE_F32 tglobaladdr:$off, I32:$addr, 0, F32:$val)>;
503*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, (regPlusGA I32:$addr,
504*9880d681SAndroid Build Coastguard Worker                                      (WebAssemblywrapper tglobaladdr:$off))),
505*9880d681SAndroid Build Coastguard Worker          (STORE_F64 tglobaladdr:$off, I32:$addr, 0, F64:$val)>;
506*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, (add I32:$addr,
507*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off))),
508*9880d681SAndroid Build Coastguard Worker          (STORE_I32 texternalsym:$off, I32:$addr, 0, I32:$val)>;
509*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, (add I32:$addr,
510*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off))),
511*9880d681SAndroid Build Coastguard Worker          (STORE_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
512*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, (add I32:$addr,
513*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off))),
514*9880d681SAndroid Build Coastguard Worker          (STORE_F32 texternalsym:$off, I32:$addr, 0, F32:$val)>;
515*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, (add I32:$addr,
516*9880d681SAndroid Build Coastguard Worker                                (WebAssemblywrapper texternalsym:$off))),
517*9880d681SAndroid Build Coastguard Worker          (STORE_F64 texternalsym:$off, I32:$addr, 0, F64:$val)>;
518*9880d681SAndroid Build Coastguard Worker
519*9880d681SAndroid Build Coastguard Worker// Select stores with just a constant offset.
520*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, imm:$off),
521*9880d681SAndroid Build Coastguard Worker          (STORE_I32 imm:$off, (CONST_I32 0), 0, I32:$val)>;
522*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, imm:$off),
523*9880d681SAndroid Build Coastguard Worker          (STORE_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
524*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, imm:$off),
525*9880d681SAndroid Build Coastguard Worker          (STORE_F32 imm:$off, (CONST_I32 0), 0, F32:$val)>;
526*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, imm:$off),
527*9880d681SAndroid Build Coastguard Worker          (STORE_F64 imm:$off, (CONST_I32 0), 0, F64:$val)>;
528*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
529*9880d681SAndroid Build Coastguard Worker          (STORE_I32 tglobaladdr:$off, (CONST_I32 0), 0, I32:$val)>;
530*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
531*9880d681SAndroid Build Coastguard Worker          (STORE_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
532*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, (WebAssemblywrapper tglobaladdr:$off)),
533*9880d681SAndroid Build Coastguard Worker          (STORE_F32 tglobaladdr:$off, (CONST_I32 0), 0, F32:$val)>;
534*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, (WebAssemblywrapper tglobaladdr:$off)),
535*9880d681SAndroid Build Coastguard Worker          (STORE_F64 tglobaladdr:$off, (CONST_I32 0), 0, F64:$val)>;
536*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I32:$val, (WebAssemblywrapper texternalsym:$off)),
537*9880d681SAndroid Build Coastguard Worker          (STORE_I32 texternalsym:$off, (CONST_I32 0), 0, I32:$val)>;
538*9880d681SAndroid Build Coastguard Workerdef : Pat<(store I64:$val, (WebAssemblywrapper texternalsym:$off)),
539*9880d681SAndroid Build Coastguard Worker          (STORE_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
540*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F32:$val, (WebAssemblywrapper texternalsym:$off)),
541*9880d681SAndroid Build Coastguard Worker          (STORE_F32 texternalsym:$off, (CONST_I32 0), 0, F32:$val)>;
542*9880d681SAndroid Build Coastguard Workerdef : Pat<(store F64:$val, (WebAssemblywrapper texternalsym:$off)),
543*9880d681SAndroid Build Coastguard Worker          (STORE_F64 texternalsym:$off, (CONST_I32 0), 0, F64:$val)>;
544*9880d681SAndroid Build Coastguard Worker
545*9880d681SAndroid Build Coastguard Workerlet Defs = [ARGUMENTS] in {
546*9880d681SAndroid Build Coastguard Worker
547*9880d681SAndroid Build Coastguard Worker// Truncating store.
548*9880d681SAndroid Build Coastguard Workerdef STORE8_I32  : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
549*9880d681SAndroid Build Coastguard Worker                                      P2Align:$p2align, I32:$val), [],
550*9880d681SAndroid Build Coastguard Worker                    "i32.store8\t$dst, ${off}(${addr})${p2align}, $val">;
551*9880d681SAndroid Build Coastguard Workerdef STORE16_I32 : I<(outs I32:$dst), (ins i32imm:$off, I32:$addr,
552*9880d681SAndroid Build Coastguard Worker                                      P2Align:$p2align, I32:$val), [],
553*9880d681SAndroid Build Coastguard Worker                    "i32.store16\t$dst, ${off}(${addr})${p2align}, $val">;
554*9880d681SAndroid Build Coastguard Workerdef STORE8_I64  : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
555*9880d681SAndroid Build Coastguard Worker                                      P2Align:$p2align, I64:$val), [],
556*9880d681SAndroid Build Coastguard Worker                    "i64.store8\t$dst, ${off}(${addr})${p2align}, $val">;
557*9880d681SAndroid Build Coastguard Workerdef STORE16_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
558*9880d681SAndroid Build Coastguard Worker                                      P2Align:$p2align, I64:$val), [],
559*9880d681SAndroid Build Coastguard Worker                    "i64.store16\t$dst, ${off}(${addr})${p2align}, $val">;
560*9880d681SAndroid Build Coastguard Workerdef STORE32_I64 : I<(outs I64:$dst), (ins i32imm:$off, I32:$addr,
561*9880d681SAndroid Build Coastguard Worker                                      P2Align:$p2align, I64:$val), [],
562*9880d681SAndroid Build Coastguard Worker                    "i64.store32\t$dst, ${off}(${addr})${p2align}, $val">;
563*9880d681SAndroid Build Coastguard Worker
564*9880d681SAndroid Build Coastguard Worker} // Defs = [ARGUMENTS]
565*9880d681SAndroid Build Coastguard Worker
566*9880d681SAndroid Build Coastguard Worker// Select truncating stores with no constant offset.
567*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val, I32:$addr),
568*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 0, I32:$addr, 0, I32:$val)>;
569*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val, I32:$addr),
570*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 0, I32:$addr, 0, I32:$val)>;
571*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val, I32:$addr),
572*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 0, I32:$addr, 0, I64:$val)>;
573*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val, I32:$addr),
574*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 0, I32:$addr, 0, I64:$val)>;
575*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val, I32:$addr),
576*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 0, I32:$addr, 0, I64:$val)>;
577*9880d681SAndroid Build Coastguard Worker
578*9880d681SAndroid Build Coastguard Worker// Select truncating stores with a constant offset.
579*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val, (regPlusImm I32:$addr, imm:$off)),
580*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 imm:$off, I32:$addr, 0, I32:$val)>;
581*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val, (regPlusImm I32:$addr, imm:$off)),
582*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 imm:$off, I32:$addr, 0, I32:$val)>;
583*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val, (regPlusImm I32:$addr, imm:$off)),
584*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 imm:$off, I32:$addr, 0, I64:$val)>;
585*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val, (regPlusImm I32:$addr, imm:$off)),
586*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 imm:$off, I32:$addr, 0, I64:$val)>;
587*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val, (regPlusImm I32:$addr, imm:$off)),
588*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 imm:$off, I32:$addr, 0, I64:$val)>;
589*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val, (or_is_add I32:$addr, imm:$off)),
590*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 imm:$off, I32:$addr, 0, I32:$val)>;
591*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val, (or_is_add I32:$addr, imm:$off)),
592*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 imm:$off, I32:$addr, 0, I32:$val)>;
593*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val, (or_is_add I32:$addr, imm:$off)),
594*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 imm:$off, I32:$addr, 0, I64:$val)>;
595*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val, (or_is_add I32:$addr, imm:$off)),
596*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 imm:$off, I32:$addr, 0, I64:$val)>;
597*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val, (or_is_add I32:$addr, imm:$off)),
598*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 imm:$off, I32:$addr, 0, I64:$val)>;
599*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val,
600*9880d681SAndroid Build Coastguard Worker                        (regPlusGA I32:$addr,
601*9880d681SAndroid Build Coastguard Worker                                   (WebAssemblywrapper tglobaladdr:$off))),
602*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 tglobaladdr:$off, I32:$addr, 0, I32:$val)>;
603*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val,
604*9880d681SAndroid Build Coastguard Worker                         (regPlusGA I32:$addr,
605*9880d681SAndroid Build Coastguard Worker                                    (WebAssemblywrapper tglobaladdr:$off))),
606*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 tglobaladdr:$off, I32:$addr, 0, I32:$val)>;
607*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val,
608*9880d681SAndroid Build Coastguard Worker                        (regPlusGA I32:$addr,
609*9880d681SAndroid Build Coastguard Worker                                   (WebAssemblywrapper tglobaladdr:$off))),
610*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
611*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val,
612*9880d681SAndroid Build Coastguard Worker                         (regPlusGA I32:$addr,
613*9880d681SAndroid Build Coastguard Worker                                    (WebAssemblywrapper tglobaladdr:$off))),
614*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
615*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val,
616*9880d681SAndroid Build Coastguard Worker                         (regPlusGA I32:$addr,
617*9880d681SAndroid Build Coastguard Worker                                    (WebAssemblywrapper tglobaladdr:$off))),
618*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 tglobaladdr:$off, I32:$addr, 0, I64:$val)>;
619*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val, (add I32:$addr,
620*9880d681SAndroid Build Coastguard Worker                                       (WebAssemblywrapper texternalsym:$off))),
621*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 texternalsym:$off, I32:$addr, 0, I32:$val)>;
622*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val,
623*9880d681SAndroid Build Coastguard Worker                         (add I32:$addr,
624*9880d681SAndroid Build Coastguard Worker                              (WebAssemblywrapper texternalsym:$off))),
625*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 texternalsym:$off, I32:$addr, 0, I32:$val)>;
626*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val,
627*9880d681SAndroid Build Coastguard Worker                        (add I32:$addr,
628*9880d681SAndroid Build Coastguard Worker                             (WebAssemblywrapper texternalsym:$off))),
629*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
630*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val,
631*9880d681SAndroid Build Coastguard Worker                         (add I32:$addr,
632*9880d681SAndroid Build Coastguard Worker                              (WebAssemblywrapper texternalsym:$off))),
633*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
634*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val,
635*9880d681SAndroid Build Coastguard Worker                         (add I32:$addr,
636*9880d681SAndroid Build Coastguard Worker                              (WebAssemblywrapper texternalsym:$off))),
637*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 texternalsym:$off, I32:$addr, 0, I64:$val)>;
638*9880d681SAndroid Build Coastguard Worker
639*9880d681SAndroid Build Coastguard Worker// Select truncating stores with just a constant offset.
640*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val, imm:$off),
641*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 imm:$off, (CONST_I32 0), 0, I32:$val)>;
642*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val, imm:$off),
643*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 imm:$off, (CONST_I32 0), 0, I32:$val)>;
644*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val, imm:$off),
645*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
646*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val, imm:$off),
647*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
648*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val, imm:$off),
649*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 imm:$off, (CONST_I32 0), 0, I64:$val)>;
650*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
651*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 tglobaladdr:$off, (CONST_I32 0), 0, I32:$val)>;
652*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
653*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 tglobaladdr:$off, (CONST_I32 0), 0, I32:$val)>;
654*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
655*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
656*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
657*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
658*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
659*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 tglobaladdr:$off, (CONST_I32 0), 0, I64:$val)>;
660*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I32:$val, (WebAssemblywrapper texternalsym:$off)),
661*9880d681SAndroid Build Coastguard Worker          (STORE8_I32 texternalsym:$off, (CONST_I32 0), 0, I32:$val)>;
662*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I32:$val, (WebAssemblywrapper texternalsym:$off)),
663*9880d681SAndroid Build Coastguard Worker          (STORE16_I32 texternalsym:$off, (CONST_I32 0), 0, I32:$val)>;
664*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei8 I64:$val, (WebAssemblywrapper texternalsym:$off)),
665*9880d681SAndroid Build Coastguard Worker          (STORE8_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
666*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei16 I64:$val, (WebAssemblywrapper texternalsym:$off)),
667*9880d681SAndroid Build Coastguard Worker          (STORE16_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
668*9880d681SAndroid Build Coastguard Workerdef : Pat<(truncstorei32 I64:$val, (WebAssemblywrapper texternalsym:$off)),
669*9880d681SAndroid Build Coastguard Worker          (STORE32_I64 texternalsym:$off, (CONST_I32 0), 0, I64:$val)>;
670*9880d681SAndroid Build Coastguard Worker
671*9880d681SAndroid Build Coastguard Workerlet Defs = [ARGUMENTS] in {
672*9880d681SAndroid Build Coastguard Worker
673*9880d681SAndroid Build Coastguard Worker// Current memory size.
674*9880d681SAndroid Build Coastguard Workerdef CURRENT_MEMORY_I32 : I<(outs I32:$dst), (ins),
675*9880d681SAndroid Build Coastguard Worker                           [(set I32:$dst, (int_wasm_current_memory))],
676*9880d681SAndroid Build Coastguard Worker                           "current_memory\t$dst">,
677*9880d681SAndroid Build Coastguard Worker                         Requires<[HasAddr32]>;
678*9880d681SAndroid Build Coastguard Workerdef CURRENT_MEMORY_I64 : I<(outs I64:$dst), (ins),
679*9880d681SAndroid Build Coastguard Worker                           [(set I64:$dst, (int_wasm_current_memory))],
680*9880d681SAndroid Build Coastguard Worker                           "current_memory\t$dst">,
681*9880d681SAndroid Build Coastguard Worker                         Requires<[HasAddr64]>;
682*9880d681SAndroid Build Coastguard Worker
683*9880d681SAndroid Build Coastguard Worker// Grow memory.
684*9880d681SAndroid Build Coastguard Workerdef GROW_MEMORY_I32 : I<(outs), (ins I32:$delta),
685*9880d681SAndroid Build Coastguard Worker                        [(int_wasm_grow_memory I32:$delta)],
686*9880d681SAndroid Build Coastguard Worker                        "grow_memory\t$delta">,
687*9880d681SAndroid Build Coastguard Worker                      Requires<[HasAddr32]>;
688*9880d681SAndroid Build Coastguard Workerdef GROW_MEMORY_I64 : I<(outs), (ins I64:$delta),
689*9880d681SAndroid Build Coastguard Worker                        [(int_wasm_grow_memory I64:$delta)],
690*9880d681SAndroid Build Coastguard Worker                        "grow_memory\t$delta">,
691*9880d681SAndroid Build Coastguard Worker                      Requires<[HasAddr64]>;
692*9880d681SAndroid Build Coastguard Worker
693*9880d681SAndroid Build Coastguard Worker} // Defs = [ARGUMENTS]
694