From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsX2k-0007ku-OV for qemu-devel@nongnu.org; Fri, 28 Jun 2013 07:40:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsX2h-00018w-N4 for qemu-devel@nongnu.org; Fri, 28 Jun 2013 07:40:46 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:58306 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsX2h-0000vW-7M for qemu-devel@nongnu.org; Fri, 28 Jun 2013 07:40:43 -0400 From: Peter Maydell Date: Fri, 28 Jun 2013 12:40:30 +0100 Message-Id: <1372419632-5521-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 0/2] Provide sextract32() and sextract64() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Richard Henderson , Markus Armbruster , patches@linaro.org 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