@@ -31,7 +31,6 @@ class Simdf32x4Case(Simdf32x4ArithmeticCase):
31
31
binary_nan_template = ('({assert_type} (invoke "{func}" ' , '{operand_1}' , '{operand_2}))' )
32
32
unary_nan_template = ('({assert_type} (invoke "{func}" ' , '{operand}))' )
33
33
34
-
35
34
def full_op_name (self , op_name ):
36
35
return self .LANE_TYPE + '.' + op_name
37
36
@@ -139,43 +138,36 @@ def gen_test_func_template(self):
139
138
[
140
139
'f32x4.min' ,
141
140
[['nan' , '0' , '0' , '1' ], ['0' , '-nan' , '1' , '0' ]],
142
- [['nan' , '- nan' , '0' , '0' ]],
141
+ [['nan:canonical ' , 'nan:canonical ' , '0' , '0' ]],
143
142
['f32x4' , 'f32x4' , 'f32x4' ]
144
143
],
145
144
[
146
145
'f32x4.min' ,
147
146
[['nan' , '0' , '0' , '0' ], ['0' , '-nan' , '1' , '0' ]],
148
- [['nan' , '- nan' , '0' , '0' ]],
147
+ [['nan:canonical ' , 'nan:canonical ' , '0' , '0' ]],
149
148
['f32x4' , 'f32x4' , 'f32x4' ]
150
149
],
151
150
[
152
151
'f32x4.max' ,
153
152
[['nan' , '0' , '0' , '1' ], ['0' , '-nan' , '1' , '0' ]],
154
- [['nan' , '- nan' , '1' , '1' ]],
153
+ [['nan:canonical ' , 'nan:canonical ' , '1' , '1' ]],
155
154
['f32x4' , 'f32x4' , 'f32x4' ]
156
155
],
157
156
[
158
157
'f32x4.max' ,
159
158
[['nan' , '0' , '0' , '0' ], ['0' , '-nan' , '1' , '0' ]],
160
- [['nan' , '- nan' , '1' , '0' ]],
159
+ [['nan:canonical ' , 'nan:canonical ' , '1' , '0' ]],
161
160
['f32x4' , 'f32x4' , 'f32x4' ]
162
161
]
163
162
]
164
163
165
- # Case number
166
- case_cnt = 0
167
-
168
- # Template for func name to extract a lane
169
- tpl_func_by_lane = 'call_indirect_vv_v_f32x4_extract_lane_{}'
170
-
171
164
# Template for assert
172
- tpl_assert = '({assert_type} \n ' \
165
+ tpl_assert = '(assert_return \n ' \
173
166
' (invoke "{func}"\n ' \
174
167
' {operand_1}\n ' \
175
168
' {operand_2}\n ' \
176
- ' {operand_3}\n ' \
177
169
' )\n ' \
178
- '{expected_result}' \
170
+ ' {expected_result}\n ' \
179
171
')'
180
172
181
173
lst_diff_lane_vs_clause_assert = []
@@ -184,79 +176,16 @@ def gen_test_func_template(self):
184
176
lst_diff_lane_vs_clause_assert .append ('' )
185
177
lst_diff_lane_vs_clause_assert .append (';; Test different lanes go through different if-then clauses' )
186
178
187
- template .insert (len (template )- 1 , '' )
188
- template .insert (len (template )- 1 , ' ;; Test different lanes go through different if-then clauses' )
189
-
190
- # Add test case for test different lanes go through different if-then clauses
191
- template .insert (len (template )- 1 , ' (type $vv_v (func (param v128 v128) (result v128)))\n '
192
- ' (table funcref (elem $f32x4_min $f32x4_max))\n '
193
- '\n '
194
- ' (func $f32x4_min (type $vv_v)\n '
195
- ' (f32x4.min (local.get 0) (local.get 1))\n '
196
- ' )\n '
197
- '\n '
198
- ' (func $f32x4_max (type $vv_v)\n '
199
- ' (f32x4.max (local.get 0) (local.get 1))\n '
200
- ' )\n '
201
- '\n '
202
- ' (func (export "call_indirect_vv_v_f32x4_extract_lane_0")\n '
203
- ' (param v128 v128 i32) (result f32)\n '
204
- ' (f32x4.extract_lane 0\n '
205
- ' (call_indirect (type $vv_v) (local.get 0) (local.get 1) (local.get 2))\n '
206
- ' )\n '
207
- ' )\n '
208
- ' (func (export "call_indirect_vv_v_f32x4_extract_lane_1")\n '
209
- ' (param v128 v128 i32) (result f32)\n '
210
- ' (f32x4.extract_lane 1\n '
211
- ' (call_indirect (type $vv_v) (local.get 0) (local.get 1) (local.get 2))\n '
212
- ' )\n '
213
- ' )\n '
214
- ' (func (export "call_indirect_vv_v_f32x4_extract_lane_2")\n '
215
- ' (param v128 v128 i32) (result f32)\n '
216
- ' (f32x4.extract_lane 2\n '
217
- ' (call_indirect (type $vv_v) (local.get 0) (local.get 1) (local.get 2))\n '
218
- ' )\n '
219
- ' )\n '
220
- ' (func (export "call_indirect_vv_v_f32x4_extract_lane_3")\n '
221
- ' (param v128 v128 i32) (result f32)\n '
222
- ' (f32x4.extract_lane 3\n '
223
- ' (call_indirect (type $vv_v) (local.get 0) (local.get 1) (local.get 2))\n '
224
- ' )\n '
225
- ' )' )
226
-
227
179
for case_data in lst_diff_lane_vs_clause :
228
180
229
- lst_diff_lane_vs_clause_assert .append (';; {lane_type} {index}' .format (lane_type = case_data [0 ], index = case_cnt ))
230
-
231
- # generate assert for every data lane
232
- for lane_idx in range (0 , len (case_data [2 ][0 ])):
233
-
234
- # get the result by lane
235
- ret = case_data [2 ][0 ][lane_idx ]
236
-
237
- idx_func = '0' if 'min' in case_data [0 ] else '1'
238
-
239
- # append assert
240
- if 'nan' in ret :
241
-
242
- lst_diff_lane_vs_clause_assert .append (tpl_assert .format (assert_type = 'assert_return_canonical_nan' ,
243
- func = tpl_func_by_lane .format (lane_idx ),
244
- operand_1 = self .v128_const ('f32x4' , case_data [1 ][0 ]),
245
- operand_2 = self .v128_const ('f32x4' , case_data [1 ][1 ]),
246
- operand_3 = self .v128_const ('i32' , idx_func ),
247
- expected_result = '' ))
248
- else :
249
-
250
- lst_diff_lane_vs_clause_assert .append (tpl_assert .format (assert_type = 'assert_return' ,
251
- func = tpl_func_by_lane .format (lane_idx ),
252
- operand_1 = self .v128_const ('f32x4' , case_data [1 ][0 ]),
253
- operand_2 = self .v128_const ('f32x4' , case_data [1 ][1 ]),
254
- operand_3 = self .v128_const ('i32' , idx_func ),
255
- expected_result = ' ' + self .v128_const ('f32' , ret )+ '\n ' ))
181
+ lst_diff_lane_vs_clause_assert .append (';; {lane_type}' .format (lane_type = case_data [0 ]))
256
182
257
- case_cnt += 1
258
- if case_cnt == 2 :
259
- case_cnt = 0
183
+ lst_diff_lane_vs_clause_assert .append (tpl_assert .format (
184
+ func = case_data [0 ],
185
+ operand_1 = self .v128_const (case_data [3 ][0 ], case_data [1 ][0 ]),
186
+ operand_2 = self .v128_const (case_data [3 ][1 ], case_data [1 ][1 ]),
187
+ expected_result = self .v128_const (case_data [3 ][2 ], case_data [2 ][0 ])
188
+ ))
260
189
261
190
lst_diff_lane_vs_clause_assert .append ('' )
262
191
@@ -312,11 +241,7 @@ def combine_binary_arith_test_data(self):
312
241
}
313
242
314
243
def get_normal_case (self ):
315
- """Normal test cases from WebAssembly core tests, 4 assert statements:
316
- assert_return
317
- assert_return_canonical_nan
318
- assert_return_arithmetic_nan
319
- assert_malformed
244
+ """Normal test cases from WebAssembly core tests.
320
245
"""
321
246
cases = []
322
247
binary_test_data = []
@@ -331,34 +256,28 @@ def get_normal_case(self):
331
256
# Normal floating point numbers as the results
332
257
binary_test_data .append (['assert_return' , op_name , p1 , p2 , result ])
333
258
else :
334
- # Since the results contain the 'nan' string, it should be in the
335
- # assert_return_canonical_nan statements
336
- binary_test_data .append (['assert_return_canonical_nan_f32x4 ' , op_name , p1 , p2 ])
259
+ # Since the results contain the 'nan' string, the result literals would be
260
+ # nan:canonical
261
+ binary_test_data .append (['assert_return ' , op_name , p1 , p2 , 'nan:canonical' ])
337
262
338
263
for p1 in self .LITERAL_NUMBERS :
339
264
for p2 in self .LITERAL_NUMBERS :
340
265
result = self .floatOp .binary_op (op , p1 , p2 , hex_form = False )
341
266
binary_test_data .append (['assert_return' , op_name , p1 , p2 , result ])
342
267
343
- # assert_return_canonical_nan and assert_return_arithmetic_nan cases
344
268
for p1 in self .NAN_NUMBERS :
345
269
for p2 in self .FLOAT_NUMBERS :
346
270
if 'nan:' in p1 or 'nan:' in p2 :
347
- # When the arguments contain 'nan:', always use assert_return_arithmetic_nan
348
- # statements for the cases. Since there 2 parameters for binary operation and
349
- # the order of the parameters matter. Different order makes different cases.
350
- binary_test_data .append (['assert_return_arithmetic_nan_f32x4' , op_name , p1 , p2 ])
351
- binary_test_data .append (['assert_return_arithmetic_nan_f32x4' , op_name , p2 , p1 ])
271
+ # When the arguments contain 'nan:', the result literal is nan:arithmetic
272
+ binary_test_data .append (['assert_return' , op_name , p1 , p2 , 'nan:arithmetic' ])
352
273
else :
353
- # No 'nan' string found, then it should be assert_return_canonical_nan.
354
- binary_test_data .append (['assert_return_canonical_nan_f32x4' , op_name , p1 , p2 ])
355
- binary_test_data .append (['assert_return_canonical_nan_f32x4' , op_name , p2 , p1 ])
274
+ # No 'nan' string found, then the result literal is nan:canonical
275
+ binary_test_data .append (['assert_return' , op_name , p1 , p2 , 'nan:canonical' ])
356
276
for p2 in self .NAN_NUMBERS :
357
- # Both parameters contain 'nan', then there must be no assert_return.
358
277
if 'nan:' in p1 or 'nan:' in p2 :
359
- binary_test_data .append (['assert_return_arithmetic_nan_f32x4 ' , op_name , p1 , p2 ])
278
+ binary_test_data .append (['assert_return ' , op_name , p1 , p2 , 'nan:arithmetic' ])
360
279
else :
361
- binary_test_data .append (['assert_return_canonical_nan_f32x4 ' , op_name , p1 , p2 ])
280
+ binary_test_data .append (['assert_return ' , op_name , p1 , p2 , 'nan:canonical' ])
362
281
363
282
for case in binary_test_data :
364
283
cases .append (self .single_binary_test (case ))
0 commit comments