Re: [Qemu-devel] [PATCH v3 15/16] target-m68k: add more FPU instructions

2017-02-17 Thread Andreas Schwab
On Feb 17 2017, Richard Henderson  wrote:

> On 02/16/2017 09:18 PM, Andreas Schwab wrote:
>> There is no guarantee that the host long double has the same range and
>> precision as floatx80.
>
> Indeed not.  However, do you have another plan for implementing the
> trancendentals?  I'm quite happy using the host long double libm as an
> estimate.  Which is better than at least BasiliskII, which uses the host
> double.

In ARAnyM, I implemented a software emulation using mpfr (but it is
still incomplete in many ways).  I don't know if something like this
would be an option for qemu.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



Re: [Qemu-devel] [PATCH v3 15/16] target-m68k: add more FPU instructions

2017-02-16 Thread Richard Henderson

On 02/16/2017 09:18 PM, Andreas Schwab wrote:

There is no guarantee that the host long double has the same range and
precision as floatx80.


Indeed not.  However, do you have another plan for implementing the 
trancendentals?  I'm quite happy using the host long double libm as an 
estimate.  Which is better than at least BasiliskII, which uses the host double.



r~



Re: [Qemu-devel] [PATCH v3 15/16] target-m68k: add more FPU instructions

2017-02-15 Thread Richard Henderson

On 02/07/2017 11:59 AM, Laurent Vivier wrote:

+static long double floatx80_to_ldouble(floatx80 val)
+{
+if (floatx80_is_infinity(val)) {
+if (floatx80_is_neg(val)) {
+return -__builtin_infl();
+}
+return __builtin_infl();
+}
+if (floatx80_is_any_nan(val)) {
+char low[20];
+sprintf(low, "0x%016"PRIx64, val.low);
+
+return nanl(low);
+}
+
+return *(long double *)
+}


This doesn't work except for x86 host.

You ought to extract the mantissa, convert the 64-bit value to long-double, and 
use ldexpl to scale the result for the exponent.


Similarly converting the other way use frexpl and ldexpl.


r~