| 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 "src/wasm/wasm-macro-gen.h" | 6 #include "src/wasm/wasm-macro-gen.h" |
| 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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 WASM_GET_LOCAL(new_val))), | 742 WASM_GET_LOCAL(new_val))), |
| 743 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, | 743 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, |
| 744 new_val, new_val, new_val, old_val), | 744 new_val, new_val, new_val, old_val), |
| 745 WASM_SET_LOCAL(simd, | 745 WASM_SET_LOCAL(simd, |
| 746 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), | 746 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), |
| 747 WASM_GET_LOCAL(new_val))), | 747 WASM_GET_LOCAL(new_val))), |
| 748 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); | 748 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); |
| 749 | 749 |
| 750 CHECK_EQ(1, r.Call(1, 2)); | 750 CHECK_EQ(1, r.Call(1, 2)); |
| 751 } | 751 } |
| 752 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | |
| 753 | 752 |
| 754 #if V8_TARGET_ARCH_ARM | |
| 755 WASM_EXEC_COMPILED_TEST(I8x16Splat) { | 753 WASM_EXEC_COMPILED_TEST(I8x16Splat) { |
| 756 FLAG_wasm_simd_prototype = true; | 754 FLAG_wasm_simd_prototype = true; |
| 757 | 755 |
| 758 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 756 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
| 759 byte lane_val = 0; | 757 byte lane_val = 0; |
| 760 byte simd = r.AllocateLocal(kWasmS128); | 758 byte simd = r.AllocateLocal(kWasmS128); |
| 761 BUILD(r, | 759 BUILD(r, |
| 762 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), | 760 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), |
| 763 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); | 761 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); |
| 764 | 762 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, | 860 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, |
| 863 new_val, new_val, new_val, new_val, new_val, new_val, | 861 new_val, new_val, new_val, new_val, new_val, new_val, |
| 864 new_val, new_val, new_val, new_val, new_val, old_val), | 862 new_val, new_val, new_val, new_val, new_val, old_val), |
| 865 WASM_SET_LOCAL(simd, | 863 WASM_SET_LOCAL(simd, |
| 866 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), | 864 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), |
| 867 WASM_GET_LOCAL(new_val))), | 865 WASM_GET_LOCAL(new_val))), |
| 868 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); | 866 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); |
| 869 | 867 |
| 870 CHECK_EQ(1, r.Call(1, 2)); | 868 CHECK_EQ(1, r.Call(1, 2)); |
| 871 } | 869 } |
| 872 #endif // V8_TARGET_ARCH_ARM | 870 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
| 873 | 871 |
| 874 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ | 872 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 875 V8_TARGET_ARCH_MIPS64 | 873 V8_TARGET_ARCH_MIPS64 |
| 876 // Determines if conversion from float to int will be valid. | 874 // Determines if conversion from float to int will be valid. |
| 877 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { | 875 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { |
| 878 const double max_uint = static_cast<double>(0xffffffffu); | 876 const double max_uint = static_cast<double>(0xffffffffu); |
| 879 const double max_int = static_cast<double>(kMaxInt); | 877 const double max_int = static_cast<double>(kMaxInt); |
| 880 const double min_int = static_cast<double>(kMinInt); | 878 const double min_int = static_cast<double>(kMinInt); |
| 881 | 879 |
| 882 // Check for NaN. | 880 // Check for NaN. |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 WASM_SIMD_CHECK_SPLAT16(I8x16, simd2, I32, packed_unsigned), WASM_ONE); | 1391 WASM_SIMD_CHECK_SPLAT16(I8x16, simd2, I32, packed_unsigned), WASM_ONE); |
| 1394 | 1392 |
| 1395 FOR_INT16_INPUTS(i) { | 1393 FOR_INT16_INPUTS(i) { |
| 1396 int32_t packed_signed = Narrow<int8_t>(*i); | 1394 int32_t packed_signed = Narrow<int8_t>(*i); |
| 1397 int32_t packed_unsigned = UnsignedNarrow<int8_t>(*i); | 1395 int32_t packed_unsigned = UnsignedNarrow<int8_t>(*i); |
| 1398 // Sign-extend here, since ExtractLane sign extends. | 1396 // Sign-extend here, since ExtractLane sign extends. |
| 1399 if (packed_unsigned & 0x80) packed_unsigned |= 0xffffff00; | 1397 if (packed_unsigned & 0x80) packed_unsigned |= 0xffffff00; |
| 1400 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); | 1398 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); |
| 1401 } | 1399 } |
| 1402 } | 1400 } |
| 1401 #endif // V8_TARGET_ARCH_ARM |
| 1403 | 1402 |
| 1403 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
| 1404 void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { | 1404 void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { |
| 1405 FLAG_wasm_simd_prototype = true; | 1405 FLAG_wasm_simd_prototype = true; |
| 1406 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1406 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
| 1407 byte a = 0; | 1407 byte a = 0; |
| 1408 byte b = 1; | 1408 byte b = 1; |
| 1409 byte expected = 2; | 1409 byte expected = 2; |
| 1410 byte simd0 = r.AllocateLocal(kWasmS128); | 1410 byte simd0 = r.AllocateLocal(kWasmS128); |
| 1411 byte simd1 = r.AllocateLocal(kWasmS128); | 1411 byte simd1 = r.AllocateLocal(kWasmS128); |
| 1412 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), | 1412 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), |
| 1413 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), | 1413 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1425 WASM_EXEC_COMPILED_TEST(I8x16AddSaturateS) { | 1425 WASM_EXEC_COMPILED_TEST(I8x16AddSaturateS) { |
| 1426 RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate); | 1426 RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate); |
| 1427 } | 1427 } |
| 1428 | 1428 |
| 1429 WASM_EXEC_COMPILED_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); } | 1429 WASM_EXEC_COMPILED_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); } |
| 1430 | 1430 |
| 1431 WASM_EXEC_COMPILED_TEST(I8x16SubSaturateS) { | 1431 WASM_EXEC_COMPILED_TEST(I8x16SubSaturateS) { |
| 1432 RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate); | 1432 RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } | |
| 1436 | |
| 1437 WASM_EXEC_COMPILED_TEST(I8x16MinS) { | 1435 WASM_EXEC_COMPILED_TEST(I8x16MinS) { |
| 1438 RunI8x16BinOpTest(kExprI8x16MinS, Minimum); | 1436 RunI8x16BinOpTest(kExprI8x16MinS, Minimum); |
| 1439 } | 1437 } |
| 1440 | 1438 |
| 1441 WASM_EXEC_COMPILED_TEST(I8x16MaxS) { | 1439 WASM_EXEC_COMPILED_TEST(I8x16MaxS) { |
| 1442 RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); | 1440 RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); |
| 1443 } | 1441 } |
| 1444 | 1442 |
| 1445 WASM_EXEC_COMPILED_TEST(I8x16AddSaturateU) { | 1443 WASM_EXEC_COMPILED_TEST(I8x16AddSaturateU) { |
| 1446 RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate); | 1444 RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1477 FOR_INT8_INPUTS(i) { | 1475 FOR_INT8_INPUTS(i) { |
| 1478 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 1476 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
| 1479 } | 1477 } |
| 1480 } | 1478 } |
| 1481 | 1479 |
| 1482 WASM_EXEC_COMPILED_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } | 1480 WASM_EXEC_COMPILED_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } |
| 1483 | 1481 |
| 1484 WASM_EXEC_COMPILED_TEST(I8x16Ne) { | 1482 WASM_EXEC_COMPILED_TEST(I8x16Ne) { |
| 1485 RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); | 1483 RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); |
| 1486 } | 1484 } |
| 1485 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
| 1486 |
| 1487 #if V8_TARGET_ARCH_ARM |
| 1488 WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } |
| 1487 | 1489 |
| 1488 WASM_EXEC_COMPILED_TEST(I8x16GtS) { | 1490 WASM_EXEC_COMPILED_TEST(I8x16GtS) { |
| 1489 RunI8x16CompareOpTest(kExprI8x16GtS, Greater); | 1491 RunI8x16CompareOpTest(kExprI8x16GtS, Greater); |
| 1490 } | 1492 } |
| 1491 | 1493 |
| 1492 WASM_EXEC_COMPILED_TEST(I8x16GeS) { | 1494 WASM_EXEC_COMPILED_TEST(I8x16GeS) { |
| 1493 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); | 1495 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); |
| 1494 } | 1496 } |
| 1495 | 1497 |
| 1496 WASM_EXEC_COMPILED_TEST(I8x16LtS) { | 1498 WASM_EXEC_COMPILED_TEST(I8x16LtS) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 \ | 1583 \ |
| 1582 CHECK_EQ(1, r.Call(0x12, 0x34)); \ | 1584 CHECK_EQ(1, r.Call(0x12, 0x34)); \ |
| 1583 } | 1585 } |
| 1584 | 1586 |
| 1585 WASM_SIMD_SELECT_TEST(32x4) | 1587 WASM_SIMD_SELECT_TEST(32x4) |
| 1586 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || | 1588 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || |
| 1587 // V8_TARGET_ARCH_MIPS64 | 1589 // V8_TARGET_ARCH_MIPS64 |
| 1588 | 1590 |
| 1589 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1591 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
| 1590 WASM_SIMD_SELECT_TEST(16x8) | 1592 WASM_SIMD_SELECT_TEST(16x8) |
| 1593 |
| 1594 WASM_SIMD_SELECT_TEST(8x16) |
| 1591 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1595 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
| 1592 | 1596 |
| 1593 #if V8_TARGET_ARCH_ARM | 1597 #if V8_TARGET_ARCH_ARM |
| 1594 WASM_SIMD_SELECT_TEST(8x16) | |
| 1595 | |
| 1596 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer | 1598 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer |
| 1597 // result. Use relational ops on numeric vectors to create the boolean vector | 1599 // result. Use relational ops on numeric vectors to create the boolean vector |
| 1598 // test inputs. Test inputs with all true, all false, one true, and one false. | 1600 // test inputs. Test inputs with all true, all false, one true, and one false. |
| 1599 #define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \ | 1601 #define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \ |
| 1600 WASM_EXEC_TEST(ReductionTest##lanes) { \ | 1602 WASM_EXEC_TEST(ReductionTest##lanes) { \ |
| 1601 FLAG_wasm_simd_prototype = true; \ | 1603 FLAG_wasm_simd_prototype = true; \ |
| 1602 WasmRunner<int32_t> r(kExecuteCompiled); \ | 1604 WasmRunner<int32_t> r(kExecuteCompiled); \ |
| 1603 byte zero = r.AllocateLocal(kWasmS128); \ | 1605 byte zero = r.AllocateLocal(kWasmS128); \ |
| 1604 byte one_one = r.AllocateLocal(kWasmS128); \ | 1606 byte one_one = r.AllocateLocal(kWasmS128); \ |
| 1605 byte reduced = r.AllocateLocal(kWasmI32); \ | 1607 byte reduced = r.AllocateLocal(kWasmI32); \ |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 WASM_SIMD_I32x4_EXTRACT_LANE( | 2013 WASM_SIMD_I32x4_EXTRACT_LANE( |
| 2012 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 2014 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
| 2013 | 2015 |
| 2014 FOR_INT32_INPUTS(i) { | 2016 FOR_INT32_INPUTS(i) { |
| 2015 int32_t expected = *i; | 2017 int32_t expected = *i; |
| 2016 r.module().WriteMemory(&memory[0], expected); | 2018 r.module().WriteMemory(&memory[0], expected); |
| 2017 CHECK_EQ(expected, r.Call()); | 2019 CHECK_EQ(expected, r.Call()); |
| 2018 } | 2020 } |
| 2019 } | 2021 } |
| 2020 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 2022 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| OLD | NEW |