From patchwork Mon Mar 12 20:27:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 884851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 400V1v50fXz9sSj for ; Tue, 13 Mar 2018 07:28:51 +1100 (AEDT) Received: from localhost ([::1]:34489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evU3t-0005Gz-Eg for incoming@patchwork.ozlabs.org; Mon, 12 Mar 2018 16:28:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evU35-0005EK-4B for qemu-devel@nongnu.org; Mon, 12 Mar 2018 16:28:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evU31-0004az-Q2 for qemu-devel@nongnu.org; Mon, 12 Mar 2018 16:27:59 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:49247) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evU31-0004SA-GU for qemu-devel@nongnu.org; Mon, 12 Mar 2018 16:27:55 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MDU2z-1esSK719LB-00Gmp0; Mon, 12 Mar 2018 21:27:46 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 12 Mar 2018 21:27:17 +0100 Message-Id: <20180312202728.23790-1-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 X-Provags-ID: V03:K0:JohlX18mzyr3spDwsgY1z/csMu0a9s8ML2G6b8aYTTFn1syEre6 YJaAQpcKQ7moAsKOVz3Q2VmO9Ngw85aZ3c/yaX5EAx3XR4tI3eSPsw69fCMLv+GFnvWvfcn hhCJWSC3D3p2ZHL7F9mSXW+/8+HUNwSODC0XiP2vb/8HJFTa1KVHwfKJ49hS8DdIcHRMUbA aKTiPDDxEU+wGo+5blstw== X-UI-Out-Filterresults: notjunk:1; V01:K0:hokJvzhCIqQ=:+xFwgQflGCFxdH6xvH/kEc ia2U6A8X0t8UDfFLH2jYMTNmMHoX/Xm9fPnu6jAT/oMBuYiLB14MDDsOD0GDNlVFSwZMedz/P k4Tx4wLxhbYbM+7x587ryMTuzK8oQ/1QFphXxRdxaWH4Q/VeBbPRxYhypYFiPgFe3MwzH6JZ3 M9KDBhGLQG/EYhmfvYGxWsndkT/IQzY7LyGoNmwDq9qs4FYmDiJS/HmjwEsVDDChIrIXl+RDR I46z3576+v5LcMBuMzHZi9vBKjnzt4SOVUa9vLbptBlwHUyd9PC90OgZ98ynJA824QL9w5jnC UcIglhDPJJipGVFjGgqElYhaErAHiU6ApuypixmivXuGa4jjLwOsZexA1fd8FLKM5hcfXySt1 QCNg9aB9lmt+omxY2rHg55qPmNKqc/b8nlSXpQ8rdKESceq871C2iRCQum7Jn5m+fH7rcjS89 87dJ+179IWQHOhKQ62/1PL0dMkhlthbSvrhnhWmQ0+ymsKIqxbhu9mG1RP9GIsuSMbSTbkxCc kAxDyXhDoeiyU52/H24zR1D7lW7MvadTTzTt61R9d035VtvcASmYkatff3RtTW7u+sJUmDLx9 hFfBrG5GibjM8CiExWWTulNkl0sy31Fc9OHOfu+U4PW99xBck8FZhyF9myHI2c03bp0oXTHP0 Ie1lq1kNSr2f+rAMj6eFeJyWCT9RCgKMBUq2njIhgtszhEmB2EwPL+R9JGrJUl5ENVl7jFiFO 35FKtRiAMpj0zKhNAq5uFwTKp9Nr4CPSQYf0Vw== 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 00/11] implement 680x0 FPU (part 5) 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 , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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(+) Reviewed-by: Richard Henderson