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/wasm/wasm-macro-gen.h" | 5 #include "src/wasm/wasm-macro-gen.h" |
6 | 6 |
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 |
11 using namespace v8::base; | 11 using namespace v8::base; |
12 using namespace v8::internal; | 12 using namespace v8::internal; |
13 using namespace v8::internal::compiler; | 13 using namespace v8::internal::compiler; |
14 using namespace v8::internal::wasm; | 14 using namespace v8::internal::wasm; |
15 | 15 |
16 WASM_EXEC_TEST(Splat) { | 16 WASM_EXEC_TEST(Splat) { |
17 FLAG_wasm_simd_prototype = true; | 17 FLAG_wasm_simd_prototype = true; |
18 | 18 |
19 // Store SIMD value in a local variable, use extract lane to check lane values | 19 // Store SIMD value in a local variable, use extract lane to check lane values |
20 // This test is not a test for ExtractLane as Splat does not create | 20 // This test is not a test for ExtractLane as Splat does not create |
21 // interesting SIMD values. | 21 // interesting SIMD values. |
22 // | 22 // |
23 // SetLocal(1, I32x4Splat(Local(0))); | 23 // SetLocal(1, I32x4Splat(Local(0))); |
24 // For each lane index | 24 // For each lane index |
25 // if(Local(0) != I32x4ExtractLane(Local(1), index) | 25 // if(Local(0) != I32x4ExtractLane(Local(1), index) |
26 // return 0 | 26 // return 0 |
27 // | 27 // |
28 // return 1 | 28 // return 1 |
29 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); | 29 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
30 r.AllocateLocal(kAstS128); | 30 r.AllocateLocal(kAstS128); |
31 BUILD(r, | 31 BUILD(r, |
32 WASM_BLOCK( | 32 WASM_BLOCK( |
33 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), | 33 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), |
34 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( | 34 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( |
35 0, WASM_GET_LOCAL(1))), | 35 0, WASM_GET_LOCAL(1))), |
36 WASM_RETURN1(WASM_ZERO)), | 36 WASM_RETURN1(WASM_ZERO)), |
37 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( | 37 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( |
38 1, WASM_GET_LOCAL(1))), | 38 1, WASM_GET_LOCAL(1))), |
39 WASM_RETURN1(WASM_ZERO)), | 39 WASM_RETURN1(WASM_ZERO)), |
40 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( | 40 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( |
41 2, WASM_GET_LOCAL(1))), | 41 2, WASM_GET_LOCAL(1))), |
42 WASM_RETURN1(WASM_ZERO)), | 42 WASM_RETURN1(WASM_ZERO)), |
43 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( | 43 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), WASM_SIMD_I32x4_EXTRACT_LANE( |
44 3, WASM_GET_LOCAL(1))), | 44 3, WASM_GET_LOCAL(1))), |
45 WASM_RETURN1(WASM_ZERO)), | 45 WASM_RETURN1(WASM_ZERO)), |
46 WASM_RETURN1(WASM_ONE))); | 46 WASM_RETURN1(WASM_ONE))); |
47 | 47 |
48 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } | 48 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } |
49 } | 49 } |
OLD | NEW |