OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/wasm/wasm-macro-gen.h" | 5 #include "src/wasm/wasm-macro-gen.h" |
6 | 6 |
7 #include "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
8 #include "test/cctest/compiler/value-helper.h" | 8 #include "test/cctest/compiler/value-helper.h" |
9 #include "test/cctest/wasm/wasm-run-utils.h" | 9 #include "test/cctest/wasm/wasm-run-utils.h" |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 #define WASM_SIMD_CHECK_SPLAT4_F32(TYPE, value, lv) \ | 90 #define WASM_SIMD_CHECK_SPLAT4_F32(TYPE, value, lv) \ |
91 WASM_SIMD_CHECK4_F32(TYPE, value, lv, lv, lv, lv) | 91 WASM_SIMD_CHECK4_F32(TYPE, value, lv, lv, lv, lv) |
92 | 92 |
93 #if V8_TARGET_ARCH_ARM | 93 #if V8_TARGET_ARCH_ARM |
94 WASM_EXEC_TEST(F32x4Splat) { | 94 WASM_EXEC_TEST(F32x4Splat) { |
95 FLAG_wasm_simd_prototype = true; | 95 FLAG_wasm_simd_prototype = true; |
96 | 96 |
97 WasmRunner<int32_t, float> r(kExecuteCompiled); | 97 WasmRunner<int32_t, float> r(kExecuteCompiled); |
98 byte lane_val = 0; | 98 byte lane_val = 0; |
99 byte simd = r.AllocateLocal(kAstS128); | 99 byte simd = r.AllocateLocal(kWasmS128); |
100 BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT( | 100 BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT( |
101 WASM_GET_LOCAL(lane_val))), | 101 WASM_GET_LOCAL(lane_val))), |
102 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, lane_val), | 102 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, lane_val), |
103 WASM_RETURN1(WASM_ONE))); | 103 WASM_RETURN1(WASM_ONE))); |
104 | 104 |
105 FOR_FLOAT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } | 105 FOR_FLOAT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } |
106 } | 106 } |
107 | 107 |
108 WASM_EXEC_TEST(F32x4ReplaceLane) { | 108 WASM_EXEC_TEST(F32x4ReplaceLane) { |
109 FLAG_wasm_simd_prototype = true; | 109 FLAG_wasm_simd_prototype = true; |
110 WasmRunner<int32_t, float, float> r(kExecuteCompiled); | 110 WasmRunner<int32_t, float, float> r(kExecuteCompiled); |
111 byte old_val = 0; | 111 byte old_val = 0; |
112 byte new_val = 1; | 112 byte new_val = 1; |
113 byte simd = r.AllocateLocal(kAstS128); | 113 byte simd = r.AllocateLocal(kWasmS128); |
114 BUILD(r, WASM_BLOCK( | 114 BUILD(r, WASM_BLOCK( |
115 WASM_SET_LOCAL(simd, | 115 WASM_SET_LOCAL(simd, |
116 WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(old_val))), | 116 WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(old_val))), |
117 WASM_SET_LOCAL( | 117 WASM_SET_LOCAL( |
118 simd, WASM_SIMD_F32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd), | 118 simd, WASM_SIMD_F32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd), |
119 WASM_GET_LOCAL(new_val))), | 119 WASM_GET_LOCAL(new_val))), |
120 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, old_val, old_val, | 120 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, old_val, old_val, |
121 old_val), | 121 old_val), |
122 WASM_SET_LOCAL( | 122 WASM_SET_LOCAL( |
123 simd, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd), | 123 simd, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd), |
(...skipping 14 matching lines...) Expand all Loading... |
138 CHECK_EQ(1, r.Call(3.14159, -1.5)); | 138 CHECK_EQ(1, r.Call(3.14159, -1.5)); |
139 } | 139 } |
140 | 140 |
141 // Tests both signed and unsigned conversion. | 141 // Tests both signed and unsigned conversion. |
142 WASM_EXEC_TEST(F32x4FromInt32x4) { | 142 WASM_EXEC_TEST(F32x4FromInt32x4) { |
143 FLAG_wasm_simd_prototype = true; | 143 FLAG_wasm_simd_prototype = true; |
144 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled); | 144 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled); |
145 byte a = 0; | 145 byte a = 0; |
146 byte expected_signed = 1; | 146 byte expected_signed = 1; |
147 byte expected_unsigned = 2; | 147 byte expected_unsigned = 2; |
148 byte simd0 = r.AllocateLocal(kAstS128); | 148 byte simd0 = r.AllocateLocal(kWasmS128); |
149 byte simd1 = r.AllocateLocal(kAstS128); | 149 byte simd1 = r.AllocateLocal(kWasmS128); |
150 byte simd2 = r.AllocateLocal(kAstS128); | 150 byte simd2 = r.AllocateLocal(kWasmS128); |
151 BUILD(r, WASM_BLOCK( | 151 BUILD(r, WASM_BLOCK( |
152 WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 152 WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
153 WASM_SET_LOCAL( | 153 WASM_SET_LOCAL( |
154 simd1, WASM_SIMD_F32x4_FROM_I32x4(WASM_GET_LOCAL(simd0))), | 154 simd1, WASM_SIMD_F32x4_FROM_I32x4(WASM_GET_LOCAL(simd0))), |
155 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected_signed), | 155 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected_signed), |
156 WASM_SET_LOCAL( | 156 WASM_SET_LOCAL( |
157 simd2, WASM_SIMD_F32x4_FROM_U32x4(WASM_GET_LOCAL(simd0))), | 157 simd2, WASM_SIMD_F32x4_FROM_U32x4(WASM_GET_LOCAL(simd0))), |
158 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd2, expected_unsigned), | 158 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd2, expected_unsigned), |
159 WASM_RETURN1(WASM_ONE))); | 159 WASM_RETURN1(WASM_ONE))); |
160 | 160 |
161 FOR_INT32_INPUTS(i) { | 161 FOR_INT32_INPUTS(i) { |
162 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), | 162 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), |
163 static_cast<float>(static_cast<uint32_t>(*i)))); | 163 static_cast<float>(static_cast<uint32_t>(*i)))); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 WASM_EXEC_TEST(S32x4Select) { | 167 WASM_EXEC_TEST(S32x4Select) { |
168 FLAG_wasm_simd_prototype = true; | 168 FLAG_wasm_simd_prototype = true; |
169 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 169 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
170 byte val1 = 0; | 170 byte val1 = 0; |
171 byte val2 = 1; | 171 byte val2 = 1; |
172 byte mask = r.AllocateLocal(kAstS128); | 172 byte mask = r.AllocateLocal(kWasmS128); |
173 byte src1 = r.AllocateLocal(kAstS128); | 173 byte src1 = r.AllocateLocal(kWasmS128); |
174 byte src2 = r.AllocateLocal(kAstS128); | 174 byte src2 = r.AllocateLocal(kWasmS128); |
175 BUILD(r, | 175 BUILD(r, |
176 WASM_BLOCK( | 176 WASM_BLOCK( |
177 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_SPLAT(WASM_ZERO)), | 177 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_SPLAT(WASM_ZERO)), |
178 WASM_SET_LOCAL(src1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val1))), | 178 WASM_SET_LOCAL(src1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val1))), |
179 WASM_SET_LOCAL(src2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val2))), | 179 WASM_SET_LOCAL(src2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val2))), |
180 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE( | 180 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE( |
181 1, WASM_GET_LOCAL(mask), WASM_I32V(-1))), | 181 1, WASM_GET_LOCAL(mask), WASM_I32V(-1))), |
182 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE( | 182 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE( |
183 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), | 183 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), |
184 WASM_SET_LOCAL(mask, WASM_SIMD_S32x4_SELECT(WASM_GET_LOCAL(mask), | 184 WASM_SET_LOCAL(mask, WASM_SIMD_S32x4_SELECT(WASM_GET_LOCAL(mask), |
185 WASM_GET_LOCAL(src1), | 185 WASM_GET_LOCAL(src1), |
186 WASM_GET_LOCAL(src2))), | 186 WASM_GET_LOCAL(src2))), |
187 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 0), | 187 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 0), |
188 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 1), | 188 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 1), |
189 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 2), | 189 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 2), |
190 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 3), | 190 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 3), |
191 WASM_RETURN1(WASM_ONE))); | 191 WASM_RETURN1(WASM_ONE))); |
192 | 192 |
193 CHECK_EQ(1, r.Call(0x1234, 0x5678)); | 193 CHECK_EQ(1, r.Call(0x1234, 0x5678)); |
194 } | 194 } |
195 | 195 |
196 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) { | 196 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) { |
197 FLAG_wasm_simd_prototype = true; | 197 FLAG_wasm_simd_prototype = true; |
198 WasmRunner<int32_t, float, float> r(kExecuteCompiled); | 198 WasmRunner<int32_t, float, float> r(kExecuteCompiled); |
199 byte a = 0; | 199 byte a = 0; |
200 byte expected = 1; | 200 byte expected = 1; |
201 byte simd = r.AllocateLocal(kAstS128); | 201 byte simd = r.AllocateLocal(kWasmS128); |
202 BUILD(r, WASM_BLOCK( | 202 BUILD(r, WASM_BLOCK( |
203 WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 203 WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
204 WASM_SET_LOCAL( | 204 WASM_SET_LOCAL( |
205 simd, WASM_SIMD_UNOP(simd_op & 0xffu, WASM_GET_LOCAL(simd))), | 205 simd, WASM_SIMD_UNOP(simd_op & 0xffu, WASM_GET_LOCAL(simd))), |
206 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), | 206 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), |
207 WASM_RETURN1(WASM_ONE))); | 207 WASM_RETURN1(WASM_ONE))); |
208 | 208 |
209 FOR_FLOAT32_INPUTS(i) { | 209 FOR_FLOAT32_INPUTS(i) { |
210 if (std::isnan(*i)) continue; | 210 if (std::isnan(*i)) continue; |
211 CHECK_EQ(1, r.Call(*i, expected_op(*i))); | 211 CHECK_EQ(1, r.Call(*i, expected_op(*i))); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 WASM_EXEC_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } | 215 WASM_EXEC_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } |
216 WASM_EXEC_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } | 216 WASM_EXEC_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } |
217 | 217 |
218 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { | 218 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { |
219 FLAG_wasm_simd_prototype = true; | 219 FLAG_wasm_simd_prototype = true; |
220 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); | 220 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); |
221 byte a = 0; | 221 byte a = 0; |
222 byte b = 1; | 222 byte b = 1; |
223 byte expected = 2; | 223 byte expected = 2; |
224 byte simd0 = r.AllocateLocal(kAstS128); | 224 byte simd0 = r.AllocateLocal(kWasmS128); |
225 byte simd1 = r.AllocateLocal(kAstS128); | 225 byte simd1 = r.AllocateLocal(kWasmS128); |
226 BUILD(r, WASM_BLOCK( | 226 BUILD(r, WASM_BLOCK( |
227 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 227 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
228 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), | 228 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), |
229 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, | 229 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, |
230 WASM_GET_LOCAL(simd0), | 230 WASM_GET_LOCAL(simd0), |
231 WASM_GET_LOCAL(simd1))), | 231 WASM_GET_LOCAL(simd1))), |
232 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), | 232 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), |
233 WASM_RETURN1(WASM_ONE))); | 233 WASM_RETURN1(WASM_ONE))); |
234 | 234 |
235 FOR_FLOAT32_INPUTS(i) { | 235 FOR_FLOAT32_INPUTS(i) { |
236 if (std::isnan(*i)) continue; | 236 if (std::isnan(*i)) continue; |
237 FOR_FLOAT32_INPUTS(j) { | 237 FOR_FLOAT32_INPUTS(j) { |
238 if (std::isnan(*j)) continue; | 238 if (std::isnan(*j)) continue; |
239 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); | 239 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); |
240 } | 240 } |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 WASM_EXEC_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } | 244 WASM_EXEC_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } |
245 WASM_EXEC_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } | 245 WASM_EXEC_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } |
246 | 246 |
247 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { | 247 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { |
248 FLAG_wasm_simd_prototype = true; | 248 FLAG_wasm_simd_prototype = true; |
249 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); | 249 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); |
250 byte a = 0; | 250 byte a = 0; |
251 byte b = 1; | 251 byte b = 1; |
252 byte expected = 2; | 252 byte expected = 2; |
253 byte simd0 = r.AllocateLocal(kAstS128); | 253 byte simd0 = r.AllocateLocal(kWasmS128); |
254 byte simd1 = r.AllocateLocal(kAstS128); | 254 byte simd1 = r.AllocateLocal(kWasmS128); |
255 BUILD(r, WASM_BLOCK( | 255 BUILD(r, WASM_BLOCK( |
256 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 256 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
257 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), | 257 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), |
258 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, | 258 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, |
259 WASM_GET_LOCAL(simd0), | 259 WASM_GET_LOCAL(simd0), |
260 WASM_GET_LOCAL(simd1))), | 260 WASM_GET_LOCAL(simd1))), |
261 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), | 261 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), |
262 WASM_RETURN1(WASM_ONE))); | 262 WASM_RETURN1(WASM_ONE))); |
263 | 263 |
264 FOR_FLOAT32_INPUTS(i) { | 264 FOR_FLOAT32_INPUTS(i) { |
(...skipping 17 matching lines...) Expand all Loading... |
282 // interesting SIMD values. | 282 // interesting SIMD values. |
283 // | 283 // |
284 // SetLocal(1, I32x4Splat(Local(0))); | 284 // SetLocal(1, I32x4Splat(Local(0))); |
285 // For each lane index | 285 // For each lane index |
286 // if(Local(0) != I32x4ExtractLane(Local(1), index) | 286 // if(Local(0) != I32x4ExtractLane(Local(1), index) |
287 // return 0 | 287 // return 0 |
288 // | 288 // |
289 // return 1 | 289 // return 1 |
290 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 290 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
291 byte lane_val = 0; | 291 byte lane_val = 0; |
292 byte simd = r.AllocateLocal(kAstS128); | 292 byte simd = r.AllocateLocal(kWasmS128); |
293 BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT( | 293 BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT( |
294 WASM_GET_LOCAL(lane_val))), | 294 WASM_GET_LOCAL(lane_val))), |
295 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, lane_val), | 295 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, lane_val), |
296 WASM_RETURN1(WASM_ONE))); | 296 WASM_RETURN1(WASM_ONE))); |
297 | 297 |
298 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } | 298 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } |
299 } | 299 } |
300 | 300 |
301 WASM_EXEC_TEST(I32x4ReplaceLane) { | 301 WASM_EXEC_TEST(I32x4ReplaceLane) { |
302 FLAG_wasm_simd_prototype = true; | 302 FLAG_wasm_simd_prototype = true; |
303 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 303 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
304 byte old_val = 0; | 304 byte old_val = 0; |
305 byte new_val = 1; | 305 byte new_val = 1; |
306 byte simd = r.AllocateLocal(kAstS128); | 306 byte simd = r.AllocateLocal(kWasmS128); |
307 BUILD(r, WASM_BLOCK( | 307 BUILD(r, WASM_BLOCK( |
308 WASM_SET_LOCAL(simd, | 308 WASM_SET_LOCAL(simd, |
309 WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(old_val))), | 309 WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(old_val))), |
310 WASM_SET_LOCAL( | 310 WASM_SET_LOCAL( |
311 simd, WASM_SIMD_I32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd), | 311 simd, WASM_SIMD_I32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd), |
312 WASM_GET_LOCAL(new_val))), | 312 WASM_GET_LOCAL(new_val))), |
313 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, old_val, old_val, | 313 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, old_val, old_val, |
314 old_val), | 314 old_val), |
315 WASM_SET_LOCAL( | 315 WASM_SET_LOCAL( |
316 simd, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd), | 316 simd, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd), |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 return result; | 373 return result; |
374 } | 374 } |
375 | 375 |
376 // Tests both signed and unsigned conversion. | 376 // Tests both signed and unsigned conversion. |
377 WASM_EXEC_TEST(I32x4FromFloat32x4) { | 377 WASM_EXEC_TEST(I32x4FromFloat32x4) { |
378 FLAG_wasm_simd_prototype = true; | 378 FLAG_wasm_simd_prototype = true; |
379 WasmRunner<int32_t, float, int32_t, int32_t> r(kExecuteCompiled); | 379 WasmRunner<int32_t, float, int32_t, int32_t> r(kExecuteCompiled); |
380 byte a = 0; | 380 byte a = 0; |
381 byte expected_signed = 1; | 381 byte expected_signed = 1; |
382 byte expected_unsigned = 2; | 382 byte expected_unsigned = 2; |
383 byte simd0 = r.AllocateLocal(kAstS128); | 383 byte simd0 = r.AllocateLocal(kWasmS128); |
384 byte simd1 = r.AllocateLocal(kAstS128); | 384 byte simd1 = r.AllocateLocal(kWasmS128); |
385 byte simd2 = r.AllocateLocal(kAstS128); | 385 byte simd2 = r.AllocateLocal(kWasmS128); |
386 BUILD(r, WASM_BLOCK( | 386 BUILD(r, WASM_BLOCK( |
387 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 387 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
388 WASM_SET_LOCAL( | 388 WASM_SET_LOCAL( |
389 simd1, WASM_SIMD_I32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), | 389 simd1, WASM_SIMD_I32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), |
390 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected_signed), | 390 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected_signed), |
391 WASM_SET_LOCAL( | 391 WASM_SET_LOCAL( |
392 simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), | 392 simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), |
393 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), | 393 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), |
394 WASM_RETURN1(WASM_ONE))); | 394 WASM_RETURN1(WASM_ONE))); |
395 | 395 |
396 FOR_FLOAT32_INPUTS(i) { | 396 FOR_FLOAT32_INPUTS(i) { |
397 int32_t signed_value = ConvertToInt(*i, false); | 397 int32_t signed_value = ConvertToInt(*i, false); |
398 int32_t unsigned_value = ConvertToInt(*i, true); | 398 int32_t unsigned_value = ConvertToInt(*i, true); |
399 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); | 399 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); |
400 } | 400 } |
401 } | 401 } |
402 #endif // V8_TARGET_ARCH_ARM | 402 #endif // V8_TARGET_ARCH_ARM |
403 | 403 |
404 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { | 404 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { |
405 FLAG_wasm_simd_prototype = true; | 405 FLAG_wasm_simd_prototype = true; |
406 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 406 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
407 byte a = 0; | 407 byte a = 0; |
408 byte b = 1; | 408 byte b = 1; |
409 byte expected = 2; | 409 byte expected = 2; |
410 byte simd0 = r.AllocateLocal(kAstS128); | 410 byte simd0 = r.AllocateLocal(kWasmS128); |
411 byte simd1 = r.AllocateLocal(kAstS128); | 411 byte simd1 = r.AllocateLocal(kWasmS128); |
412 BUILD(r, WASM_BLOCK( | 412 BUILD(r, WASM_BLOCK( |
413 WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 413 WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
414 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), | 414 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), |
415 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, | 415 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, |
416 WASM_GET_LOCAL(simd0), | 416 WASM_GET_LOCAL(simd0), |
417 WASM_GET_LOCAL(simd1))), | 417 WASM_GET_LOCAL(simd1))), |
418 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), | 418 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), |
419 WASM_RETURN1(WASM_ONE))); | 419 WASM_RETURN1(WASM_ONE))); |
420 | 420 |
421 FOR_INT32_INPUTS(i) { | 421 FOR_INT32_INPUTS(i) { |
422 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 422 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 WASM_EXEC_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } | 426 WASM_EXEC_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } |
427 | 427 |
428 WASM_EXEC_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } | 428 WASM_EXEC_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } |
429 | 429 |
430 #if V8_TARGET_ARCH_ARM | 430 #if V8_TARGET_ARCH_ARM |
431 WASM_EXEC_TEST(I32x4Equal) { RunI32x4BinOpTest(kExprI32x4Eq, Equal); } | 431 WASM_EXEC_TEST(I32x4Equal) { RunI32x4BinOpTest(kExprI32x4Eq, Equal); } |
432 | 432 |
433 WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4BinOpTest(kExprI32x4Ne, NotEqual); } | 433 WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4BinOpTest(kExprI32x4Ne, NotEqual); } |
434 #endif // V8_TARGET_ARCH_ARM | 434 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |