about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>2013-03-07 17:30:58 -0300
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>2013-03-12 17:51:20 -0300
commit380bf3efccb6c4bad2d75546b68e950b2381ae33 (patch)
treed5205af931cdaf0249ef09cc1c8ed3c1acc493bb
parentacacbda4c368576149800425fdd53905040762a5 (diff)
downloadglibc-380bf3efccb6c4bad2d75546b68e950b2381ae33.tar.gz
glibc-380bf3efccb6c4bad2d75546b68e950b2381ae33.tar.xz
glibc-380bf3efccb6c4bad2d75546b68e950b2381ae33.zip
PowerPC: Add 32-bit multilib implementation of memset and bzero
Move and rename specialized memset implementation to multilib folder and
add IFUNC memset and bzero sources.
-rw-r--r--ChangeLog18
-rw-r--r--sysdeps/powerpc/powerpc32/bzero.S20
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/Makefile3
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S22
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S22
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S22
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/bzero.S28
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c25
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/memset-power4.S (renamed from sysdeps/powerpc/powerpc32/power4/memset.S)5
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/memset-power6.S (renamed from sysdeps/powerpc/powerpc32/power6/memset.S)5
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/memset-power7.S (renamed from sysdeps/powerpc/powerpc32/power7/memset.S)5
-rw-r--r--sysdeps/powerpc/powerpc32/multiarch/memset.S117
12 files changed, 280 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index e09de03594..7969bc294f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2013-03-07  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
 
+	* sysdeps/powerpc/powerpc32/bzero.S: Port to multilib.
+	* sysdeps/powerpc/powerpc32/multiarch/Makefile (sysdep_routines):
+	Add memset and bzero implementations.
+	* sysdeps/powerpc/powerpc32/multiarch/memset.S: New file.
+	* sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c: Add bzero
+	and memset.
+	* sysdeps/powerpc/powerpc32/power4/memset.S: Moved to...
+	* sysdeps/powerpc/powerpc32/multiarch/memset-power4.S: ... here.
+	* sysdeps/powerpc/powerpc32/power6/memset.S:  Moved to...
+	* sysdeps/powerpc/powerpc32/multiarch/memset-power6.S:  ... here.
+	* sysdeps/powerpc/powerpc32/power7/memset.S: Moved to...
+	* sysdeps/powerpc/powerpc32/multiarch/memset-power7.S: ... here.
+	* sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S: New file.
+	* sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S: Likewise.
+	* sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S: Likewise.
+
+2013-03-07  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
+
 	* sysdeps/powerpc/powerpc32/multiarch/Makefile (sysdep_routines):
 	Add memcmp-power7. 
 	* sysdeps/powerpc/powerpc32/multiarch/memcmp.S: Newfile.
diff --git a/sysdeps/powerpc/powerpc32/bzero.S b/sysdeps/powerpc/powerpc32/bzero.S
index b5699243f4..642d04682e 100644
--- a/sysdeps/powerpc/powerpc32/bzero.S
+++ b/sysdeps/powerpc/powerpc32/bzero.S
@@ -16,12 +16,30 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Let other functions reuse the code of this file.  */
+#ifdef BZERO
+# define __bzero BZERO
+#endif
+
 #include <sysdep.h>
 
-ENTRY (__bzero)
+EALIGN (__bzero, 5, 0)
 
 	mr	r5,r4
 	li	r4,0
+#ifdef MEMSET_FCNT
+	b	MEMSET_FCNT@local
+#else
 	b	memset@local
+#endif
 END (__bzero)
+
+#ifdef BZERO
+libc_hidden_builtin_def (__bzero)
+#else
+# ifndef MEMSET_FCNT
+/* When BZERO and MEMSET_FCTN aren't defined, it means that this is the
+   default definition of bzero.  */
 weak_alias (__bzero, bzero)
+# endif
+#endif
diff --git a/sysdeps/powerpc/powerpc32/multiarch/Makefile b/sysdeps/powerpc/powerpc32/multiarch/Makefile
index fb0e53a393..28d74f172e 100644
--- a/sysdeps/powerpc/powerpc32/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/multiarch/Makefile
@@ -1,4 +1,5 @@
 ifeq ($(subdir),string)
 sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
-		   memcmp-power7
+		   memcmp-power7 memset-power4 memset-power6 memset-power7 \
+		   bzero-power4 bzero-power6 bzero-power7
 endif
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S b/sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S
new file mode 100644
index 0000000000..7b25c77b37
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S
@@ -0,0 +1,22 @@
+/* Optimized bzero implementation for Power4 on 32 bits.
+   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/>.  */
+
+#define BZERO __bzero_power4
+#define MEMSET_FCNT __memset_power4
+
+#include "../bzero.S"
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S b/sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S
new file mode 100644
index 0000000000..b9ac6ae2ea
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S
@@ -0,0 +1,22 @@
+/* Optimized bzero implementation for Power6 on 32 bits.
+   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/>.  */
+
+#define BZERO __bzero_power6
+#define MEMSET_FCNT __memset_power6
+
+#include "../bzero.S"
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S b/sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S
new file mode 100644
index 0000000000..b41d60cc53
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S
@@ -0,0 +1,22 @@
+/* Optimized bzero implementation for Power7 on 32 bits.
+   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/>.  */
+
+#define BZERO __bzero_power7
+#define MEMSET_FCNT __memset_power7
+
+#include "../bzero.S"
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero.S b/sysdeps/powerpc/powerpc32/multiarch/bzero.S
new file mode 100644
index 0000000000..51dbec36e8
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/bzero.S
@@ -0,0 +1,28 @@
+/* Optimized bzero implementation for PowerPC32.
+   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/>.  */
+
+
+#define MEMSET bzero
+#define INTERNAL_MEMSET __bzero
+
+#include "memset.S"
+
+weak_alias (__bzero, bzero)
+
+#define MEMSET_FCNT __memset_ppc32
+#include "../bzero.S"
diff --git a/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
index ca371beecd..42b372a4e2 100644
--- a/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
@@ -25,6 +25,11 @@
 /* Maximum number of IFUNC implementations.  */
 #define MAX_IFUNC	5
 
+/* Some of the .  */
+#define PPC_POWER4 (PPC_FEATURE_POWER4|PPC_FEATURE_ARCH_2_05|       \
+		    PPC_FEATURE_ARCH_2_06)
+#define PPC_POWER6 (PPC_FEATURE_ARCH_2_05|PPC_FEATURE_ARCH_2_06)
+
 size_t
 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 			size_t max)
@@ -37,6 +42,24 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
   hwcap = GLRO(dl_hwcap);
 
+  IFUNC_IMPL (i, name, bzero,
+	      IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_HAS_VSX,
+			      __bzero_power7)
+	      IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_POWER6,
+			      __bzero_power6)
+	      IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_POWER4,
+			      __bzero_power4)
+	      IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ppc32))
+
+  IFUNC_IMPL (i, name, memset,
+	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_HAS_VSX,
+			      __memset_power7)
+	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_POWER6,
+			      __memset_power6)
+	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_POWER4,
+			      __memset_power4)
+	      IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc32))
+
 #ifdef SHARED
   IFUNC_IMPL (i, name, memcmp,
 	      IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
@@ -48,7 +71,7 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 			      __memcpy_power7)
 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
 			      __memcpy_a2)
-	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
+	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_POWER6,
 			      __memcpy_power6)
 	      IFUNC_IMPL_ADD (array, i, memcpy,
 			      hwcap & (PPC_FEATURE_CELL_BE >> 16),
diff --git a/sysdeps/powerpc/powerpc32/power4/memset.S b/sysdeps/powerpc/powerpc32/multiarch/memset-power4.S
index 1e8785cb4a..6a46e9d1b1 100644
--- a/sysdeps/powerpc/powerpc32/power4/memset.S
+++ b/sysdeps/powerpc/powerpc32/multiarch/memset-power4.S
@@ -26,7 +26,7 @@
    to 0, to take advantage of the dcbz instruction.  */
 
 	.machine power4
-EALIGN (memset, 5, 0)
+EALIGN (__memset_power4, 5, 0)
 	CALL_MCOUNT
 
 #define rTMP	r0
@@ -222,5 +222,4 @@ L(medium_28t):
         stw     rCHR, -4(rMEMP)
 	stw	rCHR, -8(rMEMP)
 	blr
-END (memset)
-libc_hidden_builtin_def (memset)
+END (__memset_power4)
diff --git a/sysdeps/powerpc/powerpc32/power6/memset.S b/sysdeps/powerpc/powerpc32/multiarch/memset-power6.S
index ce06630014..493c1ef95f 100644
--- a/sysdeps/powerpc/powerpc32/power6/memset.S
+++ b/sysdeps/powerpc/powerpc32/multiarch/memset-power6.S
@@ -26,7 +26,7 @@
    to 0, to take advantage of the dcbz instruction.  */
 
 	.machine power6
-EALIGN (memset, 7, 0)
+EALIGN (__memset_power6, 7, 0)
 	CALL_MCOUNT
 
 #define rTMP	r0
@@ -535,5 +535,4 @@ L(medium_28t):
         stw     rCHR, -4(rMEMP)
 	stw	rCHR, -8(rMEMP)
 	blr
-END (memset)
-libc_hidden_builtin_def (memset)
+END (__memset_power6)
diff --git a/sysdeps/powerpc/powerpc32/power7/memset.S b/sysdeps/powerpc/powerpc32/multiarch/memset-power7.S
index 360ea717f4..baa741c112 100644
--- a/sysdeps/powerpc/powerpc32/power7/memset.S
+++ b/sysdeps/powerpc/powerpc32/multiarch/memset-power7.S
@@ -23,7 +23,7 @@
    Returns 's'.  */
 
 	.machine  power7
-EALIGN (memset, 5, 0)
+EALIGN (__memset_power7, 5, 0)
 	CALL_MCOUNT
 
 	.align	4
@@ -427,5 +427,4 @@ L(small):
 	stw	4,4(10)
 	blr
 
-END (memset)
-libc_hidden_builtin_def (memset)
+END (__memset_power7)
diff --git a/sysdeps/powerpc/powerpc32/multiarch/memset.S b/sysdeps/powerpc/powerpc32/multiarch/memset.S
new file mode 100644
index 0000000000..bc9559552d
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/memset.S
@@ -0,0 +1,117 @@
+/* Optimized memset implementation for PowerPC32.
+   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/>.  */
+
+/* Let other functions reuse the code of this file.  */
+#ifdef MEMSET
+# define memset MEMSET
+#endif
+
+#ifndef INTERNAL_MEMSET
+# define INTERNAL_MEMSET memset
+#endif
+
+#define CONCAT(x, y) __ ## x ## _ ## y
+#define EVALUATE(x, y) CONCAT(x, y)
+#define OPTIM(NAME) EVALUATE(memset, NAME)
+
+#include <sysdep.h>
+#include <rtld-global-offsets.h>
+
+/* Define multiple versions only for the definition in libc.  */
+#if defined SHARED && !defined NOT_IN_libc
+	.text
+ENTRY(INTERNAL_MEMSET)
+	.type   memset, @gnu_indirect_function
+# ifdef PIC
+	mflr	r11
+	cfi_register (lr,r11)
+	bcl 	20,31,1f
+1:	mflr	r5
+	addis	r5,r5,_GLOBAL_OFFSET_TABLE_-1b@ha
+	addi	r5,r5,_GLOBAL_OFFSET_TABLE_-1b@l
+	lwz	r6,_rtld_global_ro@got(r5)
+	mtlr	r11
+	cfi_same_value (lr)
+	lwz	r6,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET+4(r6)
+# else
+	lis	r6,(_dl_hwcap+4)@ha
+	lwz	r6,(_dl_hwcap+4)@l(r6)
+# endif
+	/* r5 - got pointer | r6 - _dl_hwcap */
+	andi.	r7,r6,PPC_FEATURE_HAS_VSX
+	bne-	L(power7)
+	andi.	r7,r6,PPC_FEATURE_ARCH_2_05
+	bne-	L(power6)
+	andis.	r7,r6,(PPC_FEATURE_POWER4>>16)
+	bne-	L(power4)
+# ifdef PIC
+	lwz	r3,OPTIM(ppc32)@got(r5)
+# else
+	lis	r3,OPTIM(ppc32)@ha
+	lwz	r3,OPTIM(ppc32)@l(r3)
+# endif
+	blr
+L(power7):
+# ifdef PIC
+	lwz	r3,OPTIM(power7)@got(r5)
+# else
+	lis	r3,OPTIM(power7)@ha
+	lwz	r3,OPTIM(power7)@l(r3)
+# endif
+	blr
+L(power6):
+# ifdef PIC
+	lwz	r3,OPTIM(power6)@got(r5)
+# else
+	lis	r3,OPTIM(power6)@ha
+	lwz	r3,OPTIM(power6)@l(r3)
+# endif
+	blr
+L(power4):
+# ifdef PIC
+	lwz	r3,OPTIM(power4)@got(r5)
+# else
+	lis	r3,OPTIM(power4)@ha
+	lwz	r3,OPTIM(power4)@l(r3)
+# endif
+	blr
+END(INTERNAL_MEMSET)
+
+# undef EALIGN
+# define EALIGN(name, alignt, words)                           \
+  .globl C_SYMBOL_NAME(OPTIM(ppc32));                          \
+  .type C_SYMBOL_NAME(OPTIM(ppc32)),@function ;                \
+  .align ALIGNARG(alignt);                                     \
+  EALIGN_W_##words;                                            \
+  C_LABEL(OPTIM(ppc32))                                        \
+  cfi_startproc;
+
+# undef END
+# define END(name)                                             \
+  cfi_endproc;                                                 \
+  ASM_SIZE_DIRECTIVE(OPTIM(ppc32))
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)                         \
+  .globl EVALUATE(GI, memset); 	EVALUATE(GI, memset) = OPTIM(ppc32)
+
+#endif
+
+#ifndef MEMSET
+# include "../memset.S"
+#endif