Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the simd_conversions test for AArch64 #3082

Merged
merged 1 commit into from
Jul 16, 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
3 changes: 1 addition & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
("simd", _) if platform_is_s390x() => return true,

// These are new instructions that are not really implemented in any backend.
("simd", "simd_conversions")
| ("simd", "simd_i16x8_extadd_pairwise_i8x16")
("simd", "simd_i16x8_extadd_pairwise_i8x16")
| ("simd", "simd_i32x4_extadd_pairwise_i16x8") => return true,

_ => {}
Expand Down
2 changes: 2 additions & 0 deletions cranelift/codegen/src/isa/aarch64/inst/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,8 @@ impl MachInstEmit for Inst {
VecRRNarrowOp::Uqxtn16 => (0b1, 0b00, 0b10100),
VecRRNarrowOp::Uqxtn32 => (0b1, 0b01, 0b10100),
VecRRNarrowOp::Uqxtn64 => (0b1, 0b10, 0b10100),
VecRRNarrowOp::Fcvtn32 => (0b0, 0b00, 0b10110),
VecRRNarrowOp::Fcvtn64 => (0b0, 0b01, 0b10110),
};

sink.put4(enc_vec_rr_misc(
Expand Down
22 changes: 22 additions & 0 deletions cranelift/codegen/src/isa/aarch64/inst/emit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2611,6 +2611,28 @@ fn test_aarch64_binemit() {
"uqxtn2 v11.4s, v12.2d",
));

insns.push((
Inst::VecRRNarrow {
op: VecRRNarrowOp::Fcvtn32,
rd: writable_vreg(0),
rn: vreg(0),
high_half: false,
},
"0068210E",
"fcvtn v0.4h, v0.4s",
));

insns.push((
Inst::VecRRNarrow {
op: VecRRNarrowOp::Fcvtn64,
rd: writable_vreg(31),
rn: vreg(30),
high_half: true,
},
"DF6B614E",
"fcvtn2 v31.4s, v30.2d",
));

insns.push((
Inst::VecRRPair {
op: VecPairOp::Addp,
Expand Down
16 changes: 16 additions & 0 deletions cranelift/codegen/src/isa/aarch64/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ pub enum VecRRNarrowOp {
Uqxtn32,
/// Unsigned saturating extract narrow, 64-bit elements
Uqxtn64,
/// Floating-point convert to lower precision narrow, 32-bit elements
Fcvtn32,
/// Floating-point convert to lower precision narrow, 64-bit elements
Fcvtn64,
}

/// A vector operation on a pair of elements with one register.
Expand Down Expand Up @@ -4073,6 +4077,18 @@ impl Inst {
(VecRRNarrowOp::Uqxtn64, true) => {
("uqxtn2", VectorSize::Size32x4, VectorSize::Size64x2)
}
(VecRRNarrowOp::Fcvtn32, false) => {
("fcvtn", VectorSize::Size16x4, VectorSize::Size32x4)
}
(VecRRNarrowOp::Fcvtn32, true) => {
("fcvtn2", VectorSize::Size16x8, VectorSize::Size32x4)
}
(VecRRNarrowOp::Fcvtn64, false) => {
("fcvtn", VectorSize::Size32x2, VectorSize::Size64x2)
}
(VecRRNarrowOp::Fcvtn64, true) => {
("fcvtn2", VectorSize::Size32x4, VectorSize::Size64x2)
}
};
let rd = show_vreg_vector(rd.to_reg(), mb_rru, rd_size);
let rn = show_vreg_vector(rn, mb_rru, size);
Expand Down
62 changes: 56 additions & 6 deletions cranelift/codegen/src/isa/aarch64/lower_inst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3555,12 +3555,62 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
});
}

Opcode::ConstAddr
| Opcode::FcvtLowFromSint
| Opcode::Fvdemote
| Opcode::FvpromoteLow
| Opcode::Vconcat
| Opcode::Vsplit => unimplemented!("lowering {}", op),
Opcode::FcvtLowFromSint => {
let ty = ty.unwrap();

if ty != F64X2 {
return Err(CodegenError::Unsupported(format!(
"FcvtLowFromSint: Unsupported type: {:?}",
ty
)));
}

let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
let rn = put_input_in_reg(ctx, inputs[0], NarrowValueMode::None);

ctx.emit(Inst::VecExtend {
t: VecExtendOp::Sxtl32,
rd,
rn,
high_half: false,
});
ctx.emit(Inst::VecMisc {
op: VecMisc2::Scvtf,
rd,
rn: rd.to_reg(),
size: VectorSize::Size64x2,
});
}

Opcode::FvpromoteLow => {
debug_assert_eq!(ty.unwrap(), F64X2);

let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
let rn = put_input_in_reg(ctx, inputs[0], NarrowValueMode::None);

ctx.emit(Inst::VecRRLong {
op: VecRRLongOp::Fcvtl32,
rd,
rn,
high_half: false,
});
}

Opcode::Fvdemote => {
debug_assert_eq!(ty.unwrap(), F32X4);

let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
let rn = put_input_in_reg(ctx, inputs[0], NarrowValueMode::None);

ctx.emit(Inst::VecRRNarrow {
op: VecRRNarrowOp::Fcvtn64,
rd,
rn,
high_half: false,
});
}

Opcode::ConstAddr | Opcode::Vconcat | Opcode::Vsplit => unimplemented!("lowering {}", op),
}

Ok(())
Expand Down