OLD | NEW |
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" |
(...skipping 18 matching lines...) Expand all Loading... |
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); |
38 BUILD(r, | 38 BUILD(r, |
39 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( | 39 WASM_IF_ELSE_I(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_I32V(1), 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); |
49 BUILD(r, | 49 BUILD(r, WASM_IF_ELSE_I( |
50 WASM_IF_ELSE(WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( | 50 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_I32V(1), 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); |
60 BUILD(r, | 60 BUILD(r, |
61 WASM_IF_ELSE(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( | 61 WASM_IF_ELSE_I(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_I32V(1), 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); |
71 BUILD(r, | 71 BUILD(r, |
72 WASM_IF_ELSE( | 72 WASM_IF_ELSE_I( |
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_I32V(1), 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); |
86 BUILD(r, | 86 BUILD(r, |
87 WASM_IF_ELSE( | 87 WASM_IF_ELSE_I( |
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_I32V(1), 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); |
101 r.AllocateLocal(kWasmS128); | 101 r.AllocateLocal(kWasmS128); |
102 BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), | 102 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), |
103 WASM_RETURN1( | 103 |
104 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0))))); | 104 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0))); |
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); |
111 r.AllocateLocal(kWasmS128); | 111 r.AllocateLocal(kWasmS128); |
112 BUILD(r, | 112 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), |
113 WASM_BLOCK( | 113 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(0), |
114 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), | 114 WASM_I32V(53))), |
115 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(0), | 115 WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(0))); |
116 WASM_I32V(53))), | |
117 WASM_RETURN1(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(0))))); | |
118 FOR_INT32_INPUTS(i) { CHECK_EQ(53, r.Call()); } | 116 FOR_INT32_INPUTS(i) { CHECK_EQ(53, r.Call()); } |
119 } | 117 } |
120 | 118 |
121 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) { | 119 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) { |
122 FLAG_wasm_simd_prototype = true; | 120 FLAG_wasm_simd_prototype = true; |
123 WasmRunner<int32_t> r(kExecuteCompiled); | 121 WasmRunner<int32_t> r(kExecuteCompiled); |
124 r.AllocateLocal(kWasmF32); | 122 r.AllocateLocal(kWasmF32); |
125 r.AllocateLocal(kWasmS128); | 123 r.AllocateLocal(kWasmS128); |
126 BUILD(r, WASM_BLOCK( | 124 BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(23.5))), |
127 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), |
128 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE( | 126 WASM_F32(65.25))), |
129 3, WASM_GET_LOCAL(1), WASM_F32(65.25))), | 127 WASM_SET_LOCAL(0, WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1))), |
130 WASM_SET_LOCAL( | 128 WASM_IF(WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_F32(65.25)), |
131 0, WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1))), | 129 WASM_RETURN1(WASM_I32V(1))), |
132 WASM_IF(WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_F32(65.25)), | 130 WASM_I32V(0)); |
133 WASM_RETURN1(WASM_I32V(1))), | |
134 WASM_RETURN1(WASM_I32V(0)))); | |
135 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } | 131 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
136 } | 132 } |
137 | 133 |
138 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) { | 134 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) { |
139 FLAG_wasm_simd_prototype = true; | 135 FLAG_wasm_simd_prototype = true; |
140 WasmRunner<int32_t> r(kExecuteCompiled); | 136 WasmRunner<int32_t> r(kExecuteCompiled); |
141 r.AllocateLocal(kWasmI32); | 137 r.AllocateLocal(kWasmI32); |
142 r.AllocateLocal(kWasmS128); | 138 r.AllocateLocal(kWasmS128); |
143 BUILD(r, | 139 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( |
144 WASM_BLOCK( | 140 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))), |
145 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( | 141 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), |
146 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))), | 142 WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1))); |
147 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), | |
148 WASM_RETURN1(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1))))); | |
149 FOR_INT32_INPUTS(i) { CHECK_EQ(76, r.Call()); } | 143 FOR_INT32_INPUTS(i) { CHECK_EQ(76, r.Call()); } |
150 } | 144 } |
151 | 145 |
152 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Get_Global) { | 146 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Get_Global) { |
153 FLAG_wasm_simd_prototype = true; | 147 FLAG_wasm_simd_prototype = true; |
154 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 148 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
155 int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128); | 149 int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128); |
156 *(global) = 0; | 150 *(global) = 0; |
157 *(global + 1) = 1; | 151 *(global + 1) = 1; |
158 *(global + 2) = 2; | 152 *(global + 2) = 2; |
159 *(global + 3) = 3; | 153 *(global + 3) = 3; |
160 r.AllocateLocal(kWasmI32); | 154 r.AllocateLocal(kWasmI32); |
161 BUILD(r, WASM_BLOCK( | 155 BUILD( |
162 WASM_SET_LOCAL(1, WASM_I32V(1)), | 156 r, WASM_SET_LOCAL(1, WASM_I32V(1)), |
163 WASM_IF(WASM_I32_NE(WASM_I32V(0), WASM_SIMD_I32x4_EXTRACT_LANE( | 157 WASM_IF(WASM_I32_NE(WASM_I32V(0), |
164 0, WASM_GET_GLOBAL(0))), | 158 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(0))), |
165 WASM_SET_LOCAL(1, WASM_I32V(0))), | 159 WASM_SET_LOCAL(1, WASM_I32V(0))), |
166 WASM_IF(WASM_I32_NE(WASM_I32V(1), WASM_SIMD_I32x4_EXTRACT_LANE( | 160 WASM_IF(WASM_I32_NE(WASM_I32V(1), |
167 1, WASM_GET_GLOBAL(0))), | 161 WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_GLOBAL(0))), |
168 WASM_SET_LOCAL(1, WASM_I32V(0))), | 162 WASM_SET_LOCAL(1, WASM_I32V(0))), |
169 WASM_IF(WASM_I32_NE(WASM_I32V(2), WASM_SIMD_I32x4_EXTRACT_LANE( | 163 WASM_IF(WASM_I32_NE(WASM_I32V(2), |
170 2, WASM_GET_GLOBAL(0))), | 164 WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_GLOBAL(0))), |
171 WASM_SET_LOCAL(1, WASM_I32V(0))), | 165 WASM_SET_LOCAL(1, WASM_I32V(0))), |
172 WASM_IF(WASM_I32_NE(WASM_I32V(3), WASM_SIMD_I32x4_EXTRACT_LANE( | 166 WASM_IF(WASM_I32_NE(WASM_I32V(3), |
173 3, WASM_GET_GLOBAL(0))), | 167 WASM_SIMD_I32x4_EXTRACT_LANE(3, WASM_GET_GLOBAL(0))), |
174 WASM_SET_LOCAL(1, WASM_I32V(0))), | 168 WASM_SET_LOCAL(1, WASM_I32V(0))), |
175 WASM_RETURN1(WASM_GET_LOCAL(1)))); | 169 WASM_GET_LOCAL(1)); |
176 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } | 170 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } |
177 } | 171 } |
178 | 172 |
179 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Set_Global) { | 173 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Set_Global) { |
180 FLAG_wasm_simd_prototype = true; | 174 FLAG_wasm_simd_prototype = true; |
181 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 175 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
182 int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128); | 176 int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128); |
183 BUILD(r, WASM_BLOCK( | 177 BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))), |
184 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))), | 178 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0), |
185 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE( | 179 WASM_I32V(34))), |
186 1, WASM_GET_GLOBAL(0), WASM_I32V(34))), | 180 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(0), |
187 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE( | 181 WASM_I32V(45))), |
188 2, WASM_GET_GLOBAL(0), WASM_I32V(45))), | 182 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), |
189 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE( | 183 WASM_I32V(56))), |
190 3, WASM_GET_GLOBAL(0), WASM_I32V(56))), | 184 WASM_I32V(1)); |
191 WASM_RETURN1(WASM_I32V(1)))); | |
192 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } | 185 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } |
193 CHECK_EQ(*global, 23); | 186 CHECK_EQ(*global, 23); |
194 CHECK_EQ(*(global + 1), 34); | 187 CHECK_EQ(*(global + 1), 34); |
195 CHECK_EQ(*(global + 2), 45); | 188 CHECK_EQ(*(global + 2), 45); |
196 CHECK_EQ(*(global + 3), 56); | 189 CHECK_EQ(*(global + 3), 56); |
197 } | 190 } |
198 | 191 |
199 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Get_Global) { | 192 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Get_Global) { |
200 FLAG_wasm_simd_prototype = true; | 193 FLAG_wasm_simd_prototype = true; |
201 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 194 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
202 float* global = r.module().AddGlobal<float>(kWasmS128); | 195 float* global = r.module().AddGlobal<float>(kWasmS128); |
203 *(global) = 0.0; | 196 *(global) = 0.0; |
204 *(global + 1) = 1.5; | 197 *(global + 1) = 1.5; |
205 *(global + 2) = 2.25; | 198 *(global + 2) = 2.25; |
206 *(global + 3) = 3.5; | 199 *(global + 3) = 3.5; |
207 r.AllocateLocal(kWasmI32); | 200 r.AllocateLocal(kWasmI32); |
208 BUILD(r, WASM_BLOCK( | 201 BUILD( |
209 WASM_SET_LOCAL(1, WASM_I32V(1)), | 202 r, WASM_SET_LOCAL(1, WASM_I32V(1)), |
210 WASM_IF(WASM_F32_NE(WASM_F32(0.0), WASM_SIMD_F32x4_EXTRACT_LANE( | 203 WASM_IF(WASM_F32_NE(WASM_F32(0.0), |
211 0, WASM_GET_GLOBAL(0))), | 204 WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(0))), |
212 WASM_SET_LOCAL(1, WASM_I32V(0))), | 205 WASM_SET_LOCAL(1, WASM_I32V(0))), |
213 WASM_IF(WASM_F32_NE(WASM_F32(1.5), WASM_SIMD_F32x4_EXTRACT_LANE( | 206 WASM_IF(WASM_F32_NE(WASM_F32(1.5), |
214 1, WASM_GET_GLOBAL(0))), | 207 WASM_SIMD_F32x4_EXTRACT_LANE(1, WASM_GET_GLOBAL(0))), |
215 WASM_SET_LOCAL(1, WASM_I32V(0))), | 208 WASM_SET_LOCAL(1, WASM_I32V(0))), |
216 WASM_IF(WASM_F32_NE(WASM_F32(2.25), WASM_SIMD_F32x4_EXTRACT_LANE( | 209 WASM_IF(WASM_F32_NE(WASM_F32(2.25), |
217 2, WASM_GET_GLOBAL(0))), | 210 WASM_SIMD_F32x4_EXTRACT_LANE(2, WASM_GET_GLOBAL(0))), |
218 WASM_SET_LOCAL(1, WASM_I32V(0))), | 211 WASM_SET_LOCAL(1, WASM_I32V(0))), |
219 WASM_IF(WASM_F32_NE(WASM_F32(3.5), WASM_SIMD_F32x4_EXTRACT_LANE( | 212 WASM_IF(WASM_F32_NE(WASM_F32(3.5), |
220 3, WASM_GET_GLOBAL(0))), | 213 WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_GLOBAL(0))), |
221 WASM_SET_LOCAL(1, WASM_I32V(0))), | 214 WASM_SET_LOCAL(1, WASM_I32V(0))), |
222 WASM_RETURN1(WASM_GET_LOCAL(1)))); | 215 WASM_GET_LOCAL(1)); |
223 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } | 216 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } |
224 } | 217 } |
225 | 218 |
226 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Set_Global) { | 219 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Set_Global) { |
227 FLAG_wasm_simd_prototype = true; | 220 FLAG_wasm_simd_prototype = true; |
228 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 221 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
229 float* global = r.module().AddGlobal<float>(kWasmS128); | 222 float* global = r.module().AddGlobal<float>(kWasmS128); |
230 BUILD(r, WASM_BLOCK( | 223 BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))), |
231 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))), | 224 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0), |
232 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE( | 225 WASM_F32(45.5))), |
233 1, WASM_GET_GLOBAL(0), WASM_F32(45.5))), | 226 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(0), |
234 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE( | 227 WASM_F32(32.25))), |
235 2, WASM_GET_GLOBAL(0), WASM_F32(32.25))), | 228 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), |
236 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE( | 229 WASM_F32(65.0))), |
237 3, WASM_GET_GLOBAL(0), WASM_F32(65.0))), | 230 WASM_I32V(1)); |
238 WASM_RETURN1(WASM_I32V(1)))); | |
239 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } | 231 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } |
240 CHECK_EQ(*global, 13.5); | 232 CHECK_EQ(*global, 13.5); |
241 CHECK_EQ(*(global + 1), 45.5); | 233 CHECK_EQ(*(global + 1), 45.5); |
242 CHECK_EQ(*(global + 2), 32.25); | 234 CHECK_EQ(*(global + 2), 32.25); |
243 CHECK_EQ(*(global + 3), 65.0); | 235 CHECK_EQ(*(global + 3), 65.0); |
244 } | 236 } |
245 | 237 |
246 WASM_EXEC_COMPILED_TEST(Simd_I32x4_For) { | 238 WASM_EXEC_COMPILED_TEST(Simd_I32x4_For) { |
247 FLAG_wasm_simd_prototype = true; | 239 FLAG_wasm_simd_prototype = true; |
248 WasmRunner<int32_t> r(kExecuteCompiled); | 240 WasmRunner<int32_t> r(kExecuteCompiled); |
249 r.AllocateLocal(kWasmI32); | 241 r.AllocateLocal(kWasmI32); |
250 r.AllocateLocal(kWasmS128); | 242 r.AllocateLocal(kWasmS128); |
251 BUILD( | 243 BUILD(r, |
252 r, | 244 |
253 WASM_BLOCK( | 245 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), |
254 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), | 246 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(1), |
255 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(1), | 247 WASM_I32V(53))), |
256 WASM_I32V(53))), | 248 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(1), |
257 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(1), | 249 WASM_I32V(23))), |
258 WASM_I32V(23))), | 250 WASM_SET_LOCAL(0, WASM_I32V(0)), |
259 WASM_SET_LOCAL(0, WASM_I32V(0)), | 251 WASM_LOOP( |
260 WASM_LOOP(WASM_SET_LOCAL(1, WASM_SIMD_I32x4_ADD( | 252 WASM_SET_LOCAL( |
261 WASM_GET_LOCAL(1), | 253 1, WASM_SIMD_I32x4_ADD(WASM_GET_LOCAL(1), |
262 WASM_SIMD_I32x4_SPLAT(WASM_I32V(1)))), | 254 WASM_SIMD_I32x4_SPLAT(WASM_I32V(1)))), |
263 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(5)), | 255 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(5)), WASM_BR(1))), |
264 WASM_BR(1))), | 256 WASM_SET_LOCAL(0, WASM_I32V(1)), |
265 WASM_SET_LOCAL(0, WASM_I32V(1)), | 257 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), |
266 WASM_IF( | 258 WASM_I32V(36)), |
267 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), | 259 WASM_SET_LOCAL(0, WASM_I32V(0))), |
268 WASM_I32V(36)), | 260 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1)), |
269 WASM_SET_LOCAL(0, WASM_I32V(0))), | 261 WASM_I32V(58)), |
270 WASM_IF( | 262 WASM_SET_LOCAL(0, WASM_I32V(0))), |
271 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1)), | 263 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(1)), |
272 WASM_I32V(58)), | 264 WASM_I32V(28)), |
273 WASM_SET_LOCAL(0, WASM_I32V(0))), | 265 WASM_SET_LOCAL(0, WASM_I32V(0))), |
274 WASM_IF( | 266 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), |
275 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(1)), | 267 WASM_I32V(36)), |
276 WASM_I32V(28)), | 268 WASM_SET_LOCAL(0, WASM_I32V(0))), |
277 WASM_SET_LOCAL(0, WASM_I32V(0))), | 269 WASM_GET_LOCAL(0)); |
278 WASM_IF( | |
279 WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), | |
280 WASM_I32V(36)), | |
281 WASM_SET_LOCAL(0, WASM_I32V(0))), | |
282 WASM_RETURN1(WASM_GET_LOCAL(0)))); | |
283 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } | 270 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
284 } | 271 } |
285 | 272 |
286 WASM_EXEC_COMPILED_TEST(Simd_F32x4_For) { | 273 WASM_EXEC_COMPILED_TEST(Simd_F32x4_For) { |
287 FLAG_wasm_simd_prototype = true; | 274 FLAG_wasm_simd_prototype = true; |
288 WasmRunner<int32_t> r(kExecuteCompiled); | 275 WasmRunner<int32_t> r(kExecuteCompiled); |
289 r.AllocateLocal(kWasmI32); | 276 r.AllocateLocal(kWasmI32); |
290 r.AllocateLocal(kWasmS128); | 277 r.AllocateLocal(kWasmS128); |
291 BUILD(r, WASM_BLOCK( | 278 BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))), |
292 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))), | 279 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(1), |
293 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE( | 280 WASM_F32(19.5))), |
294 3, WASM_GET_LOCAL(1), WASM_F32(19.5))), | 281 WASM_SET_LOCAL(0, WASM_I32V(0)), |
295 WASM_SET_LOCAL(0, WASM_I32V(0)), | 282 WASM_LOOP( |
296 WASM_LOOP( | 283 WASM_SET_LOCAL( |
297 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_ADD( | 284 1, WASM_SIMD_F32x4_ADD(WASM_GET_LOCAL(1), |
298 WASM_GET_LOCAL(1), | 285 WASM_SIMD_F32x4_SPLAT(WASM_F32(2.0)))), |
299 WASM_SIMD_F32x4_SPLAT(WASM_F32(2.0)))), | 286 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(3)), WASM_BR(1))), |
300 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(3)), | 287 WASM_SET_LOCAL(0, WASM_I32V(1)), |
301 WASM_BR(1))), | 288 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), |
302 WASM_SET_LOCAL(0, WASM_I32V(1)), | 289 WASM_F32(27.25)), |
303 WASM_IF(WASM_F32_NE( | 290 WASM_SET_LOCAL(0, WASM_I32V(0))), |
304 WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), | 291 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), |
305 WASM_F32(27.25)), | 292 WASM_F32(25.5)), |
306 WASM_SET_LOCAL(0, WASM_I32V(0))), | 293 WASM_SET_LOCAL(0, WASM_I32V(0))), |
307 WASM_IF(WASM_F32_NE( | 294 WASM_GET_LOCAL(0)); |
308 WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), | |
309 WASM_F32(25.5)), | |
310 WASM_SET_LOCAL(0, WASM_I32V(0))), | |
311 WASM_RETURN1(WASM_GET_LOCAL(0)))); | |
312 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } | 295 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } |
313 } | 296 } |
OLD | NEW |