@@ -4927,18 +4927,31 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
49274927 }
49284928 }
49294929 }
4930- Opcode :: ExtendedPairwiseAddSigned | Opcode :: ExtendedPairwiseAddUnsigned => {
4931- // Extended pairwise addition instructions computes extended sums within adjacent
4932- // pairs of lanes of a SIMD vector, producing a SIMD vector with half as many lanes.
4933- // Instruction sequences taken from instruction SPEC PR https://github.com/WebAssembly/simd/pull/380
4934- /*
4935- let input_ty = ctx.input_ty(insn, 0);
4936- let output_ty = ctx.output_ty(insn, 0);
4937- let src = put_input_in_reg(ctx, inputs[0]);
4938- let dst = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
4939- unreachable!();
4940- match op {
4941- Opcode::ExtendedPairwiseAddSigned => match (input_ty, output_ty) {
4930+ Opcode :: IaddPairwise => {
4931+ if let ( Some ( swiden_low) , Some ( swiden_high) ) = (
4932+ matches_input ( ctx, inputs[ 0 ] , Opcode :: SwidenLow ) ,
4933+ matches_input ( ctx, inputs[ 1 ] , Opcode :: SwidenHigh ) ,
4934+ ) {
4935+ let swiden_input = & [
4936+ InsnInput {
4937+ insn : swiden_low,
4938+ input : 0 ,
4939+ } ,
4940+ InsnInput {
4941+ insn : swiden_high,
4942+ input : 0 ,
4943+ } ,
4944+ ] ;
4945+
4946+ let input0_ty = ctx. input_ty ( swiden_low, 0 ) ;
4947+ let input1_ty = ctx. input_ty ( swiden_high, 0 ) ;
4948+ let output_ty = ctx. output_ty ( insn, 0 ) ;
4949+ let src = put_input_in_reg ( ctx, swiden_input[ 0 ] ) ;
4950+ let dst = get_output_reg ( ctx, outputs[ 0 ] ) . only_reg ( ) . unwrap ( ) ;
4951+ assert_eq ! ( input0_ty, input1_ty) ;
4952+ assert_eq ! ( swiden_input[ 0 ] . input, swiden_input[ 1 ] . input) ;
4953+
4954+ match ( input0_ty, output_ty) {
49424955 ( types:: I8X16 , types:: I16X8 ) => {
49434956 static MUL_CONST : [ u8 ; 16 ] = [ 0x01 ; 16 ] ;
49444957 let mul_const = ctx. use_constant ( VCodeConstantData :: WellKnown ( & MUL_CONST ) ) ;
@@ -4966,12 +4979,34 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
49664979 dst,
49674980 ) ) ;
49684981 }
4969- _ => unreachable!(
4970- "Type pattern not supported {:?}-{:?} not supported for {:?}.",
4971- input_ty, output_ty, op
4972- ),
4973- },
4974- Opcode::ExtendedPairwiseAddUnsigned => match (input_ty, output_ty) {
4982+ _ => {
4983+ unimplemented ! ( "Type not supported for {:?}" , op) ;
4984+ }
4985+ }
4986+ } else if let ( Some ( uwiden_low) , Some ( uwiden_high) ) = (
4987+ matches_input ( ctx, inputs[ 0 ] , Opcode :: UwidenLow ) ,
4988+ matches_input ( ctx, inputs[ 1 ] , Opcode :: UwidenHigh ) ,
4989+ ) {
4990+ let uwiden_input = & [
4991+ InsnInput {
4992+ insn : uwiden_low,
4993+ input : 0 ,
4994+ } ,
4995+ InsnInput {
4996+ insn : uwiden_high,
4997+ input : 0 ,
4998+ } ,
4999+ ] ;
5000+
5001+ let input0_ty = ctx. input_ty ( uwiden_low, 0 ) ;
5002+ let input1_ty = ctx. input_ty ( uwiden_high, 0 ) ;
5003+ let output_ty = ctx. output_ty ( insn, 0 ) ;
5004+ let src = put_input_in_reg ( ctx, uwiden_input[ 0 ] ) ;
5005+ let dst = get_output_reg ( ctx, outputs[ 0 ] ) . only_reg ( ) . unwrap ( ) ;
5006+ assert_eq ! ( input0_ty, input1_ty) ;
5007+ assert_eq ! ( uwiden_input[ 0 ] . input, uwiden_input[ 1 ] . input) ;
5008+
5009+ match ( input0_ty, output_ty) {
49755010 ( types:: I8X16 , types:: I16X8 ) => {
49765011 static MUL_CONST : [ u8 ; 16 ] = [ 0x01 ; 16 ] ;
49775012 let mul_const = ctx. use_constant ( VCodeConstantData :: WellKnown ( & MUL_CONST ) ) ;
@@ -5021,7 +5056,6 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
50215056 RegMem :: reg ( madd_const_reg. to_reg ( ) ) ,
50225057 dst,
50235058 ) ) ;
5024-
50255059 static ADDD_CONST2 : [ u8 ; 16 ] = [
50265060 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 ,
50275061 0x00 , 0x00 , 0x01 , 0x00 ,
@@ -5040,14 +5074,13 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
50405074 dst,
50415075 ) ) ;
50425076 }
5043- _ => unreachable!(
5044- "Type pattern not supported {:?}-{:?} not supported for {:?}.",
5045- input_ty, output_ty, op
5046- ),
5047- },
5048- _ => unreachable !("{:?} not supported. ", op),
5077+ _ => {
5078+ unimplemented ! ( "Type not supported for {:?}" , op ) ;
5079+ }
5080+ }
5081+ } else {
5082+ unimplemented ! ( "Operands not supported for {:?} " , op) ;
50495083 }
5050- */
50515084 }
50525085 Opcode :: UwidenHigh | Opcode :: UwidenLow | Opcode :: SwidenHigh | Opcode :: SwidenLow => {
50535086 let input_ty = ctx. input_ty ( insn, 0 ) ;
0 commit comments