qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Jia Liu <proljc@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v6 04/13] target-mips-ase-dsp: Add load instructions
Date: Thu, 23 Aug 2012 16:23:34 +0200	[thread overview]
Message-ID: <20120823142334.GE3553@ohm.aurel32.net> (raw)
In-Reply-To: <1345531999-17872-5-git-send-email-proljc@gmail.com>

On Tue, Aug 21, 2012 at 02:53:10PM +0800, Jia Liu wrote:
> Add MIPS ASE DSP Load instructions.
> 
> Signed-off-by: Jia Liu <proljc@gmail.com>
> ---
>  target-mips/translate.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 69 insertions(+)
> 
> diff --git a/target-mips/translate.c b/target-mips/translate.c
> index b049238..f154f09 100644
> --- a/target-mips/translate.c
> +++ b/target-mips/translate.c
> @@ -313,6 +313,9 @@ enum {
>      OPC_MODU_G_2E   = 0x23 | OPC_SPECIAL3,
>      OPC_DMOD_G_2E   = 0x26 | OPC_SPECIAL3,
>      OPC_DMODU_G_2E  = 0x27 | OPC_SPECIAL3,
> +
> +    /* MIPS DSP Load */
> +    OPC_LX_DSP         = 0x0A | OPC_SPECIAL3,
>  };
>  
>  /* BSHFL opcodes */
> @@ -340,6 +343,17 @@ enum {
>  #endif
>  };
>  
> +#define MASK_LX(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
> +/* MIPS DSP Load */
> +enum {
> +    OPC_LBUX = (0x06 << 6) | OPC_LX_DSP,
> +    OPC_LHX  = (0x04 << 6) | OPC_LX_DSP,
> +    OPC_LWX  = (0x00 << 6) | OPC_LX_DSP,
> +#if defined(TARGET_MIPS64)
> +    OPC_LDX = (0x08 << 6) | OPC_LX_DSP,
> +#endif
> +};
> +
>  /* Coprocessor 0 (rs field) */
>  #define MASK_CP0(op)       MASK_OP_MAJOR(op) | (op & (0x1F << 21))
>  
> @@ -12124,6 +12138,61 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)
>              check_insn(env, ctx, INSN_LOONGSON2E);
>              gen_loongson_integer(ctx, op1, rd, rs, rt);
>              break;
> +        case OPC_LX_DSP:
> +            op2 = MASK_LX(ctx->opcode);
> +            switch (op2) {
> +            case OPC_LBUX:
> +                check_insn(env, ctx, ASE_DSP);

How about factorizing the check_insn() code one level above?

> +                {
> +                    TCGv addr = tcg_temp_new();
> +
> +                    save_cpu_state(ctx, 1);

I don't think you need to save pc here, they are normal load
instructions.

> +                    gen_op_addr_add(ctx, addr, cpu_gpr[rs], cpu_gpr[rt]);
> +                    op_ld_lbu(cpu_gpr[rd], addr, ctx);
> +                    tcg_temp_free(addr);
> +                    break;
> +                }
> +            case OPC_LHX:
> +                check_insn(env, ctx, ASE_DSP);
> +                {
> +                    TCGv addr = tcg_temp_new();
> +
> +                    save_cpu_state(ctx, 1);
> +                    gen_op_addr_add(ctx, addr, cpu_gpr[rs], cpu_gpr[rt]);
> +                    op_ld_lh(cpu_gpr[rd], addr, ctx);
> +                    tcg_temp_free(addr);
> +                    break;
> +                }
> +            case OPC_LWX:
> +                check_insn(env, ctx, ASE_DSP);
> +                {
> +                    TCGv addr = tcg_temp_new();
> +
> +                    save_cpu_state(ctx, 1);
> +                    gen_op_addr_add(ctx, addr, cpu_gpr[rs], cpu_gpr[rt]);
> +                    op_ld_lw(cpu_gpr[rd], addr, ctx);
> +                    tcg_temp_free(addr);
> +                    break;
> +                }
> +#if defined(TARGET_MIPS64)
> +            case OPC_LDX:
> +                check_insn(env, ctx, ASE_DSP);
> +                {
> +                    TCGv addr = tcg_temp_new();
> +
> +                    save_cpu_state(ctx, 1);
> +                    gen_op_addr_add(ctx, addr, cpu_gpr[rs], cpu_gpr[rt]);
> +                    op_ld_ld(cpu_gpr[rd], addr, ctx);
> +                    tcg_temp_free(addr);
> +                    break;
> +                }
> +#endif
> +            default:            /* Invalid */
> +                MIPS_INVAL("MASK LX");
> +                generate_exception(ctx, EXCP_RI);
> +                break;
> +            }
> +            break;
>  #if defined(TARGET_MIPS64)
>          case OPC_DEXTM ... OPC_DEXT:
>          case OPC_DINSM ... OPC_DINS:
> -- 
> 1.7.9.5
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2012-08-23 14:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21  6:53 [Qemu-devel] [PATCH v6 00/13] QEMU MIPS ASE DSP support Jia Liu
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 01/13] target-mips-ase-dsp: Add internal functions Jia Liu
2012-08-23 13:31   ` Aurelien Jarno
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 02/13] target-mips-ase-dsp: Use correct acc value to index cpu_HI/cpu_LO rather than using a fix number Jia Liu
2012-08-23 13:33   ` Aurelien Jarno
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 03/13] target-mips-ase-dsp: Add branch instructions Jia Liu
2012-08-23 14:18   ` Aurelien Jarno
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 04/13] target-mips-ase-dsp: Add load instructions Jia Liu
2012-08-23 14:23   ` Aurelien Jarno [this message]
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 05/13] target-mips-ase-dsp: Add arithmetic instructions Jia Liu
2012-08-23 14:28   ` Aurelien Jarno
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 06/13] target-mips-ase-dsp: Add GPR Based shift instructions Jia Liu
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 07/13] target-mips-ase-dsp: Add multiply instructions Jia Liu
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 08/13] target-mips-ase-dsp: Add bit/manipulation instructions Jia Liu
2012-08-23 14:48   ` Aurelien Jarno
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 09/13] target-mips-ase-dsp: Add compare pick instructions Jia Liu
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 10/13] target-mips-ase-dsp: Add MIPS ASE DSP Accumulator and DSPControl Access instructions Jia Liu
2012-08-21  6:53 ` [Qemu-devel] [PATCH v6 11/13] target-mips-ase-dsp: Add MIPS[32|64] ASE DSP[R1|R2] generic cpu model Jia Liu
2012-08-21  9:32 ` [Qemu-devel] [PATCH v6 12/13] target-mips-ase-dsp: Add testcases Jia Liu
2012-08-21  9:34 ` [Qemu-devel] [PATCH v6 13/13] target-mips-ase-dsp: Change TODO Jia Liu

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=20120823142334.GE3553@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=proljc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).