Blame sysdeps/powerpc/powerpc32/405/strlen.S
|
Packit |
6c4009 |
/* Optimized strlen implementation for PowerPC476.
|
|
Packit |
6c4009 |
Copyright (C) 2010-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library. If not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* strlen
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Register Use
|
|
Packit |
6c4009 |
r3:source address and return length of string
|
|
Packit |
6c4009 |
r4:byte counter
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Implementation description
|
|
Packit |
6c4009 |
Load 2 words at a time and count bytes, if we find null we subtract one from
|
|
Packit |
6c4009 |
the count and return the count value. We need to subtract one because
|
|
Packit |
6c4009 |
we don't count the null character as a byte. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
EALIGN (strlen,5,0)
|
|
Packit |
6c4009 |
neg r7,r3
|
|
Packit |
6c4009 |
clrlwi. r8,r7,29
|
|
Packit |
6c4009 |
addi r4,0,0
|
|
Packit |
6c4009 |
beq L(byte_count_loop)
|
|
Packit |
6c4009 |
mtctr r8
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(loop):
|
|
Packit |
6c4009 |
lbz r5,0(r3)
|
|
Packit |
6c4009 |
cmpi cr5,r5,0x0
|
|
Packit |
6c4009 |
addi r3,r3,0x1
|
|
Packit |
6c4009 |
addi r4,r4,0x1
|
|
Packit |
6c4009 |
beq cr5,L(end_strlen)
|
|
Packit |
6c4009 |
bdnz L(loop)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(byte_count_loop):
|
|
Packit |
6c4009 |
lwz r5,0(r3)
|
|
Packit |
6c4009 |
lwz r6,4(r3)
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
add r4,r4,r12
|
|
Packit |
6c4009 |
bne L(end_strlen)
|
|
Packit |
6c4009 |
lwz r5,8(r3)
|
|
Packit |
6c4009 |
lwz r6,12(r3)
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
add r4,r4,r12
|
|
Packit |
6c4009 |
bne L(end_strlen)
|
|
Packit |
6c4009 |
lwz r5,16(r3)
|
|
Packit |
6c4009 |
lwz r6,20(r3)
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
add r4,r4,r12
|
|
Packit |
6c4009 |
bne L(end_strlen)
|
|
Packit |
6c4009 |
lwz r5,24(r3)
|
|
Packit |
6c4009 |
lwz r6,28(r3)
|
|
Packit |
6c4009 |
addi r3,r3,0x20
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
add r4,r4,r12
|
|
Packit |
6c4009 |
bne L(end_strlen)
|
|
Packit |
6c4009 |
b L(byte_count_loop)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(end_strlen):
|
|
Packit |
6c4009 |
addi r3,r4,-1
|
|
Packit |
6c4009 |
blr
|
|
Packit |
6c4009 |
END (strlen)
|
|
Packit |
6c4009 |
libc_hidden_builtin_def (strlen)
|