All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Richard Henderson <rth@twiddle.net>
Cc: Jin Guojie <jinguojie@loongson.cn>,
	qemu-devel@nongnu.org, James Hogan <james.hogan@imgtec.com>
Subject: Re: [Qemu-devel] [PATCH v3 11/11] tcg-mips: Adjust condition functions for mips64
Date: Fri, 25 Nov 2016 15:25:54 +0100	[thread overview]
Message-ID: <20161125142554.f6flqh7tbpkddy72@aurel32.net> (raw)
In-Reply-To: <088324fc-5cfd-57d7-da25-6508734fa77e@twiddle.net>

On 2016-11-25 13:06, Richard Henderson wrote:
> On 11/25/2016 04:31 AM, Jin Guojie wrote:
> > 32-bit condition functions(like brcond_i32) should only
> > compare the low half parts of two 64-bit host registers.
> > However, MIPS64 does not have distinct instruction for
> > such operation. The operands should be sign extended
> > to fit the case.
> > 
> > Gcc handles 32-bit comparison in the same way, as the
> > following example shows:
> > 
> > [a.c]
> > main()
> > {
> >   long a = 0xcccccccc;
> >   long b = 0xdddddddd;
> >   int c = (int)a > (int)b;
> > }
> 
> This problem is why opcodes like
> 
>    OPC_INDEX_extrl_i64_i32
>    OPC_INDEX_extrh_i64_i32
>    OPC_INDEX_ext_i32_i64
>    OPC_INDEX_extu_i32_i64
> 
> exist.  The intention is to keep 32-bit values in their sign-extended form,
> exactly as the mips hardware manual requires.  At which point all 32-bit
> opcodes (ADDIU, SLL, etc) will preserve the 32-bit sign extension property.

It's even stronger than that. It's required for 32-bit opcodes to work
correctly. The manual says:

| If GPR rs does not contain a sign-extended 32-bit value (bits 63..31
| equal), then the result of the operation is UNPREDICTABLE.

Aurelien

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

  reply	other threads:[~2016-11-25 14:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25  3:31 [Qemu-devel] [PATCH v3 00/11] tcg mips64 and mips r6 improvements Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 01/11] tcg-mips: Move bswap code to a subroutine Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 02/11] tcg-mips: Add mips64 opcodes Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 03/11] tcg-mips: Support 64-bit opcodes Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 04/11] tcg-mips: Add bswap32u and bswap64 Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 05/11] tcg-mips: Adjust move functions for mips64 Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 06/11] tcg-mips: Adjust load/store " Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 07/11] tcg-mips: Adjust prologue " Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 08/11] tcg-mips: Add tcg unwind info Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 09/11] tcg-mips: Adjust calling conventions for mips64 Jin Guojie
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 10/11] tcg-mips: Adjust qemu_ld/st " Jin Guojie
2016-11-25 11:55   ` Richard Henderson
2016-11-25  3:31 ` [Qemu-devel] [PATCH v3 11/11] tcg-mips: Adjust condition functions " Jin Guojie
2016-11-25 12:06   ` Richard Henderson
2016-11-25 14:25     ` Aurelien Jarno [this message]
2016-11-25 14:21 ` [Qemu-devel] [PATCH v3 00/11] tcg mips64 and mips r6 improvements Aurelien Jarno
2016-11-30 17:19 ` Aurelien Jarno
2016-11-30 18:33   ` =?gb18030?B?SmluIEd1b2ppZQ==?=
2016-11-30 19:39     ` Aurelien Jarno
2016-11-28  7:42 [Qemu-devel] [PATCH v3 11/11] tcg-mips: Adjust condition functions for mips64 Jin Guojie
2016-11-28  8:11 ` Richard Henderson

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=20161125142554.f6flqh7tbpkddy72@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=james.hogan@imgtec.com \
    --cc=jinguojie@loongson.cn \
    --cc=qemu-devel@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 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.