Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1557)

Unified Diff: test/cctest/wasm/test-run-wasm-simd-lowering.cc

Issue 2713613005: [wasm]implement simd lowering for F32x4 and I32x4 binops (Closed)
Patch Set: use namespace Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
index 706de8de350d396b76fc72dd7f778172e8f871d8..12b4a6f1db4f4537c68b4f9786b3a6ae4934d62c 100644
--- a/test/cctest/wasm/test-run-wasm-simd-lowering.cc
+++ b/test/cctest/wasm/test-run-wasm-simd-lowering.cc
@@ -2,45 +2,44 @@
// 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/compiler/value-helper.h"
-#include "test/cctest/wasm/wasm-run-utils.h"
-#include "test/common/wasm/test-signatures.h"
+#include "test/cctest/wasm/test-wasm-simd-common.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
-WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) {
- FLAG_wasm_simd_prototype = true;
- WasmRunner<int32_t> r(kExecuteCompiled);
- BUILD(r,
- WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(5))));
- FOR_INT32_INPUTS(i) { CHECK_EQ(5, r.Call()); }
-}
+namespace test_wasm_simd_common {
+WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) { RunI32x4SplatTest(); }
-WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add) {
- FLAG_wasm_simd_prototype = true;
- WasmRunner<int32_t> r(kExecuteCompiled);
- BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE(
- 0, WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)),
- WASM_SIMD_I32x4_SPLAT(WASM_I32V(6)))));
- FOR_INT32_INPUTS(i) { CHECK_EQ(11, r.Call()); }
-}
+WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) { RunF32x4SplatTest(); }
-WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) {
- FLAG_wasm_simd_prototype = true;
- WasmRunner<int32_t> r(kExecuteCompiled);
- BUILD(r,
- WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
- 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5))),
- WASM_F32(9.5)),
- WASM_I32V(1), WASM_I32V(0)));
- FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
+#define I32X4_BINOP_TEST(test_name, simd_op, func) \
+ WASM_EXEC_COMPILED_TEST(test_name) { RunI32x4BinOpTest(simd_op, func); }
+I32X4_BINOP_TEST(Simd_I32x4_Add, kExprI32x4Add, Add)
+I32X4_BINOP_TEST(Simd_I32x4_Sub, kExprI32x4Sub, Sub)
+I32X4_BINOP_TEST(Simd_I32x4_Mul, kExprI32x4Mul, Mul)
+I32X4_BINOP_TEST(Simd_128_And, kExprS128And, And)
+I32X4_BINOP_TEST(Simd_128_Or, kExprS128Or, Or)
+I32X4_BINOP_TEST(Simd_128_Xor, kExprS128Xor, Xor)
+#undef I32X4_BINOP_TEST
+
+#define F32X4_BINOP_TEST(op, name) \
+ WASM_EXEC_COMPILED_TEST(Simd_F32x4_##name) { \
+ RunF32x4BinOpTest(kExprF32x4##op, name); \
+ }
+F32X4_BINOP_TEST(Add, Add)
+F32X4_BINOP_TEST(Sub, Sub)
+F32X4_BINOP_TEST(Mul, Mul)
+F32X4_BINOP_TEST(Div, Div)
+#undef F32X4_BINOP_TEST
+WASM_EXEC_COMPILED_TEST(Simd_F32x4_Min) {
+ RunF32x4BinOpTest(kExprF32x4Min, Minimum, true);
+}
+WASM_EXEC_COMPILED_TEST(Simd_F32x4_Max) {
+ RunF32x4BinOpTest(kExprF32x4Max, Maximum, true);
}
WASM_EXEC_COMPILED_TEST(Simd_I32x4_Extract_With_F32x4) {
@@ -105,31 +104,9 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_Local) {
FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); }
}
-WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) {
- FLAG_wasm_simd_prototype = true;
- WasmRunner<int32_t> r(kExecuteCompiled);
- r.AllocateLocal(kWasmS128);
- BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
- WASM_SET_LOCAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(0),
- WASM_I32V(53))),
- WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(0)));
- FOR_INT32_INPUTS(i) { CHECK_EQ(53, r.Call()); }
-}
+WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) { RunI32x4ReplaceLaneTest(); }
-WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) {
- FLAG_wasm_simd_prototype = true;
- WasmRunner<int32_t> r(kExecuteCompiled);
- r.AllocateLocal(kWasmF32);
- r.AllocateLocal(kWasmS128);
- BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(23.5))),
- WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(1),
- WASM_F32(65.25))),
- WASM_SET_LOCAL(0, WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1))),
- WASM_IF(WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_F32(65.25)),
- WASM_RETURN1(WASM_I32V(1))),
- WASM_I32V(0));
- FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
-}
+WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) { RunF32x4ReplaceLaneTest(); }
WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) {
FLAG_wasm_simd_prototype = true;
@@ -294,3 +271,4 @@ WASM_EXEC_COMPILED_TEST(Simd_F32x4_For) {
WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
}
+} // namespace test_wasm_simd_common

Powered by Google App Engine
This is Rietveld 408576698