From e0e4f99103420565aa057bd3628d564bd9ebc4fe Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 13 Jun 2019 19:18:00 -0400 Subject: [PATCH] target/arm: Convert double-single precision conversion insns to decodetree Convert the VCVT double/single precision conversion insns to decodetree. Backports commit 6ed7e49c3693ed8411773c4880f42b2932beb12d from qemu --- qemu/target/arm/translate-vfp.inc.c | 50 +++++++++++++++++++++++++++++ qemu/target/arm/translate.c | 13 +------- qemu/target/arm/vfp.decode | 6 ++++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/qemu/target/arm/translate-vfp.inc.c b/qemu/target/arm/translate-vfp.inc.c index 6c8a4b3f..2c21edb1 100644 --- a/qemu/target/arm/translate-vfp.inc.c +++ b/qemu/target/arm/translate-vfp.inc.c @@ -2357,3 +2357,53 @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) tcg_temp_free_i64(tcg_ctx, tmp); return true; } + +static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) +{ + TCGContext *tcg_ctx = s->uc->tcg_ctx; + TCGv_i64 vd; + TCGv_i32 vm; + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vm = tcg_temp_new_i32(tcg_ctx); + vd = tcg_temp_new_i64(tcg_ctx); + neon_load_reg32(s, vm, a->vm); + gen_helper_vfp_fcvtds(tcg_ctx, vd, vm, tcg_ctx->cpu_env); + neon_store_reg64(s, vd, a->vd); + tcg_temp_free_i32(tcg_ctx, vm); + tcg_temp_free_i64(tcg_ctx, vd); + return true; +} + +static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) +{ + TCGContext *tcg_ctx = s->uc->tcg_ctx; + TCGv_i64 vm; + TCGv_i32 vd; + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vd = tcg_temp_new_i32(tcg_ctx); + vm = tcg_temp_new_i64(tcg_ctx); + neon_load_reg64(s, vm, a->vm); + gen_helper_vfp_fcvtsd(tcg_ctx, vd, vm, tcg_ctx->cpu_env); + neon_store_reg32(s, vd, a->vd); + tcg_temp_free_i32(tcg_ctx, vd); + tcg_temp_free_i64(tcg_ctx, vm); + return true; +} diff --git a/qemu/target/arm/translate.c b/qemu/target/arm/translate.c index 7e78c052..8e3a50e3 100644 --- a/qemu/target/arm/translate.c +++ b/qemu/target/arm/translate.c @@ -3145,7 +3145,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 14: + case 0 ... 15: /* Already handled by decodetree */ return 1; default: @@ -3158,10 +3158,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x0f: /* vcvt double<->single */ - rd_is_dp = !dp; - break; - case 0x10: /* vcvt.fxx.u32 */ case 0x11: /* vcvt.fxx.s32 */ rm_is_dp = false; @@ -3280,13 +3276,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 15: /* single<->double conversion */ - if (dp) { - gen_helper_vfp_fcvtsd(tcg_ctx, s->F0s, s->F0d, tcg_ctx->cpu_env); - } else { - gen_helper_vfp_fcvtds(tcg_ctx, s->F0d, s->F0s, tcg_ctx->cpu_env); - } - break; case 16: /* fuito */ gen_vfp_uito(s, dp, 0); break; diff --git a/qemu/target/arm/vfp.decode b/qemu/target/arm/vfp.decode index 9942d2ae..56b8b4e6 100644 --- a/qemu/target/arm/vfp.decode +++ b/qemu/target/arm/vfp.decode @@ -208,3 +208,9 @@ VRINTX_sp ---- 1110 1.11 0111 .... 1010 01.0 .... \ vd=%vd_sp vm=%vm_sp VRINTX_dp ---- 1110 1.11 0111 .... 1011 01.0 .... \ vd=%vd_dp vm=%vm_dp + +# VCVT between single and double: Vm precision depends on size; Vd is its reverse +VCVT_sp ---- 1110 1.11 0111 .... 1010 11.0 .... \ + vd=%vd_dp vm=%vm_sp +VCVT_dp ---- 1110 1.11 0111 .... 1011 11.0 .... \ + vd=%vd_sp vm=%vm_dp