From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
Thomas Huth <huth@tuxfamily.org>,
Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 10/11] target/m68k: implement fsinh
Date: Mon, 12 Mar 2018 21:27:27 +0100 [thread overview]
Message-ID: <20180312202728.23790-11-laurent@vivier.eu> (raw)
In-Reply-To: <20180312202728.23790-1-laurent@vivier.eu>
Using a local m68k floatx80_sinh()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
target/m68k/fpu_helper.c | 5 +++
target/m68k/helper.h | 1 +
target/m68k/softfloat.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
target/m68k/softfloat.h | 1 +
target/m68k/translate.c | 3 ++
5 files changed, 99 insertions(+)
diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index 7d68879f34..4c969dfe00 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -643,3 +643,8 @@ void HELPER(ftanh)(CPUM68KState *env, FPReg *res, FPReg *val)
{
res->d = floatx80_tanh(val->d, &env->fp_status);
}
+
+void HELPER(fsinh)(CPUM68KState *env, FPReg *res, FPReg *val)
+{
+ res->d = floatx80_sinh(val->d, &env->fp_status);
+}
diff --git a/target/m68k/helper.h b/target/m68k/helper.h
index f100141367..acdca1af03 100644
--- a/target/m68k/helper.h
+++ b/target/m68k/helper.h
@@ -84,6 +84,7 @@ DEF_HELPER_3(fasin, void, env, fp, fp)
DEF_HELPER_3(facos, void, env, fp, fp)
DEF_HELPER_3(fatanh, void, env, fp, fp)
DEF_HELPER_3(ftanh, void, env, fp, fp)
+DEF_HELPER_3(fsinh, void, env, fp, fp)
DEF_HELPER_3(mac_move, void, env, i32, i32)
DEF_HELPER_3(macmulf, i64, env, i32, i32)
diff --git a/target/m68k/softfloat.c b/target/m68k/softfloat.c
index 4ce5783f03..1528bfd147 100644
--- a/target/m68k/softfloat.c
+++ b/target/m68k/softfloat.c
@@ -2733,3 +2733,92 @@ floatx80 floatx80_tanh(floatx80 a, float_status *status)
return a;
}
}
+
+/*----------------------------------------------------------------------------
+ | Hyperbolic sine
+ *----------------------------------------------------------------------------*/
+
+floatx80 floatx80_sinh(floatx80 a, float_status *status)
+{
+ flag aSign;
+ int32_t aExp;
+ uint64_t aSig;
+
+ int8_t user_rnd_mode, user_rnd_prec;
+
+ int32_t compact;
+ floatx80 fp0, fp1, fp2;
+ float32 fact;
+
+ aSig = extractFloatx80Frac(a);
+ aExp = extractFloatx80Exp(a);
+ aSign = extractFloatx80Sign(a);
+
+ if (aExp == 0x7FFF) {
+ if ((uint64_t) (aSig << 1)) {
+ return propagateFloatx80NaNOneArg(a, status);
+ }
+ return packFloatx80(aSign, floatx80_infinity.high,
+ floatx80_infinity.low);
+ }
+
+ if (aExp == 0 && aSig == 0) {
+ return packFloatx80(aSign, 0, 0);
+ }
+
+ user_rnd_mode = status->float_rounding_mode;
+ user_rnd_prec = status->floatx80_rounding_precision;
+ status->float_rounding_mode = float_round_nearest_even;
+ status->floatx80_rounding_precision = 80;
+
+ compact = floatx80_make_compact(aExp, aSig);
+
+ if (compact > 0x400CB167) {
+ /* SINHBIG */
+ if (compact > 0x400CB2B3) {
+ status->float_rounding_mode = user_rnd_mode;
+ status->floatx80_rounding_precision = user_rnd_prec;
+
+ return roundAndPackFloatx80(status->floatx80_rounding_precision,
+ aSign, 0x8000, aSig, 0, status);
+ } else {
+ fp0 = floatx80_abs(a); /* Y = |X| */
+ fp0 = floatx80_sub(fp0, float64_to_floatx80(
+ make_float64(0x40C62D38D3D64634), status),
+ status); /* (|X|-16381LOG2_LEAD) */
+ fp0 = floatx80_sub(fp0, float64_to_floatx80(
+ make_float64(0x3D6F90AEB1E75CC7), status),
+ status); /* |X| - 16381 LOG2, ACCURATE */
+ fp0 = floatx80_etox(fp0, status);
+ fp2 = packFloatx80(aSign, 0x7FFB, one_sig);
+
+ status->float_rounding_mode = user_rnd_mode;
+ status->floatx80_rounding_precision = user_rnd_prec;
+
+ a = floatx80_mul(fp0, fp2, status);
+
+ float_raise(float_flag_inexact, status);
+
+ return a;
+ }
+ } else { /* |X| < 16380 LOG2 */
+ fp0 = floatx80_abs(a); /* Y = |X| */
+ fp0 = floatx80_etoxm1(fp0, status); /* FP0 IS Z = EXPM1(Y) */
+ fp1 = floatx80_add(fp0, float32_to_floatx80(make_float32(0x3F800000),
+ status), status); /* 1+Z */
+ fp2 = fp0;
+ fp0 = floatx80_div(fp0, fp1, status); /* Z/(1+Z) */
+ fp0 = floatx80_add(fp0, fp2, status);
+
+ fact = packFloat32(aSign, 0x7E, 0);
+
+ status->float_rounding_mode = user_rnd_mode;
+ status->floatx80_rounding_precision = user_rnd_prec;
+
+ a = floatx80_mul(fp0, float32_to_floatx80(fact, status), status);
+
+ float_raise(float_flag_inexact, status);
+
+ return a;
+ }
+}
diff --git a/target/m68k/softfloat.h b/target/m68k/softfloat.h
index 4cdb5a49ca..f033abf9ea 100644
--- a/target/m68k/softfloat.h
+++ b/target/m68k/softfloat.h
@@ -43,4 +43,5 @@ floatx80 floatx80_acos(floatx80 a, float_status *status);
floatx80 floatx80_atanh(floatx80 a, float_status *status);
floatx80 floatx80_etoxm1(floatx80 a, float_status *status);
floatx80 floatx80_tanh(floatx80 a, float_status *status);
+floatx80 floatx80_sinh(floatx80 a, float_status *status);
#endif
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 0caae904b5..7d83aaf91d 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -5042,6 +5042,9 @@ DISAS_INSN(fpu)
case 1: /* fint */
gen_helper_firound(cpu_env, cpu_dest, cpu_src);
break;
+ case 2: /* fsinh */
+ gen_helper_fsinh(cpu_env, cpu_dest, cpu_src);
+ break;
case 3: /* fintrz */
gen_helper_fitrunc(cpu_env, cpu_dest, cpu_src);
break;
--
2.14.3
next prev parent reply other threads:[~2018-03-12 20:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 20:27 [Qemu-devel] [PATCH 00/11] implement 680x0 FPU (part 5) Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 01/11] target/m68k: implement ftan Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 02/11] target/m68k: implement fsin Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 03/11] target/m68k: implement fcos Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 04/11] target/m68k: implement fsincos Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 05/11] target/m68k: implement fatan Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 06/11] target/m68k: implement fasin Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 07/11] target/m68k: implement facos Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 08/11] target/m68k: implement fatanh Laurent Vivier
2018-03-12 20:27 ` [Qemu-devel] [PATCH 09/11] target/m68k: implement ftanh Laurent Vivier
2018-03-12 20:27 ` Laurent Vivier [this message]
2018-03-12 20:27 ` [Qemu-devel] [PATCH 11/11] target/m68k: implement fcosh Laurent Vivier
2018-03-15 16:24 ` [Qemu-devel] [PATCH 00/11] implement 680x0 FPU (part 5) Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180312202728.23790-11-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=huth@tuxfamily.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).