diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-07-01 13:08:59 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2012-07-01 13:08:59 +0000 |
commit | e84eabb3871c9b39e59323bf3f6b98c2ca9d1cd0 (patch) | |
tree | dff3f1b79454b518d15a7b9bbedeb57ff156bbe8 /ports/sysdeps/powerpc/powerpc32/405/strlen.S | |
parent | 75f0d3040a2c2de8842bfa7a09e11da1a73e17d0 (diff) | |
parent | e64ac02c24b43659048622714afdc92fedf561fa (diff) |
Merge glibc-ports into ports/ directory.glibc-2.16-ports-merge
Diffstat (limited to 'ports/sysdeps/powerpc/powerpc32/405/strlen.S')
-rw-r--r-- | ports/sysdeps/powerpc/powerpc32/405/strlen.S | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/ports/sysdeps/powerpc/powerpc32/405/strlen.S b/ports/sysdeps/powerpc/powerpc32/405/strlen.S new file mode 100644 index 0000000000..210a3afd92 --- /dev/null +++ b/ports/sysdeps/powerpc/powerpc32/405/strlen.S @@ -0,0 +1,77 @@ +/* Optimized strlen implementation for PowerPC476. + Copyright (C) 2010 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/>. */ + +#include <sysdep.h> +#include <bp-sym.h> +#include <bp-asm.h> + +/* strlen + + Register Use + r3:source address and return length of string + r4:byte counter + + Implementation description + Load 2 words at a time and count bytes, if we find null we subtract one from + the count and return the count value. We need to subtract one because + we don't count the null character as a byte. */ + +EALIGN (BP_SYM (strlen),5,0) + neg r7,r3 + clrlwi. r8,r7,29 + addi r4,0,0 + beq L(byte_count_loop) + mtctr r8 + +L(loop): + lbz r5,0(r3) + cmpi cr5,r5,0x0 + addi r3,r3,0x1 + addi r4,r4,0x1 + beq cr5,L(end_strlen) + bdnz L(loop) + +L(byte_count_loop): + lwz r5,0(r3) + lwz r6,4(r3) + dlmzb. r12,r5,r6 + add r4,r4,r12 + bne L(end_strlen) + lwz r5,8(r3) + lwz r6,12(r3) + dlmzb. r12,r5,r6 + add r4,r4,r12 + bne L(end_strlen) + lwz r5,16(r3) + lwz r6,20(r3) + dlmzb. r12,r5,r6 + add r4,r4,r12 + bne L(end_strlen) + lwz r5,24(r3) + lwz r6,28(r3) + addi r3,r3,0x20 + dlmzb. r12,r5,r6 + add r4,r4,r12 + bne L(end_strlen) + b L(byte_count_loop) + +L(end_strlen): + addi r3,r4,-1 + blr +END (BP_SYM (strlen)) +libc_hidden_builtin_def (strlen) |