Blame sysdeps/powerpc/powerpc32/405/strcmp.S
|
Packit |
6c4009 |
/* Optimized strcmp 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 |
/* strcmp
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Register Use
|
|
Packit |
6c4009 |
r0:temp return equality
|
|
Packit |
6c4009 |
r3:source1 address, return equality
|
|
Packit |
6c4009 |
r4:source2 address
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Implementation description
|
|
Packit |
6c4009 |
Check 2 words from src1 and src2. If unequal jump to end and
|
|
Packit |
6c4009 |
return src1 > src2 or src1 < src2.
|
|
Packit |
6c4009 |
If null check bytes before null and then jump to end and
|
|
Packit |
6c4009 |
return src1 > src2, src1 < src2 or src1 = src2.
|
|
Packit |
6c4009 |
If src1 = src2 and no null, repeat. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
EALIGN (strcmp,5,0)
|
|
Packit |
6c4009 |
neg r7,r3
|
|
Packit |
6c4009 |
clrlwi r7,r7,20
|
|
Packit |
6c4009 |
neg r8,r4
|
|
Packit |
6c4009 |
clrlwi r8,r8,20
|
|
Packit |
6c4009 |
srwi. r7,r7,5
|
|
Packit |
6c4009 |
beq L(byte_loop)
|
|
Packit |
6c4009 |
srwi. r8,r8,5
|
|
Packit |
6c4009 |
beq L(byte_loop)
|
|
Packit |
6c4009 |
cmplw r7,r8
|
|
Packit |
6c4009 |
mtctr r7
|
|
Packit |
6c4009 |
ble L(big_loop)
|
|
Packit |
6c4009 |
mtctr r8
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(big_loop):
|
|
Packit |
6c4009 |
lwz r5,0(r3)
|
|
Packit |
6c4009 |
lwz r6,4(r3)
|
|
Packit |
6c4009 |
lwz r8,0(r4)
|
|
Packit |
6c4009 |
lwz r9,4(r4)
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
bne L(end_check)
|
|
Packit |
6c4009 |
cmplw r5,r8
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
cmplw r6,r9
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
lwz r5,8(r3)
|
|
Packit |
6c4009 |
lwz r6,12(r3)
|
|
Packit |
6c4009 |
lwz r8,8(r4)
|
|
Packit |
6c4009 |
lwz r9,12(r4)
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
bne L(end_check)
|
|
Packit |
6c4009 |
cmplw r5,r8
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
cmplw r6,r9
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
lwz r5,16(r3)
|
|
Packit |
6c4009 |
lwz r6,20(r3)
|
|
Packit |
6c4009 |
lwz r8,16(r4)
|
|
Packit |
6c4009 |
lwz r9,20(r4)
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
bne L(end_check)
|
|
Packit |
6c4009 |
cmplw r5,r8
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
cmplw r6,r9
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
lwz r5,24(r3)
|
|
Packit |
6c4009 |
lwz r6,28(r3)
|
|
Packit |
6c4009 |
addi r3,r3,0x20
|
|
Packit |
6c4009 |
lwz r8,24(r4)
|
|
Packit |
6c4009 |
lwz r9,28(r4)
|
|
Packit |
6c4009 |
addi r4,r4,0x20
|
|
Packit |
6c4009 |
dlmzb. r12,r5,r6
|
|
Packit |
6c4009 |
bne L(end_check)
|
|
Packit |
6c4009 |
cmplw r5,r8
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
cmplw r6,r9
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
bdnz L(big_loop)
|
|
Packit |
6c4009 |
b L(byte_loop)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(end_check):
|
|
Packit |
6c4009 |
subfic r12,r12,4
|
|
Packit |
6c4009 |
blt L(end_check2)
|
|
Packit |
6c4009 |
rlwinm r12,r12,3,0,31
|
|
Packit |
6c4009 |
srw r5,r5,r12
|
|
Packit |
6c4009 |
srw r8,r8,r12
|
|
Packit |
6c4009 |
cmplw r5,r8
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
b L(end_strcmp)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(end_check2):
|
|
Packit |
6c4009 |
addi r12,r12,4
|
|
Packit |
6c4009 |
cmplw r5,r8
|
|
Packit |
6c4009 |
rlwinm r12,r12,3,0,31
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
srw r6,r6,r12
|
|
Packit |
6c4009 |
srw r9,r9,r12
|
|
Packit |
6c4009 |
cmplw r6,r9
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(end_strcmp):
|
|
Packit |
6c4009 |
addi r3,r0,0
|
|
Packit |
6c4009 |
blr
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(st1):
|
|
Packit |
6c4009 |
mfcr r3
|
|
Packit |
6c4009 |
blr
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(byte_loop):
|
|
Packit |
6c4009 |
lbz r5,0(r3)
|
|
Packit |
6c4009 |
addi r3,r3,1
|
|
Packit |
6c4009 |
lbz r6,0(r4)
|
|
Packit |
6c4009 |
addi r4,r4,1
|
|
Packit |
6c4009 |
cmplw r5,r6
|
|
Packit |
6c4009 |
bne L(st1)
|
|
Packit |
6c4009 |
cmpwi r5,0
|
|
Packit |
6c4009 |
beq L(end_strcmp)
|
|
Packit |
6c4009 |
b L(byte_loop)
|
|
Packit |
6c4009 |
END (strcmp)
|
|
Packit |
6c4009 |
libc_hidden_builtin_def (strcmp)
|