From ee3096289162971bcb2b5360503c56a0136cbdcf Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 13 Jun 2019 18:45:42 -0400 Subject: [PATCH] target/arm: Convert VSQRT to decodetree Convert the VSQRT instruction to decodetree. Backports commit b8474540cbce4e2fa45010416375d1bcbe86dc15 from qemu --- qemu/target/arm/translate-vfp.inc.c | 20 ++++++++++++++++++++ qemu/target/arm/translate.c | 15 +-------------- qemu/target/arm/vfp.decode | 5 +++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/qemu/target/arm/translate-vfp.inc.c b/qemu/target/arm/translate-vfp.inc.c index 92030169..f9c22991 100644 --- a/qemu/target/arm/translate-vfp.inc.c +++ b/qemu/target/arm/translate-vfp.inc.c @@ -1933,3 +1933,23 @@ static bool trans_VNEG_dp(DisasContext *s, arg_VNEG_dp *a) { return do_vfp_2op_dp(s, gen_helper_vfp_negd, a->vd, a->vm); } + +static void gen_VSQRT_sp(TCGContext *tcg_ctx, TCGv_i32 vd, TCGv_i32 vm) +{ + gen_helper_vfp_sqrts(tcg_ctx, vd, vm, tcg_ctx->cpu_env); +} + +static bool trans_VSQRT_sp(DisasContext *s, arg_VSQRT_sp *a) +{ + return do_vfp_2op_sp(s, gen_VSQRT_sp, a->vd, a->vm); +} + +static void gen_VSQRT_dp(TCGContext *tcg_ctx, TCGv_i64 vd, TCGv_i64 vm) +{ + gen_helper_vfp_sqrtd(tcg_ctx, vd, vm, tcg_ctx->cpu_env); +} + +static bool trans_VSQRT_dp(DisasContext *s, arg_VSQRT_dp *a) +{ + return do_vfp_2op_dp(s, gen_VSQRT_dp, a->vd, a->vm); +} diff --git a/qemu/target/arm/translate.c b/qemu/target/arm/translate.c index 2384ee30..644ac77e 100644 --- a/qemu/target/arm/translate.c +++ b/qemu/target/arm/translate.c @@ -1447,15 +1447,6 @@ static inline void gen_vfp_neg(DisasContext *s, int dp) gen_helper_vfp_negs(tcg_ctx, s->F0s, s->F0s); } -static inline void gen_vfp_sqrt(DisasContext *s, int dp) -{ - TCGContext *tcg_ctx = s->uc->tcg_ctx; - if (dp) - gen_helper_vfp_sqrtd(tcg_ctx, s->F0d, s->F0d, tcg_ctx->cpu_env); - else - gen_helper_vfp_sqrts(tcg_ctx, s->F0s, s->F0s, tcg_ctx->cpu_env); -} - static inline void gen_vfp_cmp(DisasContext *s, int dp) { TCGContext *tcg_ctx = s->uc->tcg_ctx; @@ -3199,7 +3190,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 1 ... 2: + case 1 ... 3: /* Already handled by decodetree */ return 1; default: @@ -3213,7 +3204,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { case 0x00: /* vmov */ - case 0x03: /* vsqrt */ break; case 0x04: /* vcvtb.f64.f16, vcvtb.f32.f16 */ @@ -3391,9 +3381,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 0: /* cpy */ /* no-op */ break; - case 3: /* sqrt */ - gen_vfp_sqrt(s, dp); - break; case 4: /* vcvtb.f32.f16, vcvtb.f64.f16 */ { TCGv_ptr fpst = get_fpstatus_ptr(s, false); diff --git a/qemu/target/arm/vfp.decode b/qemu/target/arm/vfp.decode index 79e41963..2780e1ed 100644 --- a/qemu/target/arm/vfp.decode +++ b/qemu/target/arm/vfp.decode @@ -166,3 +166,8 @@ VNEG_sp ---- 1110 1.11 0001 .... 1010 01.0 .... \ vd=%vd_sp vm=%vm_sp VNEG_dp ---- 1110 1.11 0001 .... 1011 01.0 .... \ vd=%vd_dp vm=%vm_dp + +VSQRT_sp ---- 1110 1.11 0001 .... 1010 11.0 .... \ + vd=%vd_sp vm=%vm_sp +VSQRT_dp ---- 1110 1.11 0001 .... 1011 11.0 .... \ + vd=%vd_dp vm=%vm_dp