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

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

Issue 2583543002: Revert of [wasm] Make WasmRunner the central test structure (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « test/cctest/wasm/test-run-wasm-simd.cc ('k') | test/cctest/wasm/test-wasm-stack.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 5 #include "src/wasm/wasm-macro-gen.h"
6 #include "src/wasm/wasm-module.h" 6 #include "src/wasm/wasm-module.h"
7 7
8 #include "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/value-helper.h" 9 #include "test/cctest/compiler/value-helper.h"
10 #include "test/cctest/wasm/wasm-run-utils.h" 10 #include "test/cctest/wasm/wasm-run-utils.h"
11 #include "test/common/wasm/test-signatures.h" 11 #include "test/common/wasm/test-signatures.h"
12 12
13 using namespace v8::base; 13 using namespace v8::base;
14 using namespace v8::internal; 14 using namespace v8::internal;
15 using namespace v8::internal::compiler; 15 using namespace v8::internal::compiler;
16 using namespace v8::internal::wasm; 16 using namespace v8::internal::wasm;
17 17
18 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) { 18 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) {
19 FLAG_wasm_simd_prototype = true; 19 FLAG_wasm_simd_prototype = true;
20 WasmRunner<int32_t> r(kExecuteCompiled); 20 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
21 BUILD(r, 21 BUILD(r,
22 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)))); 22 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(5))));
23 FOR_INT32_INPUTS(i) { CHECK_EQ(5, r.Call()); } 23 FOR_INT32_INPUTS(i) { CHECK_EQ(5, r.Call()); }
24 } 24 }
25 25
26 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add) { 26 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add) {
27 FLAG_wasm_simd_prototype = true; 27 FLAG_wasm_simd_prototype = true;
28 WasmRunner<int32_t> r(kExecuteCompiled); 28 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
29 BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE( 29 BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE(
30 0, WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)), 30 0, WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)),
31 WASM_SIMD_I32x4_SPLAT(WASM_I32V(6))))); 31 WASM_SIMD_I32x4_SPLAT(WASM_I32V(6)))));
32 FOR_INT32_INPUTS(i) { CHECK_EQ(11, r.Call()); } 32 FOR_INT32_INPUTS(i) { CHECK_EQ(11, r.Call()); }
33 } 33 }
34 34
35 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) { 35 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) {
36 FLAG_wasm_simd_prototype = true; 36 FLAG_wasm_simd_prototype = true;
37 WasmRunner<int32_t> r(kExecuteCompiled); 37 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
38 BUILD(r, 38 BUILD(r,
39 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( 39 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
40 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5))), 40 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5))),
41 WASM_F32(9.5)), 41 WASM_F32(9.5)),
42 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); 42 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0))));
43 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 43 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
44 } 44 }
45 45
46 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Extract_With_F32x4) { 46 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Extract_With_F32x4) {
47 FLAG_wasm_simd_prototype = true; 47 FLAG_wasm_simd_prototype = true;
48 WasmRunner<int32_t> r(kExecuteCompiled); 48 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
49 BUILD(r, 49 BUILD(r,
50 WASM_IF_ELSE(WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( 50 WASM_IF_ELSE(WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE(
51 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))), 51 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))),
52 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))), 52 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))),
53 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); 53 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0))));
54 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 54 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
55 } 55 }
56 56
57 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Extract_With_I32x4) { 57 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Extract_With_I32x4) {
58 FLAG_wasm_simd_prototype = true; 58 FLAG_wasm_simd_prototype = true;
59 WasmRunner<int32_t> r(kExecuteCompiled); 59 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
60 BUILD(r, 60 BUILD(r,
61 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( 61 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
62 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))), 62 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))),
63 WASM_F32_REINTERPRET_I32(WASM_I32V(15))), 63 WASM_F32_REINTERPRET_I32(WASM_I32V(15))),
64 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); 64 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0))));
65 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 65 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
66 } 66 }
67 67
68 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Add_With_I32x4) { 68 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Add_With_I32x4) {
69 FLAG_wasm_simd_prototype = true; 69 FLAG_wasm_simd_prototype = true;
70 WasmRunner<int32_t> r(kExecuteCompiled); 70 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
71 BUILD(r, 71 BUILD(r,
72 WASM_IF_ELSE( 72 WASM_IF_ELSE(
73 WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( 73 WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
74 0, WASM_SIMD_F32x4_ADD( 74 0, WASM_SIMD_F32x4_ADD(
75 WASM_SIMD_I32x4_SPLAT(WASM_I32V(32)), 75 WASM_SIMD_I32x4_SPLAT(WASM_I32V(32)),
76 WASM_SIMD_I32x4_SPLAT(WASM_I32V(19)))), 76 WASM_SIMD_I32x4_SPLAT(WASM_I32V(19)))),
77 WASM_F32_ADD(WASM_F32_REINTERPRET_I32(WASM_I32V(32)), 77 WASM_F32_ADD(WASM_F32_REINTERPRET_I32(WASM_I32V(32)),
78 WASM_F32_REINTERPRET_I32(WASM_I32V(19)))), 78 WASM_F32_REINTERPRET_I32(WASM_I32V(19)))),
79 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); 79 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0))));
80 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 80 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
81 } 81 }
82 82
83 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add_With_F32x4) { 83 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add_With_F32x4) {
84 FLAG_wasm_simd_prototype = true; 84 FLAG_wasm_simd_prototype = true;
85 WasmRunner<int32_t> r(kExecuteCompiled); 85 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
86 BUILD(r, 86 BUILD(r,
87 WASM_IF_ELSE( 87 WASM_IF_ELSE(
88 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( 88 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE(
89 0, WASM_SIMD_I32x4_ADD( 89 0, WASM_SIMD_I32x4_ADD(
90 WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25)), 90 WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25)),
91 WASM_SIMD_F32x4_SPLAT(WASM_F32(31.5)))), 91 WASM_SIMD_F32x4_SPLAT(WASM_F32(31.5)))),
92 WASM_I32_ADD(WASM_I32_REINTERPRET_F32(WASM_F32(21.25)), 92 WASM_I32_ADD(WASM_I32_REINTERPRET_F32(WASM_F32(21.25)),
93 WASM_I32_REINTERPRET_F32(WASM_F32(31.5)))), 93 WASM_I32_REINTERPRET_F32(WASM_F32(31.5)))),
94 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))); 94 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0))));
95 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 95 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
96 } 96 }
97 97
98 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Local) { 98 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Local) {
99 FLAG_wasm_simd_prototype = true; 99 FLAG_wasm_simd_prototype = true;
100 WasmRunner<int32_t> r(kExecuteCompiled); 100 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
101 r.AllocateLocal(kAstS128); 101 r.AllocateLocal(kAstS128);
102 BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), 102 BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
103 WASM_RETURN1( 103 WASM_RETURN1(
104 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0))))); 104 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)))));
105 FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); } 105 FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); }
106 } 106 }
107 107
108 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) { 108 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) {
109 FLAG_wasm_simd_prototype = true; 109 FLAG_wasm_simd_prototype = true;
110 WasmRunner<int32_t> r(kExecuteCompiled); 110 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
111 r.AllocateLocal(kAstS128); 111 r.AllocateLocal(kAstS128);
112 BUILD(r, 112 BUILD(r,
113 WASM_BLOCK( 113 WASM_BLOCK(
114 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), 114 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
115 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(0), 115 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(1),
116 WASM_I32V(53))), 116 WASM_I32V(53))),
117 WASM_RETURN1(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(0))))); 117 WASM_RETURN1(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(1)))));
118 FOR_INT32_INPUTS(i) { CHECK_EQ(53, r.Call()); } 118 FOR_INT32_INPUTS(i) { CHECK_EQ(53, r.Call()); }
119 } 119 }
120 120
121 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) { 121 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) {
122 FLAG_wasm_simd_prototype = true; 122 FLAG_wasm_simd_prototype = true;
123 WasmRunner<int32_t> r(kExecuteCompiled); 123 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
124 r.AllocateLocal(kAstF32); 124 r.AllocateLocal(kAstF32);
125 r.AllocateLocal(kAstS128); 125 r.AllocateLocal(kAstS128);
126 BUILD(r, WASM_BLOCK( 126 BUILD(r, WASM_BLOCK(
127 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(23.5))), 127 WASM_SET_LOCAL(2, WASM_SIMD_F32x4_SPLAT(WASM_F32(23.5))),
128 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE( 128 WASM_SET_LOCAL(2, WASM_SIMD_F32x4_REPLACE_LANE(
129 3, WASM_GET_LOCAL(1), WASM_F32(65.25))), 129 3, WASM_GET_LOCAL(2), WASM_F32(65.25))),
130 WASM_SET_LOCAL( 130 WASM_SET_LOCAL(
131 0, WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1))), 131 1, WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(2))),
132 WASM_IF(WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_F32(65.25)), 132 WASM_IF(WASM_F32_EQ(WASM_GET_LOCAL(1), WASM_F32(65.25)),
133 WASM_RETURN1(WASM_I32V(1))), 133 WASM_RETURN1(WASM_I32V(1))),
134 WASM_RETURN1(WASM_I32V(0)))); 134 WASM_RETURN1(WASM_I32V(0))));
135 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 135 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
136 } 136 }
137 137
138 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) { 138 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) {
139 FLAG_wasm_simd_prototype = true; 139 FLAG_wasm_simd_prototype = true;
140 WasmRunner<int32_t> r(kExecuteCompiled); 140 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
141 r.AllocateLocal(kAstI32); 141 r.AllocateLocal(kAstI32);
142 r.AllocateLocal(kAstS128); 142 r.AllocateLocal(kAstS128);
143 BUILD(r, 143 BUILD(r,
144 WASM_BLOCK( 144 WASM_BLOCK(
145 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( 145 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_EXTRACT_LANE(
146 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))), 146 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))),
147 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), 147 WASM_SET_LOCAL(2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(1))),
148 WASM_RETURN1(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1))))); 148 WASM_RETURN1(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(2)))));
149 FOR_INT32_INPUTS(i) { CHECK_EQ(76, r.Call()); } 149 FOR_INT32_INPUTS(i) { CHECK_EQ(76, r.Call()); }
150 } 150 }
151 151
152 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Get_Global) { 152 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Get_Global) {
153 FLAG_wasm_simd_prototype = true; 153 FLAG_wasm_simd_prototype = true;
154 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 154 TestingModule module(kExecuteCompiled);
155 int32_t* global = r.module().AddGlobal<int32_t>(kAstS128); 155 int32_t* global = module.AddGlobal<int32_t>(kAstS128);
156 *(global) = 0; 156 *(global) = 0;
157 *(global + 1) = 1; 157 *(global + 1) = 1;
158 *(global + 2) = 2; 158 *(global + 2) = 2;
159 *(global + 3) = 3; 159 *(global + 3) = 3;
160 WasmRunner<int32_t> r(&module, MachineType::Int32());
160 r.AllocateLocal(kAstI32); 161 r.AllocateLocal(kAstI32);
161 BUILD(r, WASM_BLOCK( 162 BUILD(r, WASM_BLOCK(
162 WASM_SET_LOCAL(1, WASM_I32V(1)), 163 WASM_SET_LOCAL(1, WASM_I32V(1)),
163 WASM_IF(WASM_I32_NE(WASM_I32V(0), WASM_SIMD_I32x4_EXTRACT_LANE( 164 WASM_IF(WASM_I32_NE(WASM_I32V(0), WASM_SIMD_I32x4_EXTRACT_LANE(
164 0, WASM_GET_GLOBAL(0))), 165 0, WASM_GET_GLOBAL(0))),
165 WASM_SET_LOCAL(1, WASM_I32V(0))), 166 WASM_SET_LOCAL(1, WASM_I32V(0))),
166 WASM_IF(WASM_I32_NE(WASM_I32V(1), WASM_SIMD_I32x4_EXTRACT_LANE( 167 WASM_IF(WASM_I32_NE(WASM_I32V(1), WASM_SIMD_I32x4_EXTRACT_LANE(
167 1, WASM_GET_GLOBAL(0))), 168 1, WASM_GET_GLOBAL(0))),
168 WASM_SET_LOCAL(1, WASM_I32V(0))), 169 WASM_SET_LOCAL(1, WASM_I32V(0))),
169 WASM_IF(WASM_I32_NE(WASM_I32V(2), WASM_SIMD_I32x4_EXTRACT_LANE( 170 WASM_IF(WASM_I32_NE(WASM_I32V(2), WASM_SIMD_I32x4_EXTRACT_LANE(
170 2, WASM_GET_GLOBAL(0))), 171 2, WASM_GET_GLOBAL(0))),
171 WASM_SET_LOCAL(1, WASM_I32V(0))), 172 WASM_SET_LOCAL(1, WASM_I32V(0))),
172 WASM_IF(WASM_I32_NE(WASM_I32V(3), WASM_SIMD_I32x4_EXTRACT_LANE( 173 WASM_IF(WASM_I32_NE(WASM_I32V(3), WASM_SIMD_I32x4_EXTRACT_LANE(
173 3, WASM_GET_GLOBAL(0))), 174 3, WASM_GET_GLOBAL(0))),
174 WASM_SET_LOCAL(1, WASM_I32V(0))), 175 WASM_SET_LOCAL(1, WASM_I32V(0))),
175 WASM_RETURN1(WASM_GET_LOCAL(1)))); 176 WASM_RETURN1(WASM_GET_LOCAL(1))));
176 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } 177 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
177 } 178 }
178 179
179 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Set_Global) { 180 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Set_Global) {
180 FLAG_wasm_simd_prototype = true; 181 FLAG_wasm_simd_prototype = true;
181 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 182 TestingModule module(kExecuteCompiled);
182 int32_t* global = r.module().AddGlobal<int32_t>(kAstS128); 183 int32_t* global = module.AddGlobal<int32_t>(kAstS128);
184 WasmRunner<int32_t> r(&module, MachineType::Int32());
183 BUILD(r, WASM_BLOCK( 185 BUILD(r, WASM_BLOCK(
184 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))), 186 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))),
185 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE( 187 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(
186 1, WASM_GET_GLOBAL(0), WASM_I32V(34))), 188 1, WASM_GET_GLOBAL(0), WASM_I32V(34))),
187 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE( 189 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(
188 2, WASM_GET_GLOBAL(0), WASM_I32V(45))), 190 2, WASM_GET_GLOBAL(0), WASM_I32V(45))),
189 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE( 191 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(
190 3, WASM_GET_GLOBAL(0), WASM_I32V(56))), 192 3, WASM_GET_GLOBAL(0), WASM_I32V(56))),
191 WASM_RETURN1(WASM_I32V(1)))); 193 WASM_RETURN1(WASM_I32V(1))));
192 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } 194 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
193 CHECK_EQ(*global, 23); 195 CHECK_EQ(*global, 23);
194 CHECK_EQ(*(global + 1), 34); 196 CHECK_EQ(*(global + 1), 34);
195 CHECK_EQ(*(global + 2), 45); 197 CHECK_EQ(*(global + 2), 45);
196 CHECK_EQ(*(global + 3), 56); 198 CHECK_EQ(*(global + 3), 56);
197 } 199 }
198 200
199 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Get_Global) { 201 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Get_Global) {
200 FLAG_wasm_simd_prototype = true; 202 FLAG_wasm_simd_prototype = true;
201 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 203 TestingModule module(kExecuteCompiled);
202 float* global = r.module().AddGlobal<float>(kAstS128); 204 float* global = module.AddGlobal<float>(kAstS128);
203 *(global) = 0.0; 205 *(global) = 0.0;
204 *(global + 1) = 1.5; 206 *(global + 1) = 1.5;
205 *(global + 2) = 2.25; 207 *(global + 2) = 2.25;
206 *(global + 3) = 3.5; 208 *(global + 3) = 3.5;
209 WasmRunner<int32_t> r(&module, MachineType::Int32());
207 r.AllocateLocal(kAstI32); 210 r.AllocateLocal(kAstI32);
208 BUILD(r, WASM_BLOCK( 211 BUILD(r, WASM_BLOCK(
209 WASM_SET_LOCAL(1, WASM_I32V(1)), 212 WASM_SET_LOCAL(1, WASM_I32V(1)),
210 WASM_IF(WASM_F32_NE(WASM_F32(0.0), WASM_SIMD_F32x4_EXTRACT_LANE( 213 WASM_IF(WASM_F32_NE(WASM_F32(0.0), WASM_SIMD_F32x4_EXTRACT_LANE(
211 0, WASM_GET_GLOBAL(0))), 214 0, WASM_GET_GLOBAL(0))),
212 WASM_SET_LOCAL(1, WASM_I32V(0))), 215 WASM_SET_LOCAL(1, WASM_I32V(0))),
213 WASM_IF(WASM_F32_NE(WASM_F32(1.5), WASM_SIMD_F32x4_EXTRACT_LANE( 216 WASM_IF(WASM_F32_NE(WASM_F32(1.5), WASM_SIMD_F32x4_EXTRACT_LANE(
214 1, WASM_GET_GLOBAL(0))), 217 1, WASM_GET_GLOBAL(0))),
215 WASM_SET_LOCAL(1, WASM_I32V(0))), 218 WASM_SET_LOCAL(1, WASM_I32V(0))),
216 WASM_IF(WASM_F32_NE(WASM_F32(2.25), WASM_SIMD_F32x4_EXTRACT_LANE( 219 WASM_IF(WASM_F32_NE(WASM_F32(2.25), WASM_SIMD_F32x4_EXTRACT_LANE(
217 2, WASM_GET_GLOBAL(0))), 220 2, WASM_GET_GLOBAL(0))),
218 WASM_SET_LOCAL(1, WASM_I32V(0))), 221 WASM_SET_LOCAL(1, WASM_I32V(0))),
219 WASM_IF(WASM_F32_NE(WASM_F32(3.5), WASM_SIMD_F32x4_EXTRACT_LANE( 222 WASM_IF(WASM_F32_NE(WASM_F32(3.5), WASM_SIMD_F32x4_EXTRACT_LANE(
220 3, WASM_GET_GLOBAL(0))), 223 3, WASM_GET_GLOBAL(0))),
221 WASM_SET_LOCAL(1, WASM_I32V(0))), 224 WASM_SET_LOCAL(1, WASM_I32V(0))),
222 WASM_RETURN1(WASM_GET_LOCAL(1)))); 225 WASM_RETURN1(WASM_GET_LOCAL(1))));
223 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } 226 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
224 } 227 }
225 228
226 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Set_Global) { 229 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Set_Global) {
227 FLAG_wasm_simd_prototype = true; 230 FLAG_wasm_simd_prototype = true;
228 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 231 TestingModule module(kExecuteCompiled);
229 float* global = r.module().AddGlobal<float>(kAstS128); 232 float* global = module.AddGlobal<float>(kAstS128);
233 WasmRunner<int32_t> r(&module, MachineType::Int32());
230 BUILD(r, WASM_BLOCK( 234 BUILD(r, WASM_BLOCK(
231 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))), 235 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))),
232 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE( 236 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(
233 1, WASM_GET_GLOBAL(0), WASM_F32(45.5))), 237 1, WASM_GET_GLOBAL(0), WASM_F32(45.5))),
234 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE( 238 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(
235 2, WASM_GET_GLOBAL(0), WASM_F32(32.25))), 239 2, WASM_GET_GLOBAL(0), WASM_F32(32.25))),
236 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE( 240 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(
237 3, WASM_GET_GLOBAL(0), WASM_F32(65.0))), 241 3, WASM_GET_GLOBAL(0), WASM_F32(65.0))),
238 WASM_RETURN1(WASM_I32V(1)))); 242 WASM_RETURN1(WASM_I32V(1))));
239 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } 243 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
240 CHECK_EQ(*global, 13.5); 244 CHECK_EQ(*global, 13.5);
241 CHECK_EQ(*(global + 1), 45.5); 245 CHECK_EQ(*(global + 1), 45.5);
242 CHECK_EQ(*(global + 2), 32.25); 246 CHECK_EQ(*(global + 2), 32.25);
243 CHECK_EQ(*(global + 3), 65.0); 247 CHECK_EQ(*(global + 3), 65.0);
244 } 248 }
245 249
246 WASM_EXEC_COMPILED_TEST(Simd_I32x4_For) { 250 WASM_EXEC_COMPILED_TEST(Simd_I32x4_For) {
247 FLAG_wasm_simd_prototype = true; 251 FLAG_wasm_simd_prototype = true;
248 WasmRunner<int32_t> r(kExecuteCompiled); 252 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
249 r.AllocateLocal(kAstI32); 253 r.AllocateLocal(kAstI32);
250 r.AllocateLocal(kAstS128); 254 r.AllocateLocal(kAstS128);
251 BUILD( 255 BUILD(
252 r, 256 r,
253 WASM_BLOCK( 257 WASM_BLOCK(
254 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), 258 WASM_SET_LOCAL(2, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
255 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(1), 259 WASM_SET_LOCAL(2, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(2),
256 WASM_I32V(53))), 260 WASM_I32V(53))),
257 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(1), 261 WASM_SET_LOCAL(2, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(2),
258 WASM_I32V(23))), 262 WASM_I32V(23))),
259 WASM_SET_LOCAL(0, WASM_I32V(0)), 263 WASM_SET_LOCAL(1, WASM_I32V(0)),
260 WASM_LOOP(WASM_SET_LOCAL(1, WASM_SIMD_I32x4_ADD( 264 WASM_LOOP(WASM_SET_LOCAL(2, WASM_SIMD_I32x4_ADD(
261 WASM_GET_LOCAL(1), 265 WASM_GET_LOCAL(2),
262 WASM_SIMD_I32x4_SPLAT(WASM_I32V(1)))), 266 WASM_SIMD_I32x4_SPLAT(WASM_I32V(1)))),
263 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(5)), 267 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(1), WASM_I32V(5)),
264 WASM_BR(1))), 268 WASM_BR(1))),
265 WASM_SET_LOCAL(0, WASM_I32V(1)), 269 WASM_SET_LOCAL(1, WASM_I32V(1)),
266 WASM_IF( 270 WASM_IF(
267 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), 271 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(2)),
268 WASM_I32V(36)), 272 WASM_I32V(36)),
269 WASM_SET_LOCAL(0, WASM_I32V(0))), 273 WASM_SET_LOCAL(1, WASM_I32V(0))),
270 WASM_IF( 274 WASM_IF(
271 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1)), 275 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(2)),
272 WASM_I32V(58)), 276 WASM_I32V(58)),
273 WASM_SET_LOCAL(0, WASM_I32V(0))), 277 WASM_SET_LOCAL(1, WASM_I32V(0))),
274 WASM_IF( 278 WASM_IF(
275 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(1)), 279 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(2)),
276 WASM_I32V(28)), 280 WASM_I32V(28)),
277 WASM_SET_LOCAL(0, WASM_I32V(0))), 281 WASM_SET_LOCAL(1, WASM_I32V(0))),
278 WASM_IF( 282 WASM_IF(
279 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), 283 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(2)),
280 WASM_I32V(36)), 284 WASM_I32V(36)),
281 WASM_SET_LOCAL(0, WASM_I32V(0))), 285 WASM_SET_LOCAL(1, WASM_I32V(0))),
282 WASM_RETURN1(WASM_GET_LOCAL(0)))); 286 WASM_RETURN1(WASM_GET_LOCAL(1))));
283 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 287 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
284 } 288 }
285 289
286 WASM_EXEC_COMPILED_TEST(Simd_F32x4_For) { 290 WASM_EXEC_COMPILED_TEST(Simd_F32x4_For) {
287 FLAG_wasm_simd_prototype = true; 291 FLAG_wasm_simd_prototype = true;
288 WasmRunner<int32_t> r(kExecuteCompiled); 292 WasmRunner<int32_t> r(kExecuteCompiled, MachineType::Int32());
289 r.AllocateLocal(kAstI32); 293 r.AllocateLocal(kAstI32);
290 r.AllocateLocal(kAstS128); 294 r.AllocateLocal(kAstS128);
291 BUILD(r, WASM_BLOCK( 295 BUILD(r, WASM_BLOCK(
292 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))), 296 WASM_SET_LOCAL(2, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))),
293 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE( 297 WASM_SET_LOCAL(2, WASM_SIMD_F32x4_REPLACE_LANE(
294 3, WASM_GET_LOCAL(1), WASM_F32(19.5))), 298 3, WASM_GET_LOCAL(2), WASM_F32(19.5))),
295 WASM_SET_LOCAL(0, WASM_I32V(0)), 299 WASM_SET_LOCAL(1, WASM_I32V(0)),
296 WASM_LOOP( 300 WASM_LOOP(
297 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_ADD( 301 WASM_SET_LOCAL(2, WASM_SIMD_F32x4_ADD(
298 WASM_GET_LOCAL(1), 302 WASM_GET_LOCAL(2),
299 WASM_SIMD_F32x4_SPLAT(WASM_F32(2.0)))), 303 WASM_SIMD_F32x4_SPLAT(WASM_F32(2.0)))),
300 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(3)), 304 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(1), WASM_I32V(3)),
301 WASM_BR(1))), 305 WASM_BR(1))),
302 WASM_SET_LOCAL(0, WASM_I32V(1)), 306 WASM_SET_LOCAL(1, WASM_I32V(1)),
303 WASM_IF(WASM_F32_NE( 307 WASM_IF(WASM_F32_NE(
304 WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), 308 WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(2)),
305 WASM_F32(27.25)), 309 WASM_F32(27.25)),
306 WASM_SET_LOCAL(0, WASM_I32V(0))), 310 WASM_SET_LOCAL(1, WASM_I32V(0))),
307 WASM_IF(WASM_F32_NE( 311 WASM_IF(WASM_F32_NE(
308 WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), 312 WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(2)),
309 WASM_F32(25.5)), 313 WASM_F32(25.5)),
310 WASM_SET_LOCAL(0, WASM_I32V(0))), 314 WASM_SET_LOCAL(1, WASM_I32V(0))),
311 WASM_RETURN1(WASM_GET_LOCAL(0)))); 315 WASM_RETURN1(WASM_GET_LOCAL(1))));
312 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 316 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
313 } 317 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-simd.cc ('k') | test/cctest/wasm/test-wasm-stack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698