Convert sqrt..nearest to ISLE (AArch64) (#4508)
Converted the existing implementations for the following opcodes to ISLE on AArch64: - `sqrt` - `fneg` - `fabs` - `fpromote` - `fdemote` - `ceil` - `floor` - `trunc` - `nearest` Copyright (c) 2022 Arm Limited
This commit is contained in:
@@ -1250,107 +1250,10 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
|
||||
Opcode::FminPseudo | Opcode::FmaxPseudo => implemented_in_isle(ctx),
|
||||
|
||||
Opcode::Sqrt | Opcode::Fneg | Opcode::Fabs | Opcode::Fpromote | Opcode::Fdemote => {
|
||||
let ty = ty.unwrap();
|
||||
let rn = put_input_in_reg(ctx, inputs[0], NarrowValueMode::None);
|
||||
let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
|
||||
if !ty.is_vector() {
|
||||
let fpu_op = match op {
|
||||
Opcode::Sqrt => FPUOp1::Sqrt,
|
||||
Opcode::Fneg => FPUOp1::Neg,
|
||||
Opcode::Fabs => FPUOp1::Abs,
|
||||
Opcode::Fpromote => {
|
||||
if ty != F64 {
|
||||
return Err(CodegenError::Unsupported(format!(
|
||||
"Fpromote: Unsupported type: {:?}",
|
||||
ty
|
||||
)));
|
||||
}
|
||||
FPUOp1::Cvt32To64
|
||||
}
|
||||
Opcode::Fdemote => {
|
||||
if ty != F32 {
|
||||
return Err(CodegenError::Unsupported(format!(
|
||||
"Fdemote: Unsupported type: {:?}",
|
||||
ty
|
||||
)));
|
||||
}
|
||||
FPUOp1::Cvt64To32
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
ctx.emit(Inst::FpuRR {
|
||||
fpu_op,
|
||||
size: ScalarSize::from_ty(ctx.input_ty(insn, 0)),
|
||||
rd,
|
||||
rn,
|
||||
});
|
||||
} else {
|
||||
let op = match op {
|
||||
Opcode::Fabs => VecMisc2::Fabs,
|
||||
Opcode::Fneg => VecMisc2::Fneg,
|
||||
Opcode::Sqrt => VecMisc2::Fsqrt,
|
||||
_ => {
|
||||
return Err(CodegenError::Unsupported(format!(
|
||||
"{}: Unsupported type: {:?}",
|
||||
op, ty
|
||||
)))
|
||||
}
|
||||
};
|
||||
|
||||
ctx.emit(Inst::VecMisc {
|
||||
op,
|
||||
rd,
|
||||
rn,
|
||||
size: VectorSize::from_ty(ty),
|
||||
});
|
||||
}
|
||||
implemented_in_isle(ctx)
|
||||
}
|
||||
|
||||
Opcode::Ceil | Opcode::Floor | Opcode::Trunc | Opcode::Nearest => {
|
||||
let ty = ctx.output_ty(insn, 0);
|
||||
if !ty.is_vector() {
|
||||
let bits = ty_bits(ty);
|
||||
let op = match (op, bits) {
|
||||
(Opcode::Ceil, 32) => FpuRoundMode::Plus32,
|
||||
(Opcode::Ceil, 64) => FpuRoundMode::Plus64,
|
||||
(Opcode::Floor, 32) => FpuRoundMode::Minus32,
|
||||
(Opcode::Floor, 64) => FpuRoundMode::Minus64,
|
||||
(Opcode::Trunc, 32) => FpuRoundMode::Zero32,
|
||||
(Opcode::Trunc, 64) => FpuRoundMode::Zero64,
|
||||
(Opcode::Nearest, 32) => FpuRoundMode::Nearest32,
|
||||
(Opcode::Nearest, 64) => FpuRoundMode::Nearest64,
|
||||
_ => {
|
||||
return Err(CodegenError::Unsupported(format!(
|
||||
"{}: Unsupported type: {:?}",
|
||||
op, ty
|
||||
)))
|
||||
}
|
||||
};
|
||||
let rn = put_input_in_reg(ctx, inputs[0], NarrowValueMode::None);
|
||||
let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
|
||||
ctx.emit(Inst::FpuRound { op, rd, rn });
|
||||
} else {
|
||||
let (op, size) = match (op, ty) {
|
||||
(Opcode::Ceil, F32X4) => (VecMisc2::Frintp, VectorSize::Size32x4),
|
||||
(Opcode::Ceil, F64X2) => (VecMisc2::Frintp, VectorSize::Size64x2),
|
||||
(Opcode::Floor, F32X4) => (VecMisc2::Frintm, VectorSize::Size32x4),
|
||||
(Opcode::Floor, F64X2) => (VecMisc2::Frintm, VectorSize::Size64x2),
|
||||
(Opcode::Trunc, F32X4) => (VecMisc2::Frintz, VectorSize::Size32x4),
|
||||
(Opcode::Trunc, F64X2) => (VecMisc2::Frintz, VectorSize::Size64x2),
|
||||
(Opcode::Nearest, F32X4) => (VecMisc2::Frintn, VectorSize::Size32x4),
|
||||
(Opcode::Nearest, F64X2) => (VecMisc2::Frintn, VectorSize::Size64x2),
|
||||
_ => {
|
||||
return Err(CodegenError::Unsupported(format!(
|
||||
"{}: Unsupported type: {:?}",
|
||||
op, ty
|
||||
)))
|
||||
}
|
||||
};
|
||||
let rn = put_input_in_reg(ctx, inputs[0], NarrowValueMode::None);
|
||||
let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
|
||||
ctx.emit(Inst::VecMisc { op, rd, rn, size });
|
||||
}
|
||||
}
|
||||
Opcode::Ceil | Opcode::Floor | Opcode::Trunc | Opcode::Nearest => implemented_in_isle(ctx),
|
||||
|
||||
Opcode::Fma => {
|
||||
let ty = ty.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user