Chromium Code Reviews| Index: test/cctest/wasm/test-run-wasm-simd-lowering.cc |
| diff --git a/test/cctest/wasm/test-run-wasm-simd-lowering.cc b/test/cctest/wasm/test-run-wasm-simd-lowering.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1db3c6b322fdb1a721a1a1cd8c948efb31b30dda |
| --- /dev/null |
| +++ b/test/cctest/wasm/test-run-wasm-simd-lowering.cc |
| @@ -0,0 +1,110 @@ |
| +// 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 "src/wasm/wasm-module.h" |
| + |
| +#include "test/cctest/cctest.h" |
| +#include "test/cctest/wasm/test-run-wasm-module-helper.h" |
| +#include "test/cctest/wasm/test-signatures.h" |
| + |
| +using namespace v8::base; |
| +using namespace v8::internal; |
| +using namespace v8::internal::compiler; |
| +using namespace v8::internal::wasm; |
| + |
| +namespace { |
| +void SimpleTest(byte* code, uint32_t size, int32_t result) { |
| + FLAG_wasm_simd_prototype = true; |
| + TestSignatures sigs; |
| + v8::base::AccountingAllocator allocator; |
| + Zone zone(&allocator); |
| + |
| + WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); |
| + uint16_t f_index = builder->AddFunction(); |
| + WasmFunctionBuilder* f = builder->FunctionAt(f_index); |
| + f->SetSignature(sigs.i_v()); |
| + TestRunWasmModuleHelper::ExportAsMain(f); |
| + f->EmitCode(code, size); |
| + TestRunWasmModuleHelper::TestModule(&zone, builder, result); |
| +} |
| +} // namespace |
| + |
| +TEST(Simd_I32x4_Splat) { |
|
gdeepti
2016/08/30 17:16:06
WASM_EXEC_TEST here could work here too if you wan
aseemgarg
2016/10/10 17:35:17
Done.
|
| + byte code[] = {WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)), WASM_I8(0))}; |
| + SimpleTest(code, sizeof(code), 5); |
| +} |
| + |
| +TEST(Simd_I32x4_Add) { |
| + byte code[] = {WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)), |
| + WASM_SIMD_I32x4_SPLAT(WASM_I32V(6))), |
| + WASM_I8(0))}; |
| + SimpleTest(code, sizeof(code), 11); |
| +} |
| + |
| +TEST(Simd_F32x4_Splat) { |
| + byte code[] = {WASM_IF_ELSE( |
| + WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( |
| + WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5)), WASM_I32V(0)), |
| + WASM_F32(9.5)), |
| + WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; |
| + SimpleTest(code, sizeof(code), 1); |
| +} |
| + |
| +TEST(Simd_F32x4_Add) { |
| + byte code[] = {WASM_IF_ELSE( |
| + WASM_F32_EQ( |
| + WASM_SIMD_F32x4_EXTRACT_LANE( |
| + WASM_SIMD_F32x4_ADD(WASM_SIMD_F32x4_SPLAT(WASM_F32(13.25)), |
| + WASM_SIMD_F32x4_SPLAT(WASM_F32(6.25))), |
| + WASM_I8(0)), |
| + WASM_F32(19.5)), |
| + WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; |
| + SimpleTest(code, sizeof(code), 1); |
| +} |
| + |
| +TEST(Simd_I32x4_Extract_With_F32x4) { |
| + byte code[] = {WASM_IF_ELSE( |
| + WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5)), WASM_I32V(0)), |
| + WASM_I32_REINTERPRET_F32(WASM_F32(30.5))), |
| + WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; |
| + SimpleTest(code, sizeof(code), 1); |
| +} |
| + |
| +TEST(Simd_F32x4_Extract_With_I32x4) { |
| + byte code[] = {WASM_IF_ELSE( |
| + WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( |
| + WASM_SIMD_I32x4_SPLAT(WASM_I32V(15)), WASM_I32V(0)), |
| + WASM_F32_REINTERPRET_I32(WASM_I32V(15))), |
| + WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; |
| + SimpleTest(code, sizeof(code), 1); |
| +} |
| + |
| +TEST(Simd_F32x4_Add_With_I32x4) { |
| + byte code[] = {WASM_IF_ELSE( |
| + WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( |
| + WASM_SIMD_F32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(32)), |
| + WASM_SIMD_I32x4_SPLAT(WASM_I32V(19))), |
| + WASM_I8(0)), |
| + WASM_F32_ADD(WASM_F32_REINTERPRET_I32(WASM_I32V(32)), |
| + WASM_F32_REINTERPRET_I32(WASM_I32V(19)))), |
| + WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; |
| + SimpleTest(code, sizeof(code), 1); |
| +} |
| + |
| +TEST(Simd_I32x4_Add_With_F32x4) { |
| + byte code[] = {WASM_IF_ELSE( |
| + WASM_I32_EQ( |
| + WASM_SIMD_I32x4_EXTRACT_LANE( |
| + WASM_SIMD_I32x4_ADD(WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25)), |
| + WASM_SIMD_F32x4_SPLAT(WASM_F32(31.5))), |
| + WASM_I8(0)), |
| + WASM_I32_ADD(WASM_I32_REINTERPRET_F32(WASM_F32(21.25)), |
| + WASM_I32_REINTERPRET_F32(WASM_F32(31.5)))), |
| + WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; |
| + SimpleTest(code, sizeof(code), 1); |
|
bradnelson
2016/08/31 22:42:08
I assume you'll want tests with loops + conditions
aseemgarg
2016/10/10 17:35:17
yes. Will do in next change.
|
| +} |