From 4e8e8572c35a2812b643f2cdeec8473dd866a3e3 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Sat, 3 Mar 2018 20:57:25 -0500 Subject: [PATCH] softfloat: define floatx80_round() Add a function to round a floatx80 to the defined precision (floatx80_rounding_precision) Backports commit 0f72129281765ed64d26353284059f2bdcde7a23 from qemu --- qemu/fpu/softfloat.c | 16 ++++++++++++++++ qemu/include/fpu/softfloat.h | 1 + 2 files changed, 17 insertions(+) diff --git a/qemu/fpu/softfloat.c b/qemu/fpu/softfloat.c index cb27ec6e..8a325bc2 100644 --- a/qemu/fpu/softfloat.c +++ b/qemu/fpu/softfloat.c @@ -5046,6 +5046,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 diff --git a/qemu/include/fpu/softfloat.h b/qemu/include/fpu/softfloat.h index 13912a67..b2121abc 100644 --- a/qemu/include/fpu/softfloat.h +++ b/qemu/include/fpu/softfloat.h @@ -608,6 +608,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);