From 886ad5039f389f4ac872ea1cd4e6f026586cb40a Mon Sep 17 00:00:00 2001 From: Lars T Hansen Date: Wed, 3 Jun 2020 16:04:47 +0200 Subject: [PATCH] Add iNxM.bitmask instructions (#21) --- crates/wasmparser/src/binary_reader.rs | 3 +++ crates/wasmparser/src/operators_validator.rs | 5 ++++- crates/wasmparser/src/primitives.rs | 3 +++ crates/wasmprinter/src/lib.rs | 3 +++ crates/wast/src/ast/expr.rs | 3 +++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/wasmparser/src/binary_reader.rs b/crates/wasmparser/src/binary_reader.rs index 0b61eddbea..1489146b26 100644 --- a/crates/wasmparser/src/binary_reader.rs +++ b/crates/wasmparser/src/binary_reader.rs @@ -1526,6 +1526,7 @@ impl<'a> BinaryReader<'a> { 0x61 => Operator::I8x16Neg, 0x62 => Operator::I8x16AnyTrue, 0x63 => Operator::I8x16AllTrue, + 0x64 => Operator::I8x16Bitmask, 0x65 => Operator::I8x16NarrowI16x8S, 0x66 => Operator::I8x16NarrowI16x8U, 0x6b => Operator::I8x16Shl, @@ -1546,6 +1547,7 @@ impl<'a> BinaryReader<'a> { 0x81 => Operator::I16x8Neg, 0x82 => Operator::I16x8AnyTrue, 0x83 => Operator::I16x8AllTrue, + 0x84 => Operator::I16x8Bitmask, 0x85 => Operator::I16x8NarrowI32x4S, 0x86 => Operator::I16x8NarrowI32x4U, 0x87 => Operator::I16x8WidenLowI8x16S, @@ -1571,6 +1573,7 @@ impl<'a> BinaryReader<'a> { 0xa1 => Operator::I32x4Neg, 0xa2 => Operator::I32x4AnyTrue, 0xa3 => Operator::I32x4AllTrue, + 0xa4 => Operator::I32x4Bitmask, 0xa7 => Operator::I32x4WidenLowI16x8S, 0xa8 => Operator::I32x4WidenHighI16x8S, 0xa9 => Operator::I32x4WidenLowI16x8U, diff --git a/crates/wasmparser/src/operators_validator.rs b/crates/wasmparser/src/operators_validator.rs index 978c4215b2..214bf91930 100644 --- a/crates/wasmparser/src/operators_validator.rs +++ b/crates/wasmparser/src/operators_validator.rs @@ -1903,10 +1903,13 @@ impl OperatorValidator { } Operator::I8x16AnyTrue | Operator::I8x16AllTrue + | Operator::I8x16Bitmask | Operator::I16x8AnyTrue | Operator::I16x8AllTrue + | Operator::I16x8Bitmask | Operator::I32x4AnyTrue - | Operator::I32x4AllTrue => { + | Operator::I32x4AllTrue + | Operator::I32x4Bitmask => { self.check_simd_enabled()?; self.check_operands_1(Type::V128)?; self.func_state.change_frame_with_type(1, Type::I32)?; diff --git a/crates/wasmparser/src/primitives.rs b/crates/wasmparser/src/primitives.rs index a49361cb43..995825348f 100644 --- a/crates/wasmparser/src/primitives.rs +++ b/crates/wasmparser/src/primitives.rs @@ -617,6 +617,7 @@ pub enum Operator<'a> { I8x16Neg, I8x16AnyTrue, I8x16AllTrue, + I8x16Bitmask, I8x16Shl, I8x16ShrS, I8x16ShrU, @@ -634,6 +635,7 @@ pub enum Operator<'a> { I16x8Neg, I16x8AnyTrue, I16x8AllTrue, + I16x8Bitmask, I16x8Shl, I16x8ShrS, I16x8ShrU, @@ -652,6 +654,7 @@ pub enum Operator<'a> { I32x4Neg, I32x4AnyTrue, I32x4AllTrue, + I32x4Bitmask, I32x4Shl, I32x4ShrS, I32x4ShrU, diff --git a/crates/wasmprinter/src/lib.rs b/crates/wasmprinter/src/lib.rs index 9a5652f351..5d404c2d7b 100644 --- a/crates/wasmprinter/src/lib.rs +++ b/crates/wasmprinter/src/lib.rs @@ -975,6 +975,7 @@ impl Printer { I8x16Neg => self.result.push_str("i8x16.neg"), I8x16AnyTrue => self.result.push_str("i8x16.any_true"), I8x16AllTrue => self.result.push_str("i8x16.all_true"), + I8x16Bitmask => self.result.push_str("i8x16.bitmask"), I8x16Shl => self.result.push_str("i8x16.shl"), I8x16ShrU => self.result.push_str("i8x16.shr_u"), I8x16ShrS => self.result.push_str("i8x16.shr_s"), @@ -989,6 +990,7 @@ impl Printer { I16x8Neg => self.result.push_str("i16x8.neg"), I16x8AnyTrue => self.result.push_str("i16x8.any_true"), I16x8AllTrue => self.result.push_str("i16x8.all_true"), + I16x8Bitmask => self.result.push_str("i16x8.bitmask"), I16x8Shl => self.result.push_str("i16x8.shl"), I16x8ShrU => self.result.push_str("i16x8.shr_u"), I16x8ShrS => self.result.push_str("i16x8.shr_s"), @@ -1004,6 +1006,7 @@ impl Printer { I32x4Neg => self.result.push_str("i32x4.neg"), I32x4AnyTrue => self.result.push_str("i32x4.any_true"), I32x4AllTrue => self.result.push_str("i32x4.all_true"), + I32x4Bitmask => self.result.push_str("i32x4.bitmask"), I32x4Shl => self.result.push_str("i32x4.shl"), I32x4ShrU => self.result.push_str("i32x4.shr_u"), I32x4ShrS => self.result.push_str("i32x4.shr_s"), diff --git a/crates/wast/src/ast/expr.rs b/crates/wast/src/ast/expr.rs index 808aef99c7..1684e80660 100644 --- a/crates/wast/src/ast/expr.rs +++ b/crates/wast/src/ast/expr.rs @@ -781,6 +781,7 @@ instructions! { I8x16Neg : [0xfd, 0x61] : "i8x16.neg", I8x16AnyTrue : [0xfd, 0x62] : "i8x16.any_true", I8x16AllTrue : [0xfd, 0x63] : "i8x16.all_true", + I8x16Bitmask : [0xfd, 0x64] : "i8x16.bitmask", I8x16NarrowI16x8S : [0xfd, 0x65] : "i8x16.narrow_i16x8_s", I8x16NarrowI16x8U : [0xfd, 0x66] : "i8x16.narrow_i16x8_u", I8x16Shl : [0xfd, 0x6b] : "i8x16.shl", @@ -802,6 +803,7 @@ instructions! { I16x8Neg : [0xfd, 0x81] : "i16x8.neg", I16x8AnyTrue : [0xfd, 0x82] : "i16x8.any_true", I16x8AllTrue : [0xfd, 0x83] : "i16x8.all_true", + I16x8Bitmask : [0xfd, 0x84] : "i16x8.bitmask", I16x8NarrowI32x4S : [0xfd, 0x85] : "i16x8.narrow_i32x4_s", I16x8NarrowI32x4U : [0xfd, 0x86] : "i16x8.narrow_i32x4_u", I16x8WidenLowI8x16S : [0xfd, 0x87] : "i16x8.widen_low_i8x16_s", @@ -828,6 +830,7 @@ instructions! { I32x4Neg : [0xfd, 0xa1] : "i32x4.neg", I32x4AnyTrue : [0xfd, 0xa2] : "i32x4.any_true", I32x4AllTrue : [0xfd, 0xa3] : "i32x4.all_true", + I32x4Bitmask : [0xfd, 0xa4] : "i32x4.bitmask", I32x4WidenLowI16x8S : [0xfd, 0xa7] : "i32x4.widen_low_i16x8_s", I32x4WidenHighI16x8S : [0xfd, 0xa8] : "i32x4.widen_high_i16x8_s", I32x4WidenLowI16x8U : [0xfd, 0xa9] : "i32x4.widen_low_i16x8_u",