All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Leon Alrae <leon.alrae@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 04/15] target-mips: refactor {D}LSA, {D}ALIGN, {D}BITSWAP
Date: Wed, 24 Jun 2015 15:16:04 +0200	[thread overview]
Message-ID: <20150624131604.GA22928@aurel32.net> (raw)
In-Reply-To: <558AA333.8000602@imgtec.com>

On 2015-06-24 13:31, Leon Alrae wrote:
> On 24/06/2015 12:04, Aurelien Jarno wrote:
> >> +static void gen_align(DisasContext *ctx, int opc, int rd, int rs, int rt,
> >> +                      int bp)
> >>  {
> >> +    TCGv t0;
> >> +    if (rd == 0) {
> >> +        /* Treat as NOP. */
> >> +        return;
> >> +    }
> >> +    t0 = tcg_temp_new();
> >> +    gen_load_gpr(t0, rt);
> >> +    if (bp == 0) {
> >> +        tcg_gen_mov_tl(cpu_gpr[rd], t0);
> >> +    } else {
> >> +        TCGv t1 = tcg_temp_new();
> >> +        gen_load_gpr(t1, rs);
> >> +        switch (opc) {
> >> +        case OPC_ALIGN:
> >> +            {
> >> +                TCGv_i64 t2 = tcg_temp_new_i64();
> >> +                tcg_gen_concat_tl_i64(t2, t1, t0);
> >> +                tcg_gen_shri_i64(t2, t2, 8 * (4 - bp));
> >> +                gen_move_low32(cpu_gpr[rd], t2);
> >> +                tcg_temp_free_i64(t2);
> >> +            }
> >> +            break;
> > 
> > Not a problem in your patch (you basically just moved code), but I
> > think this implementation is incorrect. It should be the same code as
> > for DALIGN, but with the input operands zero extended to 32 bits, and
> > the result sign extended to 32 bits. Something like that should work:
> > 
> > tcg_gen_ext32u_tl(t0, t0);
> > tcg_gen_shli_tl(t0, t0, 8 * bp);
> > tcg_gen_ext32u_tl(t1, t1);
> > tcg_gen_shri_tl(t1, t1, 8 * (4 - bp));
> > tcg_gen_or_tl(cpu_gpr[rd], t1, t0);
> > tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
> > 
> > In practice we can drop the zero extension on t0 (rt) as the bits there
> > will be dropped by the sign extension on the result. Note that on
> > 32-bit, the zero and sign extension will be dropped, so there is no need
> > for #ifdef TARGET_MIPS64.
> 
> I believe existing implementation is correct and does the same thing, but it
> operates on the whole 64-bit temp containing merged rs and rt rather than
> shifting 32-bit registers separately. We discussed this last year, and the
> potential benefit is that it could be slightly faster on 64-bit host.

If it is has already been discussed, then:

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2015-06-24 13:16 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 15:38 [Qemu-devel] [PATCH v3 00/15] target-mips: add microMIPS32 R6 Instruction Set support Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 01/15] target-mips: fix {RD, WR}PGPR in microMIPS Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 02/15] target-mips: add microMIPS TLBINV, TLBINVF Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 03/15] target-mips: remove an unused argument Yongbok Kim
2015-06-23 23:35   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 04/15] target-mips: refactor {D}LSA, {D}ALIGN, {D}BITSWAP Yongbok Kim
2015-06-24 11:04   ` Aurelien Jarno
2015-06-24 12:31     ` Leon Alrae
2015-06-24 13:16       ` Aurelien Jarno [this message]
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 05/15] target-mips: rearrange gen_compute_compact_branch Yongbok Kim
2015-06-24 11:15   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 06/15] target-mips: raise RI exceptions when FIR.PS = 0 Yongbok Kim
2015-06-24 12:28   ` Aurelien Jarno
2015-06-24 14:24     ` Yongbok Kim
2015-06-24 14:59       ` Aurelien Jarno
2015-06-24 15:24         ` Aurelien Jarno
2015-06-24 15:53           ` Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 07/15] target-mips: signal RI for removed instructions in microMIPS R6 Yongbok Kim
2015-06-24 12:32   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 08/15] target-mips: add microMIPS32 R6 opcode enum Yongbok Kim
2015-06-24 13:23   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 09/15] target-mips: microMIPS32 R6 branches and jumps Yongbok Kim
2015-06-24 13:24   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 10/15] target-mips: microMIPS32 R6 POOL32A{XF} instructions Yongbok Kim
2015-06-24 13:24   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 11/15] target-mips: microMIPS32 R6 POOL32F instructions Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 12/15] target-mips: microMIPS32 R6 POOL32{I, C} instructions Yongbok Kim
2015-06-23 16:16   ` Leon Alrae
2015-06-24 13:29   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 13/15] target-mips: microMIPS32 R6 Major instructions Yongbok Kim
2015-06-24 13:33   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 14/15] target-mips: microMIPS32 R6 POOL16{A, C} instructions Yongbok Kim
2015-06-23 16:16   ` Leon Alrae
2015-06-24 13:43   ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 15/15] target-mips: add mips32r6-generic CPU definition Yongbok Kim
2015-06-24 13:44   ` Aurelien Jarno

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=20150624131604.GA22928@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=leon.alrae@imgtec.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yongbok.kim@imgtec.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.