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 |
| 7 #include "test/cctest/cctest.h" |
| 8 #include "test/cctest/compiler/value-helper.h" |
| 9 #include "test/cctest/wasm/wasm-run-utils.h" |
| 10 |
| 11 using namespace v8::base; |
| 12 using namespace v8::internal; |
| 13 using namespace v8::internal::compiler; |
| 14 using namespace v8::internal::wasm; |
| 15 |
| 16 WASM_EXEC_TEST(Splat) { |
| 17 FLAG_wasm_simd_prototype = true; |
| 18 |
| 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 |
| 21 // interesting SIMD values. |
| 22 // |
| 23 // SetLocal(1, I32x4Splat(Local(0))); |
| 24 // For each lane index |
| 25 // if(Local(0) != I32x4ExtractLane(Local(1), index) |
| 26 // return 0 |
| 27 // |
| 28 // return 1 |
| 29 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| 30 r.AllocateLocal(kAstS128); |
| 31 BUILD(r, |
| 32 WASM_BLOCK(WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), |
| 33 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| 34 WASM_SIMD_I32x4_EXTRACT_LANE( |
| 35 WASM_GET_LOCAL(1), WASM_I8(0))), |
| 36 WASM_RETURN1(WASM_ZERO)), |
| 37 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| 38 WASM_SIMD_I32x4_EXTRACT_LANE( |
| 39 WASM_GET_LOCAL(1), WASM_I8(1))), |
| 40 WASM_RETURN1(WASM_ZERO)), |
| 41 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| 42 WASM_SIMD_I32x4_EXTRACT_LANE( |
| 43 WASM_GET_LOCAL(1), WASM_I8(2))), |
| 44 WASM_RETURN1(WASM_ZERO)), |
| 45 WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| 46 WASM_SIMD_I32x4_EXTRACT_LANE( |
| 47 WASM_GET_LOCAL(1), WASM_I8(3))), |
| 48 WASM_RETURN1(WASM_ZERO)), |
| 49 WASM_RETURN1(WASM_ONE))); |
| 50 |
| 51 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } |
| 52 } |
OLD | NEW |