OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/wasm/wasm-macro-gen.h" |
| 6 #include "src/wasm/wasm-module.h" |
| 7 |
| 8 #include "test/cctest/cctest.h" |
| 9 #include "test/cctest/compiler/value-helper.h" |
| 10 #include "test/cctest/wasm/wasm-run-utils.h" |
| 11 #include "test/common/wasm/test-signatures.h" |
| 12 |
| 13 using namespace v8::base; |
| 14 using namespace v8::internal; |
| 15 using namespace v8::internal::compiler; |
| 16 using namespace v8::internal::wasm; |
| 17 |
| 18 WASM_EXEC_TEST(Simd_I32x4_Splat) { |
| 19 FLAG_wasm_simd_prototype = true; |
| 20 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 21 BUILD(r, |
| 22 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)))); |
| 23 FOR_INT32_INPUTS(i) { CHECK_EQ(5, r.Call()); } |
| 24 } |
| 25 |
| 26 WASM_EXEC_TEST(Simd_I32x4_Add) { |
| 27 FLAG_wasm_simd_prototype = true; |
| 28 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 29 BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE( |
| 30 0, WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)), |
| 31 WASM_SIMD_I32x4_SPLAT(WASM_I32V(6))))); |
| 32 FOR_INT32_INPUTS(i) { CHECK_EQ(11, r.Call()); } |
| 33 } |
| 34 |
| 35 WASM_EXEC_TEST(Simd_F32x4_Splat) { |
| 36 FLAG_wasm_simd_prototype = true; |
| 37 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 38 BUILD(r, |
| 39 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( |
| 40 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5))), |
| 41 WASM_F32(9.5)), |
| 42 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); |
| 43 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
| 44 } |
| 45 |
| 46 WASM_EXEC_TEST(Simd_I32x4_Extract_With_F32x4) { |
| 47 FLAG_wasm_simd_prototype = true; |
| 48 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 49 BUILD(r, |
| 50 WASM_IF_ELSE(WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( |
| 51 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))), |
| 52 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))), |
| 53 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); |
| 54 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
| 55 } |
| 56 |
| 57 WASM_EXEC_TEST(Simd_F32x4_Extract_With_I32x4) { |
| 58 FLAG_wasm_simd_prototype = true; |
| 59 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 60 BUILD(r, |
| 61 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( |
| 62 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))), |
| 63 WASM_F32_REINTERPRET_I32(WASM_I32V(15))), |
| 64 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); |
| 65 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
| 66 } |
| 67 |
| 68 WASM_EXEC_TEST(Simd_F32x4_Add_With_I32x4) { |
| 69 FLAG_wasm_simd_prototype = true; |
| 70 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 71 BUILD(r, |
| 72 WASM_IF_ELSE( |
| 73 WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( |
| 74 0, WASM_SIMD_F32x4_ADD( |
| 75 WASM_SIMD_I32x4_SPLAT(WASM_I32V(32)), |
| 76 WASM_SIMD_I32x4_SPLAT(WASM_I32V(19)))), |
| 77 WASM_F32_ADD(WASM_F32_REINTERPRET_I32(WASM_I32V(32)), |
| 78 WASM_F32_REINTERPRET_I32(WASM_I32V(19)))), |
| 79 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); |
| 80 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
| 81 } |
| 82 |
| 83 WASM_EXEC_TEST(Simd_I32x4_Add_With_F32x4) { |
| 84 FLAG_wasm_simd_prototype = true; |
| 85 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 86 BUILD(r, |
| 87 WASM_IF_ELSE( |
| 88 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( |
| 89 0, WASM_SIMD_I32x4_ADD( |
| 90 WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25)), |
| 91 WASM_SIMD_F32x4_SPLAT(WASM_F32(31.5)))), |
| 92 WASM_I32_ADD(WASM_I32_REINTERPRET_F32(WASM_F32(21.25)), |
| 93 WASM_I32_REINTERPRET_F32(WASM_F32(31.5)))), |
| 94 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); |
| 95 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
| 96 } |
OLD | NEW |