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

Implement i64x2.bitmask (#368) #422

Merged
merged 1 commit into from
Feb 4, 2021
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
1 change: 1 addition & 0 deletions interpreter/binary/decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ let simd_prefix s =
| 0xbfl -> i32x4_extmul_high_i16x8_u
| 0xc0l -> i64x2_eq
| 0xc1l -> i64x2_neg
| 0xc4l -> i64x2_bitmask
| 0xcbl -> i64x2_shl
| 0xccl -> i64x2_shr_s
| 0xcdl -> i64x2_shr_u
Expand Down
1 change: 1 addition & 0 deletions interpreter/binary/encode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ let encode m =
| SimdBitmask Simd.I8x16 -> simd_op 0x64l
| SimdBitmask Simd.I16x8 -> simd_op 0x84l
| SimdBitmask Simd.I32x4 -> simd_op 0xa4l
| SimdBitmask Simd.I64x2 -> simd_op 0xc4l
| SimdBitmask (_) -> assert false

| _ -> assert false
Expand Down
1 change: 1 addition & 0 deletions interpreter/exec/eval_simd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ module SimdOp (SXX : Simd.S) (Value : ValueType with type t = SXX.t) = struct
| Simd.I8x16 -> SXX.I8x16.bitmask
| Simd.I16x8 -> SXX.I16x8.bitmask
| Simd.I32x4 -> SXX.I32x4.bitmask
| Simd.I64x2 -> SXX.I64x2.bitmask
| _ -> assert false
in I32 (f (of_value 1 v))

Expand Down
1 change: 1 addition & 0 deletions interpreter/syntax/operators.ml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ let i64x2_replace_lane imm = SimdReplace (V128Op.I64x2 imm)
let i64x2_eq = Binary (V128 V128Op.(I64x2 Eq))
let i64x2_ne = Binary (V128 V128Op.(I64x2 Ne))
let i64x2_neg = Unary (V128 V128Op.(I64x2 Neg))
let i64x2_bitmask = SimdBitmask Simd.I64x2
let i64x2_add = Binary (V128 V128Op.(I64x2 Add))
let i64x2_sub = Binary (V128 V128Op.(I64x2 Sub))
let i64x2_mul = Binary (V128 V128Op.(I64x2 Mul))
Expand Down
1 change: 1 addition & 0 deletions interpreter/text/arrange.ml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ struct
| Simd.I8x16 -> "i8x16.bitmask"
| Simd.I16x8 -> "i16x8.bitmask"
| Simd.I32x4 -> "i32x4.bitmask"
| Simd.I64x2 -> "i64x2.bitmask"
| _ -> assert false

end
Expand Down
3 changes: 1 addition & 2 deletions interpreter/text/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ rule token = parse
{ only ["i8x16"; "i16x8"; "i32x4"] s lexbuf;
UNARY (simd_int_op s i8x16_all_true i16x8_all_true i32x4_all_true unreachable) }
| (simd_int_shape as s)".bitmask"
{ only ["i8x16"; "i16x8"; "i32x4"] s lexbuf;
UNARY (simd_int_op s i8x16_bitmask i16x8_bitmask i32x4_bitmask unreachable) }
{ UNARY (simd_int_op s i8x16_bitmask i16x8_bitmask i32x4_bitmask i64x2_bitmask) }
| (simd_int_shape as s)".shl"
{ SHIFT (simd_int_op s i8x16_shl i16x8_shl i32x4_shl i64x2_shl) }
| (simd_int_shape as s)".shr_s"
Expand Down
7 changes: 7 additions & 0 deletions test/core/simd/simd_boolean.wast
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
(func (export "i32x4.any_true") (param $0 v128) (result i32) (v128.any_true (local.get $0)))
(func (export "i32x4.all_true") (param $0 v128) (result i32) (i32x4.all_true (local.get $0)))
(func (export "i32x4.bitmask") (param $0 v128) (result i32) (i32x4.bitmask (local.get $0)))

(func (export "i64x2.bitmask") (param $0 v128) (result i32) (i64x2.bitmask (local.get $0)))
)

;; i8x16
Expand Down Expand Up @@ -156,6 +158,11 @@
(assert_return (invoke "i32x4.bitmask" (v128.const i32x4 -1 0 1 0xF))
(i32.const 0x00000001))

(assert_return (invoke "i64x2.bitmask" (v128.const i64x2 0xFFFFFFFF_FFFFFFFF 0xFFFFFFFF_FFFFFFFF))
(i32.const 0x00000003))
(assert_return (invoke "i64x2.bitmask" (v128.const i64x2 -1 0xF))
(i32.const 0x00000001))

;; Combination

(module (memory 1)
Expand Down