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

Side by Side 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 unified diff | Download patch
OLDNEW
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"
6 #include "src/wasm/wasm-module.h" 5 #include "src/wasm/wasm-module.h"
7 6
8 #include "test/cctest/cctest.h" 7 #include "test/cctest/wasm/test-wasm-simd-common.h"
9 #include "test/cctest/compiler/value-helper.h"
10 #include "test/cctest/wasm/wasm-run-utils.h"
11 #include "test/common/wasm/test-signatures.h"
12 8
13 using namespace v8::base; 9 using namespace v8::base;
14 using namespace v8::internal; 10 using namespace v8::internal;
15 using namespace v8::internal::compiler; 11 using namespace v8::internal::compiler;
16 using namespace v8::internal::wasm; 12 using namespace v8::internal::wasm;
17 13
18 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) { 14 namespace test_wasm_simd_common {
19 FLAG_wasm_simd_prototype = true; 15 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) { RunI32x4SplatTest(); }
20 WasmRunner<int32_t> r(kExecuteCompiled); 16
21 BUILD(r, 17 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) { RunF32x4SplatTest(); }
22 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)))); 18
23 FOR_INT32_INPUTS(i) { CHECK_EQ(5, r.Call()); } 19 #define I32X4_BINOP_TEST(test_name, simd_op, func) \
20 WASM_EXEC_COMPILED_TEST(test_name) { RunI32x4BinOpTest(simd_op, func); }
21 I32X4_BINOP_TEST(Simd_I32x4_Add, kExprI32x4Add, Add)
22 I32X4_BINOP_TEST(Simd_I32x4_Sub, kExprI32x4Sub, Sub)
23 I32X4_BINOP_TEST(Simd_I32x4_Mul, kExprI32x4Mul, Mul)
24 I32X4_BINOP_TEST(Simd_128_And, kExprS128And, And)
25 I32X4_BINOP_TEST(Simd_128_Or, kExprS128Or, Or)
26 I32X4_BINOP_TEST(Simd_128_Xor, kExprS128Xor, Xor)
27 #undef I32X4_BINOP_TEST
28
29 #define F32X4_BINOP_TEST(op, name) \
30 WASM_EXEC_COMPILED_TEST(Simd_F32x4_##name) { \
31 RunF32x4BinOpTest(kExprF32x4##op, name); \
32 }
33 F32X4_BINOP_TEST(Add, Add)
34 F32X4_BINOP_TEST(Sub, Sub)
35 F32X4_BINOP_TEST(Mul, Mul)
36 F32X4_BINOP_TEST(Div, Div)
37 #undef F32X4_BINOP_TEST
38 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Min) {
39 RunF32x4BinOpTest(kExprF32x4Min, Minimum, true);
24 } 40 }
25 41 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Max) {
26 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add) { 42 RunF32x4BinOpTest(kExprF32x4Max, Maximum, true);
27 FLAG_wasm_simd_prototype = true;
28 WasmRunner<int32_t> r(kExecuteCompiled);
29 BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE(
30 0, WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)),
31 WASM_SIMD_I32x4_SPLAT(WASM_I32V(6)))));
32 FOR_INT32_INPUTS(i) { CHECK_EQ(11, r.Call()); }
33 }
34
35 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) {
36 FLAG_wasm_simd_prototype = true;
37 WasmRunner<int32_t> r(kExecuteCompiled);
38 BUILD(r,
39 WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
40 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5))),
41 WASM_F32(9.5)),
42 WASM_I32V(1), WASM_I32V(0)));
43 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
44 } 43 }
45 44
46 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Extract_With_F32x4) { 45 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Extract_With_F32x4) {
47 FLAG_wasm_simd_prototype = true; 46 FLAG_wasm_simd_prototype = true;
48 WasmRunner<int32_t> r(kExecuteCompiled); 47 WasmRunner<int32_t> r(kExecuteCompiled);
49 BUILD(r, WASM_IF_ELSE_I( 48 BUILD(r, WASM_IF_ELSE_I(
50 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( 49 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE(
51 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))), 50 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))),
52 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))), 51 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))),
53 WASM_I32V(1), WASM_I32V(0))); 52 WASM_I32V(1), WASM_I32V(0)));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Local) { 97 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Local) {
99 FLAG_wasm_simd_prototype = true; 98 FLAG_wasm_simd_prototype = true;
100 WasmRunner<int32_t> r(kExecuteCompiled); 99 WasmRunner<int32_t> r(kExecuteCompiled);
101 r.AllocateLocal(kWasmS128); 100 r.AllocateLocal(kWasmS128);
102 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), 101 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
103 102
104 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0))); 103 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0)));
105 FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); } 104 FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); }
106 } 105 }
107 106
108 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) { 107 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) { RunI32x4ReplaceLaneTest(); }
109 FLAG_wasm_simd_prototype = true;
110 WasmRunner<int32_t> r(kExecuteCompiled);
111 r.AllocateLocal(kWasmS128);
112 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
113 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(0),
114 WASM_I32V(53))),
115 WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(0)));
116 FOR_INT32_INPUTS(i) { CHECK_EQ(53, r.Call()); }
117 }
118 108
119 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) { 109 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) { RunF32x4ReplaceLaneTest(); }
120 FLAG_wasm_simd_prototype = true;
121 WasmRunner<int32_t> r(kExecuteCompiled);
122 r.AllocateLocal(kWasmF32);
123 r.AllocateLocal(kWasmS128);
124 BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(23.5))),
125 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(1),
126 WASM_F32(65.25))),
127 WASM_SET_LOCAL(0, WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1))),
128 WASM_IF(WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_F32(65.25)),
129 WASM_RETURN1(WASM_I32V(1))),
130 WASM_I32V(0));
131 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
132 }
133 110
134 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) { 111 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) {
135 FLAG_wasm_simd_prototype = true; 112 FLAG_wasm_simd_prototype = true;
136 WasmRunner<int32_t> r(kExecuteCompiled); 113 WasmRunner<int32_t> r(kExecuteCompiled);
137 r.AllocateLocal(kWasmI32); 114 r.AllocateLocal(kWasmI32);
138 r.AllocateLocal(kWasmS128); 115 r.AllocateLocal(kWasmS128);
139 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( 116 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE(
140 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))), 117 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))),
141 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), 118 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))),
142 WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1))); 119 WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1)));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 WASM_SET_LOCAL(0, WASM_I32V(1)), 264 WASM_SET_LOCAL(0, WASM_I32V(1)),
288 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), 265 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)),
289 WASM_F32(27.25)), 266 WASM_F32(27.25)),
290 WASM_SET_LOCAL(0, WASM_I32V(0))), 267 WASM_SET_LOCAL(0, WASM_I32V(0))),
291 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), 268 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)),
292 WASM_F32(25.5)), 269 WASM_F32(25.5)),
293 WASM_SET_LOCAL(0, WASM_I32V(0))), 270 WASM_SET_LOCAL(0, WASM_I32V(0))),
294 WASM_GET_LOCAL(0)); 271 WASM_GET_LOCAL(0));
295 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 272 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
296 } 273 }
274 } // namespace test_wasm_simd_common
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698