Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit a1a5749

Browse files
committed
Adding new spec tests
1 parent 85e6e7a commit a1a5749

File tree

11 files changed

+14915
-0
lines changed

11 files changed

+14915
-0
lines changed

test/core/simd/simd_address.wast

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
;; Load/Store v128 data with different valid offset/alignment
2+
3+
(module
4+
(memory 1)
5+
(data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\10\11\12\13\14\15")
6+
(data (offset (i32.const 65505)) "\16\17\18\19\20\21\22\23\24\25\26\27\28\29\30\31")
7+
8+
(func (export "load_data_1") (param $i i32) (result v128)
9+
(v128.load offset=0 (local.get $i)) ;; 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15
10+
)
11+
(func (export "load_data_2") (param $i i32) (result v128)
12+
(v128.load align=1 (local.get $i)) ;; 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15
13+
)
14+
(func (export "load_data_3") (param $i i32) (result v128)
15+
(v128.load offset=1 align=1 (local.get $i)) ;; 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x00
16+
)
17+
(func (export "load_data_4") (param $i i32) (result v128)
18+
(v128.load offset=2 align=1 (local.get $i)) ;; 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x00 0x00
19+
)
20+
(func (export "load_data_5") (param $i i32) (result v128)
21+
(v128.load offset=15 align=1 (local.get $i)) ;; 0x15 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
22+
)
23+
24+
(func (export "store_data_0") (result v128)
25+
(v128.store offset=0 (i32.const 0) (v128.const f32x4 0 1 2 3))
26+
(v128.load offset=0 (i32.const 0))
27+
)
28+
(func (export "store_data_1") (result v128)
29+
(v128.store align=1 (i32.const 0) (v128.const i32x4 0 1 2 3))
30+
(v128.load align=1 (i32.const 0))
31+
)
32+
(func (export "store_data_2") (result v128)
33+
(v128.store offset=1 align=1 (i32.const 0) (v128.const i16x8 0 1 2 3 4 5 6 7))
34+
(v128.load offset=1 align=1 (i32.const 0))
35+
)
36+
(func (export "store_data_3") (result v128)
37+
(v128.store offset=2 align=1 (i32.const 0) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
38+
(v128.load offset=2 align=1 (i32.const 0))
39+
)
40+
(func (export "store_data_4") (result v128)
41+
(v128.store offset=15 align=1 (i32.const 0) (v128.const i32x4 0 1 2 3))
42+
(v128.load offset=15 (i32.const 0))
43+
)
44+
(func (export "store_data_5") (result v128)
45+
(v128.store offset=65520 align=1 (i32.const 0) (v128.const i32x4 0 1 2 3))
46+
(v128.load offset=65520 (i32.const 0))
47+
)
48+
)
49+
50+
(assert_return (invoke "load_data_1" (i32.const 0)) (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
51+
(assert_return (invoke "load_data_2" (i32.const 0)) (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
52+
(assert_return (invoke "load_data_3" (i32.const 0)) (v128.const i32x4 0x04030201 0x08070605 0x12111009 0x00151413))
53+
(assert_return (invoke "load_data_4" (i32.const 0)) (v128.const i32x4 0x05040302 0x09080706 0x13121110 0x00001514))
54+
(assert_return (invoke "load_data_5" (i32.const 0)) (v128.const i32x4 0x00000015 0x00000000 0x00000000 0x00000000))
55+
56+
(assert_return (invoke "load_data_1" (i32.const 0)) (v128.const i16x8 0x0100 0x0302 0x0504 0x0706 0x0908 0x1110 0x1312 0x1514))
57+
(assert_return (invoke "load_data_2" (i32.const 0)) (v128.const i16x8 0x0100 0x0302 0x0504 0x0706 0x0908 0x1110 0x1312 0x1514))
58+
(assert_return (invoke "load_data_3" (i32.const 0)) (v128.const i16x8 0x0201 0x0403 0x0605 0x0807 0x1009 0x1211 0x1413 0x0015))
59+
(assert_return (invoke "load_data_4" (i32.const 0)) (v128.const i16x8 0x0302 0x0504 0x0706 0x0908 0x1110 0x1312 0x1514 0x0000))
60+
(assert_return (invoke "load_data_5" (i32.const 0)) (v128.const i16x8 0x0015 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000))
61+
62+
(assert_return (invoke "load_data_1" (i32.const 0)) (v128.const i8x16 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15))
63+
(assert_return (invoke "load_data_2" (i32.const 0)) (v128.const i8x16 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15))
64+
(assert_return (invoke "load_data_3" (i32.const 0)) (v128.const i8x16 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x00))
65+
(assert_return (invoke "load_data_4" (i32.const 0)) (v128.const i8x16 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x00 0x00))
66+
(assert_return (invoke "load_data_5" (i32.const 0)) (v128.const i8x16 0x15 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00))
67+
68+
(assert_return (invoke "load_data_1" (i32.const 65505)) (v128.const i32x4 0x19181716 0x23222120 0x27262524 0x31302928))
69+
(assert_return (invoke "load_data_2" (i32.const 65505)) (v128.const i32x4 0x19181716 0x23222120 0x27262524 0x31302928))
70+
(assert_return (invoke "load_data_3" (i32.const 65505)) (v128.const i32x4 0x20191817 0x24232221 0x28272625 0x00313029))
71+
(assert_return (invoke "load_data_4" (i32.const 65505)) (v128.const i32x4 0x21201918 0x25242322 0x29282726 0x00003130))
72+
(assert_return (invoke "load_data_5" (i32.const 65505)) (v128.const i32x4 0x00000031 0x00000000 0x00000000 0x00000000))
73+
74+
(assert_return (invoke "load_data_1" (i32.const 65505)) (v128.const i16x8 0x1716 0x1918 0x2120 0x2322 0x2524 0x2726 0x2928 0x3130))
75+
(assert_return (invoke "load_data_2" (i32.const 65505)) (v128.const i16x8 0x1716 0x1918 0x2120 0x2322 0x2524 0x2726 0x2928 0x3130))
76+
(assert_return (invoke "load_data_3" (i32.const 65505)) (v128.const i16x8 0x1817 0x2019 0x2221 0x2423 0x2625 0x2827 0x3029 0x0031))
77+
(assert_return (invoke "load_data_4" (i32.const 65505)) (v128.const i16x8 0x1918 0x2120 0x2322 0x2524 0x2726 0x2928 0x3130 0x0000))
78+
(assert_return (invoke "load_data_5" (i32.const 65505)) (v128.const i16x8 0x0031 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000))
79+
80+
(assert_return (invoke "load_data_1" (i32.const 65505)) (v128.const i8x16 0x16 0x17 0x18 0x19 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x30 0x31))
81+
(assert_return (invoke "load_data_2" (i32.const 65505)) (v128.const i8x16 0x16 0x17 0x18 0x19 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x30 0x31))
82+
(assert_return (invoke "load_data_3" (i32.const 65505)) (v128.const i8x16 0x17 0x18 0x19 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x30 0x31 0x00))
83+
(assert_return (invoke "load_data_4" (i32.const 65505)) (v128.const i8x16 0x18 0x19 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x30 0x31 0x00 0x00))
84+
(assert_return (invoke "load_data_5" (i32.const 65505)) (v128.const i8x16 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00))
85+
86+
(assert_trap (invoke "load_data_5" (i32.const 65506)) "out of bounds memory access")
87+
88+
(assert_return (invoke "store_data_0") (v128.const f32x4 0 1 2 3))
89+
(assert_return (invoke "store_data_1") (v128.const i32x4 0 1 2 3))
90+
(assert_return (invoke "store_data_2") (v128.const i16x8 0 1 2 3 4 5 6 7))
91+
(assert_return (invoke "store_data_3") (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
92+
(assert_return (invoke "store_data_4") (v128.const i32x4 0 1 2 3))
93+
(assert_return (invoke "store_data_5") (v128.const i32x4 0 1 2 3))
94+
95+
96+
;; Load/Store v128 data with invalid offset
97+
98+
(module
99+
(memory 1)
100+
(func (export "v128.load_offset_65521")
101+
(drop (v128.load offset=65521 (i32.const 0)))
102+
)
103+
)
104+
(assert_trap (invoke "v128.load_offset_65521") "out of bounds memory access")
105+
106+
(assert_malformed
107+
(module quote
108+
"(memory 1)"
109+
"(func"
110+
" (drop (v128.load offset=-1 (i32.const 0)))"
111+
")"
112+
)
113+
"unknown operator"
114+
)
115+
116+
(module
117+
(memory 1)
118+
(func (export "v128.store_offset_65521")
119+
(v128.store offset=65521 (i32.const 0) (v128.const i32x4 0 0 0 0))
120+
)
121+
)
122+
(assert_trap (invoke "v128.store_offset_65521") "out of bounds memory access")
123+
124+
(assert_malformed
125+
(module quote
126+
"(memory 1)"
127+
"(func"
128+
" (v128.store offset=-1 (i32.const 0) (v128.const i32x4 0 0 0 0))"
129+
")"
130+
)
131+
"unknown operator"
132+
)
133+
134+
135+
;; Offset constant out of range
136+
137+
(assert_malformed
138+
(module quote
139+
"(memory 1)"
140+
"(func (drop (v128.load offset=4294967296 (i32.const 0))))"
141+
)
142+
"i32 constant"
143+
)
144+
145+
(assert_malformed
146+
(module quote
147+
"(memory 1)"
148+
"(func (v128.store offset=4294967296 (i32.const 0) (v128.const i32x4 0 0 0 0)))"
149+
)
150+
"i32 constant"
151+
)

test/core/simd/simd_align.wast

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
;; Vaild alignment (align=1, 2, 4, 8, 16)
2+
3+
(module
4+
(memory 1)
5+
(data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\10\11\12\13\14\15")
6+
7+
(func (export "v128.load_align_1") (result v128)
8+
(v128.load align=1 (i32.const 0))
9+
)
10+
(func (export "v128.load_align_2") (result v128)
11+
(v128.load align=2 (i32.const 0))
12+
)
13+
(func (export "v128.load_align_4") (result v128)
14+
(v128.load align=4 (i32.const 0))
15+
)
16+
(func (export "v128.load_align_8") (result v128)
17+
(v128.load align=8 (i32.const 0))
18+
)
19+
(func (export "v128.load_align_16") (result v128)
20+
(v128.load align=16 (i32.const 0))
21+
)
22+
23+
(func (export "v128.store_align_1") (result v128)
24+
(v128.store align=1 (i32.const 0) (v128.const i32x4 0 1 2 3))
25+
(v128.load (i32.const 0))
26+
)
27+
(func (export "v128.store_align_2") (result v128)
28+
(v128.store align=2 (i32.const 0) (v128.const i32x4 0 1 2 3))
29+
(v128.load (i32.const 0))
30+
)
31+
(func (export "v128.store_align_4") (result v128)
32+
(v128.store align=4 (i32.const 0) (v128.const i32x4 0 1 2 3))
33+
(v128.load (i32.const 0))
34+
)
35+
(func (export "v128.store_align_8") (result v128)
36+
(v128.store align=8 (i32.const 0) (v128.const i32x4 0 1 2 3))
37+
(v128.load (i32.const 0))
38+
)
39+
(func (export "v128.store_align_16") (result v128)
40+
(v128.store align=16 (i32.const 0) (v128.const i32x4 0 1 2 3))
41+
(v128.load (i32.const 0))
42+
)
43+
)
44+
45+
(assert_return (invoke "v128.load_align_1") (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
46+
(assert_return (invoke "v128.load_align_2") (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
47+
(assert_return (invoke "v128.load_align_4") (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
48+
(assert_return (invoke "v128.load_align_8") (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
49+
(assert_return (invoke "v128.load_align_16") (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
50+
51+
(assert_return (invoke "v128.store_align_1") (v128.const i32x4 0 1 2 3))
52+
(assert_return (invoke "v128.store_align_2") (v128.const i32x4 0 1 2 3))
53+
(assert_return (invoke "v128.store_align_4") (v128.const i32x4 0 1 2 3))
54+
(assert_return (invoke "v128.store_align_8") (v128.const i32x4 0 1 2 3))
55+
(assert_return (invoke "v128.store_align_16") (v128.const i32x4 0 1 2 3))
56+
57+
58+
;; Invalid alignment
59+
60+
(assert_invalid
61+
(module
62+
(memory 1)
63+
(func (drop (v128.load align=32 (i32.const 0))))
64+
)
65+
"alignment must not be larger than natural"
66+
)
67+
(assert_malformed
68+
(module quote
69+
"(memory 1)"
70+
"(func (drop (v128.load align=-1 (i32.const 0))))"
71+
)
72+
"unknown operator"
73+
)
74+
(assert_malformed
75+
(module quote
76+
"(memory 1)"
77+
"(func (drop (v128.load align=0 (i32.const 0))))"
78+
)
79+
"alignment must be a power of two"
80+
)
81+
(assert_malformed
82+
(module quote
83+
"(memory 1)"
84+
"(func (drop (v128.load align=7 (i32.const 0))))"
85+
)
86+
"alignment must be a power of two"
87+
)
88+
89+
(assert_invalid
90+
(module
91+
(memory 0)
92+
(func(v128.store align=32 (i32.const 0) (v128.const i32x4 0 0 0 0)))
93+
)
94+
"alignment must not be larger than natural"
95+
)
96+
(assert_malformed
97+
(module quote
98+
"(memory 1)"
99+
" (func (v128.store align=-1 (i32.const 0) (v128.const i32x4 0 0 0 0)))"
100+
)
101+
"unknown operator"
102+
)
103+
(assert_malformed
104+
(module quote
105+
"(memory 0)"
106+
" (func (v128.store align=0 (i32.const 0) (v128.const i32x4 0 0 0 0)))"
107+
)
108+
"alignment must be a power of two"
109+
)
110+
(assert_malformed
111+
(module quote
112+
"(memory 0)"
113+
" (func (v128.store align=7 (i32.const 0) (v128.const i32x4 0 0 0 0)))"
114+
)
115+
"alignment must be a power of two"
116+
)
117+
118+
;; Test that misaligned SIMD loads/stores don't trap
119+
120+
(module
121+
(memory 1 1)
122+
(func (export "v128.load align=16") (param $address i32) (result v128)
123+
(v128.load align=16 (local.get $address))
124+
)
125+
(func (export "v128.store align=16") (param $address i32) (param $value v128)
126+
(v128.store align=16 (local.get $address) (local.get $value))
127+
)
128+
)
129+
130+
(assert_return (invoke "v128.load align=16" (i32.const 0)) (v128.const i32x4 0 0 0 0))
131+
(assert_return (invoke "v128.load align=16" (i32.const 1)) (v128.const i32x4 0 0 0 0))
132+
(assert_return (invoke "v128.store align=16" (i32.const 1) (v128.const i8x16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)))
133+
(assert_return (invoke "v128.load align=16" (i32.const 0)) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
134+
135+
;; Test aligned and unaligned read/write
136+
137+
(module
138+
(memory 1)
139+
(func (export "v128_unalign_read_and_write") (result v128)
140+
(local v128)
141+
(v128.store (i32.const 0) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
142+
(v128.load (i32.const 0))
143+
)
144+
(func (export "v128_aligned_read_and_write") (result v128)
145+
(local v128)
146+
(v128.store align=2 (i32.const 0) (v128.const i16x8 0 1 2 3 4 5 6 7))
147+
(v128.load align=2 (i32.const 0))
148+
)
149+
(func (export "v128_aligned_read_and_unalign_write") (result v128)
150+
(local v128)
151+
(v128.store (i32.const 0) (v128.const i32x4 0 1 2 3))
152+
(v128.load align=2 (i32.const 0))
153+
)
154+
(func (export "v128_unalign_read_and_aligned_write") (result v128)
155+
(local v128)
156+
(v128.store align=2 (i32.const 0) (v128.const i32x4 0 1 2 3))
157+
(v128.load (i32.const 0))
158+
)
159+
)
160+
161+
(assert_return (invoke "v128_unalign_read_and_write") (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
162+
(assert_return (invoke "v128_aligned_read_and_write") (v128.const i16x8 0 1 2 3 4 5 6 7))
163+
(assert_return (invoke "v128_aligned_read_and_unalign_write") (v128.const i32x4 0 1 2 3))
164+
(assert_return (invoke "v128_unalign_read_and_aligned_write") (v128.const i32x4 0 1 2 3))

0 commit comments

Comments
 (0)