This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 26/36] PowerPC: finite/finitef multilib for PowerPC32
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Mon, 19 Aug 2013 18:29:55 -0300
- Subject: [PATCH 26/36] PowerPC: finite/finitef multilib for PowerPC32
- References: <52127ABC dot 40008 at linux dot vnet dot ibm dot com>
2013-08-19 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/ieee754/dbl-64/s_finite.c (__finite): Using macro to
redefine symbol name.
* sysdeps/ieee754/flt-32/s_finitef.c (__finitef): Likewise.
* sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S: Move to ...
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-power7.S: ... here.
(__finite): Rename symbol to __finite_power7 and remove strong_alias,
weak_alias and compat_symbol definitions.
* sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S: Remove unneeded
file.
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-ppc32.c: New file:
default finite implementation for PPC32.
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef-ppc32.c: New file:
default finitef implementation for PPC32.
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite.c: New file:
multiarch finite for PPC32.
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef.c: New file:
multiarch finitef for PPC32.
* sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile: Add finite and
finitef objects.
--
diff --git a/sysdeps/ieee754/dbl-64/s_finite.c b/sysdeps/ieee754/dbl-64/s_finite.c
index 47dad5d..5e7485b 100644
--- a/sysdeps/ieee754/dbl-64/s_finite.c
+++ b/sysdeps/ieee754/dbl-64/s_finite.c
@@ -23,7 +23,12 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
#include <math_private.h>
#undef __finite
-int __finite(double x)
+
+#ifndef FINITE
+# define FINITE __finite
+#endif
+
+int FINITE(double x)
{
int32_t hx;
GET_HIGH_WORD(hx,x);
diff --git a/sysdeps/ieee754/flt-32/s_finitef.c b/sysdeps/ieee754/flt-32/s_finitef.c
index dfdf4ad..4ea270a 100644
--- a/sysdeps/ieee754/flt-32/s_finitef.c
+++ b/sysdeps/ieee754/flt-32/s_finitef.c
@@ -26,7 +26,12 @@ static char rcsid[] = "$NetBSD: s_finitef.c,v 1.4 1995/05/10 20:47:18 jtc Exp $"
#include <math_private.h>
#undef __finitef
-int __finitef(float x)
+
+#ifndef FINITEF
+# define FINITEF __finitef
+#endif
+
+int FINITEF(float x)
{
int32_t ix;
GET_FLOAT_WORD(ix,x);
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
index ba07447..3bf3e52 100644
--- a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
@@ -1,7 +1,8 @@
ifeq ($(subdir),math)
sysdep_routines += s_isnan-power7 s_isnan-power6 s_isnan-power5 s_isnan-ppc32 \
s_isnanf-power6 s_isnanf-power5 s_isnanf-ppc32 \
- s_isinf-power7 s_isinf-ppc32 s_isinff-ppc32
+ s_isinf-power7 s_isinf-ppc32 s_isinff-ppc32 \
+ s_finite-power7 s_finite-ppc32 s_finitef-ppc32
libm-sysdep_routines += s_llrintf-power6 s_llrintf-power4 s_llrintf-ppc32 \
s_llrint-power6 s_llrint-power4 s_llrint-ppc32 \
@@ -11,7 +12,8 @@ libm-sysdep_routines += s_llrintf-power6 s_llrintf-power4 s_llrintf-ppc32 \
w_sqrtf-ppc32 s_isnan-power7 s_isnan-power6 \
s_isnan-power5 s_isnan-ppc32 s_isnanf-power6 \
s_isnanf-power5 s_isnanf-ppc32 s_isinf-power7 \
- s_isinf-ppc32 s_isinff-ppc32
+ s_isinf-ppc32 s_isinff-ppc32 s_finite-power7 \
+ s_finite-ppc32 s_finitef-ppc32
CFLAGS-s_llround.c = -fno-builtin-llroundf
endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-power7.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-power7.S
new file mode 100644
index 0000000..c9bebd6
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-power7.S
@@ -0,0 +1,67 @@
+/* finite(). PowerPC32/POWER7 version.
+ Copyright (C) 2010-2013 Free Software Foundation, Inc.
+ Contributed by Luis Machado <luisgpm@br.ibm.com>.
+ 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>
+
+/* int __finite(x) */
+ .section .rodata.cst8,"aM",@progbits,8
+ .align 3
+.LC0: /* 1.0 */
+ .quad 0x3ff0000000000000
+
+ .section ".text"
+ .type __finite, @function
+ .machine power7
+ENTRY (__finite_power7)
+#ifdef SHARED
+ mflr r11
+ cfi_register(lr,r11)
+
+ SETUP_GOT_ACCESS(r9,got_label)
+ addis r9,r9,.LC0-got_label@ha
+ lfd fp0,.LC0-got_label@l(r9)
+
+ mtlr r11
+ cfi_same_value (lr)
+#else
+ lis r9,.LC0@ha
+ lfd fp0,.LC0@l(r9)
+#endif
+ ftdiv cr7,fp1,fp0
+ li r3,1
+ bflr 30
+
+ /* We have -INF/+INF/NaN or a denormal. */
+
+ stwu r1,-16(r1) /* Allocate stack space. */
+ stfd fp1,8(r1) /* Transfer FP to GPR's. */
+
+ ori 2,2,0 /* Force a new dispatch group. */
+ lhz r0,8(r1) /* Fetch the upper portion of the high word of
+ the FP value (where the exponent and sign bits
+ are). */
+ clrlwi r0,r0,17 /* r0 = abs(r0). */
+ addi r1,r1,16 /* Reset the stack pointer. */
+ cmpwi cr7,r0,0x7ff0 /* r4 == 0x7ff0?. */
+ bltlr cr7 /* LT means we have a denormal. */
+ li r3,0
+ blr
+END (__finite_power7)
+weak_alias (__finite_power7, __finitef_power7)
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-ppc32.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-ppc32.c
new file mode 100644
index 0000000..a9f7d95
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite-ppc32.c
@@ -0,0 +1,34 @@
+/* finite(). PowerPC32 default version.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+ Contributed by Luis Machado <luisgpm@br.ibm.com>.
+ 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 <math.h>
+
+#undef weak_alias
+#define weak_alias(a, b)
+#undef strong_alias
+#define strong_alias(a, b)
+
+#define FINITE __finite_ppc32
+#ifdef SHARED
+# undef hidden_def
+# define hidden_def(a) \
+ __hidden_ver1 (__finite_ppc32, __GI___finite, __finite_ppc32);
+#endif
+
+#include <sysdeps/ieee754/dbl-64/s_finite.c>
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite.c
new file mode 100644
index 0000000..85a6341
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finite.c
@@ -0,0 +1,51 @@
+/* Multiple versions of finite.
+ Copyright (C) 2013 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 <math.h>
+#include <math_ldbl_opt.h>
+#include <shlib-compat.h>
+#include "init-arch.h"
+
+extern __typeof (__finite) __finite_ppc32 attribute_hidden;
+extern __typeof (__finite) __finite_power7 attribute_hidden;
+
+libc_ifunc (__finite,
+ (hwcap & PPC_FEATURE_ARCH_2_06)
+ ? __finite_power7
+ : __finite_ppc32);
+
+weak_alias (__finite, finite)
+
+#ifdef NO_LONG_DOUBLE
+strong_alias (__finite, __finitel)
+weak_alias (__finite, finitel)
+#endif
+
+#ifdef IS_IN_libm
+# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
+compat_symbol (libm, finite, finitel, GLIBC_2_0);
+# endif
+# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_1)
+compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
+# endif
+#else
+# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
+compat_symbol (libc, finite, finitel, GLIBC_2_0);
+# endif
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef-ppc32.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef-ppc32.c
new file mode 100644
index 0000000..07b7e06
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef-ppc32.c
@@ -0,0 +1,32 @@
+/* finitef(). PowerPC32 default version.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+ Contributed by Luis Machado <luisgpm@br.ibm.com>.
+ 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 <math.h>
+
+#undef weak_alias
+#define weak_alias(a, b)
+
+#define FINITEF __finitef_ppc32
+#ifdef SHARED
+# undef hidden_def
+# define hidden_def(a) \
+ __hidden_ver1 (__finitef_ppc32, __GI___finitef, __finitef_ppc32);
+#endif
+
+#include <sysdeps/ieee754/flt-32/s_finitef.c>
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef.c
new file mode 100644
index 0000000..5ffc1d7
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_finitef.c
@@ -0,0 +1,31 @@
+/* Multiple versions of finitef.
+ Copyright (C) 2013 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 <math.h>
+#include <shlib-compat.h>
+#include "init-arch.h"
+
+extern __typeof (__finitef) __finitef_ppc32 attribute_hidden;
+extern __typeof (__finitef) __finitef_power7 attribute_hidden;
+
+libc_ifunc (__finitef,
+ (hwcap & PPC_FEATURE_ARCH_2_06)
+ ? __finitef_power7
+ : __finitef_ppc32);
+
+weak_alias (__finitef, finitef)
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S
deleted file mode 100644
index b2ab5bf..0000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S
+++ /dev/null
@@ -1,94 +0,0 @@
-/* finite(). PowerPC32/POWER7 version.
- Copyright (C) 2010-2013 Free Software Foundation, Inc.
- Contributed by Luis Machado <luisgpm@br.ibm.com>.
- 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>
-
-/* int __finite(x) */
- .section .rodata.cst8,"aM",@progbits,8
- .align 3
-.LC0: /* 1.0 */
- .quad 0x3ff0000000000000
-
- .section ".text"
- .type __finite, @function
- .machine power7
-ENTRY (__finite)
-#ifdef SHARED
- mflr r11
- cfi_register(lr,r11)
-
- SETUP_GOT_ACCESS(r9,got_label)
- addis r9,r9,.LC0-got_label@ha
- lfd fp0,.LC0-got_label@l(r9)
-
- mtlr r11
- cfi_same_value (lr)
-#else
- lis r9,.LC0@ha
- lfd fp0,.LC0@l(r9)
-#endif
- ftdiv cr7,fp1,fp0
- li r3,1
- bflr 30
-
- /* We have -INF/+INF/NaN or a denormal. */
-
- stwu r1,-16(r1) /* Allocate stack space. */
- stfd fp1,8(r1) /* Transfer FP to GPR's. */
-
- ori 2,2,0 /* Force a new dispatch group. */
- lhz r0,8(r1) /* Fetch the upper portion of the high word of
- the FP value (where the exponent and sign bits
- are). */
- clrlwi r0,r0,17 /* r0 = abs(r0). */
- addi r1,r1,16 /* Reset the stack pointer. */
- cmpwi cr7,r0,0x7ff0 /* r4 == 0x7ff0?. */
- bltlr cr7 /* LT means we have a denormal. */
- li r3,0
- blr
- END (__finite)
-
-hidden_def (__finite)
-weak_alias (__finite, finite)
-
-/* It turns out that the 'double' version will also always work for
- single-precision. */
-strong_alias (__finite, __finitef)
-hidden_def (__finitef)
-weak_alias (__finitef, finitef)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__finite, __finitel)
-weak_alias (__finite, finitel)
-#endif
-
-#ifdef IS_IN_libm
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
-compat_symbol (libm, finite, finitel, GLIBC_2_0)
-# endif
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_1)
-compat_symbol (libm, __finite, __finitel, GLIBC_2_1)
-# endif
-#else
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
-compat_symbol (libc, finite, finitel, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S
deleted file mode 100644
index 54bd941..0000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_finite.S. */
--
1.7.1