From 78bf63c76d6488c828759d69f1e96ad19c61d474 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 31 Jan 2020 14:40:39 -0800 Subject: [PATCH] Translate Wasm SIMD's avgr_u to Cranelift's new avg_round instruction --- cranelift/wasm/src/code_translator.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index 9a6d24d0a2..da2a7ed186 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -1304,6 +1304,10 @@ pub fn translate_operator( let (a, b) = pop2_with_bitcast(state, type_of(op), builder); state.push1(builder.ins().umax(a, b)) } + Operator::I8x16RoundingAverageU | Operator::I16x8RoundingAverageU => { + let (a, b) = pop2_with_bitcast(state, type_of(op), builder); + state.push1(builder.ins().avg_round(a, b)) + } Operator::I8x16Neg | Operator::I16x8Neg | Operator::I32x4Neg | Operator::I64x2Neg => { let a = pop1_with_bitcast(state, type_of(op), builder); state.push1(builder.ins().ineg(a)) @@ -1491,9 +1495,7 @@ pub fn translate_operator( | Operator::I32x4Load16x4S { .. } | Operator::I32x4Load16x4U { .. } | Operator::I64x2Load32x2S { .. } - | Operator::I64x2Load32x2U { .. } - | Operator::I8x16RoundingAverageU { .. } - | Operator::I16x8RoundingAverageU { .. } => { + | Operator::I64x2Load32x2U { .. } => { return Err(wasm_unsupported!("proposed SIMD operator {:?}", op)); } }; @@ -1833,6 +1835,7 @@ fn type_of(operator: &Operator) -> Type { | Operator::I8x16MinU | Operator::I8x16MaxS | Operator::I8x16MaxU + | Operator::I8x16RoundingAverageU | Operator::I8x16Mul => I8X16, Operator::I16x8Splat @@ -1866,6 +1869,7 @@ fn type_of(operator: &Operator) -> Type { | Operator::I16x8MinU | Operator::I16x8MaxS | Operator::I16x8MaxU + | Operator::I16x8RoundingAverageU | Operator::I16x8Mul => I16X8, Operator::I32x4Splat