From patchwork Mon Feb 21 10:59:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 83819 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E9F20B70A4 for ; Mon, 21 Feb 2011 22:01:26 +1100 (EST) Received: from localhost ([127.0.0.1]:54007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrTW7-0001L1-4N for incoming@patchwork.ozlabs.org; Mon, 21 Feb 2011 06:01:23 -0500 Received: from [140.186.70.92] (port=51053 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrTUe-0001IV-7N for qemu-devel@nongnu.org; Mon, 21 Feb 2011 05:59:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrTUX-0003fw-0g for qemu-devel@nongnu.org; Mon, 21 Feb 2011 05:59:52 -0500 Received: from eu1sys200aog108.obsmtp.com ([207.126.144.125]:35965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrTUW-0003fL-NK for qemu-devel@nongnu.org; Mon, 21 Feb 2011 05:59:44 -0500 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP ID DSNKTWJFnvLbEyuBx9plLJvFcyaF70V5bz5m@postini.com; Mon, 21 Feb 2011 10:59:44 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 340C32A9 for ; Mon, 21 Feb 2011 10:59:42 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas6.st.com [10.75.90.73]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0A51B2B45 for ; Mon, 21 Feb 2011 10:59:41 +0000 (GMT) Received: from localhost.localdomain (164.129.122.40) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.2.234.1; Mon, 21 Feb 2011 11:59:41 +0100 From: Christophe Lyon To: Date: Mon, 21 Feb 2011 11:59:32 +0100 Message-ID: <1298285975-1717-3-git-send-email-christophe.lyon@st.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1298285975-1717-1-git-send-email-christophe.lyon@st.com> References: <1298285975-1717-1-git-send-email-christophe.lyon@st.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 207.126.144.125 Subject: [Qemu-devel] [PATCH 2/5] softfloat: add _set_sign(), _infinity and _half for 32 and 64 bits floats. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org These constants and utility function are needed to implement some helpers. Defining constants avoids the need to re-compute them at runtime. Signed-off-by: Christophe Lyon Reviewed-by: Peter Maydell --- fpu/softfloat.h | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/fpu/softfloat.h b/fpu/softfloat.h index f34a938..fd61dc4 100644 --- a/fpu/softfloat.h +++ b/fpu/softfloat.h @@ -379,9 +379,16 @@ INLINE int float32_is_zero_or_denormal(float32 a) return (float32_val(a) & 0x7f800000) == 0; } +INLINE float32 float32_set_sign(float32 a, int sign) +{ + return make_float32((float32_val(a) & 0x7fffffff) | (sign << 31)); +} + #define float32_zero make_float32(0) #define float32_one make_float32(0x3f800000) #define float32_ln2 make_float32(0x3f317218) +#define float32_half make_float32(0x3f000000) +#define float32_infinity make_float32(0x7f800000) /*---------------------------------------------------------------------------- @@ -479,9 +486,17 @@ INLINE int float64_is_any_nan(float64 a) return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL); } +INLINE float64 float64_set_sign(float64 a, int sign) +{ + return make_float64((float64_val(a) & 0x7fffffffffffffffULL) + | ((int64_t)sign << 63)); +} + #define float64_zero make_float64(0) #define float64_one make_float64(0x3ff0000000000000LL) #define float64_ln2 make_float64(0x3fe62e42fefa39efLL) +#define float64_half make_float64(0x3fe0000000000000LL) +#define float64_infinity make_float64(0x7ff0000000000000LL) /*---------------------------------------------------------------------------- | The pattern for a default generated double-precision NaN.