qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: rth7680@gmail.com, qemu-devel@nongnu.org,
	Petar Jovanovic <petar.jovanovic@rt-rk.com>,
	blauwirbel@gmail.com, petarj@mips.com, afaerber@suse.de,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for SHILO and SHILOV
Date: Thu, 6 Dec 2012 09:17:11 +0100	[thread overview]
Message-ID: <20121206081711.GC4244@ohm.aurel32.net> (raw)
In-Reply-To: <CAFEAcA_QqPXBPEw1BjWzP0==x6tS-4gthC5kNvaPqPQ8coGf1A@mail.gmail.com>

On Wed, Dec 05, 2012 at 04:38:22PM +0000, Peter Maydell wrote:
> On 5 December 2012 15:51, Richard Henderson <rth@twiddle.net> wrote:
> > On 2012-12-05 09:49, Peter Maydell wrote:
> >> On 5 December 2012 15:36, Richard Henderson <rth@twiddle.net> wrote:
> >>> On 2012-12-04 17:29, Petar Jovanovic wrote:
> >>>>      rs5_0 = (int8_t)(rs5_0 << 2) >> 2;
> >>>
> >>> This is more portably written as
> >>>
> >>>   rs5_0 = (rs5_0 ^ 0x20) - 0x20;
> >>
> >> ...but way more obscurely. If we want to play that
> >> kind of game can we have a sign-extension function in
> >> a header somewhere?
> >
> > I dunno about more obscurely.  It took me a minute to figure out
> > what was wanted in the original.
> >
> > As for a helper function... sure.
> 
> I don't think we should block this patch on that general
> cleanup, though. All the sign extensions in target-mips/translate.c
> are done in the double-shift way, so this is consistent with
> the existing code.
> 

While it might be a good idea to make QEMU even more portable, it should
be noticed that currently QEMU assumes that a left shift followed by the
same arithmetic right shift. This is the case in at least the alpha,
arm, m68k, mips, ppc, s390 and unicore32 targets, as well as for
implementing sign extension and division in TCG.


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

  parent reply	other threads:[~2012-12-06  8:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 23:29 [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for SHILO and SHILOV Petar Jovanovic
2012-12-05 15:36 ` Richard Henderson
2012-12-05 15:49   ` Peter Maydell
2012-12-05 15:51     ` Richard Henderson
2012-12-05 16:38       ` Peter Maydell
2012-12-05 23:16         ` Richard Henderson
2012-12-06  8:17         ` Aurelien Jarno [this message]
2012-12-05 20:41 ` Johnson, Eric
2012-12-05 21:36   ` Johnson, Eric
2012-12-05 23:31     ` Jovanovic, Petar
2012-12-06  0:13       ` Johnson, Eric
2012-12-06  8:11 ` 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=20121206081711.GC4244@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=afaerber@suse.de \
    --cc=blauwirbel@gmail.com \
    --cc=petar.jovanovic@rt-rk.com \
    --cc=petarj@mips.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth7680@gmail.com \
    --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).