qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Richard Henderson <rth@twiddle.net>,
	Markus Armbruster <armbru@redhat.com>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH 0/2] Provide sextract32() and sextract64()
Date: Fri, 28 Jun 2013 12:40:30 +0100	[thread overview]
Message-ID: <1372419632-5521-1-git-send-email-peter.maydell@linaro.org> (raw)

A common operation in instruction decoding is to take a field
from an instruction that represents a signed integer in some
arbitrary number of bits, and sign extend it into a C signed
integer type for manipulation. Provide new functions sextract32()
and sextract64() which perform this operation; they are like
the existing extract32() and extract64() except that the field
is sign-extended into the returned result.

I agree with Markus that sign-extending versions of our
extract functions are more flexible than the simple sext()
I proposed in an earlier RFC, hence the switch in this patch.
The other change is patch 2, which provides some simple test
cases. (Will be handy if we ever decide to revamp to avoid
the dependency on shift-left-signed behaviour.)

Peter Maydell (2):
  bitops: Provide sextract32() and sextract64()
  tests: Add test-bitops.c with some sextract tests

 include/qemu/bitops.h |   50 +++++++++++++++++++++++++++++++++
 tests/Makefile        |    2 ++
 tests/test-bitops.c   |   75 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+)
 create mode 100644 tests/test-bitops.c

-- 
1.7.9.5

             reply	other threads:[~2013-06-28 11:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-28 11:40 Peter Maydell [this message]
2013-06-28 11:40 ` [Qemu-devel] [PATCH 1/2] bitops: Provide sextract32() and sextract64() Peter Maydell
2013-06-28 11:40 ` [Qemu-devel] [PATCH 2/2] tests: Add test-bitops.c with some sextract tests Peter Maydell
2013-06-28 17:44 ` [Qemu-devel] [PATCH 0/2] Provide sextract32() and sextract64() Richard Henderson
2013-07-12 15:05 ` Peter Maydell
2013-07-19 11:02   ` Peter Maydell
2013-07-23 19:04 ` Anthony Liguori

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=1372419632-5521-1-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=armbru@redhat.com \
    --cc=patches@linaro.org \
    --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 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).