From nobody Tue Feb 10 20:47:58 2026 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 15114553122371022.1011758797658; Thu, 23 Nov 2017 08:41:52 -0800 (PST) Received: from localhost ([::1]:45149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuZL-0002za-7B for importer@patchew.org; Thu, 23 Nov 2017 11:41:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuU3-0007se-Da for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHuU1-0003XQ-Bv for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:15 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:59268) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eHuU1-0003W5-0O for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:13 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Ljxqo-1esc4L3Fgw-00cAoB; Thu, 23 Nov 2017 17:35:44 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:35:34 +0100 Message-Id: <20171123163538.31411-2-laurent@vivier.eu> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171123163538.31411-1-laurent@vivier.eu> References: <20171123163538.31411-1-laurent@vivier.eu> X-Provags-ID: V03:K0:pBdHk8ZL5Cyo9YH0/8CXV8jYCFXESAJnbnt/usPjT2c9XfSQhtx Flij4oYItk1k/NaAVz9dNdDUeTpAiqHKLx/N97kA8wkEDebq6qfWKWV6/2XXXfq9uclsCnh yQUaHrmccOZ6fOFXyoWG35OboMc2n8zdVSxSvY+jjcTEum2UKH7H7hCvo9Jusdum/95aBRO 77rQ77keICyWHNUGM8Y1Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:1YIGVydC38g=:WXC4opWq5/gcBHYWwgSNr1 LZ2vrYOURhwhIBcK7TAyvibHo4jECPiBpUQu1kbQJ1mZupT9nVYC7h0/G9VqA3QesVr0RY/uZ ucls/aKVVQu873RfL448ct/nhhMduMAXqUIUIrEc8XIBibBWcibzkdZBwk+4eFXy0XECe3sCg 9S4lwRUw7I90k3W675MpGlc0T97BOM8dnCJXle5U5HtCDKvQoY6G8GR3b+5kfLJHR6RbEHi8/ caT/1ahF60LhgLlhRS4fht9U5Ag1Z+H9TY1LK+JIxPx0of7isqwR4b4nEsGoVydVYzC9rXDz4 Hc6H6yNaDaWdnHsiPFeuvL0GRo/vfS9Bw+KQ4GMXXvIki8C8TlJD6O86oevsckrtYJidZ27Tg Yt8QQEl2biDtFxaKfi/VvqhmHWLyRKA+162lYHxi2wcGSXZvblR7d1jLii3F6JrZOwQP+Rq0H 5ZagoDBQC+okXH6M1UmAHgWemHyouMduHIPHwvGYcMx6+z7gg2BHsV0rXMpt0OacAxfnEJxcn hVY3C14LBexxBZfZ5rhUf3jBhz+c2Hmpq24HK2J0p4AsO84stEO/oTCRY2lpviULu0sL1VQUN w+FXwt05FaiWB+cbIPHEtRhUX9FgrtRBvlV6mJPXXh/zGWaBgPpRWKwAKhjopdL4nRm/dN6ZS 1HuDbhSZK6Ovh1PyE3vJTOw8r5vWwpfcnSffs7uGymj0zQx+7iE+mKuC+tGgIOmJ4B574za0q LOfsdS8dKlgV1HQUFf15lfGYf9WZEeQP3Nmkuw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PATCH v2 1/5] softfloat: add floatx80_mod() 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: Thomas Huth , Laurent Vivier , 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" copied from previous: Written by Andreas Grabher for Previous, NeXT Computer Emulator. Signed-off-by: Laurent Vivier --- fpu/softfloat.c | 88 +++++++++++++++++++++++++++++++++++++++++++++= ++++ include/fpu/softfloat.h | 1 + 2 files changed, 89 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 433c5dad2d..36e67e50a3 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -5701,6 +5701,94 @@ floatx80 floatx80_sqrt(floatx80 a, float_status *sta= tus) 0, zExp, zSig0, zSig1, status); } =20 +#if defined(TARGET_M68K) +/* This part is copied from previous: + * Written by Andreas Grabher for Previous, NeXT Computer Emulator. + */ + +/*------------------------------------------------------------------------= ---- + | Returns the modulo remainder of the extended double-precision floating-= point + | value `a' with respect to the corresponding value `b'. + *------------------------------------------------------------------------= ----*/ + +floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status) +{ + flag aSign, zSign; + int32_t aExp, bExp, expDiff; + uint64_t aSig0, aSig1, bSig; + uint64_t qTemp, term0, term1; + + aSig0 =3D extractFloatx80Frac(a); + aExp =3D extractFloatx80Exp(a); + aSign =3D extractFloatx80Sign(a); + bSig =3D extractFloatx80Frac(b); + bExp =3D extractFloatx80Exp(b); + + if (aExp =3D=3D 0x7FFF) { + if ((uint64_t) (aSig0 << 1) + || ((bExp =3D=3D 0x7FFF) && (uint64_t) (bSig << 1))) { + return propagateFloatx80NaN(a, b, status); + } + goto invalid; + } + if (bExp =3D=3D 0x7FFF) { + if ((uint64_t) (bSig << 1)) { + return propagateFloatx80NaN(a, b, status); + } + return a; + } + if (bExp =3D=3D 0) { + if (bSig =3D=3D 0) { + invalid: + float_raise(float_flag_invalid, status); + return floatx80_default_nan(status); + } + normalizeFloatx80Subnormal(bSig, &bExp, &bSig); + } + if (aExp =3D=3D 0) { + if ((uint64_t) (aSig0 << 1) =3D=3D 0) { + return a; + } + normalizeFloatx80Subnormal(aSig0, &aExp, &aSig0); + } + bSig |=3D LIT64(0x8000000000000000); + zSign =3D aSign; + expDiff =3D aExp - bExp; + aSig1 =3D 0; + if (expDiff < 0) { + return a; + } + qTemp =3D (bSig <=3D aSig0); + if (qTemp) { + aSig0 -=3D bSig; + } + expDiff -=3D 64; + while (0 < expDiff) { + qTemp =3D estimateDiv128To64(aSig0, aSig1, bSig); + qTemp =3D (2 < qTemp) ? qTemp - 2 : 0; + mul64To128(bSig, qTemp, &term0, &term1); + sub128(aSig0, aSig1, term0, term1, &aSig0, &aSig1); + shortShift128Left(aSig0, aSig1, 62, &aSig0, &aSig1); + } + expDiff +=3D 64; + if (0 < expDiff) { + qTemp =3D estimateDiv128To64(aSig0, aSig1, bSig); + qTemp =3D (2 < qTemp) ? qTemp - 2 : 0; + qTemp >>=3D 64 - expDiff; + mul64To128(bSig, qTemp << (64 - expDiff), &term0, &term1); + sub128(aSig0, aSig1, term0, term1, &aSig0, &aSig1); + shortShift128Left(0, bSig, 64 - expDiff, &term0, &term1); + while (le128(term0, term1, aSig0, aSig1)) { + ++qTemp; + sub128(aSig0, aSig1, term0, term1, &aSig0, &aSig1); + } + } + return + normalizeRoundAndPackFloatx80( + 80, zSign, bExp + expDiff, aSig0, aSig1, status); +} +#endif /* TARGET_M68K */ + /*------------------------------------------------------------------------= ---- | Returns 1 if the extended double-precision floating-point value `a' is e= qual | to the corresponding value `b', and 0 otherwise. The invalid exception = is diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 0f96a0edd1..ad6249b3df 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -623,6 +623,7 @@ floatx80 floatx80_sub(floatx80, floatx80, float_status = *status); floatx80 floatx80_mul(floatx80, floatx80, float_status *status); floatx80 floatx80_div(floatx80, floatx80, float_status *status); floatx80 floatx80_rem(floatx80, floatx80, float_status *status); +floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status); floatx80 floatx80_sqrt(floatx80, float_status *status); int floatx80_eq(floatx80, floatx80, float_status *status); int floatx80_le(floatx80, floatx80, float_status *status); --=20 2.13.6