about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2013-04-15 07:48:56 -0500
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>2013-04-16 08:53:52 -0500
commitf0e2c9eae9ccf2867d4c25d40428ecb4aa98d7d7 (patch)
tree6fee11c8322fe47629746e340285a3e6695fa9f0
parent1e368841229b7c49df432d11502edc095a7120ae (diff)
downloadglibc-f0e2c9eae9ccf2867d4c25d40428ecb4aa98d7d7.tar.gz
glibc-f0e2c9eae9ccf2867d4c25d40428ecb4aa98d7d7.tar.xz
glibc-f0e2c9eae9ccf2867d4c25d40428ecb4aa98d7d7.zip
PowerPC: lround/lroundf multilib for PowerPC32
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile3
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power5+.S (renamed from sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S)25
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power6x.S (renamed from sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S)25
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S13
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c55
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c1
6 files changed, 83 insertions, 39 deletions
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
index 14d33213fd..0ee4c9f8d7 100644
--- a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
@@ -23,7 +23,8 @@ libm-sysdep_routines += s_llrintf-power6 s_llrintf-power4 s_llrintf-c \
 			s_round-power5+ s_round-ppc32 \
 			s_roundf-power5+ s_roundf-ppc32 \
 			s_trunc-power5+ s_trunc-ppc32 \
-			s_truncf-power5+ s_truncf-ppc32
+			s_truncf-power5+ s_truncf-ppc32 \
+			s_lround-power6x s_lround-power5+ s_lround-ppc32
 
 CFLAGS-s_llround.c = -fno-builtin-llroundf
 endif
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power5+.S
index 0fa359d079..bb3ea76a11 100644
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power5+.S
@@ -17,19 +17,19 @@
    <http://www.gnu.org/licenses/>.  */
 #include <sysdep.h>
 #include <math_ldbl_opt.h>
-	
+
 /* long [r3] lround (float x [fp1])
-   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest 
+   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
    integer value, rounding halfway cases away from zero, regardless of
    the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a 
-   tie, choose the one that is even (least significant bit o).". 
+   "round to Nearest" as "Choose the best approximation. In case of a
+   tie, choose the one that is even (least significant bit o).".
    So we pre-round using the V2.02 Floating Round to Integer Nearest
    instruction before we use the Floating Convert to Integer Word with
    round to zero instruction.  */
 
 	.machine	"power5"
-ENTRY (__lround)
+ENTRY (__lround_power5plus)
 	stwu    r1,-16(r1)
 	cfi_adjust_cfa_offset (16)
 	frin	fp2,fp1
@@ -41,17 +41,4 @@ ENTRY (__lround)
 	lwz	r3,12(r1)
 	addi	r1,r1,16
 	blr
-	END (__lround)
-
-weak_alias (__lround, lround)
-
-strong_alias (__lround, __lroundf)
-weak_alias (__lround, lroundf)
-
-#ifdef NO_LONG_DOUBLE
-weak_alias (__lround, lroundl)
-strong_alias (__lround, __lroundl)
-#endif
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __lround, lroundl, GLIBC_2_1)
-#endif
+END (__lround_power5plus)
diff --git a/sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power6x.S
index 950b69536a..49c5a7109e 100644
--- a/sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power6x.S
@@ -18,34 +18,21 @@
 
 #include <sysdep.h>
 #include <math_ldbl_opt.h>
-	
+
 /* long [r3] lround (float x [fp1])
-   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest 
+   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
    integer value, rounding halfway cases away from zero, regardless of
    the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a 
-   tie, choose the one that is even (least significant bit o).". 
+   "round to Nearest" as "Choose the best approximation. In case of a
+   tie, choose the one that is even (least significant bit o).".
    So we pre-round using the V2.02 Floating Round to Integer Nearest
    instruction before we use the Floating Convert to Integer Word with
    round to zero instruction.  */
 
 	.machine	"power6"
-ENTRY (__lround)
+ENTRY (__lround_power6x)
 	frin	fp2,fp1	/* Pre-round +-0.5.  */
 	fctiwz	fp3,fp2	/* Convert To Integer Word lround toward 0.  */
 	mftgpr	r3,fp3	/* Transfer fpr3 to r3.  */
 	blr
-	END (__lround)
-
-weak_alias (__lround, lround)
-
-strong_alias (__lround, __lroundf)
-weak_alias (__lround, lroundf)
-
-#ifdef NO_LONG_DOUBLE
-weak_alias (__lround, lroundl)
-strong_alias (__lround, __lroundl)
-#endif
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __lround, lroundl, GLIBC_2_1)
-#endif
+END (__lround_power6x)
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S
new file mode 100644
index 0000000000..de6b91957b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S
@@ -0,0 +1,13 @@
+#include <sysdep.h>
+#include <math_ldbl_opt.h>
+
+#undef weak_alias
+#define weak_alias(a,b)
+#undef strong_alias
+#define strong_alias(a,b)
+#undef compat_symbol
+#define compat_symbol(a,b,c,d)
+
+#define __lround __lround_ppc32
+
+#include <sysdeps/powerpc/powerpc32/fpu/s_lround.S>
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c
new file mode 100644
index 0000000000..f133120fa8
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c
@@ -0,0 +1,55 @@
+/* Multiple versions of s_lround.
+   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/>.  */
+
+/* Redefine lroundf/__lroundf so that compiler won't complain abouti
+   the type mismatch with the IFUNC selector in strong_alias/weak_alias
+   below.  */
+#undef lroundf
+#define lroundf __redirect_lroundf
+#undef __lroundf
+#define __lroundf __redirect___lroundf
+#include <math.h>
+#undef lroundf
+#undef __lroundf
+#include <math_ldbl_opt.h>
+#include <shlib-compat.h>
+#include "init-arch.h"
+
+extern __typeof (__lround) __lround_ppc32 attribute_hidden;
+extern __typeof (__lround) __lround_power5plus attribute_hidden;
+extern __typeof (__lround) __lround_power6x attribute_hidden;
+
+libc_ifunc (__lround,
+	    (hwcap & PPC_FEATURE_POWER6_EXT) ?
+	      __lround_power6x
+		: (hwcap & PPC_FEATURE_POWER5_PLUS) ?
+		  __lround_power5plus
+            : __lround_ppc32);
+
+weak_alias (__lround, lround)
+
+weak_alias (__lround, lroundf)
+strong_alias(__lround, __lroundf)
+
+#ifdef NO_LONG_DOUBLE
+weak_alias (__lround, lroundl)
+strong_alias (__lround, __lroundl)
+#endif
+#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
+compat_symbol (libm, __lround, lroundl, GLIBC_2_1);
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c
new file mode 100644
index 0000000000..eb546b43ad
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c
@@ -0,0 +1 @@
+/* s_lroundf.c is in s_lround.c  */