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

[interpreter] Add i64x2.all_true #469

Merged
merged 1 commit into from
Feb 17, 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 @@ -424,6 +424,7 @@ let simd_prefix s =
| 0xccl -> i64x2_shr_s
| 0xcdl -> i64x2_shr_u
| 0xcel -> i64x2_add
| 0xcfl -> i64x2_all_true
| 0xd0l -> i64x2_ne
| 0xd1l -> i64x2_sub
| 0xd2l -> i64x2_extmul_low_i32x4_s
Expand Down
1 change: 1 addition & 0 deletions interpreter/binary/encode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ let encode m =
| Test (V128 V128Op.(I8x16 AllTrue)) -> simd_op 0x63l
| Test (V128 V128Op.(I16x8 AllTrue)) -> simd_op 0x83l
| Test (V128 V128Op.(I32x4 AllTrue)) -> simd_op 0xa3l
| Test (V128 V128Op.(I64x2 AllTrue)) -> simd_op 0xcfl
| Test (V128 _) -> assert false

| Compare (I32 I32Op.Eq) -> op 0x46
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 @@ -187,6 +187,7 @@ module SimdOp (SXX : Simd.S) (Value : ValueType with type t = SXX.t) = struct
| I8x16 AllTrue -> SXX.I8x16.all_true
| I16x8 AllTrue -> SXX.I16x8.all_true
| I32x4 AllTrue -> SXX.I32x4.all_true
| I64x2 AllTrue -> SXX.I64x2.all_true
| _ -> assert false
in fun v -> 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 @@ -410,6 +410,7 @@ let i64x2_ge_s = Binary (V128 V128Op.(I64x2 GeS))
let i64x2_abs = Unary (V128 V128Op.(I64x2 Abs))
let i64x2_neg = Unary (V128 V128Op.(I64x2 Neg))
let i64x2_bitmask = SimdBitmask Simd.I64x2
let i64x2_all_true = Test (V128 V128Op.(I64x2 AllTrue))
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 @@ -194,6 +194,7 @@ struct
| I8x16 AllTrue -> "i8x16.all_true"
| I16x8 AllTrue -> "i16x8.all_true"
| I32x4 AllTrue -> "i32x4.all_true"
| I64x2 AllTrue -> "i64x2.all_true"
| V128 AnyTrue -> "v128.any_true"
| _ -> assert false

Expand Down
3 changes: 1 addition & 2 deletions interpreter/text/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,7 @@ rule token = parse
| "i8x16.popcnt"
{ UNARY i8x16_popcnt }
| (simd_int_shape as s)".all_true"
{ only ["i8x16"; "i16x8"; "i32x4"] s lexbuf;
UNARY (simd_int_op s i8x16_all_true i16x8_all_true i32x4_all_true unreachable) }
{ UNARY (simd_int_op s i8x16_all_true i16x8_all_true i32x4_all_true i64x2_all_true) }
| (simd_int_shape as s)".bitmask"
{ UNARY (simd_int_op s i8x16_bitmask i16x8_bitmask i32x4_bitmask i64x2_bitmask) }
| (simd_int_shape as s)".shl"
Expand Down
20 changes: 20 additions & 0 deletions test/core/simd/simd_boolean.wast
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
(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.all_true") (param $0 v128) (result i32) (i64x2.all_true (local.get $0)))
(func (export "i64x2.bitmask") (param $0 v128) (result i32) (i64x2.bitmask (local.get $0)))
)

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

;; i64x2
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 0 0))
(i32.const 0))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 0 1))
(i32.const 0))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 1 0))
(i32.const 0))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 1 1))
(i32.const 1))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 -1 0))
(i32.const 0))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 0x00 0x00))
(i32.const 0))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 0xFF 0xFF))
(i32.const 1))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 0xAB 0xAB))
(i32.const 1))
(assert_return (invoke "i64x2.all_true" (v128.const i64x2 0x55 0x55))
(i32.const 1))
(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))
Expand Down