]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/powerpc/powerpc64/a2/memcpy.S
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / powerpc / powerpc64 / a2 / memcpy.S
index ac95171aa8fefe090975144f5ced541cb9498214..6d5c5afddbdd3c91d71802c97e1a4bef176da248 100644 (file)
@@ -1,5 +1,5 @@
 /* Optimized memcpy implementation for PowerPC A2.
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
    Contributed by Michael Brutman <brutman@us.ibm.com>.
    This file is part of the GNU C Library.
 
    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, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <bp-sym.h>
-#include <bp-asm.h>
+
+#ifndef MEMCPY
+# define MEMCPY memcpy
+#endif
 
 #define PREFETCH_AHEAD 4        /* no cache lines SRC prefetching ahead  */
 #define ZERO_AHEAD 2            /* no cache lines DST zeroing ahead  */
@@ -33,7 +34,7 @@
 
 
        .machine  a2
-EALIGN (BP_SYM (memcpy), 5, 0)
+ENTRY (MEMCPY, 5)
        CALL_MCOUNT 3
 
        dcbt    0,r4            /* Prefetch ONE SRC cacheline  */
@@ -117,9 +118,35 @@ EALIGN (BP_SYM (memcpy), 5, 0)
 
        .align 4
 L(dst_aligned):
+       cmpdi   cr0,r9,0        /* Cache line size set? */
+       bne+    cr0,L(cachelineset)
+
+/* __cache_line_size not set: generic byte copy without much optimization */
+       clrldi. r0,r5,63        /* If length is odd copy one byte */
+       beq     L(cachelinenotset_align)
+       lbz     r7,0(r4)        /* Read one byte from source */
+       addi    r5,r5,-1        /* Update length */
+       addi    r4,r4,1         /* Update source pointer address */
+       stb     r7,0(r6)        /* Store one byte at dest */
+       addi    r6,r6,1         /* Update dest pointer address */
+L(cachelinenotset_align):
+       cmpdi   cr7,r5,0        /* If length is 0 return */
+       beqlr   cr7
+       ori     r2,r2,0         /* Force a new dispatch group */
+L(cachelinenotset_loop):
+       addic.  r5,r5,-2        /* Update length */
+       lbz     r7,0(r4)        /* Load 2 bytes from source */
+       lbz     r8,1(r4)
+       addi    r4,r4,2         /* Update source pointer address */
+       stb     r7,0(r6)        /* Store 2 bytes on dest */
+       stb     r8,1(r6)
+       addi    r6,r6,2         /* Update dest pointer address */
+       bne     L(cachelinenotset_loop)
+       blr
 
 
-       cmpd   cr5,r5,r10       /* Less than a cacheline to go? */
+L(cachelineset):
+       cmpd    cr5,r5,r10       /* Less than a cacheline to go? */
 
        neg     r7,r6           /* How far to next cacheline bdy? */
 
@@ -497,5 +524,5 @@ L(endloop2_128):
        b       L(lessthancacheline)
 
 
-END_GEN_TB (BP_SYM (memcpy),TB_TOCLESS)
+END_GEN_TB (MEMCPY,TB_TOCLESS)
 libc_hidden_builtin_def (memcpy)