Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/core/simd/meta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ Currently it only support following simd test files generation.
- 'simd_i16x8_cmp.wast'
- 'simd_i32x4_cmp.wast'
- 'simd_f32x4_cmp.wast'
- 'simd_f64x2_cmp.wast'
- 'simd_i8x16_arith.wast'
- 'simd_i16x8_arith.wast'
- 'simd_i32x4_arith.wast'
- 'simd_f32x4_arith.wast'
- 'simd_bitwise.wast'
- 'simd_i8x16_sat_arith.wast'
- 'simd_i16x8_sat_arith.wast'
- 'simd_f32x4.wast'


Usage:
Expand Down
14 changes: 13 additions & 1 deletion test/core/simd/meta/gen_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
'simd_i16x8_cmp',
'simd_i32x4_cmp',
'simd_f32x4_cmp',
'simd_f64x2_cmp',
'simd_i8x16_arith',
'simd_i16x8_arith',
'simd_i32x4_arith',
'simd_f32x4_arith',
'simd_sat_arith',
'simd_bitwise',
'simd_f32x4',
)


Expand All @@ -24,6 +32,10 @@ def gen_group_tests(mod_name):


def main():
"""
Default program entry
"""

parser = argparse.ArgumentParser(
description='Front-end script to call other modules to generate SIMD tests')
parser.add_argument('-a', '--all', dest='gen_all', action='store_true',
Expand All @@ -44,4 +56,4 @@ def main():

if __name__ == '__main__':
main()
print('Done.')
print('Done.')
27 changes: 22 additions & 5 deletions test/core/simd/meta/simd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
This python file is a tool class for SIMD and
Expand All @@ -9,13 +8,31 @@

class SIMD(object):

# Constant template
CONST = '({}.const {})'

# v128 Constant template
V128_CONST = '(v128.const {} {})'

# Params:
# val: constant data, string or list,
# lane_type: lane type, [i8x16, i16x8, i32x4, f32x4]
def const(self, val, lane_type):
"""
generation constant data, [e.g. i32, i64, f32, f64]
Params:
val: constant data, string or list,
lane_type: lane type, [i32, i64, f32, f64]
"""
return self.CONST.format(lane_type, ''.join(val))

def v128_const(self, val, lane_type):
"""
generation v128 constant data, [e.g. i8x16, i16x8, i32x4, f32x4]
Params:
val: constant data, string or list,
lane_type: lane type, [e.g. i8x16, i16x8, i32x4, f32x4]
"""

if lane_type.lower().find('x') == -1:
return self.const(val, lane_type)

lane_cnt = int(lane_type[1:].split('x')[1])

Expand Down Expand Up @@ -63,4 +80,4 @@ def v128_const(self, val, lane_type):
data_elem = ' '.join(data_elem)

# Returns v128 constant text
return self.V128_CONST.format(lane_type, data_elem)
return self.V128_CONST.format(lane_type, data_elem)
Loading