From 49826b965c44ae7897d15c97158c26b6a208e53e Mon Sep 17 00:00:00 2001 From: Lars T Hansen Date: Tue, 15 Dec 2020 09:26:40 +0100 Subject: [PATCH] Add extending multiply simd instructions --- crates/wasmparser/src/binary_reader.rs | 12 ++++++++++++ crates/wasmparser/src/operators_validator.rs | 14 +++++++++++++- crates/wasmparser/src/primitives.rs | 12 ++++++++++++ crates/wasmprinter/src/lib.rs | 13 +++++++++++++ crates/wast/src/ast/expr.rs | 14 +++++++++++++- 5 files changed, 63 insertions(+), 2 deletions(-) diff --git a/crates/wasmparser/src/binary_reader.rs b/crates/wasmparser/src/binary_reader.rs index 892f53905a..c130c162c8 100644 --- a/crates/wasmparser/src/binary_reader.rs +++ b/crates/wasmparser/src/binary_reader.rs @@ -1691,7 +1691,11 @@ impl<'a> BinaryReader<'a> { 0x97 => Operator::I16x8MinU, 0x98 => Operator::I16x8MaxS, 0x99 => Operator::I16x8MaxU, + 0x9a => Operator::I16x8ExtMulLowI8x16S, 0x9b => Operator::I16x8RoundingAverageU, + 0x9d => Operator::I16x8ExtMulHighI8x16S, + 0x9e => Operator::I16x8ExtMulLowI8x16U, + 0x9f => Operator::I16x8ExtMulHighI8x16U, 0xa0 => Operator::I32x4Abs, 0xa1 => Operator::I32x4Neg, 0xa2 => Operator::I32x4AnyTrue, @@ -1712,13 +1716,21 @@ impl<'a> BinaryReader<'a> { 0xb8 => Operator::I32x4MaxS, 0xb9 => Operator::I32x4MaxU, 0xba => Operator::I32x4DotI16x8S, + 0xbb => Operator::I32x4ExtMulLowI16x8S, + 0xbd => Operator::I32x4ExtMulHighI16x8S, + 0xbe => Operator::I32x4ExtMulLowI16x8U, + 0xbf => Operator::I32x4ExtMulHighI16x8U, 0xc1 => Operator::I64x2Neg, 0xcb => Operator::I64x2Shl, 0xcc => Operator::I64x2ShrS, 0xcd => Operator::I64x2ShrU, 0xce => Operator::I64x2Add, 0xd1 => Operator::I64x2Sub, + 0xd2 => Operator::I64x2ExtMulLowI32x4S, + 0xd3 => Operator::I64x2ExtMulHighI32x4S, 0xd5 => Operator::I64x2Mul, + 0xd6 => Operator::I64x2ExtMulLowI32x4U, + 0xd7 => Operator::I64x2ExtMulHighI32x4U, 0xd8 => Operator::F32x4Ceil, 0xd9 => Operator::F32x4Floor, 0xda => Operator::F32x4Trunc, diff --git a/crates/wasmparser/src/operators_validator.rs b/crates/wasmparser/src/operators_validator.rs index e764db784c..6f06e08793 100644 --- a/crates/wasmparser/src/operators_validator.rs +++ b/crates/wasmparser/src/operators_validator.rs @@ -1596,7 +1596,19 @@ impl OperatorValidator { | Operator::I8x16NarrowI16x8S | Operator::I8x16NarrowI16x8U | Operator::I16x8NarrowI32x4S - | Operator::I16x8NarrowI32x4U => { + | Operator::I16x8NarrowI32x4U + | Operator::I16x8ExtMulLowI8x16S + | Operator::I16x8ExtMulHighI8x16S + | Operator::I16x8ExtMulLowI8x16U + | Operator::I16x8ExtMulHighI8x16U + | Operator::I32x4ExtMulLowI16x8S + | Operator::I32x4ExtMulHighI16x8S + | Operator::I32x4ExtMulLowI16x8U + | Operator::I32x4ExtMulHighI16x8U + | Operator::I64x2ExtMulLowI32x4S + | Operator::I64x2ExtMulHighI32x4S + | Operator::I64x2ExtMulLowI32x4U + | Operator::I64x2ExtMulHighI32x4U => { self.check_simd_enabled()?; self.pop_operand(Some(Type::V128))?; self.pop_operand(Some(Type::V128))?; diff --git a/crates/wasmparser/src/primitives.rs b/crates/wasmparser/src/primitives.rs index 3f92a09ed4..06f3cb5fe1 100644 --- a/crates/wasmparser/src/primitives.rs +++ b/crates/wasmparser/src/primitives.rs @@ -812,6 +812,18 @@ pub enum Operator<'a> { I32x4WidenHighI16x8S, I32x4WidenLowI16x8U, I32x4WidenHighI16x8U, + I16x8ExtMulLowI8x16S, + I16x8ExtMulHighI8x16S, + I16x8ExtMulLowI8x16U, + I16x8ExtMulHighI8x16U, + I32x4ExtMulLowI16x8S, + I32x4ExtMulHighI16x8S, + I32x4ExtMulLowI16x8U, + I32x4ExtMulHighI16x8U, + I64x2ExtMulLowI32x4S, + I64x2ExtMulHighI32x4S, + I64x2ExtMulLowI32x4U, + I64x2ExtMulHighI32x4U, V128Load8x8S { memarg: MemoryImmediate }, V128Load8x8U { memarg: MemoryImmediate }, V128Load16x4S { memarg: MemoryImmediate }, diff --git a/crates/wasmprinter/src/lib.rs b/crates/wasmprinter/src/lib.rs index 9ed318548e..d7a095e5c9 100644 --- a/crates/wasmprinter/src/lib.rs +++ b/crates/wasmprinter/src/lib.rs @@ -1354,6 +1354,19 @@ impl Printer { I32x4WidenLowI16x8U => self.result.push_str("i32x4.widen_low_i16x8_u"), I32x4WidenHighI16x8U => self.result.push_str("i32x4.widen_high_i16x8_u"), + I16x8ExtMulLowI8x16S => self.result.push_str("i16x8.extmul_low_i8x16_s"), + I16x8ExtMulHighI8x16S => self.result.push_str("i16x8.extmul_high_i8x16_s"), + I16x8ExtMulLowI8x16U => self.result.push_str("i16x8.extmul_low_i8x16_u"), + I16x8ExtMulHighI8x16U => self.result.push_str("i16x8.extmul_high_i8x16_u"), + I32x4ExtMulLowI16x8S => self.result.push_str("i32x4.extmul_low_i16x8_s"), + I32x4ExtMulHighI16x8S => self.result.push_str("i32x4.extmul_high_i16x8_s"), + I32x4ExtMulLowI16x8U => self.result.push_str("i32x4.extmul_low_i16x8_u"), + I32x4ExtMulHighI16x8U => self.result.push_str("i32x4.extmul_high_i16x8_u"), + I64x2ExtMulLowI32x4S => self.result.push_str("i64x2.extmul_low_i32x4_s"), + I64x2ExtMulHighI32x4S => self.result.push_str("i64x2.extmul_high_i32x4_s"), + I64x2ExtMulLowI32x4U => self.result.push_str("i64x2.extmul_low_i32x4_u"), + I64x2ExtMulHighI32x4U => self.result.push_str("i64x2.extmul_high_i32x4_u"), + V128Load8x8S { memarg } => self.mem_instr("v128.load8x8_s", memarg, 8)?, V128Load8x8U { memarg } => self.mem_instr("v128.load8x8_u", memarg, 8)?, V128Load16x4S { memarg } => self.mem_instr("v128.load16x4_s", memarg, 8)?, diff --git a/crates/wast/src/ast/expr.rs b/crates/wast/src/ast/expr.rs index 1dd3bd0ebd..5932b8de90 100644 --- a/crates/wast/src/ast/expr.rs +++ b/crates/wast/src/ast/expr.rs @@ -959,7 +959,11 @@ instructions! { I16x8MinU : [0xfd, 0x97] : "i16x8.min_u", I16x8MaxS : [0xfd, 0x98] : "i16x8.max_s", I16x8MaxU : [0xfd, 0x99] : "i16x8.max_u", + I16x8ExtMulLowI8x16S : [0xfd, 0x9a] : "i16x8.extmul_low_i8x16_s", I16x8AvgrU : [0xfd, 0x9b] : "i16x8.avgr_u", + I16x8ExtMulHighI8x16S : [0xfd, 0x9d] : "i16x8.extmul_high_i8x16_s", + I16x8ExtMulLowI8x16U : [0xfd, 0x9e] : "i16x8.extmul_low_i8x16_u", + I16x8ExtMulHighI8x16U : [0xfd, 0x9f] : "i16x8.extmul_high_i8x16_u", I32x4Abs : [0xfd, 0xa0] : "i32x4.abs", I32x4Neg : [0xfd, 0xa1] : "i32x4.neg", @@ -969,7 +973,7 @@ instructions! { I32x4WidenLowI16x8S : [0xfd, 0xa7] : "i32x4.widen_low_i16x8_s", I32x4WidenHighI16x8S : [0xfd, 0xa8] : "i32x4.widen_high_i16x8_s", I32x4WidenLowI16x8U : [0xfd, 0xa9] : "i32x4.widen_low_i16x8_u", - I32x4WidenHighI16x8u : [0xfd, 0xaa] : "i32x4.widen_high_i16x8_u", + I32x4WidenHighI16x8U : [0xfd, 0xaa] : "i32x4.widen_high_i16x8_u", I32x4Shl : [0xfd, 0xab] : "i32x4.shl", I32x4ShrS : [0xfd, 0xac] : "i32x4.shr_s", I32x4ShrU : [0xfd, 0xad] : "i32x4.shr_u", @@ -981,6 +985,10 @@ instructions! { I32x4MaxS : [0xfd, 0xb8] : "i32x4.max_s", I32x4MaxU : [0xfd, 0xb9] : "i32x4.max_u", I32x4DotI16x8S : [0xfd, 0xba] : "i32x4.dot_i16x8_s", + I32x4ExtMulLowI16x8S : [0xfd, 0xbb] : "i32x4.extmul_low_i16x8_s", + I32x4ExtMulHighI16x8S : [0xfd, 0xbd] : "i32x4.extmul_high_i16x8_s", + I32x4ExtMulLowI16x8U : [0xfd, 0xbe] : "i32x4.extmul_low_i16x8_u", + I32x4ExtMulHighI16x8U : [0xfd, 0xbf] : "i32x4.extmul_high_i16x8_u", I64x2Neg : [0xfd, 0xc1] : "i64x2.neg", I64x2Shl : [0xfd, 0xcb] : "i64x2.shl", @@ -988,7 +996,11 @@ instructions! { I64x2ShrU : [0xfd, 0xcd] : "i64x2.shr_u", I64x2Add : [0xfd, 0xce] : "i64x2.add", I64x2Sub : [0xfd, 0xd1] : "i64x2.sub", + I64x2ExtMulLowI32x4S : [0xfd, 0xd2] : "i64x2.extmul_low_i32x4_s", + I64x2ExtMulHighI32x4S : [0xfd, 0xd3] : "i64x2.extmul_high_i32x4_s", I64x2Mul : [0xfd, 0xd5] : "i64x2.mul", + I64x2ExtMulLowI32x4U : [0xfd, 0xd6] : "i64x2.extmul_low_i32x4_u", + I64x2ExtMulHighI32x4U : [0xfd, 0xd7] : "i64x2.extmul_high_i32x4_u", F32x4Ceil : [0xfd, 0xd8] : "f32x4.ceil", F32x4Floor : [0xfd, 0xd9] : "f32x4.floor",