From nobody Thu Nov 6 20:32:03 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487747003603263.05225053450033; Tue, 21 Feb 2017 23:03:23 -0800 (PST) Received: from localhost ([::1]:50284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQxN-0005KO-4e for importer@patchew.org; Wed, 22 Feb 2017 02:03:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQV8-000357-Lt for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgQV5-00083p-Vx for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:10 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:39245) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgQV5-0007yw-B3; Wed, 22 Feb 2017 01:34:07 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vSndK4V6Qz9sDC; Wed, 22 Feb 2017 17:33:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1487745237; bh=VBtRIqk8dOJ0KzlSI8011oT3gkDCPFtX0xF+x8UCXTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gGqP9Al41d8yVSIj1EjrCZW8udQCxAK3yAFBR/BLXkbfcXx4/GJVQ4rwc78+Ox/5R x8KmsiyEp1AaOUatgXOJunqmCjnkZ3ftSiK6aRi2z4Kc1PXlw/zCQQ2VztvsH4Y3vQ RE0Lyk2Oo889gV2Ib9cnevFrNMi6pniptbY9KKAw= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:33:28 +1100 Message-Id: <20170222063348.32176-24-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170222063348.32176-1-david@gibson.dropbear.id.au> References: <20170222063348.32176-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 23/43] softfloat: Add float128_to_uint64_round_to_zero() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, Bharata B Rao , imammedo@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bharata B Rao Implement float128_to_uint64() and use that to implement float128_to_uint64_round_to_zero() This is required by xscvqpudz instruction of PowerPC ISA 3.0. Signed-off-by: Bharata B Rao Reviewed-by: Peter Maydell Signed-off-by: David Gibson --- fpu/softfloat.c | 59 +++++++++++++++++++++++++++++++++++++++++++++= ++++ include/fpu/softfloat.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 5ccba76..47e4646 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -6128,6 +6128,65 @@ int64_t float128_to_int64_round_to_zero(float128 a, = float_status *status) } =20 /*------------------------------------------------------------------------= ---- +| Returns the result of converting the quadruple-precision floating-point = value +| `a' to the 64-bit unsigned integer format. The conversion is +| performed according to the IEC/IEEE Standard for Binary Floating-Point +| Arithmetic---which means in particular that the conversion is rounded +| according to the current rounding mode. If `a' is a NaN, the largest +| positive integer is returned. If the conversion overflows, the +| largest unsigned integer is returned. If 'a' is negative, the value is +| rounded and zero is returned; negative values that do not round to zero +| will raise the inexact exception. +*-------------------------------------------------------------------------= ---*/ + +uint64_t float128_to_uint64(float128 a, float_status *status) +{ + flag aSign; + int aExp; + int shiftCount; + uint64_t aSig0, aSig1; + + aSig0 =3D extractFloat128Frac0(a); + aSig1 =3D extractFloat128Frac1(a); + aExp =3D extractFloat128Exp(a); + aSign =3D extractFloat128Sign(a); + if (aSign && (aExp > 0x3FFE)) { + float_raise(float_flag_invalid, status); + if (float128_is_any_nan(a)) { + return LIT64(0xFFFFFFFFFFFFFFFF); + } else { + return 0; + } + } + if (aExp) { + aSig0 |=3D LIT64(0x0001000000000000); + } + shiftCount =3D 0x402F - aExp; + if (shiftCount <=3D 0) { + if (0x403E < aExp) { + float_raise(float_flag_invalid, status); + return LIT64(0xFFFFFFFFFFFFFFFF); + } + shortShift128Left(aSig0, aSig1, -shiftCount, &aSig0, &aSig1); + } else { + shift64ExtraRightJamming(aSig0, aSig1, shiftCount, &aSig0, &aSig1); + } + return roundAndPackUint64(aSign, aSig0, aSig1, status); +} + +uint64_t float128_to_uint64_round_to_zero(float128 a, float_status *status) +{ + uint64_t v; + signed char current_rounding_mode =3D status->float_rounding_mode; + + set_float_rounding_mode(float_round_to_zero, status); + v =3D float128_to_uint64(a, status); + set_float_rounding_mode(current_rounding_mode, status); + + return v; +} + +/*------------------------------------------------------------------------= ---- | Returns the result of converting the quadruple-precision floating-point | value `a' to the single-precision floating-point format. The conversion | is performed according to the IEC/IEEE Standard for Binary Floating-Point diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 8a39028..a09ad0e 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -714,6 +714,8 @@ int32_t float128_to_int32(float128, float_status *statu= s); int32_t float128_to_int32_round_to_zero(float128, float_status *status); int64_t float128_to_int64(float128, float_status *status); int64_t float128_to_int64_round_to_zero(float128, float_status *status); +uint64_t float128_to_uint64(float128, float_status *status); +uint64_t float128_to_uint64_round_to_zero(float128, float_status *status); float32 float128_to_float32(float128, float_status *status); float64 float128_to_float64(float128, float_status *status); floatx80 float128_to_floatx80(float128, float_status *status); --=20 2.9.3