From patchwork Fri Jun 30 12:30:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 782840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wzbYh150Wz9s7f for ; Fri, 30 Jun 2017 22:34:00 +1000 (AEST) Received: from localhost ([::1]:44342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQv7V-0001JI-MS for incoming@patchwork.ozlabs.org; Fri, 30 Jun 2017 08:33:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQv4g-0008Aa-PV for qemu-devel@nongnu.org; Fri, 30 Jun 2017 08:31:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQv4a-0005uv-Vx for qemu-devel@nongnu.org; Fri, 30 Jun 2017 08:31:02 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:56310) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dQv4a-0005sP-CP for qemu-devel@nongnu.org; Fri, 30 Jun 2017 08:30:56 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LmT7D-1dzz2b07Yh-00aFgI; Fri, 30 Jun 2017 14:30:54 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 30 Jun 2017 14:30:47 +0200 Message-Id: <20170630123050.19834-5-laurent@vivier.eu> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630123050.19834-1-laurent@vivier.eu> References: <20170630123050.19834-1-laurent@vivier.eu> X-Provags-ID: V03:K0:iZgoKiJgU88Mlz6yhHFiLbAtWBfDtWuZhuC4MMv9KXEhYPMJ579 MNeSWPHLdbY9HGVlS3Q/qf2vZCBH9VkhV11T8++V7LQsHPZ1ZLwI/9VTOJn0zE9mEJLS0h3 Y23w6JTW4ZvCXjEdcwskgBp737l2mZSNgEAW6nlDlVNOCKpRvu6AFvgxcqfWUeLiYrZaQ8n BS78szmgY98U7LrYiw4Hw== X-UI-Out-Filterresults: notjunk:1; V01:K0:GW6Vf8RAZiM=:RzKs6qy2fa2uwJsse0006i sTx4mEAgn6hk3rLgXzKdawbB6gqWZjAQDzi7LtybyTPs5hlrbMDMHVtQayGtkuCoz8prn52UW NBwU0BDToqQzrxto+r5WTgR3z4Aqw/Na1IpNr5q98AwSL5qBPLxSqVRaiAiHkSn+g6+3Yjgkx g1umKVxi3V6yu3oO1IwsGuoqxm8NWJGW/xVXjvKmSgGqZ4isecTjz6xfDn59ZhhZRvgVp7FLw EcQX8KM7p7wfsD837NftUt87KK2lH2w2rmT/Y9ECqNM+GThUBxh60JVvBJ9F7RDSy14xmLG0O 6xLQWKCtjYZfpDoHTagJbC96GQX7YolIs6RhTEHam8o2B7HWmIR69f8517vhVPrQmy8vCzdv5 ltgmqS2UxfZR3fLSRnEcLyfavYzgNE71iUF/hx6I8ZMSvAPAEWBixElGLkj9SXV0zvdP+k6zh NSjirjlQNJbBXGmUis/S+bXv1QZRoh/ub6BeITc1RnnbgYzpUjGxa6U9D6k6fSx72HQ+4SX95 r6UBBXzBRfYdOpbfK8yca5hg4eFpgdq1dB67k4au4UC3tsH8eqR/BgFyr+8bXEE0UtDNmStE7 ZGZMugTg8XhUxt6Oi7ZE9pi4fwVHXw9gCtCASqyt8vUSOVCK3dh0Y0OtZNLXCnGXGvmCeZDRw jhwv+klThV09Uu/HYmU93p/xOzY+23M6lTUpS0iAJFnRSGDf6afcLsR+rNyVgf1oCDI4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.131 Subject: [Qemu-devel] [PULL 4/7] softfloat: define floatx80_round() 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: Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a function to round a floatx80 to the defined precision (floatx80_rounding_precision) Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Reviewed-by: Aurelien Jarno Message-Id: <20170628204241.32106-5-laurent@vivier.eu> --- fpu/softfloat.c | 16 ++++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 17 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 7af14e2..433c5da 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -5086,6 +5086,22 @@ float128 floatx80_to_float128(floatx80 a, float_status *status) } /*---------------------------------------------------------------------------- +| Rounds the extended double-precision floating-point value `a' +| to the precision provided by floatx80_rounding_precision and returns the +| result as an extended double-precision floating-point value. +| The operation is performed according to the IEC/IEEE Standard for Binary +| Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +floatx80 floatx80_round(floatx80 a, float_status *status) +{ + return roundAndPackFloatx80(status->floatx80_rounding_precision, + extractFloatx80Sign(a), + extractFloatx80Exp(a), + extractFloatx80Frac(a), 0, status); +} + +/*---------------------------------------------------------------------------- | Rounds the extended double-precision floating-point value `a' to an integer, | and returns the result as an extended quadruple-precision floating-point | value. The operation is performed according to the IEC/IEEE Standard for diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index f1288ef..d9689ec 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -621,6 +621,7 @@ float128 floatx80_to_float128(floatx80, float_status *status); /*---------------------------------------------------------------------------- | Software IEC/IEEE extended double-precision operations. *----------------------------------------------------------------------------*/ +floatx80 floatx80_round(floatx80 a, float_status *status); floatx80 floatx80_round_to_int(floatx80, float_status *status); floatx80 floatx80_add(floatx80, floatx80, float_status *status); floatx80 floatx80_sub(floatx80, floatx80, float_status *status);