Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry committed Nov 5, 2019
1 parent 6689add commit 8f33792
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
39 changes: 21 additions & 18 deletions test/core/simd/meta/simd_f64x2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def gen_test_fn_template(self):
# Function template
tpl_func = ' (func (export "{}"){} (result v128) ({} {}{}))'

# Const data for min and max
lst_instr_with_const = [
# Raw data list specific for "const vs const" and "param vs const" tests
const_test_raw_data = [
[
[['0', '1'], ['0', '2']],
[['0', '1'], ['0', '2']]
Expand Down Expand Up @@ -64,8 +64,9 @@ def gen_test_fn_template(self):
]
]

# Assert data
lst_oprt_with_const_assert = {}
# Test data list combined with `const_test_raw_data` and corresponding ops and function names
# specific for "const vs const" and "param vs const" tests
const_test_data = {}

# Generate func and assert
for op in self.BINARY_OPS:
Expand All @@ -76,7 +77,7 @@ def gen_test_fn_template(self):
template.insert(len(template)-1, ' ;; {} const vs const'.format(op_name))

# Add const vs const cases
for case_data in lst_instr_with_const:
for case_data in const_test_raw_data:

func_name = "{}_with_const_{}".format(op_name, len(template)-7)
template.insert(len(template)-1,
Expand All @@ -86,18 +87,18 @@ def gen_test_fn_template(self):

ret_idx = 0 if op == 'min' else 1

if op not in lst_oprt_with_const_assert:
lst_oprt_with_const_assert[op] = []
if op not in const_test_data:
const_test_data[op] = []

lst_oprt_with_const_assert[op].append([func_name, case_data[1][ret_idx]])
const_test_data[op].append([func_name, case_data[1][ret_idx]])

# Add comment for the case script " ;; [f64x2.min, f64x2.max] param vs const"
template.insert(len(template)-1, ' ;; {} param vs const'.format(op_name))

case_cnt = 0

# Add param vs const cases
for case_data in lst_instr_with_const:
for case_data in const_test_raw_data:

func_name = "{}_with_const_{}".format(op_name, len(template)-7)

Expand All @@ -110,19 +111,17 @@ def gen_test_fn_template(self):
func_param_1 = '(local.get 0)'

template.insert(len(template)-1,
tpl_func.format(func_name, '(param v128)', op_name, func_param_0, ' ' + func_param_1))
tpl_func.format(func_name, ' (param v128)', op_name, func_param_0, ' ' + func_param_1))

ret_idx = 0 if op == 'min' else 1

if op not in lst_oprt_with_const_assert:
lst_oprt_with_const_assert[op] = []
if op not in const_test_data:
const_test_data[op] = []

lst_oprt_with_const_assert[op].append([func_name, case_data[0][1], case_data[1][ret_idx]])
const_test_data[op].append([func_name, case_data[0][1], case_data[1][ret_idx]])

case_cnt += 1

# print(lst_oprt_with_const_assert)

# Generate func for abs
op_name = self.full_op_name('abs')
template.insert(len(template)-1, '')
Expand Down Expand Up @@ -262,10 +261,10 @@ def gen_test_fn_template(self):
lst_diff_lane_vs_clause_assert.append('')

# Add test for operations with constant operands
for key in lst_oprt_with_const_assert:
for key in const_test_data:

case_cnt = 0
for case_data in lst_oprt_with_const_assert[key]:
for case_data in const_test_data[key]:

# Add comment for the param combination
if case_cnt == 0:
Expand Down Expand Up @@ -294,6 +293,8 @@ def gen_test_fn_template(self):

@property
def combine_ternary_arith_test_data(self):
# This method overrides the base class method from SimdArithmeticCase
# used for generating test data for min and max combination tests.
return {
'min-max': [
['1.125'] * 2, ['0.25'] * 2, ['0.125'] * 2, ['0.125'] * 2
Expand All @@ -305,6 +306,8 @@ def combine_ternary_arith_test_data(self):

@property
def combine_binary_arith_test_data(self):
# This method overrides the base class method from SimdArithmeticCase
# used for generating test data for min, max and abs combination tests.
return {
'min-abs': [
['-1.125'] * 2, ['0.125'] * 2, ['0.125'] * 2
Expand Down Expand Up @@ -440,4 +443,4 @@ def gen_test_cases():


if __name__ == '__main__':
gen_test_cases()
gen_test_cases()
32 changes: 16 additions & 16 deletions test/core/simd/simd_f64x2.wast
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
(func (export "f64x2.min_with_const_6") (result v128) (f64x2.min (v128.const f64x2 0x00 0x01) (v128.const f64x2 0x00 0x01)))
(func (export "f64x2.min_with_const_7") (result v128) (f64x2.min (v128.const f64x2 0x02 0x80000000) (v128.const f64x2 0x02 0x80000000)))
;; f64x2.min param vs const
(func (export "f64x2.min_with_const_9")(param v128) (result v128) (f64x2.min (local.get 0) (v128.const f64x2 0 1)))
(func (export "f64x2.min_with_const_10")(param v128) (result v128) (f64x2.min (v128.const f64x2 2 -3) (local.get 0)))
(func (export "f64x2.min_with_const_11")(param v128) (result v128) (f64x2.min (v128.const f64x2 0 1) (local.get 0)))
(func (export "f64x2.min_with_const_12")(param v128) (result v128) (f64x2.min (local.get 0) (v128.const f64x2 2 3)))
(func (export "f64x2.min_with_const_13")(param v128) (result v128) (f64x2.min (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.min_with_const_14")(param v128) (result v128) (f64x2.min (v128.const f64x2 0x02 0x80000000) (local.get 0)))
(func (export "f64x2.min_with_const_15")(param v128) (result v128) (f64x2.min (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.min_with_const_16")(param v128) (result v128) (f64x2.min (v128.const f64x2 0x02 0x80000000) (local.get 0)))
(func (export "f64x2.min_with_const_9") (param v128) (result v128) (f64x2.min (local.get 0) (v128.const f64x2 0 1)))
(func (export "f64x2.min_with_const_10") (param v128) (result v128) (f64x2.min (v128.const f64x2 2 -3) (local.get 0)))
(func (export "f64x2.min_with_const_11") (param v128) (result v128) (f64x2.min (v128.const f64x2 0 1) (local.get 0)))
(func (export "f64x2.min_with_const_12") (param v128) (result v128) (f64x2.min (local.get 0) (v128.const f64x2 2 3)))
(func (export "f64x2.min_with_const_13") (param v128) (result v128) (f64x2.min (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.min_with_const_14") (param v128) (result v128) (f64x2.min (v128.const f64x2 0x02 0x80000000) (local.get 0)))
(func (export "f64x2.min_with_const_15") (param v128) (result v128) (f64x2.min (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.min_with_const_16") (param v128) (result v128) (f64x2.min (v128.const f64x2 0x02 0x80000000) (local.get 0)))
;; f64x2.max const vs const
(func (export "f64x2.max_with_const_18") (result v128) (f64x2.max (v128.const f64x2 0 1) (v128.const f64x2 0 2)))
(func (export "f64x2.max_with_const_19") (result v128) (f64x2.max (v128.const f64x2 2 -3) (v128.const f64x2 1 3)))
Expand All @@ -33,14 +33,14 @@
(func (export "f64x2.max_with_const_24") (result v128) (f64x2.max (v128.const f64x2 0x00 0x01) (v128.const f64x2 0x00 0x01)))
(func (export "f64x2.max_with_const_25") (result v128) (f64x2.max (v128.const f64x2 0x02 0x80000000) (v128.const f64x2 0x02 0x80000000)))
;; f64x2.max param vs const
(func (export "f64x2.max_with_const_27")(param v128) (result v128) (f64x2.max (local.get 0) (v128.const f64x2 0 1)))
(func (export "f64x2.max_with_const_28")(param v128) (result v128) (f64x2.max (v128.const f64x2 2 -3) (local.get 0)))
(func (export "f64x2.max_with_const_29")(param v128) (result v128) (f64x2.max (v128.const f64x2 0 1) (local.get 0)))
(func (export "f64x2.max_with_const_30")(param v128) (result v128) (f64x2.max (local.get 0) (v128.const f64x2 2 3)))
(func (export "f64x2.max_with_const_31")(param v128) (result v128) (f64x2.max (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.max_with_const_32")(param v128) (result v128) (f64x2.max (v128.const f64x2 0x02 0x80000000) (local.get 0)))
(func (export "f64x2.max_with_const_33")(param v128) (result v128) (f64x2.max (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.max_with_const_34")(param v128) (result v128) (f64x2.max (v128.const f64x2 0x02 0x80000000) (local.get 0)))
(func (export "f64x2.max_with_const_27") (param v128) (result v128) (f64x2.max (local.get 0) (v128.const f64x2 0 1)))
(func (export "f64x2.max_with_const_28") (param v128) (result v128) (f64x2.max (v128.const f64x2 2 -3) (local.get 0)))
(func (export "f64x2.max_with_const_29") (param v128) (result v128) (f64x2.max (v128.const f64x2 0 1) (local.get 0)))
(func (export "f64x2.max_with_const_30") (param v128) (result v128) (f64x2.max (local.get 0) (v128.const f64x2 2 3)))
(func (export "f64x2.max_with_const_31") (param v128) (result v128) (f64x2.max (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.max_with_const_32") (param v128) (result v128) (f64x2.max (v128.const f64x2 0x02 0x80000000) (local.get 0)))
(func (export "f64x2.max_with_const_33") (param v128) (result v128) (f64x2.max (v128.const f64x2 0x00 0x01) (local.get 0)))
(func (export "f64x2.max_with_const_34") (param v128) (result v128) (f64x2.max (v128.const f64x2 0x02 0x80000000) (local.get 0)))

(func (export "f64x2.abs_with_const_35") (result v128) (f64x2.abs (v128.const f64x2 -0 -1)))
(func (export "f64x2.abs_with_const_36") (result v128) (f64x2.abs (v128.const f64x2 -2 -3)))
Expand Down

0 comments on commit 8f33792

Please sign in to comment.