| 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 WASM_SIMD_CHECK_F32x4(simd, new_val, new_val, new_val, old_val), | 443 WASM_SIMD_CHECK_F32x4(simd, new_val, new_val, new_val, old_val), |
| 444 WASM_SET_LOCAL(simd, | 444 WASM_SET_LOCAL(simd, |
| 445 WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), | 445 WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), |
| 446 WASM_GET_LOCAL(new_val))), | 446 WASM_GET_LOCAL(new_val))), |
| 447 WASM_SIMD_CHECK_SPLAT_F32x4(simd, new_val), WASM_RETURN1(WASM_ONE)); | 447 WASM_SIMD_CHECK_SPLAT_F32x4(simd, new_val), WASM_RETURN1(WASM_ONE)); |
| 448 | 448 |
| 449 CHECK_EQ(1, r.Call(3.14159f, -1.5f)); | 449 CHECK_EQ(1, r.Call(3.14159f, -1.5f)); |
| 450 } | 450 } |
| 451 | 451 |
| 452 // Tests both signed and unsigned conversion. | 452 // Tests both signed and unsigned conversion. |
| 453 WASM_EXEC_COMPILED_TEST(F32x4FromInt32x4) { | 453 WASM_EXEC_COMPILED_TEST(F32x4ConvertI32x4) { |
| 454 FLAG_wasm_simd_prototype = true; | 454 FLAG_wasm_simd_prototype = true; |
| 455 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled); | 455 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled); |
| 456 byte a = 0; | 456 byte a = 0; |
| 457 byte expected_signed = 1; | 457 byte expected_signed = 1; |
| 458 byte expected_unsigned = 2; | 458 byte expected_unsigned = 2; |
| 459 byte simd0 = r.AllocateLocal(kWasmS128); | 459 byte simd0 = r.AllocateLocal(kWasmS128); |
| 460 byte simd1 = r.AllocateLocal(kWasmS128); | 460 byte simd1 = r.AllocateLocal(kWasmS128); |
| 461 byte simd2 = r.AllocateLocal(kWasmS128); | 461 byte simd2 = r.AllocateLocal(kWasmS128); |
| 462 BUILD( | 462 BUILD( |
| 463 r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 463 r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 int32_t result = | 884 int32_t result = |
| 885 unsigned_integer ? static_cast<uint32_t>(val) : static_cast<int32_t>(val); | 885 unsigned_integer ? static_cast<uint32_t>(val) : static_cast<int32_t>(val); |
| 886 | 886 |
| 887 if (!CanRoundToZeroAndConvert(val, unsigned_integer)) { | 887 if (!CanRoundToZeroAndConvert(val, unsigned_integer)) { |
| 888 result = ConvertInvalidValue(val, unsigned_integer); | 888 result = ConvertInvalidValue(val, unsigned_integer); |
| 889 } | 889 } |
| 890 return result; | 890 return result; |
| 891 } | 891 } |
| 892 | 892 |
| 893 // Tests both signed and unsigned conversion. | 893 // Tests both signed and unsigned conversion. |
| 894 WASM_EXEC_COMPILED_TEST(I32x4FromFloat32x4) { | 894 WASM_EXEC_COMPILED_TEST(I32x4Convert32x4) { |
| 895 FLAG_wasm_simd_prototype = true; | 895 FLAG_wasm_simd_prototype = true; |
| 896 WasmRunner<int32_t, float, int32_t, int32_t> r(kExecuteCompiled); | 896 WasmRunner<int32_t, float, int32_t, int32_t> r(kExecuteCompiled); |
| 897 byte a = 0; | 897 byte a = 0; |
| 898 byte expected_signed = 1; | 898 byte expected_signed = 1; |
| 899 byte expected_unsigned = 2; | 899 byte expected_unsigned = 2; |
| 900 byte simd0 = r.AllocateLocal(kWasmS128); | 900 byte simd0 = r.AllocateLocal(kWasmS128); |
| 901 byte simd1 = r.AllocateLocal(kWasmS128); | 901 byte simd1 = r.AllocateLocal(kWasmS128); |
| 902 byte simd2 = r.AllocateLocal(kWasmS128); | 902 byte simd2 = r.AllocateLocal(kWasmS128); |
| 903 BUILD( | 903 BUILD( |
| 904 r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 904 r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1855 WASM_SIMD_I32x4_EXTRACT_LANE( | 1855 WASM_SIMD_I32x4_EXTRACT_LANE( |
| 1856 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 1856 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
| 1857 | 1857 |
| 1858 FOR_INT32_INPUTS(i) { | 1858 FOR_INT32_INPUTS(i) { |
| 1859 int32_t expected = *i; | 1859 int32_t expected = *i; |
| 1860 r.module().WriteMemory(&memory[0], expected); | 1860 r.module().WriteMemory(&memory[0], expected); |
| 1861 CHECK_EQ(expected, r.Call()); | 1861 CHECK_EQ(expected, r.Call()); |
| 1862 } | 1862 } |
| 1863 } | 1863 } |
| 1864 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 1864 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| OLD | NEW |