From nobody Thu Nov 6 20:35:56 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 1487746452542271.13936223553344; Tue, 21 Feb 2017 22:54:12 -0800 (PST) Received: from localhost ([::1]:50223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQoU-0005P1-IY for importer@patchew.org; Wed, 22 Feb 2017 01:54:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQV7-000334-H5 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgQV4-00081b-SS for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:09 -0500 Received: from ozlabs.org ([103.22.144.67]:34091) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgQV4-0007yZ-Ch; Wed, 22 Feb 2017 01:34:06 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vSndK1qy2z9sDg; 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=PwBEBwsl4SCoWVZ/DNEGZkEY85JSBXtSXIq/aqntOKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVtDEzTE73N0tAETjq0woGcCkyme8Kv55/aRbnevU2uOt5i76cvno2s4K/jyH0kQQ vKcJ1DpU+WY3IyuLheyH4jl9c60MWdfWK0lnJhn+IA9BefNzvOMdz14ip5GhiGQMVj lCVCs0v2PrIURdpcQBfS2RMNmjbF1xz20tNLI3lI= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:33:29 +1100 Message-Id: <20170222063348.32176-25-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: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 24/43] softfloat: Add float128_to_uint32_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 float128_to_uint32_round_to_zero() is needed by xscvqpuwz instruction of PowerPC ISA 3.0. Signed-off-by: Bharata B Rao Reviewed-by: Peter Maydell Signed-off-by: David Gibson --- fpu/softfloat.c | 28 ++++++++++++++++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 29 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 47e4646..485a006 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -6188,6 +6188,34 @@ uint64_t float128_to_uint64_round_to_zero(float128 a= , float_status *status) =20 /*------------------------------------------------------------------------= ---- | Returns the result of converting the quadruple-precision floating-point +| value `a' to the 32-bit unsigned integer format. The conversion +| is performed according to the IEC/IEEE Standard for Binary Floating-Point +| Arithmetic except that the conversion is always rounded toward zero. +| If `a' is a NaN, the largest positive integer is returned. Otherwise, +| 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. +*-------------------------------------------------------------------------= ---*/ + +uint32_t float128_to_uint32_round_to_zero(float128 a, float_status *status) +{ + uint64_t v; + uint32_t res; + int old_exc_flags =3D get_float_exception_flags(status); + + v =3D float128_to_uint64_round_to_zero(a, status); + if (v > 0xffffffff) { + res =3D 0xffffffff; + } else { + return v; + } + set_float_exception_flags(old_exc_flags, status); + float_raise(float_flag_invalid, status); + return res; +} + +/*------------------------------------------------------------------------= ---- +| 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 | Arithmetic. diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index a09ad0e..f1288ef 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -716,6 +716,7 @@ int64_t float128_to_int64(float128, float_status *statu= s); 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); +uint32_t float128_to_uint32_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