2010-03-10 15:14:16 +00:00
|
|
|
/* Optimized memcpy implementation for PowerPC64/POWER7.
|
2022-01-01 18:54:23 +00:00
|
|
|
Copyright (C) 2010-2022 Free Software Foundation, Inc.
|
2010-03-10 15:14:16 +00:00
|
|
|
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
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2010-03-10 15:14:16 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
|
|
|
|
|
2017-08-08 17:14:49 +00:00
|
|
|
/* void * [r3] memcpy (void *dst [r3], void *src [r4], size_t len [r5]);
|
2010-03-10 15:14:16 +00:00
|
|
|
Returns 'dst'. */
|
|
|
|
|
2017-04-11 17:18:35 +00:00
|
|
|
#ifndef MEMCPY
|
|
|
|
# define MEMCPY memcpy
|
|
|
|
#endif
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
#define dst 11 /* Use r11 so r3 kept unchanged. */
|
|
|
|
#define src 4
|
|
|
|
#define cnt 5
|
|
|
|
|
2010-03-10 15:14:16 +00:00
|
|
|
.machine power7
|
PowerPC64 ENTRY_TOCLESS
A number of functions in the sysdeps/powerpc/powerpc64/ tree don't use
or change r2, yet declare a global entry that sets up r2. This patch
fixes that problem, and consolidates the ENTRY and EALIGN macros.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(NOPS, ENTRY_3): New macros.
(ENTRY): Rewrite.
(ENTRY_TOCLESS): Define.
(EALIGN, EALIGN_W_0, EALIGN_W_1, EALIGN_W_2, EALIGN_W_4, EALIGN_W_5,
EALIGN_W_6, EALIGN_W_7, EALIGN_W_8): Delete.
* sysdeps/powerpc/powerpc64/a2/memcpy.S: Replace EALIGN with ENTRY.
* sysdeps/powerpc/powerpc64/dl-trampoline.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_ceil.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floor.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floorf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_rint.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_rintf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_round.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_roundf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_trunc.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Likewise.
* sysdeps/powerpc/powerpc64/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strstr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_cosf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_sinf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strcasestr.S: Likewise.
* sysdeps/powerpc/powerpc64/addmul_1.S: Use ENTRY_TOCLESS.
* sysdeps/powerpc/powerpc64/cell/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_copysignl.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_fabsl.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_llrintf.S: Likewise.
* sysdeps/powerpc/powerpc64/lshift.S: Likewise.
* sysdeps/powerpc/powerpc64/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/mul_1.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S: Likewise.
* sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/add_n.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memmove.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/mempcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strcasecmp.S (strcasecmp_l):
Likewise.
* sysdeps/powerpc/powerpc64/power7/strchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strchrnul.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strncpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strnlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strrchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strncpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strnlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strrchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strspn.S: Likewise.
* sysdeps/powerpc/powerpc64/power9/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power9/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/strchr.S: Likewise.
* sysdeps/powerpc/powerpc64/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/strlen.S: Likewise.
* sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/ppc-mcount.S: Store LR earlier. Don't
add nop when SHARED.
* sysdeps/powerpc/powerpc64/start.S: Fix comment.
* sysdeps/powerpc/powerpc64/multiarch/strrchr-power8.S (ENTRY): Don't
define.
(ENTRY_TOCLESS): Define.
* sysdeps/powerpc/powerpc32/sysdep.h (ENTRY_TOCLESS): Define.
* sysdeps/powerpc/fpu/s_fma.S: Use ENTRY_TOCLESS.
* sysdeps/powerpc/fpu/s_fmaf.S: Likewise.
2017-06-14 01:15:50 +00:00
|
|
|
ENTRY_TOCLESS (MEMCPY, 5)
|
2010-03-10 15:14:16 +00:00
|
|
|
CALL_MCOUNT 3
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
cmpldi cr1,cnt,31
|
2010-03-10 15:14:16 +00:00
|
|
|
neg 0,3
|
|
|
|
ble cr1, L(copy_LT_32) /* If move < 32 bytes use short move
|
|
|
|
code. */
|
|
|
|
|
2014-06-25 16:54:31 +00:00
|
|
|
/* Align copies using VSX instructions to quadword. It is to avoid alignment
|
|
|
|
traps when memcpy is used on non-cacheable memory (for instance, memory
|
|
|
|
mapped I/O). */
|
2013-08-17 09:17:22 +00:00
|
|
|
andi. 10,3,15
|
|
|
|
clrldi 11,4,60
|
|
|
|
cmpld cr6,10,11 /* SRC and DST alignments match? */
|
|
|
|
|
|
|
|
mr dst,3
|
2010-03-10 15:14:16 +00:00
|
|
|
bne cr6,L(copy_GE_32_unaligned)
|
2013-08-17 09:17:22 +00:00
|
|
|
beq L(aligned_copy)
|
2010-03-10 15:14:16 +00:00
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
mtocrf 0x01,0
|
|
|
|
clrldi 0,0,60
|
2010-03-10 15:14:16 +00:00
|
|
|
|
2014-06-25 16:54:31 +00:00
|
|
|
/* Get the DST and SRC aligned to 16 bytes. */
|
2013-08-17 09:17:22 +00:00
|
|
|
1:
|
|
|
|
bf 31,2f
|
|
|
|
lbz 6,0(src)
|
|
|
|
addi src,src,1
|
|
|
|
stb 6,0(dst)
|
|
|
|
addi dst,dst,1
|
|
|
|
2:
|
|
|
|
bf 30,4f
|
|
|
|
lhz 6,0(src)
|
|
|
|
addi src,src,2
|
|
|
|
sth 6,0(dst)
|
|
|
|
addi dst,dst,2
|
2010-03-10 15:14:16 +00:00
|
|
|
4:
|
2013-08-17 09:17:22 +00:00
|
|
|
bf 29,8f
|
|
|
|
lwz 6,0(src)
|
|
|
|
addi src,src,4
|
|
|
|
stw 6,0(dst)
|
|
|
|
addi dst,dst,4
|
|
|
|
8:
|
|
|
|
bf 28,16f
|
|
|
|
ld 6,0(src)
|
|
|
|
addi src,src,8
|
|
|
|
std 6,0(dst)
|
|
|
|
addi dst,dst,8
|
|
|
|
16:
|
|
|
|
subf cnt,0,cnt
|
|
|
|
|
|
|
|
/* Main aligned copy loop. Copies 128 bytes at a time. */
|
|
|
|
L(aligned_copy):
|
|
|
|
li 6,16
|
|
|
|
li 7,32
|
|
|
|
li 8,48
|
|
|
|
mtocrf 0x02,cnt
|
|
|
|
srdi 12,cnt,7
|
|
|
|
cmpdi 12,0
|
|
|
|
beq L(aligned_tail)
|
2017-10-25 15:13:53 +00:00
|
|
|
lvx 6,0,src
|
|
|
|
lvx 7,src,6
|
2013-08-17 09:17:22 +00:00
|
|
|
mtctr 12
|
2011-09-08 01:54:41 +00:00
|
|
|
b L(aligned_128loop)
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
.align 4
|
2011-09-08 01:54:41 +00:00
|
|
|
L(aligned_128head):
|
|
|
|
/* for the 2nd + iteration of this loop. */
|
2017-10-25 15:13:53 +00:00
|
|
|
lvx 6,0,src
|
|
|
|
lvx 7,src,6
|
2011-09-08 01:54:41 +00:00
|
|
|
L(aligned_128loop):
|
2017-10-25 15:13:53 +00:00
|
|
|
lvx 8,src,7
|
|
|
|
lvx 9,src,8
|
|
|
|
stvx 6,0,dst
|
2013-08-17 09:17:22 +00:00
|
|
|
addi src,src,64
|
2017-10-25 15:13:53 +00:00
|
|
|
stvx 7,dst,6
|
|
|
|
stvx 8,dst,7
|
|
|
|
stvx 9,dst,8
|
|
|
|
lvx 6,0,src
|
|
|
|
lvx 7,src,6
|
2013-08-17 09:17:22 +00:00
|
|
|
addi dst,dst,64
|
2017-10-25 15:13:53 +00:00
|
|
|
lvx 8,src,7
|
|
|
|
lvx 9,src,8
|
2013-08-17 09:17:22 +00:00
|
|
|
addi src,src,64
|
2017-10-25 15:13:53 +00:00
|
|
|
stvx 6,0,dst
|
|
|
|
stvx 7,dst,6
|
|
|
|
stvx 8,dst,7
|
|
|
|
stvx 9,dst,8
|
2013-08-17 09:17:22 +00:00
|
|
|
addi dst,dst,64
|
2011-09-08 01:54:41 +00:00
|
|
|
bdnz L(aligned_128head)
|
2010-03-10 15:14:16 +00:00
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
L(aligned_tail):
|
|
|
|
mtocrf 0x01,cnt
|
|
|
|
bf 25,32f
|
2017-10-25 15:13:53 +00:00
|
|
|
lvx 6,0,src
|
|
|
|
lvx 7,src,6
|
|
|
|
lvx 8,src,7
|
|
|
|
lvx 9,src,8
|
2013-08-17 09:17:22 +00:00
|
|
|
addi src,src,64
|
2017-10-25 15:13:53 +00:00
|
|
|
stvx 6,0,dst
|
|
|
|
stvx 7,dst,6
|
|
|
|
stvx 8,dst,7
|
|
|
|
stvx 9,dst,8
|
2013-08-17 09:17:22 +00:00
|
|
|
addi dst,dst,64
|
|
|
|
32:
|
|
|
|
bf 26,16f
|
2017-10-25 15:13:53 +00:00
|
|
|
lvx 6,0,src
|
|
|
|
lvx 7,src,6
|
2013-08-17 09:17:22 +00:00
|
|
|
addi src,src,32
|
2017-10-25 15:13:53 +00:00
|
|
|
stvx 6,0,dst
|
|
|
|
stvx 7,dst,6
|
2013-08-17 09:17:22 +00:00
|
|
|
addi dst,dst,32
|
|
|
|
16:
|
|
|
|
bf 27,8f
|
2017-10-25 15:13:53 +00:00
|
|
|
lvx 6,0,src
|
2013-08-17 09:17:22 +00:00
|
|
|
addi src,src,16
|
2017-10-25 15:13:53 +00:00
|
|
|
stvx 6,0,dst
|
2013-08-17 09:17:22 +00:00
|
|
|
addi dst,dst,16
|
|
|
|
8:
|
|
|
|
bf 28,4f
|
|
|
|
ld 6,0(src)
|
|
|
|
addi src,src,8
|
|
|
|
std 6,0(dst)
|
|
|
|
addi dst,dst,8
|
|
|
|
4: /* Copies 4~7 bytes. */
|
|
|
|
bf 29,L(tail2)
|
|
|
|
lwz 6,0(src)
|
|
|
|
stw 6,0(dst)
|
|
|
|
bf 30,L(tail5)
|
|
|
|
lhz 7,4(src)
|
|
|
|
sth 7,4(dst)
|
|
|
|
bflr 31
|
|
|
|
lbz 8,6(src)
|
|
|
|
stb 8,6(dst)
|
|
|
|
/* Return original DST pointer. */
|
2010-03-10 15:28:04 +00:00
|
|
|
blr
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
|
|
|
|
/* Handle copies of 0~31 bytes. */
|
|
|
|
.align 4
|
2010-03-10 15:14:16 +00:00
|
|
|
L(copy_LT_32):
|
2013-08-17 09:17:22 +00:00
|
|
|
mr dst,3
|
|
|
|
cmpldi cr6,cnt,8
|
|
|
|
mtocrf 0x01,cnt
|
2010-03-10 15:28:04 +00:00
|
|
|
ble cr6,L(copy_LE_8)
|
|
|
|
|
|
|
|
/* At least 9 bytes to go. */
|
|
|
|
neg 8,4
|
2013-08-17 09:17:22 +00:00
|
|
|
andi. 0,8,3
|
|
|
|
cmpldi cr1,cnt,16
|
2010-03-10 15:28:04 +00:00
|
|
|
beq L(copy_LT_32_aligned)
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
/* Force 4-byte alignment for SRC. */
|
|
|
|
mtocrf 0x01,0
|
|
|
|
subf cnt,0,cnt
|
|
|
|
2:
|
|
|
|
bf 30,1f
|
|
|
|
lhz 6,0(src)
|
|
|
|
addi src,src,2
|
|
|
|
sth 6,0(dst)
|
|
|
|
addi dst,dst,2
|
|
|
|
1:
|
|
|
|
bf 31,L(end_4bytes_alignment)
|
|
|
|
lbz 6,0(src)
|
|
|
|
addi src,src,1
|
|
|
|
stb 6,0(dst)
|
|
|
|
addi dst,dst,1
|
|
|
|
|
|
|
|
.align 4
|
2010-03-10 15:14:16 +00:00
|
|
|
L(end_4bytes_alignment):
|
2013-08-17 09:17:22 +00:00
|
|
|
cmpldi cr1,cnt,16
|
|
|
|
mtocrf 0x01,cnt
|
2010-03-10 15:14:16 +00:00
|
|
|
|
|
|
|
L(copy_LT_32_aligned):
|
|
|
|
/* At least 6 bytes to go, and SRC is word-aligned. */
|
2010-03-10 15:28:04 +00:00
|
|
|
blt cr1,8f
|
|
|
|
|
|
|
|
/* Copy 16 bytes. */
|
2013-08-17 09:17:22 +00:00
|
|
|
lwz 6,0(src)
|
|
|
|
lwz 7,4(src)
|
|
|
|
stw 6,0(dst)
|
|
|
|
lwz 8,8(src)
|
|
|
|
stw 7,4(dst)
|
|
|
|
lwz 6,12(src)
|
|
|
|
addi src,src,16
|
|
|
|
stw 8,8(dst)
|
|
|
|
stw 6,12(dst)
|
|
|
|
addi dst,dst,16
|
2010-03-10 15:28:04 +00:00
|
|
|
8: /* Copy 8 bytes. */
|
2013-08-17 09:17:22 +00:00
|
|
|
bf 28,L(tail4)
|
|
|
|
lwz 6,0(src)
|
|
|
|
lwz 7,4(src)
|
|
|
|
addi src,src,8
|
|
|
|
stw 6,0(dst)
|
|
|
|
stw 7,4(dst)
|
|
|
|
addi dst,dst,8
|
|
|
|
|
|
|
|
.align 4
|
|
|
|
/* Copies 4~7 bytes. */
|
|
|
|
L(tail4):
|
|
|
|
bf 29,L(tail2)
|
|
|
|
lwz 6,0(src)
|
|
|
|
stw 6,0(dst)
|
|
|
|
bf 30,L(tail5)
|
|
|
|
lhz 7,4(src)
|
|
|
|
sth 7,4(dst)
|
|
|
|
bflr 31
|
|
|
|
lbz 8,6(src)
|
|
|
|
stb 8,6(dst)
|
|
|
|
/* Return original DST pointer. */
|
|
|
|
blr
|
2010-03-10 15:28:04 +00:00
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
.align 4
|
|
|
|
/* Copies 2~3 bytes. */
|
|
|
|
L(tail2):
|
2010-03-10 15:28:04 +00:00
|
|
|
bf 30,1f
|
2013-08-17 09:17:22 +00:00
|
|
|
lhz 6,0(src)
|
|
|
|
sth 6,0(dst)
|
|
|
|
bflr 31
|
|
|
|
lbz 7,2(src)
|
|
|
|
stb 7,2(dst)
|
2010-03-10 15:28:04 +00:00
|
|
|
blr
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
.align 4
|
|
|
|
L(tail5):
|
|
|
|
bflr 31
|
|
|
|
lbz 6,4(src)
|
|
|
|
stb 6,4(dst)
|
|
|
|
blr
|
2010-03-10 15:28:04 +00:00
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
.align 4
|
|
|
|
1:
|
|
|
|
bflr 31
|
|
|
|
lbz 6,0(src)
|
|
|
|
stb 6,0(dst)
|
|
|
|
/* Return original DST pointer. */
|
2010-03-10 15:28:04 +00:00
|
|
|
blr
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
|
|
|
|
/* Handles copies of 0~8 bytes. */
|
|
|
|
.align 4
|
2010-03-10 15:14:16 +00:00
|
|
|
L(copy_LE_8):
|
2013-08-17 09:17:22 +00:00
|
|
|
bne cr6,L(tail4)
|
2010-03-10 15:14:16 +00:00
|
|
|
|
2010-03-10 15:28:04 +00:00
|
|
|
/* Though we could've used ld/std here, they are still
|
|
|
|
slow for unaligned cases. */
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
lwz 6,0(src)
|
|
|
|
lwz 7,4(src)
|
|
|
|
stw 6,0(dst)
|
|
|
|
stw 7,4(dst)
|
2010-03-10 15:28:04 +00:00
|
|
|
blr
|
|
|
|
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
/* Handle copies of 32+ bytes where DST is aligned (to quadword) but
|
|
|
|
SRC is not. Use aligned quadword loads from SRC, shifted to realign
|
|
|
|
the data, allowing for aligned DST stores. */
|
|
|
|
.align 4
|
2010-03-10 15:14:16 +00:00
|
|
|
L(copy_GE_32_unaligned):
|
2013-08-17 09:17:22 +00:00
|
|
|
clrldi 0,0,60 /* Number of bytes until the 1st dst quadword. */
|
|
|
|
srdi 9,cnt,4 /* Number of full quadwords remaining. */
|
2010-03-10 15:28:04 +00:00
|
|
|
|
|
|
|
beq L(copy_GE_32_unaligned_cont)
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
/* DST is not quadword aligned, get it aligned. */
|
2010-03-10 15:28:04 +00:00
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
mtocrf 0x01,0
|
|
|
|
subf cnt,0,cnt
|
2010-03-10 15:28:04 +00:00
|
|
|
|
|
|
|
/* Vector instructions work best when proper alignment (16-bytes)
|
|
|
|
is present. Move 0~15 bytes as needed to get DST quadword-aligned. */
|
2013-08-17 09:17:22 +00:00
|
|
|
1:
|
2010-03-10 15:28:04 +00:00
|
|
|
bf 31,2f
|
2013-08-17 09:17:22 +00:00
|
|
|
lbz 6,0(src)
|
|
|
|
addi src,src,1
|
|
|
|
stb 6,0(dst)
|
|
|
|
addi dst,dst,1
|
|
|
|
2:
|
2010-03-10 15:28:04 +00:00
|
|
|
bf 30,4f
|
2013-08-17 09:17:22 +00:00
|
|
|
lhz 6,0(src)
|
|
|
|
addi src,src,2
|
|
|
|
sth 6,0(dst)
|
|
|
|
addi dst,dst,2
|
|
|
|
4:
|
2010-03-10 15:28:04 +00:00
|
|
|
bf 29,8f
|
2013-08-17 09:17:22 +00:00
|
|
|
lwz 6,0(src)
|
|
|
|
addi src,src,4
|
|
|
|
stw 6,0(dst)
|
|
|
|
addi dst,dst,4
|
|
|
|
8:
|
2010-03-10 15:28:04 +00:00
|
|
|
bf 28,0f
|
2013-08-17 09:17:22 +00:00
|
|
|
ld 6,0(src)
|
|
|
|
addi src,src,8
|
|
|
|
std 6,0(dst)
|
|
|
|
addi dst,dst,8
|
2010-03-10 15:14:16 +00:00
|
|
|
0:
|
2013-08-17 09:17:22 +00:00
|
|
|
srdi 9,cnt,4 /* Number of full quadwords remaining. */
|
2010-03-10 15:14:16 +00:00
|
|
|
|
2010-03-10 15:28:04 +00:00
|
|
|
/* The proper alignment is present, it is OK to copy the bytes now. */
|
2010-03-10 15:14:16 +00:00
|
|
|
L(copy_GE_32_unaligned_cont):
|
|
|
|
|
2010-03-10 15:28:04 +00:00
|
|
|
/* Setup two indexes to speed up the indexed vector operations. */
|
2013-08-17 09:17:22 +00:00
|
|
|
clrldi 10,cnt,60
|
|
|
|
li 6,16 /* Index for 16-bytes offsets. */
|
2010-03-10 15:28:04 +00:00
|
|
|
li 7,32 /* Index for 32-bytes offsets. */
|
2013-08-17 09:17:22 +00:00
|
|
|
cmpldi cr1,10,0
|
|
|
|
srdi 8,cnt,5 /* Setup the loop counter. */
|
|
|
|
mtocrf 0x01,9
|
|
|
|
cmpldi cr6,9,1
|
|
|
|
#ifdef __LITTLE_ENDIAN__
|
|
|
|
lvsr 5,0,src
|
|
|
|
#else
|
|
|
|
lvsl 5,0,src
|
|
|
|
#endif
|
|
|
|
lvx 3,0,src
|
|
|
|
li 0,0
|
|
|
|
bf 31,L(setup_unaligned_loop)
|
|
|
|
|
|
|
|
/* Copy another 16 bytes to align to 32-bytes due to the loop. */
|
|
|
|
lvx 4,src,6
|
|
|
|
#ifdef __LITTLE_ENDIAN__
|
|
|
|
vperm 6,4,3,5
|
|
|
|
#else
|
|
|
|
vperm 6,3,4,5
|
|
|
|
#endif
|
|
|
|
addi src,src,16
|
|
|
|
stvx 6,0,dst
|
|
|
|
addi dst,dst,16
|
2010-03-10 15:28:04 +00:00
|
|
|
vor 3,4,4
|
2013-08-17 09:17:22 +00:00
|
|
|
clrrdi 0,src,60
|
2010-03-10 15:14:16 +00:00
|
|
|
|
|
|
|
L(setup_unaligned_loop):
|
2013-08-17 09:17:22 +00:00
|
|
|
mtctr 8
|
|
|
|
ble cr6,L(end_unaligned_loop)
|
2010-03-10 15:14:16 +00:00
|
|
|
|
2010-03-10 15:28:04 +00:00
|
|
|
/* Copy 32 bytes at a time using vector instructions. */
|
2013-08-17 09:17:22 +00:00
|
|
|
.align 4
|
2010-03-10 15:14:16 +00:00
|
|
|
L(unaligned_loop):
|
|
|
|
|
2010-03-10 15:28:04 +00:00
|
|
|
/* Note: vr6/vr10 may contain data that was already copied,
|
|
|
|
but in order to get proper alignment, we may have to copy
|
|
|
|
some portions again. This is faster than having unaligned
|
|
|
|
vector instructions though. */
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
lvx 4,src,6
|
|
|
|
#ifdef __LITTLE_ENDIAN__
|
|
|
|
vperm 6,4,3,5
|
|
|
|
#else
|
|
|
|
vperm 6,3,4,5
|
|
|
|
#endif
|
|
|
|
lvx 3,src,7
|
|
|
|
#ifdef __LITTLE_ENDIAN__
|
|
|
|
vperm 10,3,4,5
|
|
|
|
#else
|
|
|
|
vperm 10,4,3,5
|
|
|
|
#endif
|
|
|
|
addi src,src,32
|
|
|
|
stvx 6,0,dst
|
|
|
|
stvx 10,dst,6
|
|
|
|
addi dst,dst,32
|
2010-03-10 15:28:04 +00:00
|
|
|
bdnz L(unaligned_loop)
|
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
clrrdi 0,src,60
|
|
|
|
|
|
|
|
.align 4
|
2010-03-10 15:14:16 +00:00
|
|
|
L(end_unaligned_loop):
|
|
|
|
|
2010-03-10 15:28:04 +00:00
|
|
|
/* Check for tail bytes. */
|
2013-08-17 09:17:22 +00:00
|
|
|
mtocrf 0x01,cnt
|
|
|
|
beqlr cr1
|
2010-03-10 15:28:04 +00:00
|
|
|
|
2013-08-17 09:17:22 +00:00
|
|
|
add src,src,0
|
2010-03-10 15:28:04 +00:00
|
|
|
|
|
|
|
/* We have 1~15 tail bytes to copy, and DST is quadword aligned. */
|
2013-08-17 09:17:22 +00:00
|
|
|
/* Copy 8 bytes. */
|
2010-03-10 15:28:04 +00:00
|
|
|
bf 28,4f
|
2013-08-17 09:17:22 +00:00
|
|
|
lwz 6,0(src)
|
|
|
|
lwz 7,4(src)
|
|
|
|
addi src,src,8
|
|
|
|
stw 6,0(dst)
|
|
|
|
stw 7,4(dst)
|
|
|
|
addi dst,dst,8
|
|
|
|
4: /* Copy 4~7 bytes. */
|
|
|
|
bf 29,L(tail2)
|
|
|
|
lwz 6,0(src)
|
|
|
|
stw 6,0(dst)
|
|
|
|
bf 30,L(tail5)
|
|
|
|
lhz 7,4(src)
|
|
|
|
sth 7,4(dst)
|
|
|
|
bflr 31
|
|
|
|
lbz 8,6(src)
|
|
|
|
stb 8,6(dst)
|
|
|
|
/* Return original DST pointer. */
|
2010-03-10 15:28:04 +00:00
|
|
|
blr
|
2010-03-10 15:14:16 +00:00
|
|
|
|
2017-04-11 17:18:35 +00:00
|
|
|
END_GEN_TB (MEMCPY,TB_TOCLESS)
|
2010-03-10 15:14:16 +00:00
|
|
|
libc_hidden_builtin_def (memcpy)
|