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 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1703 WASM_EXEC_COMPILED_TEST(S32x4TransposeRight) { | 1703 WASM_EXEC_COMPILED_TEST(S32x4TransposeRight) { |
1704 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 5, 3, 7}}); | 1704 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 5, 3, 7}}); |
1705 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 1, 3, 3}}); | 1705 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 1, 3, 3}}); |
1706 } | 1706 } |
1707 | 1707 |
1708 // Reverses are only unary. | 1708 // Reverses are only unary. |
1709 WASM_EXEC_COMPILED_TEST(S32x2Reverse) { | 1709 WASM_EXEC_COMPILED_TEST(S32x2Reverse) { |
1710 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 0, 3, 2}}); | 1710 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 0, 3, 2}}); |
1711 } | 1711 } |
1712 | 1712 |
| 1713 // Test irregular shuffle. |
| 1714 WASM_EXEC_COMPILED_TEST(S32x4Irregular) { |
| 1715 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 4, 4, 5}}); |
| 1716 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 0, 0, 1}}); |
| 1717 } |
| 1718 |
1713 WASM_EXEC_COMPILED_TEST(S16x8ZipLeft) { | 1719 WASM_EXEC_COMPILED_TEST(S16x8ZipLeft) { |
1714 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 8, 1, 9, 2, 10, 3, 11}}); | 1720 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 8, 1, 9, 2, 10, 3, 11}}); |
1715 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3}}); | 1721 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3}}); |
1716 } | 1722 } |
1717 | 1723 |
1718 WASM_EXEC_COMPILED_TEST(S16x8ZipRight) { | 1724 WASM_EXEC_COMPILED_TEST(S16x8ZipRight) { |
1719 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, | 1725 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, |
1720 {{4, 12, 5, 13, 6, 14, 7, 15}}); | 1726 {{4, 12, 5, 13, 6, 14, 7, 15}}); |
1721 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{4, 4, 5, 5, 6, 6, 7, 7}}); | 1727 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{4, 4, 5, 5, 6, 6, 7, 7}}); |
1722 } | 1728 } |
(...skipping 23 matching lines...) Expand all Loading... |
1746 } | 1752 } |
1747 | 1753 |
1748 WASM_EXEC_COMPILED_TEST(S16x4Reverse) { | 1754 WASM_EXEC_COMPILED_TEST(S16x4Reverse) { |
1749 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4}}); | 1755 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4}}); |
1750 } | 1756 } |
1751 | 1757 |
1752 WASM_EXEC_COMPILED_TEST(S16x2Reverse) { | 1758 WASM_EXEC_COMPILED_TEST(S16x2Reverse) { |
1753 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6}}); | 1759 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6}}); |
1754 } | 1760 } |
1755 | 1761 |
| 1762 WASM_EXEC_COMPILED_TEST(S16x8Irregular) { |
| 1763 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 8, 8, 0, 2, 10, 3, 11}}); |
| 1764 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 0, 0, 2, 2, 3, 3}}); |
| 1765 } |
| 1766 |
1756 WASM_EXEC_COMPILED_TEST(S8x16ZipLeft) { | 1767 WASM_EXEC_COMPILED_TEST(S8x16ZipLeft) { |
1757 RunBinaryLaneOpTest<int8_t>( | 1768 RunBinaryLaneOpTest<int8_t>( |
1758 kExprS8x16Shuffle, | 1769 kExprS8x16Shuffle, |
1759 {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); | 1770 {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); |
1760 RunBinaryLaneOpTest<int8_t>( | 1771 RunBinaryLaneOpTest<int8_t>( |
1761 kExprS8x16Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); | 1772 kExprS8x16Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); |
1762 } | 1773 } |
1763 | 1774 |
1764 WASM_EXEC_COMPILED_TEST(S8x16ZipRight) { | 1775 WASM_EXEC_COMPILED_TEST(S8x16ZipRight) { |
1765 RunBinaryLaneOpTest<int8_t>( | 1776 RunBinaryLaneOpTest<int8_t>( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 WASM_EXEC_COMPILED_TEST(S8x4Reverse) { | 1821 WASM_EXEC_COMPILED_TEST(S8x4Reverse) { |
1811 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4, 11, | 1822 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4, 11, |
1812 10, 9, 8, 15, 14, 13, 12}}); | 1823 10, 9, 8, 15, 14, 13, 12}}); |
1813 } | 1824 } |
1814 | 1825 |
1815 WASM_EXEC_COMPILED_TEST(S8x2Reverse) { | 1826 WASM_EXEC_COMPILED_TEST(S8x2Reverse) { |
1816 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, | 1827 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, |
1817 11, 10, 13, 12, 15, 14}}); | 1828 11, 10, 13, 12, 15, 14}}); |
1818 } | 1829 } |
1819 | 1830 |
| 1831 WASM_EXEC_COMPILED_TEST(S8x16Irregular) { |
| 1832 RunBinaryLaneOpTest<int8_t>( |
| 1833 kExprS8x16Shuffle, |
| 1834 {{0, 16, 0, 16, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); |
| 1835 RunBinaryLaneOpTest<int8_t>( |
| 1836 kExprS8x16Shuffle, {{0, 0, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); |
| 1837 } |
| 1838 |
1820 // Test shuffles that concatenate the two vectors. | 1839 // Test shuffles that concatenate the two vectors. |
1821 template <typename T> | 1840 template <typename T> |
1822 void RunConcatOpTest(WasmOpcode simd_op) { | 1841 void RunConcatOpTest(WasmOpcode simd_op) { |
1823 static const int kLanes = kSimd128Size / sizeof(T); | 1842 static const int kLanes = kSimd128Size / sizeof(T); |
1824 std::array<T, kLanes> expected; | 1843 std::array<T, kLanes> expected; |
1825 for (int bias = 1; bias < kLanes; bias++) { | 1844 for (int bias = 1; bias < kLanes; bias++) { |
1826 int i = 0; | 1845 int i = 0; |
1827 // last kLanes - bias bytes of first vector. | 1846 // last kLanes - bias bytes of first vector. |
1828 for (int j = bias; j < kLanes; j++) { | 1847 for (int j = bias; j < kLanes; j++) { |
1829 expected[i++] = j; | 1848 expected[i++] = j; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 WASM_SIMD_I32x4_EXTRACT_LANE( | 2297 WASM_SIMD_I32x4_EXTRACT_LANE( |
2279 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 2298 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
2280 | 2299 |
2281 FOR_INT32_INPUTS(i) { | 2300 FOR_INT32_INPUTS(i) { |
2282 int32_t expected = *i; | 2301 int32_t expected = *i; |
2283 r.module().WriteMemory(&memory[0], expected); | 2302 r.module().WriteMemory(&memory[0], expected); |
2284 CHECK_EQ(expected, r.Call()); | 2303 CHECK_EQ(expected, r.Call()); |
2285 } | 2304 } |
2286 } | 2305 } |
2287 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 | 2306 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 |
OLD | NEW |