Skip to content
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
10 changes: 4 additions & 6 deletions interpreter/text/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ let vec_lane_lit shape l at =
| V128.F32x4 () -> NumPat (F32 (F32.of_string l) @@@ at)
| V128.F64x2 () -> NumPat (F64 (F64.of_string l) @@@ at)

let shuffle_lit ss loc =
if not (List.length ss = 16) then
error (at loc) "invalid lane length";
List.map (fun s -> nat8 s.it loc) ss

let nanop f nan =
let open Source in
let open Value in
Expand Down Expand Up @@ -651,7 +646,10 @@ plaininstr :
| VEC_TEST { fun c -> $1 }
| VEC_SHIFT { fun c -> $1 }
| VEC_BITMASK { fun c -> $1 }
| VEC_SHUFFLE list(num) { fun c -> i8x16_shuffle (shuffle_lit $2 $sloc) }
| VEC_SHUFFLE list(laneidx)
{ if List.length $2 <> 16 then
error (at $sloc) "wrong number of lane indices";
fun c -> i8x16_shuffle $2 }
| VEC_SPLAT { fun c -> $1 }
| VEC_EXTRACT laneidx { fun c -> $1 $2 }
| VEC_REPLACE laneidx { fun c -> $1 $2 }
Expand Down
22 changes: 11 additions & 11 deletions test/core/simd/simd_lane.wast
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,14 @@
;; i8x16.shuffle: the 1st argument must be 16-byte literals in 0..32
(assert_malformed (module quote "(func (param v128) (result v128)"
"(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 (local.get 0) (local.get 0)))")
"invalid lane length")
"wrong number of lane indices")
(assert_malformed (module quote "(func (param v128) (result v128)"
"(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (local.get 0) (local.get 0)))")
"invalid lane length")
"wrong number of lane indices")
(assert_malformed (module quote "(func (result v128)"
"(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -1"
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0)"
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "i8 constant out of range")
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "unexpected token")
(assert_malformed (module quote "(func (result v128)"
"(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 256"
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0)"
Expand Down Expand Up @@ -600,27 +600,27 @@
(assert_malformed (module quote "(func (result v128) "
"(i8x16.shuffle (v128.const i8x16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31) "
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) "
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "invalid lane length")
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "wrong number of lane indices")
(assert_malformed (module quote "(func (result v128) "
"(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15.0 "
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) "
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "i8 constant out of range")
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "unexpected token")
(assert_malformed (module quote "(func (result v128) "
"(i8x16.shuffle 0.5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 "
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) "
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "i8 constant out of range")
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "unexpected token")
(assert_malformed (module quote "(func (result v128) "
"(i8x16.shuffle -inf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 "
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) "
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "i8 constant out of range")
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "unexpected token")
(assert_malformed (module quote "(func (result v128) "
"(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 inf "
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) "
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "i8 constant out of range")
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "unexpected token")
(assert_malformed (module quote "(func (result v128) "
"(i8x16.shuffle nan 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 "
"(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) "
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "i8 constant out of range")
"(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "unexpected token")


;; Combination with each other
Expand Down Expand Up @@ -1243,7 +1243,7 @@
" )"
")"
)
"invalid lane length"
"wrong number of lane indices"
)
(assert_invalid
(module
Expand All @@ -1261,5 +1261,5 @@
" (i8x16.shuffle)"
")"
)
"invalid lane length"
"wrong number of lane indices"
)
Loading