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

Commit ef06db0

Browse files
committed
Implement i64x2.bitmask (#368)
This was accepted into this proposal in #410.
1 parent b300c7a commit ef06db0

File tree

7 files changed

+13
-2
lines changed

7 files changed

+13
-2
lines changed

interpreter/binary/decode.ml

+1
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ let simd_prefix s =
395395
| 0xbfl -> i32x4_extmul_high_i16x8_u
396396
| 0xc0l -> i64x2_eq
397397
| 0xc1l -> i64x2_neg
398+
| 0xc4l -> i64x2_bitmask
398399
| 0xcbl -> i64x2_shl
399400
| 0xccl -> i64x2_shr_s
400401
| 0xcdl -> i64x2_shr_u

interpreter/binary/encode.ml

+1
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ let encode m =
622622
| SimdBitmask Simd.I8x16 -> simd_op 0x64l
623623
| SimdBitmask Simd.I16x8 -> simd_op 0x84l
624624
| SimdBitmask Simd.I32x4 -> simd_op 0xa4l
625+
| SimdBitmask Simd.I64x2 -> simd_op 0xc4l
625626
| SimdBitmask (_) -> assert false
626627

627628
| _ -> assert false

interpreter/exec/eval_simd.ml

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ module SimdOp (SXX : Simd.S) (Value : ValueType with type t = SXX.t) = struct
233233
| Simd.I8x16 -> SXX.I8x16.bitmask
234234
| Simd.I16x8 -> SXX.I16x8.bitmask
235235
| Simd.I32x4 -> SXX.I32x4.bitmask
236+
| Simd.I64x2 -> SXX.I64x2.bitmask
236237
| _ -> assert false
237238
in I32 (f (of_value 1 v))
238239

interpreter/syntax/operators.ml

+1
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ let i64x2_replace_lane imm = SimdReplace (V128Op.I64x2 imm)
390390
let i64x2_eq = Binary (V128 V128Op.(I64x2 Eq))
391391
let i64x2_ne = Binary (V128 V128Op.(I64x2 Ne))
392392
let i64x2_neg = Unary (V128 V128Op.(I64x2 Neg))
393+
let i64x2_bitmask = SimdBitmask Simd.I64x2
393394
let i64x2_add = Binary (V128 V128Op.(I64x2 Add))
394395
let i64x2_sub = Binary (V128 V128Op.(I64x2 Sub))
395396
let i64x2_mul = Binary (V128 V128Op.(I64x2 Mul))

interpreter/text/arrange.ml

+1
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ struct
406406
| Simd.I8x16 -> "i8x16.bitmask"
407407
| Simd.I16x8 -> "i16x8.bitmask"
408408
| Simd.I32x4 -> "i32x4.bitmask"
409+
| Simd.I64x2 -> "i64x2.bitmask"
409410
| _ -> assert false
410411

411412
end

interpreter/text/lexer.mll

+1-2
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,7 @@ rule token = parse
536536
{ only ["i8x16"; "i16x8"; "i32x4"] s lexbuf;
537537
UNARY (simd_int_op s i8x16_all_true i16x8_all_true i32x4_all_true unreachable) }
538538
| (simd_int_shape as s)".bitmask"
539-
{ only ["i8x16"; "i16x8"; "i32x4"] s lexbuf;
540-
UNARY (simd_int_op s i8x16_bitmask i16x8_bitmask i32x4_bitmask unreachable) }
539+
{ UNARY (simd_int_op s i8x16_bitmask i16x8_bitmask i32x4_bitmask i64x2_bitmask) }
541540
| (simd_int_shape as s)".shl"
542541
{ SHIFT (simd_int_op s i8x16_shl i16x8_shl i32x4_shl i64x2_shl) }
543542
| (simd_int_shape as s)".shr_s"

test/core/simd/simd_boolean.wast

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
(func (export "i32x4.any_true") (param $0 v128) (result i32) (v128.any_true (local.get $0)))
1313
(func (export "i32x4.all_true") (param $0 v128) (result i32) (i32x4.all_true (local.get $0)))
1414
(func (export "i32x4.bitmask") (param $0 v128) (result i32) (i32x4.bitmask (local.get $0)))
15+
16+
(func (export "i64x2.bitmask") (param $0 v128) (result i32) (i64x2.bitmask (local.get $0)))
1517
)
1618

1719
;; i8x16
@@ -156,6 +158,11 @@
156158
(assert_return (invoke "i32x4.bitmask" (v128.const i32x4 -1 0 1 0xF))
157159
(i32.const 0x00000001))
158160

161+
(assert_return (invoke "i64x2.bitmask" (v128.const i64x2 0xFFFFFFFF_FFFFFFFF 0xFFFFFFFF_FFFFFFFF))
162+
(i32.const 0x00000003))
163+
(assert_return (invoke "i64x2.bitmask" (v128.const i64x2 -1 0xF))
164+
(i32.const 0x00000001))
165+
159166
;; Combination
160167

161168
(module (memory 1)

0 commit comments

Comments
 (0)