From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14646 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] mips: add single-instruction math functions Date: Wed, 11 Sep 2019 13:05:04 +0300 Message-ID: <20190911103224.504A15C44C@mx7.valuehost.ru> Reply-To: musl@lists.openwall.com Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="167560"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-14662-gllmg-musl=m.gmane.org@lists.openwall.com Wed Sep 11 12:32:48 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1i7zvc-000hWG-2Z for gllmg-musl@m.gmane.org; Wed, 11 Sep 2019 12:32:48 +0200 Original-Received: (qmail 27935 invoked by uid 550); 11 Sep 2019 10:32:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 27866 invoked from network); 11 Sep 2019 10:32:39 -0000 Xref: news.gmane.org gmane.linux.lib.musl.general:14646 Archived-At: non-commit text: gcc puts annoying nop into the delay slot for these functions, e.g.: abs.d $f0,$f12 jr $ra nop is there any way to get rid of this without using pure .S? SQRT.fmt exists on MIPS II+ (float), MIPS III+ (double). ABS.fmt exists on MIPS I+ but only cores with ABS2008 flag in FCSR implement the required behaviour. --- src/math/mips/fabs.c | 16 ++++++++++++++++ src/math/mips/fabsf.c | 16 ++++++++++++++++ src/math/mips/sqrt.c | 16 ++++++++++++++++ src/math/mips/sqrtf.c | 16 ++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 src/math/mips/fabs.c create mode 100644 src/math/mips/fabsf.c create mode 100644 src/math/mips/sqrt.c create mode 100644 src/math/mips/sqrtf.c diff --git a/src/math/mips/fabs.c b/src/math/mips/fabs.c new file mode 100644 index 00000000..0a5aa3b1 --- /dev/null +++ b/src/math/mips/fabs.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && defined(__mips_abs2008) + +#include + +double fabs(double x) +{ + double r; + __asm__("abs.d %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../fabs.c" + +#endif diff --git a/src/math/mips/fabsf.c b/src/math/mips/fabsf.c new file mode 100644 index 00000000..35307be6 --- /dev/null +++ b/src/math/mips/fabsf.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && defined(__mips_abs2008) + +#include + +float fabsf(float x) +{ + float r; + __asm__("abs.s %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../fabsf.c" + +#endif diff --git a/src/math/mips/sqrt.c b/src/math/mips/sqrt.c new file mode 100644 index 00000000..595c9dbc --- /dev/null +++ b/src/math/mips/sqrt.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && __mips >= 3 + +#include + +double sqrt(double x) +{ + double r; + __asm__("sqrt.d %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../sqrt.c" + +#endif diff --git a/src/math/mips/sqrtf.c b/src/math/mips/sqrtf.c new file mode 100644 index 00000000..84090d2d --- /dev/null +++ b/src/math/mips/sqrtf.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && __mips >= 2 + +#include + +float sqrtf(float x) +{ + float r; + __asm__("sqrt.s %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../sqrtf.c" + +#endif -- 2.23.0.windows.1