diff --git a/interpreter/text/parser.mly b/interpreter/text/parser.mly index 8d0cfdd1e3..b1a32431f2 100644 --- a/interpreter/text/parser.mly +++ b/interpreter/text/parser.mly @@ -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 @@ -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 } diff --git a/test/core/simd/simd_lane.wast b/test/core/simd/simd_lane.wast index fc65d798c5..0bbf382c8a 100644 --- a/test/core/simd/simd_lane.wast +++ b/test/core/simd/simd_lane.wast @@ -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)" @@ -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 @@ -1243,7 +1243,7 @@ " )" ")" ) - "invalid lane length" + "wrong number of lane indices" ) (assert_invalid (module @@ -1261,5 +1261,5 @@ " (i8x16.shuffle)" ")" ) - "invalid lane length" + "wrong number of lane indices" )