diff options
Diffstat (limited to 'sysdeps/powerpc/powerpc32/fpu')
-rw-r--r-- | sysdeps/powerpc/powerpc32/fpu/Makefile | 6 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/fpu/s_llrint.c | 9 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/fpu/s_llrintf.c | 7 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/fpu/s_lrint.S | 40 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/fpu/s_lrint.c | 40 |
5 files changed, 62 insertions, 40 deletions
diff --git a/sysdeps/powerpc/powerpc32/fpu/Makefile b/sysdeps/powerpc/powerpc32/fpu/Makefile index e05073970d..c79b192f60 100644 --- a/sysdeps/powerpc/powerpc32/fpu/Makefile +++ b/sysdeps/powerpc/powerpc32/fpu/Makefile @@ -1,3 +1,9 @@ +ifeq ($(subdir),math) +# lrint is aliased to lrintf, so suppress compiler builtins to +# avoid mismatched signatures. +CFLAGS-s_lrint.c += -fno-builtin-lrintf +endif + ifeq ($(subdir),misc) sysdep_routines += fprsave fprrest endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_llrint.c b/sysdeps/powerpc/powerpc32/fpu/s_llrint.c index 7e91d606c2..42558efd46 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_llrint.c +++ b/sysdeps/powerpc/powerpc32/fpu/s_llrint.c @@ -26,6 +26,12 @@ long long int __llrint (double x) { +#ifdef _ARCH_PWR4 + /* Assume powerpc64 instructions availability. */ + long long int ret; + __asm__ ("fctid %0, %1" : "=d" (ret) : "d" (x)); + return ret; +#else double rx = rint (x); if (HAVE_PPC_FCTIDZ || rx != x) return (long long int) rx; @@ -53,5 +59,8 @@ __llrint (double x) else return (long long int) (long int) rx << 32; } +#endif } +#ifndef __llrint libm_alias_double (__llrint, llrint) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c b/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c index 021a86fada..b75655e2c1 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c +++ b/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c @@ -24,6 +24,12 @@ long long int __llrintf (float x) { +#ifdef _ARCH_PWR4 + /* Assume powerpc64 instructions availability. */ + long long int ret; + __asm__ ("fctid %0, %1" : "=d" (ret) : "d" (x)); + return ret; +#else float rx = rintf (x); if (HAVE_PPC_FCTIDZ || rx != x) return (long long int) rx; @@ -43,5 +49,6 @@ __llrintf (float x) mant <<= exponent - 23; return (long long int) ((i0 & 0x80000000) != 0 ? -mant : mant); } +#endif } libm_alias_float (__llrint, llrint) diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lrint.S b/sysdeps/powerpc/powerpc32/fpu/s_lrint.S deleted file mode 100644 index fdad180116..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_lrint.S +++ /dev/null @@ -1,40 +0,0 @@ -/* Round double to long int. PowerPC32 version. - Copyright (C) 2004-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <math_ldbl_opt.h> -#include <libm-alias-float.h> -#include <libm-alias-double.h> - -/* long int[r3] __lrint (double x[fp1]) */ -ENTRY (__lrint) - stwu r1,-16(r1) - fctiw fp13,fp1 - stfd fp13,8(r1) - nop /* Ensure the following load is in a different dispatch group */ - nop /* to avoid pipe stall on POWER4&5. */ - nop - lwz r3,8+LOWORD(r1) - addi r1,r1,16 - blr - END (__lrint) - -libm_alias_double (__lrint, lrint) - -strong_alias (__lrint, __lrintf) -libm_alias_float (__lrint, lrint) diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lrint.c b/sysdeps/powerpc/powerpc32/fpu/s_lrint.c new file mode 100644 index 0000000000..21bdc5c063 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_lrint.c @@ -0,0 +1,40 @@ +/* Round to nearest integer. PowerPC32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see <http://www.gnu.org/licenses/>. */ + +#define NO_MATH_REDIRECT +#define lrintf __redirect_lrintf +#define __lrintf __redirect___lrintf +#include <math.h> +#undef lrintf +#undef __lrintf +#include <fenv_private.h> +#include <libm-alias-double.h> +#include <libm-alias-float.h> + +long int +__lrint (double x) +{ + long long int ret; + __asm__ ("fctiw %0, %1" : "=d" (ret) : "d" (x)); + return ret; +} +#ifndef __lrint +libm_alias_double (__lrint, lrint) +strong_alias (__lrint, __lrintf) +libm_alias_float (__lrint, lrint) +#endif |