qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: gkurz@kaod.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v2 04/15] target/ppc: introduce separate VSX_CMP macro for xvcmp* instructions
Date: Wed, 12 Jun 2019 11:52:24 +1000	[thread overview]
Message-ID: <20190612015224.GG3998@umbus.fritz.box> (raw)
In-Reply-To: <20190602110903.3431-5-mark.cave-ayland@ilande.co.uk>

[-- Attachment #1: Type: text/plain, Size: 10552 bytes --]

On Sun, Jun 02, 2019 at 12:08:52PM +0100, Mark Cave-Ayland wrote:
> Rather than perform the VSR register decoding within the helper itself,
> introduce a new VSX_CMP macro which performs the decode based upon xT, xA
> and xB at translation time.
> 
> Subsequent commits will make the same changes for other instructions however
> the xvcmp* instructions are different in that they return a set of flags to be
> optionally written back to the crf[6] register. Move this logic from the
> helper function to the generator function, along with the
> float_status update.

What's the advantage of this.  Since we still have a helper, don't we
suffer the cost of the helper call *plus* the now-generated
instructions?

> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  target/ppc/fpu_helper.c             | 15 +++++-------
>  target/ppc/helper.h                 | 20 +++++++++------
>  target/ppc/translate/vsx-impl.inc.c | 49 +++++++++++++++++++++++++++++++------
>  3 files changed, 59 insertions(+), 25 deletions(-)
> 
> diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
> index 5edf913a89..4b9b695333 100644
> --- a/target/ppc/fpu_helper.c
> +++ b/target/ppc/fpu_helper.c
> @@ -2746,12 +2746,11 @@ VSX_MAX_MINJ(xsminjdp, 0);
>   *   exp   - expected result of comparison
>   */
>  #define VSX_CMP(op, nels, tp, fld, cmp, svxvc, exp)                       \
> -void helper_##op(CPUPPCState *env, uint32_t opcode)                       \
> +uint32_t helper_##op(CPUPPCState *env, ppc_vsr_t *xt,                     \
> +                     ppc_vsr_t *xa, ppc_vsr_t *xb)                        \
>  {                                                                         \
> -    ppc_vsr_t *xt = &env->vsr[xT(opcode)];                                \
> -    ppc_vsr_t *xa = &env->vsr[xA(opcode)];                                \
> -    ppc_vsr_t *xb = &env->vsr[xB(opcode)];                                \
>      ppc_vsr_t t = *xt;                                                    \
> +    uint32_t crf6 = 0;                                                    \
>      int i;                                                                \
>      int all_true = 1;                                                     \
>      int all_false = 1;                                                    \
> @@ -2780,11 +2779,9 @@ void helper_##op(CPUPPCState *env, uint32_t opcode)                       \
>      }                                                                     \
>                                                                            \
>      *xt = t;                                                              \
> -    if ((opcode >> (31 - 21)) & 1) {                                      \
> -        env->crf[6] = (all_true ? 0x8 : 0) | (all_false ? 0x2 : 0);       \
> -    }                                                                     \
> -    do_float_check_status(env, GETPC());                                  \
> - }
> +    crf6 = (all_true ? 0x8 : 0) | (all_false ? 0x2 : 0);                  \
> +    return crf6;                                                          \
> +}
>  
>  VSX_CMP(xvcmpeqdp, 2, float64, VsrD(i), eq, 0, 1)
>  VSX_CMP(xvcmpgedp, 2, float64, VsrD(i), le, 1, 1)
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index 02b67a333e..8666415169 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -108,6 +108,10 @@ DEF_HELPER_FLAGS_1(ftsqrt, TCG_CALL_NO_RWG_SE, i32, i64)
>  #define dh_ctype_avr ppc_avr_t *
>  #define dh_is_signed_avr dh_is_signed_ptr
>  
> +#define dh_alias_vsr ptr
> +#define dh_ctype_vsr ppc_vsr_t *
> +#define dh_is_signed_vsr dh_is_signed_ptr
> +
>  DEF_HELPER_3(vavgub, void, avr, avr, avr)
>  DEF_HELPER_3(vavguh, void, avr, avr, avr)
>  DEF_HELPER_3(vavguw, void, avr, avr, avr)
> @@ -468,10 +472,10 @@ DEF_HELPER_2(xvnmsubadp, void, env, i32)
>  DEF_HELPER_2(xvnmsubmdp, void, env, i32)
>  DEF_HELPER_2(xvmaxdp, void, env, i32)
>  DEF_HELPER_2(xvmindp, void, env, i32)
> -DEF_HELPER_2(xvcmpeqdp, void, env, i32)
> -DEF_HELPER_2(xvcmpgedp, void, env, i32)
> -DEF_HELPER_2(xvcmpgtdp, void, env, i32)
> -DEF_HELPER_2(xvcmpnedp, void, env, i32)
> +DEF_HELPER_FLAGS_4(xvcmpeqdp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
> +DEF_HELPER_FLAGS_4(xvcmpgedp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
> +DEF_HELPER_FLAGS_4(xvcmpgtdp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
> +DEF_HELPER_FLAGS_4(xvcmpnedp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
>  DEF_HELPER_2(xvcvdpsp, void, env, i32)
>  DEF_HELPER_2(xvcvdpsxds, void, env, i32)
>  DEF_HELPER_2(xvcvdpsxws, void, env, i32)
> @@ -506,10 +510,10 @@ DEF_HELPER_2(xvnmsubasp, void, env, i32)
>  DEF_HELPER_2(xvnmsubmsp, void, env, i32)
>  DEF_HELPER_2(xvmaxsp, void, env, i32)
>  DEF_HELPER_2(xvminsp, void, env, i32)
> -DEF_HELPER_2(xvcmpeqsp, void, env, i32)
> -DEF_HELPER_2(xvcmpgesp, void, env, i32)
> -DEF_HELPER_2(xvcmpgtsp, void, env, i32)
> -DEF_HELPER_2(xvcmpnesp, void, env, i32)
> +DEF_HELPER_FLAGS_4(xvcmpeqsp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
> +DEF_HELPER_FLAGS_4(xvcmpgesp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
> +DEF_HELPER_FLAGS_4(xvcmpgtsp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
> +DEF_HELPER_FLAGS_4(xvcmpnesp, TCG_CALL_NO_RWG, i32, env, vsr, vsr, vsr)
>  DEF_HELPER_2(xvcvspdp, void, env, i32)
>  DEF_HELPER_2(xvcvsphp, void, env, i32)
>  DEF_HELPER_2(xvcvhpsp, void, env, i32)
> diff --git a/target/ppc/translate/vsx-impl.inc.c b/target/ppc/translate/vsx-impl.inc.c
> index 199d22da97..fb52a5bbf7 100644
> --- a/target/ppc/translate/vsx-impl.inc.c
> +++ b/target/ppc/translate/vsx-impl.inc.c
> @@ -20,6 +20,13 @@ static inline void set_cpu_vsrl(int n, TCGv_i64 src)
>      tcg_gen_st_i64(src, cpu_env, vsr64_offset(n, false));
>  }
>  
> +static inline TCGv_ptr gen_vsr_ptr(int reg)
> +{
> +    TCGv_ptr r = tcg_temp_new_ptr();
> +    tcg_gen_addi_ptr(r, cpu_env, vsr_full_offset(reg));
> +    return r;
> +}
> +
>  #define VSX_LOAD_SCALAR(name, operation)                      \
>  static void gen_##name(DisasContext *ctx)                     \
>  {                                                             \
> @@ -957,6 +964,40 @@ VSX_VECTOR_MOVE(xvnabssp, OP_NABS, SGN_MASK_SP)
>  VSX_VECTOR_MOVE(xvnegsp, OP_NEG, SGN_MASK_SP)
>  VSX_VECTOR_MOVE(xvcpsgnsp, OP_CPSGN, SGN_MASK_SP)
>  
> +#define VSX_CMP(name, op1, op2, inval, type)                                  \
> +static void gen_##name(DisasContext *ctx)                                     \
> +{                                                                             \
> +    TCGv_i32 ignored;                                                         \
> +    TCGv_ptr xt, xa, xb;                                                      \
> +    if (unlikely(!ctx->vsx_enabled)) {                                        \
> +        gen_exception(ctx, POWERPC_EXCP_VSXU);                                \
> +        return;                                                               \
> +    }                                                                         \
> +    xt = gen_vsr_ptr(xT(ctx->opcode));                                        \
> +    xa = gen_vsr_ptr(xA(ctx->opcode));                                        \
> +    xb = gen_vsr_ptr(xB(ctx->opcode));                                        \
> +    if ((ctx->opcode >> (31 - 21)) & 1) {                                     \
> +        gen_helper_##name(cpu_crf[6], cpu_env, xt, xa, xb);                   \
> +    } else {                                                                  \
> +        ignored = tcg_temp_new_i32();                                         \
> +        gen_helper_##name(ignored, cpu_env, xt, xa, xb);                      \
> +        tcg_temp_free_i32(ignored);                                           \
> +    }                                                                         \
> +    gen_helper_float_check_status(cpu_env);                                   \
> +    tcg_temp_free_ptr(xt);                                                    \
> +    tcg_temp_free_ptr(xa);                                                    \
> +    tcg_temp_free_ptr(xb);                                                    \
> +}
> +
> +VSX_CMP(xvcmpeqdp, 0x0C, 0x0C, 0, PPC2_VSX)
> +VSX_CMP(xvcmpgedp, 0x0C, 0x0E, 0, PPC2_VSX)
> +VSX_CMP(xvcmpgtdp, 0x0C, 0x0D, 0, PPC2_VSX)
> +VSX_CMP(xvcmpnedp, 0x0C, 0x0F, 0, PPC2_ISA300)
> +VSX_CMP(xvcmpeqsp, 0x0C, 0x08, 0, PPC2_VSX)
> +VSX_CMP(xvcmpgesp, 0x0C, 0x0A, 0, PPC2_VSX)
> +VSX_CMP(xvcmpgtsp, 0x0C, 0x09, 0, PPC2_VSX)
> +VSX_CMP(xvcmpnesp, 0x0C, 0x0B, 0, PPC2_VSX)
> +
>  #define GEN_VSX_HELPER_2(name, op1, op2, inval, type)                         \
>  static void gen_##name(DisasContext *ctx)                                     \
>  {                                                                             \
> @@ -1096,10 +1137,6 @@ GEN_VSX_HELPER_2(xvnmsubadp, 0x04, 0x1E, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvnmsubmdp, 0x04, 0x1F, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvmaxdp, 0x00, 0x1C, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvmindp, 0x00, 0x1D, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpeqdp, 0x0C, 0x0C, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpgtdp, 0x0C, 0x0D, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpgedp, 0x0C, 0x0E, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpnedp, 0x0C, 0x0F, 0, PPC2_ISA300)
>  GEN_VSX_HELPER_2(xvcvdpsp, 0x12, 0x18, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvcvdpsxds, 0x10, 0x1D, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvcvdpsxws, 0x10, 0x0D, 0, PPC2_VSX)
> @@ -1134,10 +1171,6 @@ GEN_VSX_HELPER_2(xvnmsubasp, 0x04, 0x1A, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvnmsubmsp, 0x04, 0x1B, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvmaxsp, 0x00, 0x18, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvminsp, 0x00, 0x19, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpeqsp, 0x0C, 0x08, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpgtsp, 0x0C, 0x09, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpgesp, 0x0C, 0x0A, 0, PPC2_VSX)
> -GEN_VSX_HELPER_2(xvcmpnesp, 0x0C, 0x0B, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvcvspdp, 0x12, 0x1C, 0, PPC2_VSX)
>  GEN_VSX_HELPER_2(xvcvhpsp, 0x16, 0x1D, 0x18, PPC2_ISA300)
>  GEN_VSX_HELPER_2(xvcvsphp, 0x16, 0x1D, 0x19, PPC2_ISA300)

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-06-12  2:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-02 11:08 [Qemu-devel] [PATCH v2 00/15] target/ppc: remove getVSR()/putVSR() and further tidy-up Mark Cave-Ayland
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 01/15] target/ppc: remove getVSR()/putVSR() from fpu_helper.c Mark Cave-Ayland
2019-06-12 19:45   ` Richard Henderson
2019-06-16  8:01     ` Mark Cave-Ayland
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 02/15] target/ppc: remove getVSR()/putVSR() from mem_helper.c Mark Cave-Ayland
2019-06-12  1:04   ` David Gibson
2019-06-16  7:40     ` Mark Cave-Ayland
2019-06-12 19:47   ` Richard Henderson
2019-06-16  7:57     ` Mark Cave-Ayland
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 03/15] target/ppc: remove getVSR()/putVSR() from int_helper.c Mark Cave-Ayland
2019-06-12 19:49   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 04/15] target/ppc: introduce separate VSX_CMP macro for xvcmp* instructions Mark Cave-Ayland
2019-06-12  1:52   ` David Gibson [this message]
2019-06-12  4:22     ` Richard Henderson
2019-06-12  5:16       ` David Gibson
2019-06-12 15:58         ` Richard Henderson
2019-06-12 19:59   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 05/15] target/ppc: introduce GEN_VSX_HELPER_X3 macro to fpu_helper.c Mark Cave-Ayland
2019-06-12 20:02   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 06/15] target/ppc: introduce separate generator and helper for xscvqpdp Mark Cave-Ayland
2019-06-12 20:04   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 07/15] target/ppc: introduce GEN_VSX_HELPER_X2 macro to fpu_helper.c Mark Cave-Ayland
2019-06-12 20:05   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 08/15] target/ppc: introduce GEN_VSX_HELPER_X2_AB " Mark Cave-Ayland
2019-06-12 20:06   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 09/15] target/ppc: introduce GEN_VSX_HELPER_X1 " Mark Cave-Ayland
2019-06-13  3:28   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 10/15] target/ppc: introduce GEN_VSX_HELPER_R3 " Mark Cave-Ayland
2019-06-13  3:29   ` Richard Henderson
2019-06-02 11:08 ` [Qemu-devel] [PATCH v2 11/15] target/ppc: introduce GEN_VSX_HELPER_R2 " Mark Cave-Ayland
2019-06-13  3:31   ` Richard Henderson
2019-06-02 11:09 ` [Qemu-devel] [PATCH v2 12/15] target/ppc: introduce GEN_VSX_HELPER_R2_AB " Mark Cave-Ayland
2019-06-02 11:09 ` [Qemu-devel] [PATCH v2 13/15] target/ppc: decode target register in VSX_VECTOR_LOAD_STORE_LENGTH at translation time Mark Cave-Ayland
2019-06-02 11:09 ` [Qemu-devel] [PATCH v2 14/15] target/ppc: decode target register in VSX_EXTRACT_INSERT " Mark Cave-Ayland
2019-06-02 11:09 ` [Qemu-devel] [PATCH v2 15/15] target/ppc: improve VSX_FMADD with new GEN_VSX_HELPER_VSX_MADD macro Mark Cave-Ayland
2019-06-13  3:41   ` Richard Henderson
2019-06-03 10:48 ` [Qemu-devel] [PATCH v2 00/15] target/ppc: remove getVSR()/putVSR() and further tidy-up no-reply
2019-06-04 18:48   ` Mark Cave-Ayland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190612015224.GG3998@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=gkurz@kaod.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).