about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2013-04-10 15:00:32 -0500
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>2013-04-12 07:23:32 -0500
commita49b77834098275476a3994498d2c42c8c10471f (patch)
tree286c5d85ff63a789a4fd49a07966ce4c35d0d202
parent42747c841a2a4c6c269f59c6c7d688a82a64a4b4 (diff)
downloadglibc-a49b77834098275476a3994498d2c42c8c10471f.tar.gz
glibc-a49b77834098275476a3994498d2c42c8c10471f.tar.xz
glibc-a49b77834098275476a3994498d2c42c8c10471f.zip
PowerPC: sqrt multilib for PowerPC32
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile3
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-c.c13
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-power4.S (renamed from sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt.S)21
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-power5.S (renamed from sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt.S)23
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt.c (renamed from sysdeps/powerpc/fpu/w_sqrt.c)42
5 files changed, 45 insertions, 57 deletions
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
index b877357723..0584f8ad3e 100644
--- a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
@@ -2,7 +2,8 @@ ifeq ($(subdir),math)
 libm-sysdep_routines += s_llrintf-power6 s_llrintf-power4 s_llrintf-c \
 			s_llrint-power6 s_llrint-power4 s_llrint-c \
 			s_llround-power6 s_llround-power5+ s_llround-power4 \
-			s_llround-c
+			s_llround-c \
+			w_sqrt-power5 w_sqrt-power4 w_sqrt-c
 
 CFLAGS-s_llround.c = -fno-builtin-llroundf
 endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-c.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-c.c
new file mode 100644
index 0000000000..75a1b9a492
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-c.c
@@ -0,0 +1,13 @@
+#include <math.h>
+
+/* The PPC32 default implementation will fallback to __ieee754_sqrt symbol
+   from sysdeps/powerpc/fpu/e_sqrt.c  */
+
+#define __sqrt __sqrt_ppc32
+#undef weak_alias
+#define weak_alias(a, b)
+#undef strong_alias
+#define strong_alias(a, b)
+
+
+#include <math/w_sqrt.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-power4.S
index 4f1c17680d..5dae2ac988 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt.S
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-power4.S
@@ -25,27 +25,27 @@
    sets the appropriate floating point exceptions.  Extended checking is
    only needed to set errno (via __kernel_standard) if the input value
    is negative.
-   
+
    The fsqrt will set FPCC and FU (Floating Point Unordered or NaN
    to indicated that the input value was negative or NaN. Use Move to
    Condition Register from FPSCR to copy the FPCC field to cr1.  The
    branch on summary overflow transfers control to w_sqrt to process
    any error conditions. Otherwise we can return the result directly.
-   
+
    This part of the function is a leaf routine,  so no need to stack a
    frame or execute prologue/epilogue code. This means it is safe to
    transfer directly to w_sqrt as long as the input value (f1) is
    preserved. Putting the sqrt result into f2 (double parameter 2)
    allows passing both the input value and sqrt result into the extended
    wrapper so there is no need to recompute.
-   
+
    This tactic avoids the overhead of stacking a frame for the normal
    (non-error) case.  Until gcc supports prologue shrink-wrapping
    this is the best we can do.  */
 
 	.section	".text"
 	.machine power4
-EALIGN (__sqrt, 5, 0)
+EALIGN (__sqrt_power4, 5, 0)
 	fsqrt	fp2,fp1
 	mcrfs	cr1,4
 	bso-	cr1,.Lw_sqrt
@@ -95,15 +95,4 @@ EALIGN (__sqrt, 5, 0)
 	bl	__kernel_standard@plt
 	fmr	fp12,fp1
 	b	.L4
-	END	(__sqrt)
-
-weak_alias (__sqrt, sqrt)
-
-#ifdef NO_LONG_DOUBLE
-weak_alias (__sqrt, sqrtl)
-strong_alias (__sqrt, __sqrtl)
-#endif
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
-compat_symbol (libm, __sqrt, sqrtl, GLIBC_2_0)
-#endif
-
+END(__sqrt_power4)
diff --git a/sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-power5.S
index 23559aa192..4b4f895241 100644
--- a/sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt.S
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-power5.S
@@ -25,26 +25,26 @@
    sets the appropriate floating point exceptions.  Extended checking is
    only needed to set errno (via __kernel_standard) if the input value
    is negative.
-   
+
    So compare the input value against the absolute value of itself.
    This will compare equal unless the value is negative (EDOM) or a NAN,
    in which case we branch to the extend wrapper.  If equal we can return
    the result directly.
-   
+
    This part of the function looks like a leaf routine,  so no need to
    stack a frame or execute prologue/epilogue code. It is safe to
    branch directly to w_sqrt as long as the input value (f1) is
    preserved. Putting the sqrt result into f2 (float parameter 2)
    allows passing both the input value and sqrt result into the extended
    wrapper so there is no need to recompute.
-   
+
    This tactic avoids the overhead of stacking a frame for the normal
    (non-error) case.  Until gcc supports prologue shrink-wrapping
    this is the best we can do.  */
 
 	.section	".text"
-	.machine power4
-EALIGN (__sqrt, 5, 0)
+	.machine power5
+EALIGN (__sqrt_power5, 5, 0)
 	fabs	fp0,fp1
 	fsqrt	fp2,fp1
 	fcmpu	cr1,fp0,fp1
@@ -93,15 +93,4 @@ EALIGN (__sqrt, 5, 0)
 	bl	__kernel_standard@plt
 	fmr	fp12,fp1
 	b	.L4
-	END	(__sqrt)
-
-weak_alias (__sqrt, sqrt)
-
-#ifdef NO_LONG_DOUBLE
-weak_alias (__sqrt, sqrtl)
-strong_alias (__sqrt, __sqrtl)
-#endif
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
-compat_symbol (libm, __sqrt, sqrtl, GLIBC_2_0)
-#endif
-
+END (__sqrt_power5)
diff --git a/sysdeps/powerpc/fpu/w_sqrt.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt.c
index 2488ad9b97..f7a92535f4 100644
--- a/sysdeps/powerpc/fpu/w_sqrt.c
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt.c
@@ -1,5 +1,5 @@
-/* Double-precision floating point square root wrapper.
-   Copyright (C) 2004-2013 Free Software Foundation, Inc.
+/* Multiple versions of w_sqrt.
+   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
@@ -17,28 +17,24 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
-#include <math_private.h>
-#include <fenv_libc.h>
-
-double
-__sqrt (double x)		/* wrapper sqrt */
-{
-#ifdef _IEEE_LIBM
-  return __ieee754_sqrt (x);
-#else
-  double z;
-  z = __ieee754_sqrt (x);
-  if (_LIB_VERSION == _IEEE_ || (x != x))
-    return z;
-
-  if (x < 0.0)
-    return __kernel_standard (x, x, 26);	/* sqrt(negative) */
-  else
-    return z;
-#endif
-}
+#include <math_ldbl_opt.h>
+#include <shlib-compat.h>
+#include "init-arch.h"
+
+extern __typeof (__sqrt) __sqrt_ppc32 attribute_hidden;
+extern __typeof (__sqrt) __sqrt_power4 attribute_hidden;
+extern __typeof (__sqrt) __sqrt_power5 attribute_hidden;
+
+libc_ifunc (__sqrt,
+	    (hwcap & PPC_FEATURE_POWER5)
+	    ? __sqrt_power5 :
+	      (hwcap & PPC_FEATURE_POWER4)
+	      ? __sqrt_power4
+	    : __sqrt_ppc32);
 
 weak_alias (__sqrt, sqrt)
+
 #ifdef NO_LONG_DOUBLE
-  strong_alias (__sqrt, __sqrtl) weak_alias (__sqrt, sqrtl)
+strong_alias (__sqrt, __sqrtl)
+weak_alias (__sqrt, sqrtl)
 #endif