2002-09-17 23:50:03 +00:00
|
|
|
/* Optimized stpcpy implementation for PowerPC64.
|
2013-01-02 19:01:50 +00:00
|
|
|
Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
2002-09-17 23:50:03 +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
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2002-09-17 23:50:03 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
|
|
|
|
/* See strlen.s for comments on how the end-of-string testing works. */
|
|
|
|
|
|
|
|
/* char * [r3] stpcpy (char *dest [r3], const char *src [r4]) */
|
|
|
|
|
2013-03-06 00:10:21 +00:00
|
|
|
EALIGN (__stpcpy, 4, 0)
|
2004-10-06 22:09:35 +00:00
|
|
|
CALL_MCOUNT 2
|
2002-09-17 23:50:03 +00:00
|
|
|
|
|
|
|
#define rTMP r0
|
|
|
|
#define rRTN r3
|
2013-03-06 00:10:21 +00:00
|
|
|
#define rDEST r3 /* pointer to previous word in dest */
|
|
|
|
#define rSRC r4 /* pointer to previous word in src */
|
2002-09-17 23:50:03 +00:00
|
|
|
#define rWORD r6 /* current word from src */
|
|
|
|
#define rFEFE r7 /* 0xfefefeff */
|
|
|
|
#define r7F7F r8 /* 0x7f7f7f7f */
|
|
|
|
#define rNEG r9 /* ~(word in src | 0x7f7f7f7f) */
|
|
|
|
#define rALT r10 /* alternate word from src */
|
|
|
|
|
|
|
|
or rTMP, rSRC, rDEST
|
|
|
|
clrldi. rTMP, rTMP, 62
|
|
|
|
addi rDEST, rDEST, -4
|
|
|
|
bne L(unaligned)
|
|
|
|
|
|
|
|
lis rFEFE, -0x101
|
|
|
|
lis r7F7F, 0x7f7f
|
|
|
|
lwz rWORD, 0(rSRC)
|
|
|
|
addi rFEFE, rFEFE, -0x101
|
|
|
|
addi r7F7F, r7F7F, 0x7f7f
|
|
|
|
b L(g2)
|
|
|
|
|
|
|
|
L(g0): lwzu rALT, 4(rSRC)
|
|
|
|
stwu rWORD, 4(rDEST)
|
|
|
|
add rTMP, rFEFE, rALT
|
|
|
|
nor rNEG, r7F7F, rALT
|
|
|
|
and. rTMP, rTMP, rNEG
|
|
|
|
bne- L(g1)
|
|
|
|
lwzu rWORD, 4(rSRC)
|
|
|
|
stwu rALT, 4(rDEST)
|
|
|
|
L(g2): add rTMP, rFEFE, rWORD
|
|
|
|
nor rNEG, r7F7F, rWORD
|
|
|
|
and. rTMP, rTMP, rNEG
|
|
|
|
beq+ L(g0)
|
|
|
|
|
|
|
|
mr rALT, rWORD
|
|
|
|
/* We've hit the end of the string. Do the rest byte-by-byte. */
|
|
|
|
L(g1): rlwinm. rTMP, rALT, 8, 24, 31
|
|
|
|
stbu rTMP, 4(rDEST)
|
|
|
|
beqlr-
|
|
|
|
rlwinm. rTMP, rALT, 16, 24, 31
|
|
|
|
stbu rTMP, 1(rDEST)
|
|
|
|
beqlr-
|
|
|
|
rlwinm. rTMP, rALT, 24, 24, 31
|
|
|
|
stbu rTMP, 1(rDEST)
|
|
|
|
beqlr-
|
|
|
|
stbu rALT, 1(rDEST)
|
|
|
|
blr
|
|
|
|
|
|
|
|
/* Oh well. In this case, we just do a byte-by-byte copy. */
|
|
|
|
.align 4
|
|
|
|
nop
|
|
|
|
L(unaligned):
|
|
|
|
lbz rWORD, 0(rSRC)
|
|
|
|
addi rDEST, rDEST, 3
|
|
|
|
cmpwi rWORD, 0
|
|
|
|
beq- L(u2)
|
|
|
|
|
|
|
|
L(u0): lbzu rALT, 1(rSRC)
|
|
|
|
stbu rWORD, 1(rDEST)
|
|
|
|
cmpwi rALT, 0
|
|
|
|
beq- L(u1)
|
|
|
|
nop /* Let 601 load start of loop. */
|
|
|
|
lbzu rWORD, 1(rSRC)
|
|
|
|
stbu rALT, 1(rDEST)
|
|
|
|
cmpwi rWORD, 0
|
|
|
|
bne+ L(u0)
|
|
|
|
L(u2): stbu rWORD, 1(rDEST)
|
|
|
|
blr
|
|
|
|
L(u1): stbu rALT, 1(rDEST)
|
|
|
|
blr
|
2013-03-06 00:10:21 +00:00
|
|
|
END (__stpcpy)
|
2002-09-17 23:50:03 +00:00
|
|
|
|
2013-03-06 00:10:21 +00:00
|
|
|
weak_alias (__stpcpy, stpcpy)
|
2002-09-17 23:50:03 +00:00
|
|
|
libc_hidden_def (__stpcpy)
|
Update.
2004-05-27 Jakub Jelinek <jakub@redhat.com>
* sysdeps/i386/fpu/bits/mathinline.h (__expm1_code): Define using
__builtin_expm1l for GCC 3.5+.
(__expl): Define using __builtin_expl for GCC 3.4+.
(exp, expf, expl): Don't define for GCC 3.4+.
(tan, tanf, tanl): Don't define for GCC 3.5+.
(__atan2l): Define using __builtin_atan2l for GCC 3.4+.
(atan2, atan2f, atan2l): Don't define for GCC 3.4+ or !__FAST_MATH__.
(fmod, fmodf, fmodl): Don't define for GCC 3.5+ or !__FAST_MATH__.
(fabsf, fabsl): Only provide if __USE_MISC or __USE_ISOC99.
(sin, sinf, sinl, cos, cosf, cosl, log, logf, logl): Don't define
for GCC 3.4+.
(log10, log10f, log10l, asin, asinf, asinl, acos, acosf, acosl):
Don't define for GCC 3.5+.
(atan, atanf, atanl): Don't define for GCC 3.4+ or !__FAST_MATH__.
(log1p, log1pf, log1pl, logb, logbf, logbl, log2, log2f, log2l): Don't
define for GCC 3.5+.
(drem, dremf, dreml): Don't define for GCC 3.5+ or !__FAST_MATH__.
* sysdeps/sparc/fpu/bits/mathinline.h (sqrt, sqrtf, sqrtl): Don't
define for GCC 3.2+.
2004-05-27 Jakub Jelinek <jakub@redhat.com>
* string/bits/string2.h (__bzero): Define even for GCC 3.0+.
* sysdeps/alpha/stpcpy.S (stpcpy): Add libc_hidden_builtin_def.
* sysdeps/alpha/alphaev67/stpcpy.S (stpcpy): Likewise.
* sysdeps/powerpc/powerpc32/stpcpy.S (stpcpy): Likewise.
* sysdeps/powerpc/powerpc64/stpcpy.S (stpcpy): Likewise.
* sysdeps/sparc/sparc32/stpcpy.S (stpcpy): Likewise.
* sysdeps/sparc/sparc64/stpcpy.S (stpcpy): Likewise.
* sysdeps/i386/stpcpy.S (stpcpy): Likewise.
* sysdeps/i386/i586/stpcpy.S (stpcpy): Likewise.
* sysdeps/generic/stpcpy.c (stpcpy): Likewise.
* sysdeps/x86_64/stpcpy.S (stpcpy): Likewise.
* sysdeps/i386/i586/memcpy.S (memcpy): Remove
libc_hidden_builtin_def if MEMPCPY_P.
* sysdeps/x86_64/memcpy.S (memcpy): Likewise.
* sysdeps/i386/i686/mempcpy.S (mempcpy): Add libc_hidden_builtin_def.
* sysdeps/i386/i586/mempcpy.S (mempcpy): Likewise.
* sysdeps/generic/mempcpy.c (mempcpy): Likewise.
* sysdeps/x86_64/mempcpy.S (mempcpy): Likewise.
2004-05-28 06:56:51 +00:00
|
|
|
libc_hidden_builtin_def (stpcpy)
|