AArch64: Implement SIMD floating-point comparisons
Copyright (c) 2020, Arm Limited.
This commit is contained in:
@@ -1279,6 +1279,11 @@ impl MachInstEmit for Inst {
|
||||
I32X4 => 0b10,
|
||||
_ => 0,
|
||||
};
|
||||
let enc_size_for_fcmp = match ty {
|
||||
F32X4 => 0b0,
|
||||
F64X2 => 0b1,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
let (top11, bit15_10) = match alu_op {
|
||||
VecALUOp::SQAddScalar => {
|
||||
@@ -1302,6 +1307,9 @@ impl MachInstEmit for Inst {
|
||||
VecALUOp::Cmgt => (0b010_01110_00_1 | enc_size << 1, 0b001101),
|
||||
VecALUOp::Cmhi => (0b011_01110_00_1 | enc_size << 1, 0b001101),
|
||||
VecALUOp::Cmhs => (0b011_01110_00_1 | enc_size << 1, 0b001111),
|
||||
VecALUOp::Fcmeq => (0b010_01110_00_1 | enc_size_for_fcmp << 1, 0b111001),
|
||||
VecALUOp::Fcmgt => (0b011_01110_10_1 | enc_size_for_fcmp << 1, 0b111001),
|
||||
VecALUOp::Fcmge => (0b011_01110_00_1 | enc_size_for_fcmp << 1, 0b111001),
|
||||
// The following logical instructions operate on bytes, so are not encoded differently
|
||||
// for the different vector types.
|
||||
VecALUOp::And => {
|
||||
|
||||
@@ -2209,6 +2209,42 @@ fn test_aarch64_binemit() {
|
||||
"cmhs v8.4s, v2.4s, v15.4s",
|
||||
));
|
||||
|
||||
insns.push((
|
||||
Inst::VecRRR {
|
||||
alu_op: VecALUOp::Fcmeq,
|
||||
rd: writable_vreg(28),
|
||||
rn: vreg(12),
|
||||
rm: vreg(4),
|
||||
ty: F32X4,
|
||||
},
|
||||
"9CE5244E",
|
||||
"fcmeq v28.4s, v12.4s, v4.4s",
|
||||
));
|
||||
|
||||
insns.push((
|
||||
Inst::VecRRR {
|
||||
alu_op: VecALUOp::Fcmgt,
|
||||
rd: writable_vreg(3),
|
||||
rn: vreg(16),
|
||||
rm: vreg(31),
|
||||
ty: F64X2,
|
||||
},
|
||||
"03E6FF6E",
|
||||
"fcmgt v3.2d, v16.2d, v31.2d",
|
||||
));
|
||||
|
||||
insns.push((
|
||||
Inst::VecRRR {
|
||||
alu_op: VecALUOp::Fcmge,
|
||||
rd: writable_vreg(18),
|
||||
rn: vreg(23),
|
||||
rm: vreg(0),
|
||||
ty: F64X2,
|
||||
},
|
||||
"F2E6606E",
|
||||
"fcmge v18.2d, v23.2d, v0.2d",
|
||||
));
|
||||
|
||||
insns.push((
|
||||
Inst::VecRRR {
|
||||
alu_op: VecALUOp::And,
|
||||
|
||||
@@ -225,6 +225,12 @@ pub enum VecALUOp {
|
||||
Cmhs,
|
||||
/// Compare unsigned higher or same
|
||||
Cmhi,
|
||||
/// Floating-point compare equal
|
||||
Fcmeq,
|
||||
/// Floating-point compare greater than
|
||||
Fcmgt,
|
||||
/// Floating-point compare greater than or equal
|
||||
Fcmge,
|
||||
/// Bitwise and
|
||||
And,
|
||||
/// Bitwise bit clear
|
||||
@@ -2085,7 +2091,9 @@ impl MachInst for Inst {
|
||||
I8 | I16 | I32 | I64 | B1 | B8 | B16 | B32 | B64 => Ok(RegClass::I64),
|
||||
F32 | F64 => Ok(RegClass::V128),
|
||||
IFLAGS | FFLAGS => Ok(RegClass::I64),
|
||||
B8X16 | I8X16 | B16X8 | I16X8 | B32X4 | I32X4 | B64X2 | I64X2 => Ok(RegClass::V128),
|
||||
B8X16 | I8X16 | B16X8 | I16X8 | B32X4 | I32X4 | B64X2 | I64X2 | F32X4 | F64X2 => {
|
||||
Ok(RegClass::V128)
|
||||
}
|
||||
_ => Err(CodegenError::Unsupported(format!(
|
||||
"Unexpected SSA-value type: {}",
|
||||
ty
|
||||
@@ -2720,6 +2728,9 @@ impl ShowWithRRU for Inst {
|
||||
VecALUOp::Cmgt => ("cmgt", true, ty),
|
||||
VecALUOp::Cmhs => ("cmhs", true, ty),
|
||||
VecALUOp::Cmhi => ("cmhi", true, ty),
|
||||
VecALUOp::Fcmeq => ("fcmeq", true, ty),
|
||||
VecALUOp::Fcmgt => ("fcmgt", true, ty),
|
||||
VecALUOp::Fcmge => ("fcmge", true, ty),
|
||||
VecALUOp::And => ("and", true, I8X16),
|
||||
VecALUOp::Bic => ("bic", true, I8X16),
|
||||
VecALUOp::Orr => ("orr", true, I8X16),
|
||||
|
||||
Reference in New Issue
Block a user