[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 50/85] target/arm: Convert FCVTN, BFCVTN to decodetree
From: |
Peter Maydell |
Subject: |
[PULL 50/85] target/arm: Convert FCVTN, BFCVTN to decodetree |
Date: |
Fri, 13 Dec 2024 17:31:54 +0000 |
From: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241211163036.2297116-51-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/tcg/a64.decode | 5 ++
target/arm/tcg/translate-a64.c | 89 ++++++++++++++++++----------------
2 files changed, 52 insertions(+), 42 deletions(-)
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
index 295329448f1..456912cd7ca 100644
--- a/target/arm/tcg/a64.decode
+++ b/target/arm/tcg/a64.decode
@@ -21,6 +21,7 @@
%rd 0:5
%esz_sd 22:1 !function=plus_2
+%esz_hs 22:1 !function=plus_1
%esz_hsd 22:2 !function=xor_2
%hl 11:1 21:1
%hlm 11:1 20:2
@@ -74,6 +75,7 @@
@qrr_b . q:1 ...... .. ...... ...... rn:5 rd:5 &qrr_e esz=0
@qrr_h . q:1 ...... .. ...... ...... rn:5 rd:5 &qrr_e esz=1
@qrr_bh . q:1 ...... . esz:1 ...... ...... rn:5 rd:5 &qrr_e
+@qrr_hs . q:1 ...... .. ...... ...... rn:5 rd:5 &qrr_e esz=%esz_hs
@qrr_e . q:1 ...... esz:2 ...... ...... rn:5 rd:5 &qrr_e
@qrrr_b . q:1 ...... ... rm:5 ...... rn:5 rd:5 &qrrr_e esz=0
@@ -1676,3 +1678,6 @@ XTN 0.00 1110 ..1 00001 00101 0 ..... .....
@qrr_e
SQXTUN_v 0.10 1110 ..1 00001 00101 0 ..... ..... @qrr_e
SQXTN_v 0.00 1110 ..1 00001 01001 0 ..... ..... @qrr_e
UQXTN_v 0.10 1110 ..1 00001 01001 0 ..... ..... @qrr_e
+
+FCVTN_v 0.00 1110 0.1 00001 01101 0 ..... ..... @qrr_hs
+BFCVTN_v 0.00 1110 101 00001 01101 0 ..... ..... @qrr_h
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index 7b76945b0ac..d4d19c9caaf 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -9051,6 +9051,49 @@ TRANS(SQXTUN_v, do_2misc_narrow_vector, a,
f_scalar_sqxtun)
TRANS(SQXTN_v, do_2misc_narrow_vector, a, f_scalar_sqxtn)
TRANS(UQXTN_v, do_2misc_narrow_vector, a, f_scalar_uqxtn)
+static void gen_fcvtn_hs(TCGv_i64 d, TCGv_i64 n)
+{
+ TCGv_i32 tcg_lo = tcg_temp_new_i32();
+ TCGv_i32 tcg_hi = tcg_temp_new_i32();
+ TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR);
+ TCGv_i32 ahp = get_ahp_flag();
+
+ tcg_gen_extr_i64_i32(tcg_lo, tcg_hi, n);
+ gen_helper_vfp_fcvt_f32_to_f16(tcg_lo, tcg_lo, fpst, ahp);
+ gen_helper_vfp_fcvt_f32_to_f16(tcg_hi, tcg_hi, fpst, ahp);
+ tcg_gen_deposit_i32(tcg_lo, tcg_lo, tcg_hi, 16, 16);
+ tcg_gen_extu_i32_i64(d, tcg_lo);
+}
+
+static void gen_fcvtn_sd(TCGv_i64 d, TCGv_i64 n)
+{
+ TCGv_i32 tmp = tcg_temp_new_i32();
+ gen_helper_vfp_fcvtsd(tmp, n, tcg_env);
+ tcg_gen_extu_i32_i64(d, tmp);
+}
+
+static ArithOneOp * const f_vector_fcvtn[] = {
+ NULL,
+ gen_fcvtn_hs,
+ gen_fcvtn_sd,
+};
+TRANS(FCVTN_v, do_2misc_narrow_vector, a, f_vector_fcvtn)
+
+static void gen_bfcvtn_hs(TCGv_i64 d, TCGv_i64 n)
+{
+ TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR);
+ TCGv_i32 tmp = tcg_temp_new_i32();
+ gen_helper_bfcvt_pair(tmp, n, fpst);
+ tcg_gen_extu_i32_i64(d, tmp);
+}
+
+static ArithOneOp * const f_vector_bfcvtn[] = {
+ NULL,
+ gen_bfcvtn_hs,
+ NULL,
+};
+TRANS_FEAT(BFCVTN_v, aa64_bf16, do_2misc_narrow_vector, a, f_vector_bfcvtn)
+
/* Common vector code for handling integer to FP conversion */
static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
int elements, int is_signed,
@@ -9633,33 +9676,6 @@ static void handle_2misc_narrow(DisasContext *s, bool
scalar,
tcg_res[pass] = tcg_temp_new_i64();
switch (opcode) {
- case 0x16: /* FCVTN, FCVTN2 */
- /* 32 bit to 16 bit or 64 bit to 32 bit float conversion */
- if (size == 2) {
- TCGv_i32 tmp = tcg_temp_new_i32();
- gen_helper_vfp_fcvtsd(tmp, tcg_op, tcg_env);
- tcg_gen_extu_i32_i64(tcg_res[pass], tmp);
- } else {
- TCGv_i32 tcg_lo = tcg_temp_new_i32();
- TCGv_i32 tcg_hi = tcg_temp_new_i32();
- TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR);
- TCGv_i32 ahp = get_ahp_flag();
-
- tcg_gen_extr_i64_i32(tcg_lo, tcg_hi, tcg_op);
- gen_helper_vfp_fcvt_f32_to_f16(tcg_lo, tcg_lo, fpst, ahp);
- gen_helper_vfp_fcvt_f32_to_f16(tcg_hi, tcg_hi, fpst, ahp);
- tcg_gen_deposit_i32(tcg_lo, tcg_lo, tcg_hi, 16, 16);
- tcg_gen_extu_i32_i64(tcg_res[pass], tcg_lo);
- }
- break;
- case 0x36: /* BFCVTN, BFCVTN2 */
- {
- TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR);
- TCGv_i32 tmp = tcg_temp_new_i32();
- gen_helper_bfcvt_pair(tmp, tcg_op, fpst);
- tcg_gen_extu_i32_i64(tcg_res[pass], tmp);
- }
- break;
case 0x56: /* FCVTXN, FCVTXN2 */
{
/*
@@ -9675,6 +9691,8 @@ static void handle_2misc_narrow(DisasContext *s, bool
scalar,
default:
case 0x12: /* XTN, SQXTUN */
case 0x14: /* SQXTN, UQXTN */
+ case 0x16: /* FCVTN, FCVTN2 */
+ case 0x36: /* BFCVTN, BFCVTN2 */
g_assert_not_reached();
}
@@ -10088,21 +10106,6 @@ static void disas_simd_two_reg_misc(DisasContext *s,
uint32_t insn)
unallocated_encoding(s);
return;
}
- /* fall through */
- case 0x16: /* FCVTN, FCVTN2 */
- /* handle_2misc_narrow does a 2*size -> size operation, but these
- * instructions encode the source size rather than dest size.
- */
- if (!fp_access_check(s)) {
- return;
- }
- handle_2misc_narrow(s, false, opcode, 0, is_q, size - 1, rn, rd);
- return;
- case 0x36: /* BFCVTN, BFCVTN2 */
- if (!dc_isar_feature(aa64_bf16, s) || size != 2) {
- unallocated_encoding(s);
- return;
- }
if (!fp_access_check(s)) {
return;
}
@@ -10155,6 +10158,8 @@ static void disas_simd_two_reg_misc(DisasContext *s,
uint32_t insn)
}
break;
default:
+ case 0x16: /* FCVTN, FCVTN2 */
+ case 0x36: /* BFCVTN, BFCVTN2 */
unallocated_encoding(s);
return;
}
--
2.34.1
- [PULL 31/85] target/arm: Convert FCVT (scalar) to decodetree, (continued)
- [PULL 31/85] target/arm: Convert FCVT (scalar) to decodetree, Peter Maydell, 2024/12/13
- [PULL 35/85] target/arm: Convert SQABS, SQNEG to decodetree, Peter Maydell, 2024/12/13
- [PULL 37/85] target/arm: Introduce gen_gvec_cls, gen_gvec_clz, Peter Maydell, 2024/12/13
- [PULL 41/85] target/arm: Convert CMGT, CMGE, GMLT, GMLE, CMEQ (zero) to decodetree, Peter Maydell, 2024/12/13
- [PULL 40/85] target/arm: Convert CNT, NOT, RBIT (vector) to decodetree, Peter Maydell, 2024/12/13
- [PULL 42/85] target/arm: Introduce gen_gvec_rev{16,32,64}, Peter Maydell, 2024/12/13
- [PULL 43/85] target/arm: Convert handle_rev to decodetree, Peter Maydell, 2024/12/13
- [PULL 47/85] target/arm: Remove helper_neon_{add,sub}l_u{16,32}, Peter Maydell, 2024/12/13
- [PULL 46/85] target/arm: Convert handle_2misc_pairwise to decodetree, Peter Maydell, 2024/12/13
- [PULL 52/85] target/arm: Convert SHLL to decodetree, Peter Maydell, 2024/12/13
- [PULL 50/85] target/arm: Convert FCVTN, BFCVTN to decodetree,
Peter Maydell <=
- [PULL 54/85] target/arm: Convert FABS, FNEG (vector) to decodetree, Peter Maydell, 2024/12/13
- [PULL 53/85] target/arm: Implement gen_gvec_fabs, gen_gvec_fneg, Peter Maydell, 2024/12/13
- [PULL 07/85] target/arm: Convert RBIT, REV16, REV32, REV64 to decodetree, Peter Maydell, 2024/12/13
- [PULL 39/85] target/arm: Introduce gen_gvec_cnt, gen_gvec_rbit, Peter Maydell, 2024/12/13
- [PULL 45/85] target/arm: Introduce gen_gvec_{s,u}{add,ada}lp, Peter Maydell, 2024/12/13
- [PULL 56/85] target/arm: Convert FRINT* (vector) to decodetree, Peter Maydell, 2024/12/13
- [PULL 60/85] target/arm: Convert [US]CVTF (vector, fixed-point) scalar to decodetree, Peter Maydell, 2024/12/13
- [PULL 58/85] target/arm: Convert FCVT* (vector, fixed-point) scalar to decodetree, Peter Maydell, 2024/12/13
- [PULL 61/85] target/arm: Rename helper_gvec_vcvt_[hf][su] with _rz, Peter Maydell, 2024/12/13
- [PULL 63/85] target/arm: Convert FCVTZ[SU] (vector, fixed-point) to decodetree, Peter Maydell, 2024/12/13