qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 00/11] implement 680x0 FPU (part 5)
Date: Mon, 12 Mar 2018 21:27:17 +0100	[thread overview]
Message-ID: <20180312202728.23790-1-laurent@vivier.eu> (raw)

Implement fcosh, fsinh, ftanh, fatanh, facos, fasin,
fatan, fsincos, fcos, fsin, ftan.

This is the last series to implement FPU instructions for 680x0...

As previously, all the floatx80 functions are copied from "Previous",
the NeXT Computer Emulator, and written by Andreas Grabher.

I did not improve or clean up the code, it's a simple port of
Andreas' work from "Previous".

I think this series will need some improvemants in the future:
for intance sin and cos functions can be merged in sincos
function (and we have unmodified "adjn" variable in floatx80_cos()
and floatx80_sin() that can be removed otherwise).

"Previous" code I have ported to QEMU can be found in (r844):

  http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/

"Previous" code is a C implementation of m68040 assembly language functions
found in ($NetBSD: copyright.s,v 1.2 1994/10/26 07:48:57 cgd Exp)

  https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/

All the original work is under SoftFloat-2a license, and additional work
under BSD license or GPL-v2-or-later license.

All softfloat new functions are added in target/m68k as they are derived
from m68k code.

I have compared results of these instructions from a real m68040 and from
QEMU, and they match (sincos differs [1] because in QEMU we compute it as
sin and cos, and on m68040 sin and cos results differ also with
sincos results. It looks like a rounding problem, perhaps a bug in m68040
FPU? or in my test program?)

I know this will need more work, but for the moment I only would
like to provide these new instructions to the maintream of QEMU.

[1] Example:

sincos -6.125952 -> (0.156586, 0.987664)

QEMU:

  sincos c0010000c407cd1182c2bb27 -> 3ffc0000a05812beea449a4d
                                     3ffe0000fcd791d65887d19a
  sin c0010000c407cd1182c2bb27    -> 3ffc0000a05812beea449a4d
  cos c0010000c407cd1182c2bb27    -> 3ffe0000fcd791d65887d19a

m68040:

  sincos c0010000c407cd1182c2bb27 -> 3ffc0000a05812beea449a4d
                                     3ffe0000fcd791d65887d199 <<--
  sin c0010000c407cd1182c2bb27    -> 3ffc0000a05812beea449a4d
  cos c0010000c407cd1182c2bb27    -> 3ffe0000fcd791d65887d19a

test program is basically:

    register long double a, sin, cos, pi;
    long double step;

    asm("fmovecr #0, %0" : "=f" (pi));
    step = pi / 1024;
    for (a = -2*pi; a <= 2*pi; a+= step) {
        asm("fsincos.x %2, %0, %1" : "=f" (cos), "=f" (sin) : "f" (a));
        print_result(a, sin, cos);
        asm("fsin.x %1, %0" : "=f" (sin) : "f" (a));
        asm("fcos.x %1, %0" : "=f" (cos) : "f" (a));
        print_result(a, sin, cos);
    }

Laurent Vivier (11):
  target/m68k: implement ftan
  target/m68k: implement fsin
  target/m68k: implement fcos
  target/m68k: implement fsincos
  target/m68k: implement fatan
  target/m68k: implement fasin
  target/m68k: implement facos
  target/m68k: implement fatanh
  target/m68k: implement ftanh
  target/m68k: implement fsinh
  target/m68k: implement fcosh

 target/m68k/fpu_helper.c            |   61 ++
 target/m68k/helper.h                |   11 +
 target/m68k/softfloat.c             | 1637 +++++++++++++++++++++++++++++++++++
 target/m68k/softfloat.h             |   11 +
 target/m68k/softfloat_fpsp_tables.h |  267 ++++++
 target/m68k/translate.c             |   38 +
 6 files changed, 2025 insertions(+)

-- 
2.14.3

             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 Laurent Vivier [this message]
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 ` [Qemu-devel] [PATCH 10/11] target/m68k: implement fsinh Laurent Vivier
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-1-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).