[AArch64] Merge 32- and 64-bit FPUOp1 (#4031)

Copyright (c) 2022, Arm Limited.
This commit is contained in:
Sam Parker
2022-04-14 22:00:48 +01:00
committed by GitHub
parent 9a02320dd4
commit dd442a4d2f
7 changed files with 237 additions and 206 deletions

View File

@@ -1671,19 +1671,28 @@ impl MachInstEmit for Inst {
rn,
));
}
&Inst::FpuRR { fpu_op, rd, rn } => {
&Inst::FpuRR {
fpu_op,
size,
rd,
rn,
} => {
let rd = allocs.next_writable(rd);
let rn = allocs.next(rn);
let top22 = match fpu_op {
FPUOp1::Abs32 => 0b000_11110_00_1_000001_10000,
FPUOp1::Abs64 => 0b000_11110_01_1_000001_10000,
FPUOp1::Neg32 => 0b000_11110_00_1_000010_10000,
FPUOp1::Neg64 => 0b000_11110_01_1_000010_10000,
FPUOp1::Sqrt32 => 0b000_11110_00_1_000011_10000,
FPUOp1::Sqrt64 => 0b000_11110_01_1_000011_10000,
FPUOp1::Cvt32To64 => 0b000_11110_00_1_000101_10000,
FPUOp1::Cvt64To32 => 0b000_11110_01_1_000100_10000,
FPUOp1::Abs => 0b000_11110_00_1_000001_10000,
FPUOp1::Neg => 0b000_11110_00_1_000010_10000,
FPUOp1::Sqrt => 0b000_11110_00_1_000011_10000,
FPUOp1::Cvt32To64 => {
debug_assert_eq!(size, ScalarSize::Size32);
0b000_11110_00_1_000101_10000
}
FPUOp1::Cvt64To32 => {
debug_assert_eq!(size, ScalarSize::Size64);
0b000_11110_01_1_000100_10000
}
};
let top22 = top22 | size.ftype() << 12;
sink.put4(enc_fpurr(top22, rd, rn));
}
&Inst::FpuRRR {

View File

@@ -5348,7 +5348,8 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Abs32,
fpu_op: FPUOp1::Abs,
size: ScalarSize::Size32,
rd: writable_vreg(15),
rn: vreg(30),
},
@@ -5358,7 +5359,8 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Abs64,
fpu_op: FPUOp1::Abs,
size: ScalarSize::Size64,
rd: writable_vreg(15),
rn: vreg(30),
},
@@ -5368,7 +5370,8 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Neg32,
fpu_op: FPUOp1::Neg,
size: ScalarSize::Size32,
rd: writable_vreg(15),
rn: vreg(30),
},
@@ -5378,7 +5381,8 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Neg64,
fpu_op: FPUOp1::Neg,
size: ScalarSize::Size64,
rd: writable_vreg(15),
rn: vreg(30),
},
@@ -5388,7 +5392,8 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Sqrt32,
fpu_op: FPUOp1::Sqrt,
size: ScalarSize::Size32,
rd: writable_vreg(15),
rn: vreg(30),
},
@@ -5398,7 +5403,8 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Sqrt64,
fpu_op: FPUOp1::Sqrt,
size: ScalarSize::Size64,
rd: writable_vreg(15),
rn: vreg(30),
},
@@ -5409,6 +5415,7 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Cvt32To64,
size: ScalarSize::Size32,
rd: writable_vreg(15),
rn: vreg(30),
},
@@ -5419,6 +5426,7 @@ fn test_aarch64_binemit() {
insns.push((
Inst::FpuRR {
fpu_op: FPUOp1::Cvt64To32,
size: ScalarSize::Size64,
rd: writable_vreg(15),
rn: vreg(30),
},

View File

@@ -1675,19 +1675,25 @@ impl Inst {
let rn = pretty_print_vreg_scalar(rn, size, allocs);
format!("fmov {}, {}", rd, rn)
}
&Inst::FpuRR { fpu_op, rd, rn } => {
let (op, sizesrc, sizedest) = match fpu_op {
FPUOp1::Abs32 => ("fabs", ScalarSize::Size32, ScalarSize::Size32),
FPUOp1::Abs64 => ("fabs", ScalarSize::Size64, ScalarSize::Size64),
FPUOp1::Neg32 => ("fneg", ScalarSize::Size32, ScalarSize::Size32),
FPUOp1::Neg64 => ("fneg", ScalarSize::Size64, ScalarSize::Size64),
FPUOp1::Sqrt32 => ("fsqrt", ScalarSize::Size32, ScalarSize::Size32),
FPUOp1::Sqrt64 => ("fsqrt", ScalarSize::Size64, ScalarSize::Size64),
FPUOp1::Cvt32To64 => ("fcvt", ScalarSize::Size32, ScalarSize::Size64),
FPUOp1::Cvt64To32 => ("fcvt", ScalarSize::Size64, ScalarSize::Size32),
&Inst::FpuRR {
fpu_op,
size,
rd,
rn,
} => {
let op = match fpu_op {
FPUOp1::Abs => "fabs",
FPUOp1::Neg => "fneg",
FPUOp1::Sqrt => "fsqrt",
FPUOp1::Cvt32To64 | FPUOp1::Cvt64To32 => "fcvt",
};
let rd = pretty_print_vreg_scalar(rd.to_reg(), sizedest, allocs);
let rn = pretty_print_vreg_scalar(rn, sizesrc, allocs);
let dst_size = match fpu_op {
FPUOp1::Cvt32To64 => ScalarSize::Size64,
FPUOp1::Cvt64To32 => ScalarSize::Size32,
_ => size,
};
let rd = pretty_print_vreg_scalar(rd.to_reg(), dst_size, allocs);
let rn = pretty_print_vreg_scalar(rn, size, allocs);
format!("{} {}, {}", op, rd, rn)
}
&Inst::FpuRRR {