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/assembler-inl.h" | 5 #include "src/assembler-inl.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 #include "test/cctest/compiler/value-helper.h" | 7 #include "test/cctest/compiler/value-helper.h" |
8 #include "test/cctest/wasm/wasm-run-utils.h" | 8 #include "test/cctest/wasm/wasm-run-utils.h" |
9 #include "test/common/wasm/wasm-macro-gen.h" | 9 #include "test/common/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 WASM_GET_LOCAL(new_val))), | 653 WASM_GET_LOCAL(new_val))), |
654 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, new_val, old_val), | 654 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, new_val, old_val), |
655 WASM_SET_LOCAL(simd, | 655 WASM_SET_LOCAL(simd, |
656 WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), | 656 WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), |
657 WASM_GET_LOCAL(new_val))), | 657 WASM_GET_LOCAL(new_val))), |
658 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, new_val), WASM_ONE); | 658 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, new_val), WASM_ONE); |
659 | 659 |
660 CHECK_EQ(1, r.Call(1, 2)); | 660 CHECK_EQ(1, r.Call(1, 2)); |
661 } | 661 } |
662 | 662 |
663 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 663 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
664 WASM_EXEC_COMPILED_TEST(I16x8Splat) { | 664 WASM_EXEC_COMPILED_TEST(I16x8Splat) { |
665 FLAG_wasm_simd_prototype = true; | 665 FLAG_wasm_simd_prototype = true; |
666 | 666 |
667 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 667 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
668 byte lane_val = 0; | 668 byte lane_val = 0; |
669 byte simd = r.AllocateLocal(kWasmS128); | 669 byte simd = r.AllocateLocal(kWasmS128); |
670 BUILD(r, | 670 BUILD(r, |
671 WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))), | 671 WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))), |
672 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE); | 672 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE); |
673 | 673 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 WASM_GET_LOCAL(new_val))), | 716 WASM_GET_LOCAL(new_val))), |
717 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, | 717 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, |
718 new_val, new_val, new_val, old_val), | 718 new_val, new_val, new_val, old_val), |
719 WASM_SET_LOCAL(simd, | 719 WASM_SET_LOCAL(simd, |
720 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), | 720 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), |
721 WASM_GET_LOCAL(new_val))), | 721 WASM_GET_LOCAL(new_val))), |
722 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); | 722 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); |
723 | 723 |
724 CHECK_EQ(1, r.Call(1, 2)); | 724 CHECK_EQ(1, r.Call(1, 2)); |
725 } | 725 } |
| 726 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
726 | 727 |
| 728 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
727 WASM_EXEC_COMPILED_TEST(I8x16Splat) { | 729 WASM_EXEC_COMPILED_TEST(I8x16Splat) { |
728 FLAG_wasm_simd_prototype = true; | 730 FLAG_wasm_simd_prototype = true; |
729 | 731 |
730 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 732 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
731 byte lane_val = 0; | 733 byte lane_val = 0; |
732 byte simd = r.AllocateLocal(kWasmS128); | 734 byte simd = r.AllocateLocal(kWasmS128); |
733 BUILD(r, | 735 BUILD(r, |
734 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), | 736 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), |
735 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); | 737 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); |
736 | 738 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 FOR_INT32_INPUTS(i) { | 1174 FOR_INT32_INPUTS(i) { |
1173 int32_t packed_signed = Narrow<int16_t>(*i); | 1175 int32_t packed_signed = Narrow<int16_t>(*i); |
1174 int32_t packed_unsigned = UnsignedNarrow<int16_t>(*i); | 1176 int32_t packed_unsigned = UnsignedNarrow<int16_t>(*i); |
1175 // Sign-extend here, since ExtractLane sign extends. | 1177 // Sign-extend here, since ExtractLane sign extends. |
1176 if (packed_unsigned & 0x8000) packed_unsigned |= 0xffff0000; | 1178 if (packed_unsigned & 0x8000) packed_unsigned |= 0xffff0000; |
1177 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); | 1179 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); |
1178 } | 1180 } |
1179 } | 1181 } |
1180 #endif // V8_TARGET_ARCH_ARM | 1182 #endif // V8_TARGET_ARCH_ARM |
1181 | 1183 |
1182 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1184 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
1183 void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { | 1185 void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { |
1184 FLAG_wasm_simd_prototype = true; | 1186 FLAG_wasm_simd_prototype = true; |
1185 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1187 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1186 byte a = 0; | 1188 byte a = 0; |
1187 byte b = 1; | 1189 byte b = 1; |
1188 byte expected = 2; | 1190 byte expected = 2; |
1189 byte simd0 = r.AllocateLocal(kWasmS128); | 1191 byte simd0 = r.AllocateLocal(kWasmS128); |
1190 byte simd1 = r.AllocateLocal(kWasmS128); | 1192 byte simd1 = r.AllocateLocal(kWasmS128); |
1191 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 1193 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
1192 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), | 1194 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 FOR_INT16_INPUTS(i) { | 1258 FOR_INT16_INPUTS(i) { |
1257 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 1259 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
1258 } | 1260 } |
1259 } | 1261 } |
1260 | 1262 |
1261 WASM_EXEC_COMPILED_TEST(I16x8Eq) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); } | 1263 WASM_EXEC_COMPILED_TEST(I16x8Eq) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); } |
1262 | 1264 |
1263 WASM_EXEC_COMPILED_TEST(I16x8Ne) { | 1265 WASM_EXEC_COMPILED_TEST(I16x8Ne) { |
1264 RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); | 1266 RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); |
1265 } | 1267 } |
1266 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1268 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
1267 | 1269 |
1268 #if V8_TARGET_ARCH_ARM | 1270 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
1269 WASM_EXEC_COMPILED_TEST(I16x8LtS) { | 1271 WASM_EXEC_COMPILED_TEST(I16x8LtS) { |
1270 RunI16x8CompareOpTest(kExprI16x8LtS, Less); | 1272 RunI16x8CompareOpTest(kExprI16x8LtS, Less); |
1271 } | 1273 } |
1272 | 1274 |
1273 WASM_EXEC_COMPILED_TEST(I16x8LeS) { | 1275 WASM_EXEC_COMPILED_TEST(I16x8LeS) { |
1274 RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); | 1276 RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); |
1275 } | 1277 } |
1276 | 1278 |
1277 WASM_EXEC_COMPILED_TEST(I16x8GtS) { | 1279 WASM_EXEC_COMPILED_TEST(I16x8GtS) { |
1278 RunI16x8CompareOpTest(kExprI16x8GtS, Greater); | 1280 RunI16x8CompareOpTest(kExprI16x8GtS, Greater); |
(...skipping 11 matching lines...) Expand all Loading... |
1290 RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual); | 1292 RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual); |
1291 } | 1293 } |
1292 | 1294 |
1293 WASM_EXEC_COMPILED_TEST(I16x8LtU) { | 1295 WASM_EXEC_COMPILED_TEST(I16x8LtU) { |
1294 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); | 1296 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); |
1295 } | 1297 } |
1296 | 1298 |
1297 WASM_EXEC_COMPILED_TEST(I16x8LeU) { | 1299 WASM_EXEC_COMPILED_TEST(I16x8LeU) { |
1298 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); | 1300 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); |
1299 } | 1301 } |
1300 #endif // V8_TARGET_ARCH_ARM | 1302 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
1301 | 1303 |
1302 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1304 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
1303 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, | 1305 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, |
1304 int shift) { | 1306 int shift) { |
1305 FLAG_wasm_simd_prototype = true; | 1307 FLAG_wasm_simd_prototype = true; |
1306 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1308 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1307 byte a = 0; | 1309 byte a = 0; |
1308 byte expected = 1; | 1310 byte expected = 1; |
1309 byte simd = r.AllocateLocal(kWasmS128); | 1311 byte simd = r.AllocateLocal(kWasmS128); |
1310 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 1312 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
1311 WASM_SET_LOCAL( | 1313 WASM_SET_LOCAL( |
1312 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), | 1314 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), |
1313 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); | 1315 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); |
1314 | 1316 |
1315 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } | 1317 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } |
1316 } | 1318 } |
1317 | 1319 |
1318 WASM_EXEC_COMPILED_TEST(I16x8Shl) { | 1320 WASM_EXEC_COMPILED_TEST(I16x8Shl) { |
1319 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); | 1321 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); |
1320 } | 1322 } |
1321 | 1323 |
1322 WASM_EXEC_COMPILED_TEST(I16x8ShrS) { | 1324 WASM_EXEC_COMPILED_TEST(I16x8ShrS) { |
1323 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); | 1325 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); |
1324 } | 1326 } |
1325 | 1327 |
1326 WASM_EXEC_COMPILED_TEST(I16x8ShrU) { | 1328 WASM_EXEC_COMPILED_TEST(I16x8ShrU) { |
1327 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); | 1329 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); |
1328 } | 1330 } |
1329 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1331 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
1330 | 1332 |
1331 #if V8_TARGET_ARCH_ARM | 1333 #if V8_TARGET_ARCH_ARM |
1332 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { | 1334 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { |
1333 FLAG_wasm_simd_prototype = true; | 1335 FLAG_wasm_simd_prototype = true; |
1334 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1336 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1335 byte a = 0; | 1337 byte a = 0; |
1336 byte expected = 1; | 1338 byte expected = 1; |
1337 byte simd = r.AllocateLocal(kWasmS128); | 1339 byte simd = r.AllocateLocal(kWasmS128); |
1338 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), | 1340 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), |
1339 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 1341 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 WASM_SIMD_I32x4_EXTRACT_LANE( | 2209 WASM_SIMD_I32x4_EXTRACT_LANE( |
2208 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 2210 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
2209 | 2211 |
2210 FOR_INT32_INPUTS(i) { | 2212 FOR_INT32_INPUTS(i) { |
2211 int32_t expected = *i; | 2213 int32_t expected = *i; |
2212 r.module().WriteMemory(&memory[0], expected); | 2214 r.module().WriteMemory(&memory[0], expected); |
2213 CHECK_EQ(expected, r.Call()); | 2215 CHECK_EQ(expected, r.Call()); |
2214 } | 2216 } |
2215 } | 2217 } |
2216 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 2218 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
OLD | NEW |