From nobody Fri Oct 24 09:45:20 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.zohomail.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 1519398169197676.9623917276353; Fri, 23 Feb 2018 07:02:49 -0800 (PST) Received: from localhost ([::1]:45037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epEs4-0007jp-9K for importer@patchew.org; Fri, 23 Feb 2018 10:02:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epEpo-0006NO-9Y for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:00:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epEpl-0005b7-5H for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:00:28 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:55107) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1epEpk-0005ZM-MV for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:00:25 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MXTpy-1fCw4L1MTW-00WXA0; Fri, 23 Feb 2018 16:00:03 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 23 Feb 2018 15:59:56 +0100 Message-Id: <20180223145959.18761-2-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180223145959.18761-1-laurent@vivier.eu> References: <20180223145959.18761-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K0:0eHsvcsISjf9OQ7hgpUms7aqBKYcmbtR+fsCEJXaZZ0vv0xOubG 63qDKAp8v94tmTGyrNlY8FSysTTfNBd98YR1fs25Emhxf2hlu+oIeUeNht3rS4y60Ioyeu1 tGJB+lANh15KxDaZp8BX+4srViiZkhLEAD/y5bp3uRfyDlTzkdTzcVfK8+ulDpjQIRRzCcm 52ndF4nkLG4GJxJd0dD2Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:DDyPE9Y58+M=:Wol75Ret8JER7Ci+WPSApT PlieOkaHnty6Fzd8Ef7anlsT5068ArdKokFU1NcgX+skylvkxHVMcEtAE7XlQ1LSpf8w14Rh3 +hkGcvgp6DvvZcuByQO5Ym3NjgwAidTqTC7qvWwNLDlX/Sxt0iAwz0TFZkBtH8BEIXKNNtfTT 4CDgF8ug/vPEz7U4C1CVpDnrr6Hfban6E3e1gk6gfk2yx3UCf5XhMLXLNXoVXBT5HFMcu9YPM +y4Elz+FyU2AnPHUKdtwYXMAGQvfwCXg6uwta8xar69rqgIsMjq7GEPCREoTkEmiOa3tbjiPn 5PE7Pgsy0iuyhrNeIJ1oSqA5Oom5lm4YTIq53gfLgIT9k/kOSBve5LcnLiQEMLNezrSHKVYp8 wTPvTjN34Q2VOxvgdWooATQ2T/adlqOfgbTAZ8uHRzx81TT9ZSqiM8fwzpgU3Js/Ure7HQFPu 1BZQZs6tXRIzHdRmxIfJwEcYCANNzLnq6JWTTLCp43OblAzA2dAFw90QCCKbz+ss/B1q8o7dx 5CA+cH9/oxk3F1koB7b+IgdNXcqVcGExPexkx4nozrRpwFX9xgpSt/cSif4qnwQ9aH008OBka 40G7ZqZgKfC5YYaGOeQGfQN6AcEmyXLf9GUOmykqD9Bvi2a2/L3KcK3xbpvf4/bZJlgCfy9k0 FeL4TfXDm8pIHv2ZlfzIE0jEB2qZoCvBEAkHeQZDVRIBBpNp2okvkq5vKvNrf7Qa/KAY46yV+ CB42RuWRfrY63+w7l0v2wjZLtOxd050qzGh/R3HhKh8pD+yvnkmSuGI8Q6k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.130 Subject: [Qemu-devel] [PATCH v3 1/4] softfloat: export some functions 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: Peter Maydell , Thomas Huth , Laurent Vivier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Move fpu/softfloat-macros.h to include/fpu/ Export floatx80 functions to be used by target floatx80 specific implementations. Exports: propagateFloatx80NaN(), extractFloatx80Frac(), extractFloatx80Exp(), extractFloatx80Sign(), normalizeFloatx80Subnormal(), packFloatx80(), roundAndPackFloatx80(), normalizeRoundAndPackFloatx80() Also exports packFloat32() that will be used to implement m68k fsinh, fcos, fsin, ftan operations. Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson --- CC: Aurelien Jarno CC: Alex Benn=C3=A9e CC: Peter Maydell fpu/softfloat-specialize.h | 3 +- fpu/softfloat.c | 91 +++--------------------- {fpu =3D> include/fpu}/softfloat-macros.h | 10 +-- include/fpu/softfloat.h | 120 ++++++++++++++++++++++++++++= ++++ 4 files changed, 136 insertions(+), 88 deletions(-) rename {fpu =3D> include/fpu}/softfloat-macros.h (98%) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index e81ca001e1..46126e9e0a 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -1011,8 +1011,7 @@ static floatx80 commonNaNToFloatx80(commonNaNT a, flo= at_status *status) | `b' is a signaling NaN, the invalid exception is raised. *-------------------------------------------------------------------------= ---*/ =20 -static floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, - float_status *status) +floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) { flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; diff --git a/fpu/softfloat.c b/fpu/softfloat.c index e7fb0d357a..fb4853682e 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -93,7 +93,7 @@ this code that are retained. | division and square root approximations. (Can be specialized to target = if | desired.) *-------------------------------------------------------------------------= ---*/ -#include "softfloat-macros.h" +#include "fpu/softfloat-macros.h" =20 /*------------------------------------------------------------------------= ---- | Functions and definitions to determine: (1) whether tininess for underf= low @@ -2192,25 +2192,6 @@ static void =20 } =20 -/*------------------------------------------------------------------------= ---- -| Packs the sign `zSign', exponent `zExp', and significand `zSig' into a -| single-precision floating-point value, returning the result. After being -| shifted into the proper positions, the three fields are simply added -| together to form the result. This means that any integer portion of `zS= ig' -| will be added into the exponent. Since a properly normalized significand -| will have an integer portion equal to 1, the `zExp' input should be 1 le= ss -| than the desired result exponent whenever `zSig' is a complete, normaliz= ed -| significand. -*-------------------------------------------------------------------------= ---*/ - -static inline float32 packFloat32(flag zSign, int zExp, uint32_t zSig) -{ - - return make_float32( - ( ( (uint32_t) zSign )<<31 ) + ( ( (uint32_t) zExp )<<23 ) + zSi= g); - -} - /*------------------------------------------------------------------------= ---- | Takes an abstract floating-point value having sign `zSign', exponent `zE= xp', | and significand `zSig', and returns the proper single-precision floating- @@ -2490,42 +2471,6 @@ static float64 =20 } =20 -/*------------------------------------------------------------------------= ---- -| Returns the fraction bits of the extended double-precision floating-point -| value `a'. -*-------------------------------------------------------------------------= ---*/ - -static inline uint64_t extractFloatx80Frac( floatx80 a ) -{ - - return a.low; - -} - -/*------------------------------------------------------------------------= ---- -| Returns the exponent bits of the extended double-precision floating-point -| value `a'. -*-------------------------------------------------------------------------= ---*/ - -static inline int32_t extractFloatx80Exp( floatx80 a ) -{ - - return a.high & 0x7FFF; - -} - -/*------------------------------------------------------------------------= ---- -| Returns the sign bit of the extended double-precision floating-point val= ue -| `a'. -*-------------------------------------------------------------------------= ---*/ - -static inline flag extractFloatx80Sign( floatx80 a ) -{ - - return a.high>>15; - -} - /*------------------------------------------------------------------------= ---- | Normalizes the subnormal extended double-precision floating-point value | represented by the denormalized significand `aSig'. The normalized expo= nent @@ -2533,30 +2478,14 @@ static inline flag extractFloatx80Sign( floatx80 a ) | `zSigPtr', respectively. *-------------------------------------------------------------------------= ---*/ =20 -static void - normalizeFloatx80Subnormal( uint64_t aSig, int32_t *zExpPtr, uint64_t *zS= igPtr ) +void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, + uint64_t *zSigPtr) { int8_t shiftCount; =20 shiftCount =3D countLeadingZeros64( aSig ); *zSigPtr =3D aSig<> 15; +} + +/*------------------------------------------------------------------------= ---- +| Packs the sign `zSign', exponent `zExp', and significand `zSig' into an +| extended double-precision floating-point value, returning the result. +*-------------------------------------------------------------------------= ---*/ + +static inline floatx80 packFloatx80(flag zSign, int32_t zExp, uint64_t zSi= g) +{ + floatx80 z; + + z.low =3D zSig; + z.high =3D (((uint16_t)zSign) << 15) + zExp; + return z; +} + +/*------------------------------------------------------------------------= ---- +| Normalizes the subnormal extended double-precision floating-point value +| represented by the denormalized significand `aSig'. The normalized expo= nent +| and significand are stored at the locations pointed to by `zExpPtr' and +| `zSigPtr', respectively. +*-------------------------------------------------------------------------= ---*/ + +void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, + uint64_t *zSigPtr); + +/*------------------------------------------------------------------------= ---- +| Takes two extended double-precision floating-point values `a' and `b', o= ne +| of which is a NaN, and returns the appropriate NaN result. If either `a= ' or +| `b' is a signaling NaN, the invalid exception is raised. +*-------------------------------------------------------------------------= ---*/ + +floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status= ); + +/*------------------------------------------------------------------------= ---- +| Takes an abstract floating-point value having sign `zSign', exponent `zE= xp', +| and extended significand formed by the concatenation of `zSig0' and `zSi= g1', +| and returns the proper extended double-precision floating-point value +| corresponding to the abstract input. Ordinarily, the abstract value is +| rounded and packed into the extended double-precision format, with the +| inexact exception raised if the abstract input cannot be represented +| exactly. However, if the abstract value is too large, the overflow and +| inexact exceptions are raised and an infinity or maximal finite value is +| returned. If the abstract value is too small, the input value is rounde= d to +| a subnormal number, and the underflow and inexact exceptions are raised = if +| the abstract input cannot be represented exactly as a subnormal extended +| double-precision floating-point number. +| If `roundingPrecision' is 32 or 64, the result is rounded to the same +| number of bits as single or double precision, respectively. Otherwise, = the +| result is rounded to the full precision of the extended double-precision +| format. +| The input significand must be normalized or smaller. If the input +| significand is not normalized, `zExp' must be 0; in that case, the result +| returned is a subnormal number, and it must not require rounding. The +| handling of underflow and overflow follows the IEC/IEEE Standard for Bin= ary +| Floating-Point Arithmetic. +*-------------------------------------------------------------------------= ---*/ + +floatx80 roundAndPackFloatx80(int8_t roundingPrecision, flag zSign, + int32_t zExp, uint64_t zSig0, uint64_t zSig1, + float_status *status); + +/*------------------------------------------------------------------------= ---- +| Takes an abstract floating-point value having sign `zSign', exponent +| `zExp', and significand formed by the concatenation of `zSig0' and `zSig= 1', +| and returns the proper extended double-precision floating-point value +| corresponding to the abstract input. This routine is just like +| `roundAndPackFloatx80' except that the input significand does not have t= o be +| normalized. +*-------------------------------------------------------------------------= ---*/ + +floatx80 normalizeRoundAndPackFloatx80(int8_t roundingPrecision, + flag zSign, int32_t zExp, + uint64_t zSig0, uint64_t zSig1, + float_status *status); + /*------------------------------------------------------------------------= ---- | The pattern for a default generated extended double-precision NaN. *-------------------------------------------------------------------------= ---*/ --=20 2.14.3