blob: 1058993b35be3955eadff7f638ad25d033b1796c [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "test/unittests/test-utils.h"
6
7#include "src/wasm/wasm-macro-gen.h"
8
9namespace v8 {
10namespace internal {
11namespace wasm {
12
13class WasmMacroGenTest : public TestWithZone {};
14
15#define EXPECT_SIZE(size, ...) \
16 do { \
17 byte code[] = {__VA_ARGS__}; \
18 EXPECT_EQ(size, sizeof(code)); \
19 } while (false)
20
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000021TEST_F(WasmMacroGenTest, Constants) {
22 EXPECT_SIZE(2, WASM_ONE);
23 EXPECT_SIZE(2, WASM_ZERO);
24
25 EXPECT_SIZE(2, WASM_I8(122));
26 EXPECT_SIZE(2, WASM_I8(254));
27
Ben Murdochda12d292016-06-02 14:46:10 +010028 EXPECT_SIZE(2, WASM_I32V_1(1));
29 EXPECT_SIZE(3, WASM_I32V_2(200));
30 EXPECT_SIZE(4, WASM_I32V_3(10000));
31 EXPECT_SIZE(5, WASM_I32V_4(-9828934));
32 EXPECT_SIZE(6, WASM_I32V_5(-1119828934));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000033
Ben Murdochda12d292016-06-02 14:46:10 +010034 EXPECT_SIZE(2, WASM_I64V_1(1));
35 EXPECT_SIZE(3, WASM_I64V_2(300));
36 EXPECT_SIZE(4, WASM_I64V_3(10000));
37 EXPECT_SIZE(5, WASM_I64V_4(-9828934));
38 EXPECT_SIZE(6, WASM_I64V_5(-1119828934));
39 EXPECT_SIZE(10, WASM_I64V_9(0x123456789abcdef0ULL));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000040
41 EXPECT_SIZE(5, WASM_F32(1.0f));
42 EXPECT_SIZE(5, WASM_F32(10000.0f));
43 EXPECT_SIZE(5, WASM_F32(-9828934.0f));
44
45 EXPECT_SIZE(9, WASM_F64(1.5));
46 EXPECT_SIZE(9, WASM_F64(10200.0));
47 EXPECT_SIZE(9, WASM_F64(-9818934.0));
48}
49
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000050TEST_F(WasmMacroGenTest, Statements) {
51 EXPECT_SIZE(1, WASM_NOP);
52
53 EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO));
54
55 EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO));
56
Ben Murdochda12d292016-06-02 14:46:10 +010057 EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000058
Ben Murdochc5610432016-08-08 18:44:38 +010059 EXPECT_SIZE(5, WASM_IF(WASM_ZERO, WASM_NOP));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000060
Ben Murdochc5610432016-08-08 18:44:38 +010061 EXPECT_SIZE(7, WASM_IF_ELSE(WASM_ZERO, WASM_NOP, WASM_NOP));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000062
63 EXPECT_SIZE(5, WASM_SELECT(WASM_ZERO, WASM_NOP, WASM_NOP));
64
65 EXPECT_SIZE(3, WASM_BR(0));
66 EXPECT_SIZE(5, WASM_BR_IF(0, WASM_ZERO));
67
68 EXPECT_SIZE(3, WASM_BLOCK(1, WASM_NOP));
69 EXPECT_SIZE(4, WASM_BLOCK(2, WASM_NOP, WASM_NOP));
70 EXPECT_SIZE(5, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_NOP));
71
72 EXPECT_SIZE(5, WASM_INFINITE_LOOP);
73
74 EXPECT_SIZE(3, WASM_LOOP(1, WASM_NOP));
75 EXPECT_SIZE(4, WASM_LOOP(2, WASM_NOP, WASM_NOP));
76 EXPECT_SIZE(5, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_NOP));
77 EXPECT_SIZE(5, WASM_LOOP(1, WASM_BR(0)));
78 EXPECT_SIZE(7, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO)));
79
Ben Murdochc5610432016-08-08 18:44:38 +010080 EXPECT_SIZE(2, WASM_RETURN0);
81 EXPECT_SIZE(4, WASM_RETURN1(WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000082
83 EXPECT_SIZE(1, WASM_UNREACHABLE);
84}
85
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000086TEST_F(WasmMacroGenTest, MacroStatements) {
Ben Murdochc5610432016-08-08 18:44:38 +010087 EXPECT_SIZE(10, WASM_WHILE(WASM_I8(0), WASM_NOP));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000088 EXPECT_SIZE(7, WASM_INC_LOCAL(0));
89 EXPECT_SIZE(7, WASM_INC_LOCAL_BY(0, 3));
90
91 EXPECT_SIZE(3, WASM_BREAK(0));
92 EXPECT_SIZE(3, WASM_CONTINUE(0));
93}
94
Ben Murdochda12d292016-06-02 14:46:10 +010095TEST_F(WasmMacroGenTest, BrTable) {
Ben Murdochc5610432016-08-08 18:44:38 +010096 EXPECT_SIZE(9, WASM_BR_TABLE(WASM_ZERO, 1, BR_TARGET(1)));
97 EXPECT_SIZE(11, WASM_BR_TABLEV(WASM_ZERO, WASM_ZERO, 1, BR_TARGET(1)));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000098}
99
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000100TEST_F(WasmMacroGenTest, Expressions) {
101 EXPECT_SIZE(2, WASM_GET_LOCAL(0));
102 EXPECT_SIZE(2, WASM_GET_LOCAL(1));
103 EXPECT_SIZE(2, WASM_GET_LOCAL(12));
104 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(0));
105 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(1));
106 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(12));
Ben Murdochda12d292016-06-02 14:46:10 +0100107 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
108 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO));
109 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000110
111 EXPECT_SIZE(3, WASM_NOT(WASM_ZERO));
112
Ben Murdochc5610432016-08-08 18:44:38 +0100113 EXPECT_SIZE(5, WASM_BRV(1, WASM_ZERO));
114 EXPECT_SIZE(7, WASM_BRV_IF(1, WASM_ZERO, WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000115
116 EXPECT_SIZE(4, WASM_BLOCK(1, WASM_ZERO));
117 EXPECT_SIZE(5, WASM_BLOCK(2, WASM_NOP, WASM_ZERO));
118 EXPECT_SIZE(6, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_ZERO));
119
120 EXPECT_SIZE(4, WASM_LOOP(1, WASM_ZERO));
121 EXPECT_SIZE(5, WASM_LOOP(2, WASM_NOP, WASM_ZERO));
122 EXPECT_SIZE(6, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_ZERO));
123}
124
Ben Murdoch097c5b22016-05-18 11:27:45 +0100125TEST_F(WasmMacroGenTest, CallFunction) {
Ben Murdochc5610432016-08-08 18:44:38 +0100126 EXPECT_SIZE(3, WASM_CALL_FUNCTION0(0));
127 EXPECT_SIZE(3, WASM_CALL_FUNCTION0(1));
128 EXPECT_SIZE(3, WASM_CALL_FUNCTION0(11));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000129
Ben Murdochc5610432016-08-08 18:44:38 +0100130 EXPECT_SIZE(5, WASM_CALL_FUNCTION1(0, WASM_ZERO));
131 EXPECT_SIZE(7, WASM_CALL_FUNCTION2(1, WASM_ZERO, WASM_ZERO));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100132}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000133
Ben Murdoch097c5b22016-05-18 11:27:45 +0100134TEST_F(WasmMacroGenTest, CallImport) {
Ben Murdochc5610432016-08-08 18:44:38 +0100135 EXPECT_SIZE(3, WASM_CALL_IMPORT0(0));
136 EXPECT_SIZE(3, WASM_CALL_IMPORT0(1));
137 EXPECT_SIZE(3, WASM_CALL_IMPORT0(11));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100138
Ben Murdochc5610432016-08-08 18:44:38 +0100139 EXPECT_SIZE(5, WASM_CALL_IMPORT1(0, WASM_ZERO));
140 EXPECT_SIZE(7, WASM_CALL_IMPORT2(1, WASM_ZERO, WASM_ZERO));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100141}
142
143TEST_F(WasmMacroGenTest, CallIndirect) {
Ben Murdochc5610432016-08-08 18:44:38 +0100144 EXPECT_SIZE(5, WASM_CALL_INDIRECT0(0, WASM_ZERO));
145 EXPECT_SIZE(5, WASM_CALL_INDIRECT0(1, WASM_ZERO));
146 EXPECT_SIZE(5, WASM_CALL_INDIRECT0(11, WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000147
Ben Murdochc5610432016-08-08 18:44:38 +0100148 EXPECT_SIZE(7, WASM_CALL_INDIRECT1(0, WASM_ZERO, WASM_ZERO));
149 EXPECT_SIZE(9, WASM_CALL_INDIRECT2(1, WASM_ZERO, WASM_ZERO, WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000150}
151
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000152TEST_F(WasmMacroGenTest, Int32Ops) {
153 EXPECT_SIZE(5, WASM_I32_ADD(WASM_ZERO, WASM_ZERO));
154 EXPECT_SIZE(5, WASM_I32_SUB(WASM_ZERO, WASM_ZERO));
155 EXPECT_SIZE(5, WASM_I32_MUL(WASM_ZERO, WASM_ZERO));
156 EXPECT_SIZE(5, WASM_I32_DIVS(WASM_ZERO, WASM_ZERO));
157 EXPECT_SIZE(5, WASM_I32_DIVU(WASM_ZERO, WASM_ZERO));
158 EXPECT_SIZE(5, WASM_I32_REMS(WASM_ZERO, WASM_ZERO));
159 EXPECT_SIZE(5, WASM_I32_REMU(WASM_ZERO, WASM_ZERO));
160 EXPECT_SIZE(5, WASM_I32_AND(WASM_ZERO, WASM_ZERO));
161 EXPECT_SIZE(5, WASM_I32_IOR(WASM_ZERO, WASM_ZERO));
162 EXPECT_SIZE(5, WASM_I32_XOR(WASM_ZERO, WASM_ZERO));
163 EXPECT_SIZE(5, WASM_I32_SHL(WASM_ZERO, WASM_ZERO));
164 EXPECT_SIZE(5, WASM_I32_SHR(WASM_ZERO, WASM_ZERO));
165 EXPECT_SIZE(5, WASM_I32_SAR(WASM_ZERO, WASM_ZERO));
Ben Murdochda12d292016-06-02 14:46:10 +0100166 EXPECT_SIZE(5, WASM_I32_ROR(WASM_ZERO, WASM_ZERO));
167 EXPECT_SIZE(5, WASM_I32_ROL(WASM_ZERO, WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000168 EXPECT_SIZE(5, WASM_I32_EQ(WASM_ZERO, WASM_ZERO));
169
170 EXPECT_SIZE(5, WASM_I32_LTS(WASM_ZERO, WASM_ZERO));
171 EXPECT_SIZE(5, WASM_I32_LES(WASM_ZERO, WASM_ZERO));
172 EXPECT_SIZE(5, WASM_I32_LTU(WASM_ZERO, WASM_ZERO));
173 EXPECT_SIZE(5, WASM_I32_LEU(WASM_ZERO, WASM_ZERO));
174
175 EXPECT_SIZE(5, WASM_I32_GTS(WASM_ZERO, WASM_ZERO));
176 EXPECT_SIZE(5, WASM_I32_GES(WASM_ZERO, WASM_ZERO));
177 EXPECT_SIZE(5, WASM_I32_GTU(WASM_ZERO, WASM_ZERO));
178 EXPECT_SIZE(5, WASM_I32_GEU(WASM_ZERO, WASM_ZERO));
179
180 EXPECT_SIZE(3, WASM_I32_CLZ(WASM_ZERO));
181 EXPECT_SIZE(3, WASM_I32_CTZ(WASM_ZERO));
182 EXPECT_SIZE(3, WASM_I32_POPCNT(WASM_ZERO));
Ben Murdochda12d292016-06-02 14:46:10 +0100183
184 EXPECT_SIZE(3, WASM_I32_EQZ(WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000185}
186
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000187TEST_F(WasmMacroGenTest, Int64Ops) {
188 EXPECT_SIZE(5, WASM_I64_ADD(WASM_ZERO, WASM_ZERO));
189 EXPECT_SIZE(5, WASM_I64_SUB(WASM_ZERO, WASM_ZERO));
190 EXPECT_SIZE(5, WASM_I64_MUL(WASM_ZERO, WASM_ZERO));
191 EXPECT_SIZE(5, WASM_I64_DIVS(WASM_ZERO, WASM_ZERO));
192 EXPECT_SIZE(5, WASM_I64_DIVU(WASM_ZERO, WASM_ZERO));
193 EXPECT_SIZE(5, WASM_I64_REMS(WASM_ZERO, WASM_ZERO));
194 EXPECT_SIZE(5, WASM_I64_REMU(WASM_ZERO, WASM_ZERO));
195 EXPECT_SIZE(5, WASM_I64_AND(WASM_ZERO, WASM_ZERO));
196 EXPECT_SIZE(5, WASM_I64_IOR(WASM_ZERO, WASM_ZERO));
197 EXPECT_SIZE(5, WASM_I64_XOR(WASM_ZERO, WASM_ZERO));
198 EXPECT_SIZE(5, WASM_I64_SHL(WASM_ZERO, WASM_ZERO));
199 EXPECT_SIZE(5, WASM_I64_SHR(WASM_ZERO, WASM_ZERO));
200 EXPECT_SIZE(5, WASM_I64_SAR(WASM_ZERO, WASM_ZERO));
Ben Murdochda12d292016-06-02 14:46:10 +0100201 EXPECT_SIZE(5, WASM_I64_ROR(WASM_ZERO, WASM_ZERO));
202 EXPECT_SIZE(5, WASM_I64_ROL(WASM_ZERO, WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000203 EXPECT_SIZE(5, WASM_I64_EQ(WASM_ZERO, WASM_ZERO));
204
205 EXPECT_SIZE(5, WASM_I64_LTS(WASM_ZERO, WASM_ZERO));
206 EXPECT_SIZE(5, WASM_I64_LES(WASM_ZERO, WASM_ZERO));
207 EXPECT_SIZE(5, WASM_I64_LTU(WASM_ZERO, WASM_ZERO));
208 EXPECT_SIZE(5, WASM_I64_LEU(WASM_ZERO, WASM_ZERO));
209
210 EXPECT_SIZE(5, WASM_I64_GTS(WASM_ZERO, WASM_ZERO));
211 EXPECT_SIZE(5, WASM_I64_GES(WASM_ZERO, WASM_ZERO));
212 EXPECT_SIZE(5, WASM_I64_GTU(WASM_ZERO, WASM_ZERO));
213 EXPECT_SIZE(5, WASM_I64_GEU(WASM_ZERO, WASM_ZERO));
214
215 EXPECT_SIZE(3, WASM_I64_CLZ(WASM_ZERO));
216 EXPECT_SIZE(3, WASM_I64_CTZ(WASM_ZERO));
217 EXPECT_SIZE(3, WASM_I64_POPCNT(WASM_ZERO));
Ben Murdochda12d292016-06-02 14:46:10 +0100218
219 EXPECT_SIZE(3, WASM_I64_EQZ(WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000220}
221
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000222TEST_F(WasmMacroGenTest, Float32Ops) {
223 EXPECT_SIZE(5, WASM_F32_ADD(WASM_ZERO, WASM_ZERO));
224 EXPECT_SIZE(5, WASM_F32_SUB(WASM_ZERO, WASM_ZERO));
225 EXPECT_SIZE(5, WASM_F32_MUL(WASM_ZERO, WASM_ZERO));
226 EXPECT_SIZE(5, WASM_F32_DIV(WASM_ZERO, WASM_ZERO));
227 EXPECT_SIZE(5, WASM_F32_MIN(WASM_ZERO, WASM_ZERO));
228 EXPECT_SIZE(5, WASM_F32_MAX(WASM_ZERO, WASM_ZERO));
229 EXPECT_SIZE(5, WASM_F32_COPYSIGN(WASM_ZERO, WASM_ZERO));
230
231 EXPECT_SIZE(3, WASM_F32_ABS(WASM_ZERO));
232 EXPECT_SIZE(3, WASM_F32_NEG(WASM_ZERO));
233 EXPECT_SIZE(3, WASM_F32_CEIL(WASM_ZERO));
234 EXPECT_SIZE(3, WASM_F32_FLOOR(WASM_ZERO));
235 EXPECT_SIZE(3, WASM_F32_TRUNC(WASM_ZERO));
236 EXPECT_SIZE(3, WASM_F32_NEARESTINT(WASM_ZERO));
237 EXPECT_SIZE(3, WASM_F32_SQRT(WASM_ZERO));
238
239 EXPECT_SIZE(5, WASM_F32_EQ(WASM_ZERO, WASM_ZERO));
240 EXPECT_SIZE(5, WASM_F32_LT(WASM_ZERO, WASM_ZERO));
241 EXPECT_SIZE(5, WASM_F32_LE(WASM_ZERO, WASM_ZERO));
242 EXPECT_SIZE(5, WASM_F32_GT(WASM_ZERO, WASM_ZERO));
243 EXPECT_SIZE(5, WASM_F32_GE(WASM_ZERO, WASM_ZERO));
244}
245
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000246TEST_F(WasmMacroGenTest, Float64Ops) {
247 EXPECT_SIZE(5, WASM_F64_ADD(WASM_ZERO, WASM_ZERO));
248 EXPECT_SIZE(5, WASM_F64_SUB(WASM_ZERO, WASM_ZERO));
249 EXPECT_SIZE(5, WASM_F64_MUL(WASM_ZERO, WASM_ZERO));
250 EXPECT_SIZE(5, WASM_F64_DIV(WASM_ZERO, WASM_ZERO));
251 EXPECT_SIZE(5, WASM_F64_MIN(WASM_ZERO, WASM_ZERO));
252 EXPECT_SIZE(5, WASM_F64_MAX(WASM_ZERO, WASM_ZERO));
253 EXPECT_SIZE(5, WASM_F64_COPYSIGN(WASM_ZERO, WASM_ZERO));
254
255 EXPECT_SIZE(3, WASM_F64_ABS(WASM_ZERO));
256 EXPECT_SIZE(3, WASM_F64_NEG(WASM_ZERO));
257 EXPECT_SIZE(3, WASM_F64_CEIL(WASM_ZERO));
258 EXPECT_SIZE(3, WASM_F64_FLOOR(WASM_ZERO));
259 EXPECT_SIZE(3, WASM_F64_TRUNC(WASM_ZERO));
260 EXPECT_SIZE(3, WASM_F64_NEARESTINT(WASM_ZERO));
261 EXPECT_SIZE(3, WASM_F64_SQRT(WASM_ZERO));
262
263 EXPECT_SIZE(5, WASM_F64_EQ(WASM_ZERO, WASM_ZERO));
264 EXPECT_SIZE(5, WASM_F64_LT(WASM_ZERO, WASM_ZERO));
265 EXPECT_SIZE(5, WASM_F64_LE(WASM_ZERO, WASM_ZERO));
266 EXPECT_SIZE(5, WASM_F64_GT(WASM_ZERO, WASM_ZERO));
267 EXPECT_SIZE(5, WASM_F64_GE(WASM_ZERO, WASM_ZERO));
268}
269
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000270TEST_F(WasmMacroGenTest, Conversions) {
271 EXPECT_SIZE(3, WASM_I32_SCONVERT_F32(WASM_ZERO));
272 EXPECT_SIZE(3, WASM_I32_SCONVERT_F64(WASM_ZERO));
273 EXPECT_SIZE(3, WASM_I32_UCONVERT_F32(WASM_ZERO));
274 EXPECT_SIZE(3, WASM_I32_UCONVERT_F64(WASM_ZERO));
275 EXPECT_SIZE(3, WASM_I32_CONVERT_I64(WASM_ZERO));
276 EXPECT_SIZE(3, WASM_I64_SCONVERT_F32(WASM_ZERO));
277 EXPECT_SIZE(3, WASM_I64_SCONVERT_F64(WASM_ZERO));
278 EXPECT_SIZE(3, WASM_I64_UCONVERT_F32(WASM_ZERO));
279 EXPECT_SIZE(3, WASM_I64_UCONVERT_F64(WASM_ZERO));
280 EXPECT_SIZE(3, WASM_I64_SCONVERT_I32(WASM_ZERO));
281 EXPECT_SIZE(3, WASM_I64_UCONVERT_I32(WASM_ZERO));
282 EXPECT_SIZE(3, WASM_F32_SCONVERT_I32(WASM_ZERO));
283 EXPECT_SIZE(3, WASM_F32_UCONVERT_I32(WASM_ZERO));
284 EXPECT_SIZE(3, WASM_F32_SCONVERT_I64(WASM_ZERO));
285 EXPECT_SIZE(3, WASM_F32_UCONVERT_I64(WASM_ZERO));
286 EXPECT_SIZE(3, WASM_F32_CONVERT_F64(WASM_ZERO));
287 EXPECT_SIZE(3, WASM_F32_REINTERPRET_I32(WASM_ZERO));
288 EXPECT_SIZE(3, WASM_F64_SCONVERT_I32(WASM_ZERO));
289 EXPECT_SIZE(3, WASM_F64_UCONVERT_I32(WASM_ZERO));
290 EXPECT_SIZE(3, WASM_F64_SCONVERT_I64(WASM_ZERO));
291 EXPECT_SIZE(3, WASM_F64_UCONVERT_I64(WASM_ZERO));
292 EXPECT_SIZE(3, WASM_F64_CONVERT_F32(WASM_ZERO));
293 EXPECT_SIZE(3, WASM_F64_REINTERPRET_I64(WASM_ZERO));
294}
295
296static const MachineType kMemTypes[] = {
297 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
298 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
299 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(),
300 MachineType::Float64()};
301
302TEST_F(WasmMacroGenTest, LoadsAndStores) {
303 for (size_t i = 0; i < arraysize(kMemTypes); i++) {
Ben Murdochda12d292016-06-02 14:46:10 +0100304 EXPECT_SIZE(5, WASM_LOAD_MEM(kMemTypes[i], WASM_ZERO));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000305 }
306 for (size_t i = 0; i < arraysize(kMemTypes); i++) {
Ben Murdochda12d292016-06-02 14:46:10 +0100307 EXPECT_SIZE(7, WASM_STORE_MEM(kMemTypes[i], WASM_ZERO, WASM_GET_LOCAL(0)));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000308 }
309}
310
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000311TEST_F(WasmMacroGenTest, LoadsAndStoresWithOffset) {
312 for (size_t i = 0; i < arraysize(kMemTypes); i++) {
313 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO));
314 }
315 for (size_t i = 0; i < arraysize(kMemTypes); i++) {
316 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO,
317 WASM_GET_LOCAL(0)));
318 }
319}
320} // namespace wasm
321} // namespace internal
322} // namespace v8