]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: sqrtf multilib for PowerPC32
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Wed, 10 Apr 2013 20:42:10 +0000 (15:42 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 12 Apr 2013 12:23:33 +0000 (07:23 -0500)
sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrt-c.c
sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf-c.c [new file with mode: 0644]
sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf-power4.S [moved from sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf.S with 97% similarity]
sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf-power5.S [moved from sysdeps/powerpc/powerpc32/power5/fpu/w_sqrtf.S with 96% similarity]
sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf.c [new file with mode: 0644]

index 0584f8ad3e6f70e05091cc25aac86f669d97c158..1eae5b31c95cac239325f521c1799f6ecd26b369 100644 (file)
@@ -3,7 +3,8 @@ 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 \
-                       w_sqrt-power5 w_sqrt-power4 w_sqrt-c
+                       w_sqrt-power5 w_sqrt-power4 w_sqrt-c \
+                       w_sqrtf-power5 w_sqrtf-power4 w_sqrtf-c
 
 CFLAGS-s_llround.c = -fno-builtin-llroundf
 endif
index 75a1b9a492e547bf740294122ba4d905872ea276..3bfa77ea2dcbec93f3629892a1fab6bc9949429d 100644 (file)
@@ -3,11 +3,11 @@
 /* The PPC32 default implementation will fallback to __ieee754_sqrt symbol
    from sysdeps/powerpc/fpu/e_sqrt.c  */
 
-#define __sqrt __sqrt_ppc32
+#define __sqrtf __sqrtf_ppc32
 #undef weak_alias
 #define weak_alias(a, b)
 #undef strong_alias
 #define strong_alias(a, b)
 
 
-#include <math/w_sqrt.c>
+#include <math/w_sqrtf.c>
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf-c.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf-c.c
new file mode 100644 (file)
index 0000000..75a1b9a
--- /dev/null
@@ -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>
similarity index 97%
rename from sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf.S
rename to sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf-power4.S
index 0da5b7a8e3b41aabff35743ccda2ce099be85113..8616bf97b8340689eaec02ee5bfc86841edde601 100644 (file)
    sets the appropriate floating point exceptions.  Extended checking is
    only needed to set errno (via __kernel_standard) if the input value
    is negative.
-   
+
    The fsqrts 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 (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 (__sqrtf, 5, 0)
+EALIGN (__sqrtf_power4, 5, 0)
        fsqrts  fp2,fp1
        mcrfs   cr1,4
        bso-    cr1,.Lw_sqrtf
@@ -95,7 +95,4 @@ EALIGN (__sqrtf, 5, 0)
        bl      __kernel_standard@plt
        fmr     fp12,fp1
        b       .L4
-       END     (__sqrtf)
-
-weak_alias (__sqrtf, sqrtf)
-
+END (__sqrtf_power4)
similarity index 96%
rename from sysdeps/powerpc/powerpc32/power5/fpu/w_sqrtf.S
rename to sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf-power5.S
index 590c24caf339091bf56526fd56a4dfb378946ac6..fef5bf42fab2b95b73979c93ea749047ca0cc6c8 100644 (file)
    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 (__sqrtf, 5, 0)
+       .machine power5
+EALIGN (__sqrtf_power5, 5, 0)
        fabs    fp0,fp1
        fsqrts  fp2,fp1
        fcmpu   cr1,fp0,fp1
@@ -93,7 +93,4 @@ EALIGN (__sqrtf, 5, 0)
        bl      __kernel_standard@plt
        fmr     fp12,fp1
        b       .L4
-       END     (__sqrtf)
-
-weak_alias (__sqrtf, sqrtf)
-
+END (__sqrtf_power5)
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/w_sqrtf.c
new file mode 100644 (file)
index 0000000..41a09d8
--- /dev/null
@@ -0,0 +1,35 @@
+/* Multiple versions of sqrtf
+   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 (__sqrtf) __sqrtf_ppc32 attribute_hidden;
+extern __typeof (__sqrtf) __sqrtf_power4 attribute_hidden;
+extern __typeof (__sqrtf) __sqrtf_power5 attribute_hidden;
+
+libc_ifunc (__sqrtf,
+           (hwcap & PPC_FEATURE_POWER5)
+           ? __sqrtf_power5 :
+             (hwcap & PPC_FEATURE_POWER4)
+             ? __sqrtf_power4
+           : __sqrtf_ppc32);
+
+weak_alias (__sqrtf, sqrtf)