Chromium Code Reviews| Index: test/cctest/wasm/test-run-wasm-simd.cc |
| diff --git a/test/cctest/wasm/test-run-wasm-simd.cc b/test/cctest/wasm/test-run-wasm-simd.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5406cd0d0d0d5d760c44e966034a43623dd3752b |
| --- /dev/null |
| +++ b/test/cctest/wasm/test-run-wasm-simd.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "src/wasm/wasm-macro-gen.h" |
| + |
| +#include "test/cctest/cctest.h" |
| +#include "test/cctest/compiler/value-helper.h" |
| +#include "test/cctest/wasm/wasm-run-utils.h" |
| + |
| +using namespace v8::base; |
| +using namespace v8::internal; |
| +using namespace v8::internal::compiler; |
| +using namespace v8::internal::wasm; |
| + |
| +// Store SIMD value in a local variable, use extract lane to check lane values |
| +// |
| +// SetLocal(1, I32x4Splat(Local(0))); |
| +// For each lane index |
| +// if(Local(0) != I32x4ExtractLane(Local(1), index) |
| +// return 0 |
| +// |
| +// return 1 |
| + |
| +WASM_EXEC_TEST(SplatExtract) { |
| + FLAG_wasm_simd_prototype = true; |
| + |
| + WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32()); |
| + r.AllocateLocal(kAstS128); |
| + BUILD(r, |
| + WASM_BLOCK(WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), |
|
bbudge
2016/08/22 19:09:52
Using splat, it's not really possible to write a g
gdeepti
2016/08/22 23:26:11
Agree that it is not possible to have a good test
bbudge
2016/08/23 13:57:13
If it's not too hard, implementing ReplaceLane wou
gdeepti
2016/08/23 19:53:34
Did not think of replace lane, I'll add replace la
|
| + WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| + WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_GET_LOCAL(1), WASM_I8(0))), |
| + WASM_RETURN1(WASM_ZERO)), |
| + WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| + WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_GET_LOCAL(1), WASM_I8(1))), |
| + WASM_RETURN1(WASM_ZERO)), |
| + WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| + WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_GET_LOCAL(1), WASM_I8(2))), |
| + WASM_RETURN1(WASM_ZERO)), |
| + WASM_IF(WASM_I32_NE(WASM_GET_LOCAL(0), |
| + WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_GET_LOCAL(1), WASM_I8(3))), |
| + WASM_RETURN1(WASM_ZERO)), |
| + WASM_RETURN1(WASM_ONE))); |
| + |
| + FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } |
| +} |