| 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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 WASM_SET_LOCAL(simd, | 734 WASM_SET_LOCAL(simd, |
| 735 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), | 735 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), |
| 736 WASM_GET_LOCAL(new_val))), | 736 WASM_GET_LOCAL(new_val))), |
| 737 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); | 737 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); |
| 738 | 738 |
| 739 CHECK_EQ(1, r.Call(1, 2)); | 739 CHECK_EQ(1, r.Call(1, 2)); |
| 740 } | 740 } |
| 741 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || | 741 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || |
| 742 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 742 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
| 743 | 743 |
| 744 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 744 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
| 745 WASM_EXEC_COMPILED_TEST(I8x16Splat) { | 745 WASM_EXEC_COMPILED_TEST(I8x16Splat) { |
| 746 FLAG_wasm_simd_prototype = true; | 746 FLAG_wasm_simd_prototype = true; |
| 747 | 747 |
| 748 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 748 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
| 749 byte lane_val = 0; | 749 byte lane_val = 0; |
| 750 byte simd = r.AllocateLocal(kWasmS128); | 750 byte simd = r.AllocateLocal(kWasmS128); |
| 751 BUILD(r, | 751 BUILD(r, |
| 752 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), | 752 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), |
| 753 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); | 753 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); |
| 754 | 754 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, | 852 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, |
| 853 new_val, new_val, new_val, new_val, new_val, new_val, | 853 new_val, new_val, new_val, new_val, new_val, new_val, |
| 854 new_val, new_val, new_val, new_val, new_val, old_val), | 854 new_val, new_val, new_val, new_val, new_val, old_val), |
| 855 WASM_SET_LOCAL(simd, | 855 WASM_SET_LOCAL(simd, |
| 856 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), | 856 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), |
| 857 WASM_GET_LOCAL(new_val))), | 857 WASM_GET_LOCAL(new_val))), |
| 858 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); | 858 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); |
| 859 | 859 |
| 860 CHECK_EQ(1, r.Call(1, 2)); | 860 CHECK_EQ(1, r.Call(1, 2)); |
| 861 } | 861 } |
| 862 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 862 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
| 863 | 863 |
| 864 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ | 864 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 865 V8_TARGET_ARCH_MIPS64 | 865 V8_TARGET_ARCH_MIPS64 |
| 866 // Determines if conversion from float to int will be valid. | 866 // Determines if conversion from float to int will be valid. |
| 867 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { | 867 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { |
| 868 const double max_uint = static_cast<double>(0xffffffffu); | 868 const double max_uint = static_cast<double>(0xffffffffu); |
| 869 const double max_int = static_cast<double>(kMaxInt); | 869 const double max_int = static_cast<double>(kMaxInt); |
| 870 const double min_int = static_cast<double>(kMinInt); | 870 const double min_int = static_cast<double>(kMinInt); |
| 871 | 871 |
| 872 // Check for NaN. | 872 // Check for NaN. |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 WASM_EXEC_COMPILED_TEST(I16x8ShrS) { | 1355 WASM_EXEC_COMPILED_TEST(I16x8ShrS) { |
| 1356 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); | 1356 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 WASM_EXEC_COMPILED_TEST(I16x8ShrU) { | 1359 WASM_EXEC_COMPILED_TEST(I16x8ShrU) { |
| 1360 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); | 1360 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); |
| 1361 } | 1361 } |
| 1362 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || | 1362 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || |
| 1363 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 1363 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
| 1364 | 1364 |
| 1365 #if V8_TARGET_ARCH_ARM | 1365 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| 1366 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { | 1366 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { |
| 1367 FLAG_wasm_simd_prototype = true; | 1367 FLAG_wasm_simd_prototype = true; |
| 1368 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1368 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
| 1369 byte a = 0; | 1369 byte a = 0; |
| 1370 byte expected = 1; | 1370 byte expected = 1; |
| 1371 byte simd = r.AllocateLocal(kWasmS128); | 1371 byte simd = r.AllocateLocal(kWasmS128); |
| 1372 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), | 1372 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), |
| 1373 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 1373 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
| 1374 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); | 1374 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); |
| 1375 | 1375 |
| 1376 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } | 1376 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 WASM_EXEC_COMPILED_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); } | 1379 WASM_EXEC_COMPILED_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); } |
| 1380 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| 1380 | 1381 |
| 1382 #if V8_TARGET_ARCH_ARM |
| 1381 // Tests both signed and unsigned conversion from I16x8 (packing). | 1383 // Tests both signed and unsigned conversion from I16x8 (packing). |
| 1382 WASM_EXEC_COMPILED_TEST(I8x16ConvertI16x8) { | 1384 WASM_EXEC_COMPILED_TEST(I8x16ConvertI16x8) { |
| 1383 FLAG_wasm_simd_prototype = true; | 1385 FLAG_wasm_simd_prototype = true; |
| 1384 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1386 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
| 1385 byte a = 0; | 1387 byte a = 0; |
| 1386 byte packed_signed = 1; | 1388 byte packed_signed = 1; |
| 1387 byte packed_unsigned = 2; | 1389 byte packed_unsigned = 2; |
| 1388 byte simd0 = r.AllocateLocal(kWasmS128); | 1390 byte simd0 = r.AllocateLocal(kWasmS128); |
| 1389 byte simd1 = r.AllocateLocal(kWasmS128); | 1391 byte simd1 = r.AllocateLocal(kWasmS128); |
| 1390 byte simd2 = r.AllocateLocal(kWasmS128); | 1392 byte simd2 = r.AllocateLocal(kWasmS128); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1401 FOR_INT16_INPUTS(i) { | 1403 FOR_INT16_INPUTS(i) { |
| 1402 int32_t packed_signed = Narrow<int8_t>(*i); | 1404 int32_t packed_signed = Narrow<int8_t>(*i); |
| 1403 int32_t packed_unsigned = UnsignedNarrow<int8_t>(*i); | 1405 int32_t packed_unsigned = UnsignedNarrow<int8_t>(*i); |
| 1404 // Sign-extend here, since ExtractLane sign extends. | 1406 // Sign-extend here, since ExtractLane sign extends. |
| 1405 if (packed_unsigned & 0x80) packed_unsigned |= 0xffffff00; | 1407 if (packed_unsigned & 0x80) packed_unsigned |= 0xffffff00; |
| 1406 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); | 1408 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); |
| 1407 } | 1409 } |
| 1408 } | 1410 } |
| 1409 #endif // V8_TARGET_ARCH_ARM | 1411 #endif // V8_TARGET_ARCH_ARM |
| 1410 | 1412 |
| 1411 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1413 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
| 1412 void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { | 1414 void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { |
| 1413 FLAG_wasm_simd_prototype = true; | 1415 FLAG_wasm_simd_prototype = true; |
| 1414 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1416 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
| 1415 byte a = 0; | 1417 byte a = 0; |
| 1416 byte b = 1; | 1418 byte b = 1; |
| 1417 byte expected = 2; | 1419 byte expected = 2; |
| 1418 byte simd0 = r.AllocateLocal(kWasmS128); | 1420 byte simd0 = r.AllocateLocal(kWasmS128); |
| 1419 byte simd1 = r.AllocateLocal(kWasmS128); | 1421 byte simd1 = r.AllocateLocal(kWasmS128); |
| 1420 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), | 1422 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), |
| 1421 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), | 1423 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 FOR_INT8_INPUTS(i) { | 1485 FOR_INT8_INPUTS(i) { |
| 1484 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 1486 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
| 1485 } | 1487 } |
| 1486 } | 1488 } |
| 1487 | 1489 |
| 1488 WASM_EXEC_COMPILED_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } | 1490 WASM_EXEC_COMPILED_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } |
| 1489 | 1491 |
| 1490 WASM_EXEC_COMPILED_TEST(I8x16Ne) { | 1492 WASM_EXEC_COMPILED_TEST(I8x16Ne) { |
| 1491 RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); | 1493 RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); |
| 1492 } | 1494 } |
| 1493 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1495 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
| 1494 | 1496 |
| 1495 #if V8_TARGET_ARCH_ARM | 1497 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| 1496 WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } | 1498 WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } |
| 1497 | 1499 |
| 1498 WASM_EXEC_COMPILED_TEST(I8x16GtS) { | 1500 WASM_EXEC_COMPILED_TEST(I8x16GtS) { |
| 1499 RunI8x16CompareOpTest(kExprI8x16GtS, Greater); | 1501 RunI8x16CompareOpTest(kExprI8x16GtS, Greater); |
| 1500 } | 1502 } |
| 1501 | 1503 |
| 1502 WASM_EXEC_COMPILED_TEST(I8x16GeS) { | 1504 WASM_EXEC_COMPILED_TEST(I8x16GeS) { |
| 1503 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); | 1505 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); |
| 1504 } | 1506 } |
| 1505 | 1507 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1); | 1548 RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1); |
| 1547 } | 1549 } |
| 1548 | 1550 |
| 1549 WASM_EXEC_COMPILED_TEST(I8x16ShrS) { | 1551 WASM_EXEC_COMPILED_TEST(I8x16ShrS) { |
| 1550 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1); | 1552 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1); |
| 1551 } | 1553 } |
| 1552 | 1554 |
| 1553 WASM_EXEC_COMPILED_TEST(I8x16ShrU) { | 1555 WASM_EXEC_COMPILED_TEST(I8x16ShrU) { |
| 1554 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); | 1556 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); |
| 1555 } | 1557 } |
| 1556 #endif // V8_TARGET_ARCH_ARM | 1558 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| 1557 | 1559 |
| 1558 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || \ | 1560 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || \ |
| 1559 V8_TARGET_ARCH_MIPS64 | 1561 V8_TARGET_ARCH_MIPS64 |
| 1560 // Test Select by making a mask where the first two lanes are true and the rest | 1562 // Test Select by making a mask where the first two lanes are true and the rest |
| 1561 // false, and comparing for non-equality with zero to materialize a bool vector. | 1563 // false, and comparing for non-equality with zero to materialize a bool vector. |
| 1562 #define WASM_SIMD_SELECT_TEST(format) \ | 1564 #define WASM_SIMD_SELECT_TEST(format) \ |
| 1563 WASM_EXEC_COMPILED_TEST(S##format##Select) { \ | 1565 WASM_EXEC_COMPILED_TEST(S##format##Select) { \ |
| 1564 FLAG_wasm_simd_prototype = true; \ | 1566 FLAG_wasm_simd_prototype = true; \ |
| 1565 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ | 1567 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ |
| 1566 byte val1 = 0; \ | 1568 byte val1 = 0; \ |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 WASM_SIMD_I32x4_EXTRACT_LANE( | 2280 WASM_SIMD_I32x4_EXTRACT_LANE( |
| 2279 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 2281 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
| 2280 | 2282 |
| 2281 FOR_INT32_INPUTS(i) { | 2283 FOR_INT32_INPUTS(i) { |
| 2282 int32_t expected = *i; | 2284 int32_t expected = *i; |
| 2283 r.module().WriteMemory(&memory[0], expected); | 2285 r.module().WriteMemory(&memory[0], expected); |
| 2284 CHECK_EQ(expected, r.Call()); | 2286 CHECK_EQ(expected, r.Call()); |
| 2285 } | 2287 } |
| 2286 } | 2288 } |
| 2287 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 | 2289 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 |
| OLD | NEW |