From nobody Fri May 3 08:15:35 2024 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 From nobody Fri May 3 08:15:35 2024 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 1511455147914137.8135239376951; Thu, 23 Nov 2017 08:39:07 -0800 (PST) Received: from localhost ([::1]:45136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuWl-0001Q2-UO for importer@patchew.org; Thu, 23 Nov 2017 11:39:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuTx-0007ow-IY for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHuTu-0003NE-3b for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:09 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:61899) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eHuTt-0003Lj-PJ for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:06 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MYYMv-1ee41Z1eFt-00V7FU; Thu, 23 Nov 2017 17:35:44 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:35:35 +0100 Message-Id: <20171123163538.31411-3-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:nVsEJGY/0p6yIil6sxxeAdAWJd87ejheRt9wYZIQvF/fXgWywT4 KMgiYphGtE5i9JY/UqjFusJCZHb4ohV22slDwJNt4YZtlhjFu8uuL0RaqcByHIa5XeqIoog CnOS1ikQP/1CNeB5dDEeVfTNjW7OjVQgpGVkaykCEzDm75NX18Z3PN+TVMfxOkaBj7fCcS2 ies3woDdAWKsq+MFn0H3Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:gVl3GwLxTlg=:S1EhjUK+wsVta1LwvcAYdJ m6NisvPJoWS4Bersem2a5n90NPqrBk9hlwgZDDdR6/jFyg3L6vf5zu+z0ZcrKkvCK7ETkDqPm 8nCod9bn/mekXwOAwp/K+KvYn3N21HjwvdJ7zvyrYhONBWZpj5jR9g6Cip9kV0ugud0P/N0ys u+skvou6y0EASV6lsvjaKyIOkHIi2LBLeCX+X+DBtZX/wRKIUoEfazYp0geO96HLUJZf2sk3H T+he6jXr+qnKDzpJq6D26XeTmMG/QOT7OaTPjpZmGBuAjxow8qUMRTeW/40TySeMfv9XRozEp 8K8KkvWUWfQ8isuXijJHT6M00jv26xY4pIT5cLOpGLo3R0EXa6P9enOu7yiD0HB36QOpr8UCo FwD3ve/MYN0Y5EdWcxK3V/XDroru0a/TbJXZhXHHensPmCkPD23d3aQYbAPg5WUi9P1FlDlg1 zgICDrMoPcA/J12ahNGJGeU66gaHZhNDoYlfDWS3xF4JKHV4wQ9/bPw04aVOqKBGdPftDfC7c QGQwnnKT3+t8OxSwI6nGHqcI8rKWP40aM2v+7deBqfLT4nrmZsscyva8njg25hQ7GIPBS0tDl MmKWOI6FCfJgim3b+Vq2ydCpmHyaF7DTGyj6IZmZ+XnvYO+2WNukrfK0qn7i/L4q7XvIQjK0I XS1/mU/iKb05jUbQHkAqrQl4N0c4ZUT71SshUi5WXckrh05PsofRpfBODQJ/8B/HQwlsPAvYT nvDrOHuQkiTSIL7iXE5I027NJGRVLzufLM92Ew== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.135 Subject: [Qemu-devel] [PATCH v2 2/5] target/m68k: add fmod/frem 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" Use floatx80_mod() and floatx80_rem() The quotient byte of the FPSR is updated with the result of the operation. Signed-off-by: Laurent Vivier --- target/m68k/cpu.h | 1 + target/m68k/fpu_helper.c | 33 +++++++++++++++++++++++++++++++++ target/m68k/helper.h | 2 ++ target/m68k/translate.c | 6 ++++++ 4 files changed, 42 insertions(+) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index afae5f68ac..4ba613dfbe 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -234,6 +234,7 @@ typedef enum { /* Quotient */ =20 #define FPSR_QT_MASK 0x00ff0000 +#define FPSR_QT_SHIFT 16 =20 /* Floating-Point Control Register */ /* Rounding mode */ diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index 665e7609af..dd8b6950d6 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -508,3 +508,36 @@ uint32_t HELPER(fmovemd_ld_postinc)(CPUM68KState *env,= uint32_t addr, { return fmovem_postinc(env, addr, mask, cpu_ld_float64_ra); } + +static void make_quotient(CPUM68KState *env, floatx80 val) +{ + int32_t quotient; + int sign; + + if (floatx80_is_any_nan(val)) { + return; + } + + quotient =3D floatx80_to_int32(val, &env->fp_status); + sign =3D quotient < 0; + if (sign) { + quotient =3D -quotient; + } + + quotient =3D (sign << 7) | (quotient & 0x7f); + env->fpsr =3D (env->fpsr & ~FPSR_QT_MASK) | (quotient << FPSR_QT_SHIFT= ); +} + +void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) +{ + res->d =3D floatx80_mod(val1->d, val0->d, &env->fp_status); + + make_quotient(env, res->d); +} + +void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) +{ + res->d =3D floatx80_rem(val1->d, val0->d, &env->fp_status); + + make_quotient(env, res->d); +} diff --git a/target/m68k/helper.h b/target/m68k/helper.h index eebe52dae5..ff9d99ae27 100644 --- a/target/m68k/helper.h +++ b/target/m68k/helper.h @@ -61,6 +61,8 @@ DEF_HELPER_3(fmovemx_ld_postinc, i32, env, i32, i32) DEF_HELPER_3(fmovemd_st_predec, i32, env, i32, i32) DEF_HELPER_3(fmovemd_st_postinc, i32, env, i32, i32) DEF_HELPER_3(fmovemd_ld_postinc, i32, env, i32, i32) +DEF_HELPER_4(fmod, void, env, fp, fp, fp) +DEF_HELPER_4(frem, void, env, fp, fp, fp) =20 DEF_HELPER_3(mac_move, void, env, i32, i32) DEF_HELPER_3(macmulf, i64, env, i32, i32) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index b60909222c..66f873899f 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -4686,6 +4686,9 @@ DISAS_INSN(fpu) case 0x64: /* fddiv */ gen_helper_fddiv(cpu_env, cpu_dest, cpu_src, cpu_dest); break; + case 0x21: /* fmod */ + gen_helper_fmod(cpu_env, cpu_dest, cpu_src, cpu_dest); + break; case 0x22: /* fadd */ gen_helper_fadd(cpu_env, cpu_dest, cpu_src, cpu_dest); break; @@ -4707,6 +4710,9 @@ DISAS_INSN(fpu) case 0x24: /* fsgldiv */ gen_helper_fsgldiv(cpu_env, cpu_dest, cpu_src, cpu_dest); break; + case 0x25: /* frem */ + gen_helper_frem(cpu_env, cpu_dest, cpu_src, cpu_dest); + break; case 0x27: /* fsglmul */ gen_helper_fsglmul(cpu_env, cpu_dest, cpu_src, cpu_dest); break; --=20 2.13.6 From nobody Fri May 3 08:15:35 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151145523912163.909290109521635; Thu, 23 Nov 2017 08:40:39 -0800 (PST) Received: from localhost ([::1]:45146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuYD-0002Qv-A0 for importer@patchew.org; Thu, 23 Nov 2017 11:40:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuU1-0007rX-FQ for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHuTx-0003Td-Vg for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:13 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:62261) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eHuTx-0003Rl-IN for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:09 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Mfepz-1eWwUl4Bop-00P1dW; Thu, 23 Nov 2017 17:35:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:35:36 +0100 Message-Id: <20171123163538.31411-4-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:YYLANwjSTHUBZqhTo89+mik0iKJgjCNZFfAl8BuKKuC25inxCGV vhLKassVWMxx9LubxmcapoTptVoVo0KuTnbiYIyjOEoJvSHzPwUane18RDukXRNGD+Rr293 YAvWbtOGbp69uTyhWQnykF1D3MN5ovwReIeCnpRrTk8hzQ5uKlcFRFtnNVoMGT2iJcqSwC5 wE4N/FuJEODIrtM4WGiBQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:WhxFZHfiB9w=:idJOqI0Y/7LQfx6cfcjL+0 LWdUbSkpAZ4CULwc6lD/vG5PeqGrfIOm7/i0WlBySQkf1ldhR9EdxNmtvZNZEsDZkfvd0IfjZ khmO2HB9fE9vbuuJ6hpxQbTG+iFnW6IJIV8cRJ0plhK76X4nmRnkSX44AEOjhjlSPNSJBrZW3 1dxcJksv5Or0p3OA9LDEKa+uzEybm7tUHia+FeWmZ/H6mjJa6zOYjkJwD0vAtzVD5RcJswJXn jUggc4ILgUAdnbYPqhrMj+RVnaaToOKu1xZup4oazkLmy0ZpPxno8ai3UnOI582ncsaMPHp2a ax5rMqIW2fnVCtO5IROfnkmKXlk7LDJF6iR+7K4lJ7bdyHTppIf8CoXGQaGzD4912TYRirTiC pSH9+aNvhNqiXgC7TZ9ES+mR8jbPjuromdYLbQ3pnVA79Z9A5OL4ekCu5KwNxwlpRm5SC2qFP p8pr0kq/EBVRqvjCnoYpzZIgJTcYsVXOzK3pzyQHJT0hqLFuGDMljgwO+8sjVaJ4B9SZ+foxW tEr3NbQ9YFZ0MeAedXWfsGR9y31LGh3ci3qlvujDRHeY+atcz8vcbneZVS1WcPrdvaGF2wK1i /kfG1H7oXyNXD1hh4gnArT5p3Jjh+RC5KxXLQnvMl8v4BPQUQWCq2T3BWpyHMSHhcdTxj1WeY 8MTkP/tYBmyvurl1ixfFuywBP5T1XK+4mHA+AGhwFg0bboehUSgnpmW6DJwuR5CzAN4HxYZ1F 6uXF5jsdWf7254y0b678Qq3RoXG9L47W8MF9Yw== 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 3/5] softfloat: use floatx80_infinity in softfloat 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" Since f3218a8 ("softfloat: add floatx80 constants") floatx80_infinity is defined but never used. This patch updates floatx80 functions to use this definition. This allows to define a different default Infinity value on m68k: the m68k FPU defines infinity with all bits set to zero in the mantissa. Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson --- fpu/softfloat-specialize.h | 14 ++++++++++++++ fpu/softfloat.c | 38 ++++++++++++++++++++++++++------------ include/fpu/softfloat.h | 9 +++++++-- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index de2c5d5702..1cb3502e5a 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -178,6 +178,20 @@ floatx80 floatx80_default_nan(float_status *status) } =20 /*------------------------------------------------------------------------= ---- +| The pattern for a default generated extended double-precision inf. +*-------------------------------------------------------------------------= ---*/ + +#define floatx80_infinity_high 0x7FFF +#if defined(TARGET_M68K) +#define floatx80_infinity_low LIT64(0x0000000000000000) +#else +#define floatx80_infinity_low LIT64(0x8000000000000000) +#endif + +const floatx80 floatx80_infinity + =3D make_floatx80_init(floatx80_infinity_high, floatx80_infinity_low); + +/*------------------------------------------------------------------------= ---- | The pattern for a default generated quadruple-precision NaN. *-------------------------------------------------------------------------= ---*/ float128 float128_default_nan(float_status *status) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 36e67e50a3..c6289bba75 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -913,7 +913,9 @@ static floatx80 roundAndPackFloatx80(int8_t roundingPre= cision, flag zSign, ) { return packFloatx80( zSign, 0x7FFE, ~ roundMask ); } - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 = ) ); + return packFloatx80(zSign, + floatx80_infinity_high, + floatx80_infinity_low); } if ( zExp <=3D 0 ) { isTiny =3D @@ -1885,7 +1887,9 @@ floatx80 float32_to_floatx80(float32 a, float_status = *status) if (aSig) { return commonNaNToFloatx80(float32ToCommonNaN(a, status), stat= us); } - return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); + return packFloatx80(aSign, + floatx80_infinity_high, + floatx80_infinity_low); } if ( aExp =3D=3D 0 ) { if ( aSig =3D=3D 0 ) return packFloatx80( aSign, 0, 0 ); @@ -3666,7 +3670,9 @@ floatx80 float64_to_floatx80(float64 a, float_status = *status) if (aSig) { return commonNaNToFloatx80(float64ToCommonNaN(a, status), stat= us); } - return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); + return packFloatx80(aSign, + floatx80_infinity_high, + floatx80_infinity_low); } if ( aExp =3D=3D 0 ) { if ( aSig =3D=3D 0 ) return packFloatx80( aSign, 0, 0 ); @@ -4927,8 +4933,8 @@ int64_t floatx80_to_int64(floatx80 a, float_status *s= tatus) if ( shiftCount ) { float_raise(float_flag_invalid, status); if ( ! aSign - || ( ( aExp =3D=3D 0x7FFF ) - && ( aSig !=3D LIT64( 0x8000000000000000 ) ) ) + || ((aExp =3D=3D floatx80_infinity_high) + && (aSig !=3D floatx80_infinity_low)) ) { return LIT64( 0x7FFFFFFFFFFFFFFF ); } @@ -5235,7 +5241,9 @@ static floatx80 addFloatx80Sigs(floatx80 a, floatx80 = b, flag zSign, if ((uint64_t)(bSig << 1)) { return propagateFloatx80NaN(a, b, status); } - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 = ) ); + return packFloatx80(zSign, + floatx80_infinity_high, + floatx80_infinity_low); } if ( aExp =3D=3D 0 ) ++expDiff; shift64ExtraRightJamming( aSig, 0, - expDiff, &aSig, &zSig1 ); @@ -5310,7 +5318,8 @@ static floatx80 subFloatx80Sigs(floatx80 a, floatx80 = b, flag zSign, if ((uint64_t)(bSig << 1)) { return propagateFloatx80NaN(a, b, status); } - return packFloatx80( zSign ^ 1, 0x7FFF, LIT64( 0x8000000000000000 = ) ); + return packFloatx80(zSign ^ 1, floatx80_infinity_high, + floatx80_infinity_low); } if ( aExp =3D=3D 0 ) ++expDiff; shift128RightJamming( aSig, 0, - expDiff, &aSig, &zSig1 ); @@ -5415,7 +5424,8 @@ floatx80 floatx80_mul(floatx80 a, floatx80 b, float_s= tatus *status) return propagateFloatx80NaN(a, b, status); } if ( ( bExp | bSig ) =3D=3D 0 ) goto invalid; - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); + return packFloatx80(zSign, floatx80_infinity_high, + floatx80_infinity_low); } if ( bExp =3D=3D 0x7FFF ) { if ((uint64_t)(bSig << 1)) { @@ -5426,7 +5436,8 @@ floatx80 floatx80_mul(floatx80 a, floatx80 b, float_s= tatus *status) float_raise(float_flag_invalid, status); return floatx80_default_nan(status); } - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); + return packFloatx80(zSign, floatx80_infinity_high, + floatx80_infinity_low); } if ( aExp =3D=3D 0 ) { if ( aSig =3D=3D 0 ) return packFloatx80( zSign, 0, 0 ); @@ -5480,7 +5491,8 @@ floatx80 floatx80_div(floatx80 a, floatx80 b, float_s= tatus *status) } goto invalid; } - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); + return packFloatx80(zSign, floatx80_infinity_high, + floatx80_infinity_low); } if ( bExp =3D=3D 0x7FFF ) { if ((uint64_t)(bSig << 1)) { @@ -5496,7 +5508,8 @@ floatx80 floatx80_div(floatx80 a, floatx80 b, float_s= tatus *status) return floatx80_default_nan(status); } float_raise(float_flag_divbyzero, status); - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 = ) ); + return packFloatx80(zSign, floatx80_infinity_high, + floatx80_infinity_low); } normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); } @@ -6407,7 +6420,8 @@ floatx80 float128_to_floatx80(float128 a, float_statu= s *status) if ( aSig0 | aSig1 ) { return commonNaNToFloatx80(float128ToCommonNaN(a, status), sta= tus); } - return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); + return packFloatx80(aSign, floatx80_infinity_high, + floatx80_infinity_low); } if ( aExp =3D=3D 0 ) { if ( ( aSig0 | aSig1 ) =3D=3D 0 ) return packFloatx80( aSign, 0, 0= ); diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index ad6249b3df..413cdb20cb 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -614,6 +614,11 @@ float64 floatx80_to_float64(floatx80, float_status *st= atus); float128 floatx80_to_float128(floatx80, float_status *status); =20 /*------------------------------------------------------------------------= ---- +| The pattern for an extended double-precision inf. +*-------------------------------------------------------------------------= ---*/ +extern const floatx80 floatx80_infinity; + +/*------------------------------------------------------------------------= ---- | Software IEC/IEEE extended double-precision operations. *-------------------------------------------------------------------------= ---*/ floatx80 floatx80_round(floatx80 a, float_status *status); @@ -654,7 +659,8 @@ static inline floatx80 floatx80_chs(floatx80 a) =20 static inline int floatx80_is_infinity(floatx80 a) { - return (a.high & 0x7fff) =3D=3D 0x7fff && a.low =3D=3D 0x8000000000000= 000LL; + return (a.high & 0x7fff) =3D=3D floatx80_infinity.high && + a.low =3D=3D floatx80_infinity.low; } =20 static inline int floatx80_is_neg(floatx80 a) @@ -697,7 +703,6 @@ static inline bool floatx80_invalid_encoding(floatx80 a) #define floatx80_ln2 make_floatx80(0x3ffe, 0xb17217f7d1cf79acLL) #define floatx80_pi make_floatx80(0x4000, 0xc90fdaa22168c235LL) #define floatx80_half make_floatx80(0x3ffe, 0x8000000000000000LL) -#define floatx80_infinity make_floatx80(0x7fff, 0x8000000000000000LL) =20 /*------------------------------------------------------------------------= ---- | The pattern for a default generated extended double-precision NaN. --=20 2.13.6 From nobody Fri May 3 08:15:35 2024 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 1511455175145171.01957974937977; Thu, 23 Nov 2017 08:39:35 -0800 (PST) Received: from localhost ([::1]:45137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuX4-0001bn-EB for importer@patchew.org; Thu, 23 Nov 2017 11:39:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuU3-0007sd-DL 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 1eHuU0-0003WU-Jz for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:15 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:64143) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eHuU0-0003VI-9E for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:12 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MDJ7o-1eNLzR2mpo-00Gbhh; Thu, 23 Nov 2017 17:35:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:35:37 +0100 Message-Id: <20171123163538.31411-5-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:DlGaK4S2tKfdPNxvhQIe4pQEWazmsyPaJu9OnYW5/b35me+WAnl C8Duu/mPRFJ0FOHqqnPrawk06akPj9Hraj9RO893qqfvcIaL0vLtW9sj1UpBADrx+Y2TQwl Fwst3SYTFl79H8Z+5LOKsLe4TIDJKt7wTCjuVdIVlbFj5Ec1cgtdXeaYD5iEEXZvGvp3jTa XNK0nE1Bu1wHxVvnG7Mjw== X-UI-Out-Filterresults: notjunk:1;V01:K0:h1r5imn1MOw=:eiBuu1yG7rHFRC8M7Yek97 fjlHWvO3Ta33gw7nROQD7HVrojNiNXI+tojwr/9ETGs5hFlJtzHbbdi+DRfPJpSBo7Kpcjmuc uthTYmOAwc5irjcekBwOvjDPVn2IV5q41+E4yLibNnSpXN0oixsfKL/60RG+69XCzqjzLwmZa HzRazOjPzgd6CmsliQ4V/D4Kjmtt+NUHfXXdh2oUZLyl5XVjJuWcXuVLutDrT4N+8MelE2MGD BVlHIgCx6GdelXxdLbDvpZD7A7s1SuaIUu00vLTTlZRfdf100icWbiNZ5Cv956ak6b6ufUf+2 RD46AvU9z0zwwG2bG5z9AdikJokYEye9dS9w38TM6kV+ijjbdwaCwxeaPDbR+ymbDBHUfgf9l rg4ndFPdm5C2fMriihMxqlozBtwq13/KXXupXJrIvl53XoavXDnkaOCss6sw3d5HdOdzyefcu h4gQon3yjYWS73kqAp4+I4wPK/CC/WE6KaeM597IMafpehbwls64mZY2Ld8RbrVtI8h3EWF5Z j5C6nGP8O9PMMHqFpRHonGK9DvneJLw0eerPL96JZw8mB23yY5f2XF5bjl3o+nzCYxIhQ2L8B LiYlDY5RSgjQlH6sofUftr1U4+bZACcNYB9X+NIxdBjA4OHDf9nd5JzuMdYgYMZ+8aL06Sx6j JvxE9cvn0m36qC2TyIxzValYTQcY6oS7zrMuXYseQWcI78VxVP8vtAUlHza7bmgtcdCte2qoO TsbdJT1QZd7meBONb+rInv8t4yWjEjkB7WxgBA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.133 Subject: [Qemu-devel] [PATCH v2 4/5] softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale() 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-specialize.h | 15 ++++++ fpu/softfloat.c | 132 +++++++++++++++++++++++++++++++++++++++++= ++++ include/fpu/softfloat.h | 3 ++ 3 files changed, 150 insertions(+) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 1cb3502e5a..4706a0ec3a 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -1163,6 +1163,21 @@ static floatx80 propagateFloatx80NaN(floatx80 a, flo= atx80 b, } } =20 +#if defined(TARGET_M68K) +static floatx80 propagateFloatx80NaNOneArg(floatx80 a, float_status *statu= s) +{ + if (floatx80_is_signaling_nan(a, status)) { + float_raise(float_flag_invalid, status); + } + + if (status->default_nan_mode) { + return floatx80_default_nan(status); + } + + return floatx80_maybe_silence_nan(a, status); +} +#endif + #ifdef NO_SIGNALING_NANS int float128_is_quiet_nan(float128 a_, float_status *status) { diff --git a/fpu/softfloat.c b/fpu/softfloat.c index c6289bba75..a17e849fe7 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -5800,6 +5800,138 @@ floatx80 floatx80_mod(floatx80 a, floatx80 b, float= _status *status) normalizeRoundAndPackFloatx80( 80, zSign, bExp + expDiff, aSig0, aSig1, status); } + +/*------------------------------------------------------------------------= ---- + | Returns the mantissa of the extended double-precision floating-point + | value `a'. + *------------------------------------------------------------------------= ----*/ + +floatx80 floatx80_getman(floatx80 a, float_status *status) +{ + flag aSign; + int32_t aExp; + uint64_t aSig; + + aSig =3D extractFloatx80Frac(a); + aExp =3D extractFloatx80Exp(a); + aSign =3D extractFloatx80Sign(a); + + if (aExp =3D=3D 0x7FFF) { + if ((uint64_t) (aSig << 1)) { + return propagateFloatx80NaNOneArg(a , status); + } + float_raise(float_flag_invalid , status); + return floatx80_default_nan(status); + } + + if (aExp =3D=3D 0) { + if (aSig =3D=3D 0) { + return packFloatx80(aSign, 0, 0); + } + normalizeFloatx80Subnormal(aSig, &aExp, &aSig); + } + + return roundAndPackFloatx80(status->floatx80_rounding_precision, aSign, + 0x3FFF, aSig, 0, status); +} + +/*------------------------------------------------------------------------= ---- + | Returns the exponent of the extended double-precision floating-point + | value `a' as an extended double-precision value. + *------------------------------------------------------------------------= ----*/ + +floatx80 floatx80_getexp(floatx80 a, float_status *status) +{ + flag aSign; + int32_t aExp; + uint64_t aSig; + + aSig =3D extractFloatx80Frac(a); + aExp =3D extractFloatx80Exp(a); + aSign =3D extractFloatx80Sign(a); + + if (aExp =3D=3D 0x7FFF) { + if ((uint64_t) (aSig << 1)) { + return propagateFloatx80NaNOneArg(a , status); + } + float_raise(float_flag_invalid , status); + return floatx80_default_nan(status); + } + + if (aExp =3D=3D 0) { + if (aSig =3D=3D 0) { + return packFloatx80(aSign, 0, 0); + } + normalizeFloatx80Subnormal(aSig, &aExp, &aSig); + } + + return int32_to_floatx80(aExp - 0x3FFF, status); +} + +/*------------------------------------------------------------------------= ---- + | Scales extended double-precision floating-point value in operand `a' by + | value `b'. The function truncates the value in the second operand 'b' to + | an integral value and adds that value to the exponent of the operand 'a= '. + | The operation performed according to the IEC/IEEE Standard for Binary + | Floating-Point Arithmetic. + *------------------------------------------------------------------------= ----*/ + +floatx80 floatx80_scale(floatx80 a, floatx80 b, float_status *status) +{ + flag aSign, bSign; + int32_t aExp, bExp, shiftCount; + uint64_t aSig, bSig; + + aSig =3D extractFloatx80Frac(a); + aExp =3D extractFloatx80Exp(a); + aSign =3D extractFloatx80Sign(a); + bSig =3D extractFloatx80Frac(b); + bExp =3D extractFloatx80Exp(b); + bSign =3D extractFloatx80Sign(b); + + if (bExp =3D=3D 0x7FFF) { + if ((uint64_t) (bSig << 1) || + ((aExp =3D=3D 0x7FFF) && (uint64_t) (aSig << 1))) { + return propagateFloatx80NaN(a, b, status); + } + float_raise(float_flag_invalid , status); + return floatx80_default_nan(status); + } + if (aExp =3D=3D 0x7FFF) { + if ((uint64_t) (aSig << 1)) { + return propagateFloatx80NaN(a, b, status); + } + return packFloatx80(aSign, floatx80_infinity_high, + floatx80_infinity_low); + } + if (aExp =3D=3D 0) { + if (aSig =3D=3D 0) { + return packFloatx80(aSign, 0, 0); + } + if (bExp < 0x3FFF) { + return a; + } + normalizeFloatx80Subnormal(aSig, &aExp, &aSig); + } + + if (bExp < 0x3FFF) { + return a; + } + + if (0x400F < bExp) { + aExp =3D bSign ? -0x6001 : 0xE000; + return roundAndPackFloatx80(status->floatx80_rounding_precision, + aSign, aExp, aSig, 0, status); + } + + shiftCount =3D 0x403E - bExp; + bSig >>=3D shiftCount; + aExp =3D bSign ? (aExp - bSig) : (aExp + bSig); + + return roundAndPackFloatx80(status->floatx80_rounding_precision, + aSign, aExp, aSig, 0, status); + +} #endif /* TARGET_M68K */ =20 /*------------------------------------------------------------------------= ---- diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 413cdb20cb..84ddcb12a1 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -630,6 +630,9 @@ 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); +floatx80 floatx80_getman(floatx80 a, float_status *status); +floatx80 floatx80_getexp(floatx80 a, float_status *status); +floatx80 floatx80_scale(floatx80 a, floatx80 b, float_status *status); int floatx80_eq(floatx80, floatx80, float_status *status); int floatx80_le(floatx80, floatx80, float_status *status); int floatx80_lt(floatx80, floatx80, float_status *status); --=20 2.13.6 From nobody Fri May 3 08:15:35 2024 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 1511455057311894.8538461062994; Thu, 23 Nov 2017 08:37:37 -0800 (PST) Received: from localhost ([::1]:45131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuVK-0000PC-L5 for importer@patchew.org; Thu, 23 Nov 2017 11:37:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHuU3-0007sr-N1 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 1eHuTz-0003Vb-UW for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:15 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:50277) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eHuTz-0003UH-JK for qemu-devel@nongnu.org; Thu, 23 Nov 2017 11:36:11 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MG40o-1eKcAG1Izm-00Ey4h; Thu, 23 Nov 2017 17:35:46 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:35:38 +0100 Message-Id: <20171123163538.31411-6-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:i6sRqI+60FQhiF1rebSateRcqcsHjm2cqz7pr3n3LlPuyZ93BQ5 6OZT9NQqVoJ2rtylopysCaWQ025jjjNj3DeYo6oqw4D3cdLM6DI2d2FPCb33tkix2PUkkzx uK3pgQDY8cV8K9wVqG895r0piaBEyqVktSdAD9JFXRonU0NnzYgSSPUD4Ac55TV436OdlSR /dZhfGx8OZaEjWTuicJMw== X-UI-Out-Filterresults: notjunk:1;V01:K0:76wrh/PIfwg=:lxMbcmgAIYYpQ5k/mw9JDQ S2NiMv3VGJxBD2l4LEAPPanrCqxvdpCNdWLkBbhn28R9vLHLlO5pt0fmFRGjnpSMZ0393gjvv PFXJGIGRY1VC13YrAnRBB8/AiTHgc5oepStPTopLoqCZSADWod7KKP2Ocs9lQnVOdRE8XoJxz 6/7vm2XIf6dOl99aUaUQGoTkrgKXfD8yeD6iQnJrO97zOob5KjkfDoB45uDkYoumdmD0rBCg+ Frngta31TBM1E5DAec0wnlWzxwhF0EBuDWSmcLj8jpOicvceZYkApO2PAbTSY2qxuDoN9c0rD g0/QVAnqANyDw9e4Zf5c277yK0eeCfAMVaB0Lor/pug2gfh7ptbI+Nf+9C1KApqYTINGcNDK8 s5FR4Lnp5SbWDPjTcE9Q3+PP+gyaO9QcwUH4Sz9efCJPzEb4KlgrrW/FzKxvivhLsvKQj1Ttm wVla6Mel22nXWKgQ59q/iqHvXuYUfQtih7jzxsS+fTXX5V+Lk2Bz5AipLxasE+OVu3aq0csnI VEtR93N5fsrLiMCDtfaodwPPTqn5QSkAb17FEEgRO4FrzcEX6gaGtEros+eyeYWGcxp/25r58 R2jgdCDrH0XHh/EMFj2c34z2rm8j2KTfvdv18wKx8rl/YT1xxHPRrrybJpC7WFL9+tB84RPwg ftD95MQ6ZVL337jmiuaed0zWGPNQCHJ+JheVoyOwvMGk/zW/tOuXZ7tBe7/o3z5WjeOpm10lP SIuKjwE0Mg/FekqsXfHqxwnMPhQNYqioJv3/Hw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.133 Subject: [Qemu-devel] [PATCH v2 5/5] target-m68k: add fscale, fgetman and fgetexp 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" using floatx80_scale(), floatx80_getman() and floatx80_getexp() Signed-off-by: Laurent Vivier --- target/m68k/fpu_helper.c | 15 +++++++++++++++ target/m68k/helper.h | 3 +++ target/m68k/translate.c | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index dd8b6950d6..6be2b90eba 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -541,3 +541,18 @@ void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg= *val0, FPReg *val1) =20 make_quotient(env, res->d); } + +void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val) +{ + res->d =3D floatx80_getexp(val->d, &env->fp_status); +} + +void HELPER(fgetman)(CPUM68KState *env, FPReg *res, FPReg *val) +{ + res->d =3D floatx80_getman(val->d, &env->fp_status); +} + +void HELPER(fscale)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val= 1) +{ + res->d =3D floatx80_scale(val1->d, val0->d, &env->fp_status); +} diff --git a/target/m68k/helper.h b/target/m68k/helper.h index ff9d99ae27..ccdda73187 100644 --- a/target/m68k/helper.h +++ b/target/m68k/helper.h @@ -63,6 +63,9 @@ DEF_HELPER_3(fmovemd_st_postinc, i32, env, i32, i32) DEF_HELPER_3(fmovemd_ld_postinc, i32, env, i32, i32) DEF_HELPER_4(fmod, void, env, fp, fp, fp) DEF_HELPER_4(frem, void, env, fp, fp, fp) +DEF_HELPER_3(fgetexp, void, env, fp, fp) +DEF_HELPER_3(fgetman, void, env, fp, fp) +DEF_HELPER_4(fscale, void, env, fp, fp, fp) =20 DEF_HELPER_3(mac_move, void, env, i32, i32) DEF_HELPER_3(macmulf, i64, env, i32, i32) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 66f873899f..c0c2e8c757 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -4677,6 +4677,12 @@ DISAS_INSN(fpu) case 0x5e: /* fdneg */ gen_helper_fdneg(cpu_env, cpu_dest, cpu_src); break; + case 0x1e: /* fgetexp */ + gen_helper_fgetexp(cpu_env, cpu_dest, cpu_src); + break; + case 0x1f: /* fgetman */ + gen_helper_fgetman(cpu_env, cpu_dest, cpu_src); + break; case 0x20: /* fdiv */ gen_helper_fdiv(cpu_env, cpu_dest, cpu_src, cpu_dest); break; @@ -4713,6 +4719,9 @@ DISAS_INSN(fpu) case 0x25: /* frem */ gen_helper_frem(cpu_env, cpu_dest, cpu_src, cpu_dest); break; + case 0x26: /* fscale */ + gen_helper_fscale(cpu_env, cpu_dest, cpu_src, cpu_dest); + break; case 0x27: /* fsglmul */ gen_helper_fsglmul(cpu_env, cpu_dest, cpu_src, cpu_dest); break; --=20 2.13.6