2018-12-21 01:48:04 +00:00
|
|
|
/* The assembly function for string compare. C-SKY ABIV2 version.
|
2019-01-01 00:11:28 +00:00
|
|
|
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
2018-12-21 01:48:04 +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
|
|
|
|
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/>. */
|
2018-12-21 01:48:04 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
|
|
|
|
ENTRY (strcmp)
|
|
|
|
mov a3, a0
|
|
|
|
/* Check if the s1 addr is aligned. */
|
|
|
|
xor a2, a3, a1
|
|
|
|
andi a2, 0x3
|
|
|
|
bnez a2, 7f
|
|
|
|
andi t1, a0, 0x3
|
|
|
|
bnez t1, 5f
|
|
|
|
|
|
|
|
1:
|
|
|
|
/* If aligned, load word each time. */
|
|
|
|
ldw t0, (a3, 0)
|
|
|
|
ldw t1, (a1, 0)
|
|
|
|
/* If s1[i] != s2[i], goto 2f. */
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
/* If s1[i] == s2[i], check if s1 or s2 is at the end. */
|
|
|
|
tstnbz t0
|
|
|
|
/* If at the end, goto 3f (finish comparing). */
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
ldw t0, (a3, 4)
|
|
|
|
ldw t1, (a1, 4)
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
tstnbz t0
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
ldw t0, (a3, 8)
|
|
|
|
ldw t1, (a1, 8)
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
tstnbz t0
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
ldw t0, (a3, 12)
|
|
|
|
ldw t1, (a1, 12)
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
tstnbz t0
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
ldw t0, (a3, 16)
|
|
|
|
ldw t1, (a1, 16)
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
tstnbz t0
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
ldw t0, (a3, 20)
|
|
|
|
ldw t1, (a1, 20)
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
tstnbz t0
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
ldw t0, (a3, 24)
|
|
|
|
ldw t1, (a1, 24)
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
tstnbz t0
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
ldw t0, (a3, 28)
|
|
|
|
ldw t1, (a1, 28)
|
|
|
|
cmpne t0, t1
|
|
|
|
bt 2f
|
|
|
|
tstnbz t0
|
|
|
|
bf 3f
|
|
|
|
|
|
|
|
addi a3, 32
|
|
|
|
addi a1, 32
|
|
|
|
|
|
|
|
br 1b
|
|
|
|
|
|
|
|
/* s1[i] != s2[i] in word, so we check byte 3. */
|
|
|
|
2:
|
|
|
|
xtrb3 a0, t0
|
|
|
|
xtrb3 a2, t1
|
|
|
|
subu a0, a2
|
|
|
|
bez a2, 4f
|
|
|
|
bnez a0, 4f
|
|
|
|
|
|
|
|
/* Check byte 2. */
|
|
|
|
xtrb2 a0, t0
|
|
|
|
xtrb2 a2, t1
|
|
|
|
subu a0, a2
|
|
|
|
bez a2, 4f
|
|
|
|
bnez a0, 4f
|
|
|
|
|
|
|
|
/* Check byte 1. */
|
|
|
|
xtrb1 a0, t0
|
|
|
|
xtrb1 a2, t1
|
|
|
|
subu a0, a2
|
|
|
|
bez a2, 4f
|
|
|
|
bnez a0, 4f
|
|
|
|
|
|
|
|
/* Check byte 0. */
|
|
|
|
xtrb0 a0, t0
|
|
|
|
xtrb0 a2, t1
|
|
|
|
subu a0, a2
|
|
|
|
|
|
|
|
jmp lr
|
|
|
|
3:
|
|
|
|
movi a0, 0
|
|
|
|
4:
|
|
|
|
jmp lr
|
|
|
|
|
|
|
|
/* Compare when s1 or s2 is not aligned. */
|
|
|
|
5:
|
|
|
|
subi t1, 4
|
|
|
|
6:
|
|
|
|
ldb a0, (a3, 0)
|
|
|
|
ldb a2, (a1, 0)
|
|
|
|
subu a0, a2
|
|
|
|
bnez a0, 4b
|
|
|
|
addi t1, 1
|
|
|
|
bez a2, 4b
|
|
|
|
addi a1, 1
|
|
|
|
addi a3, 1
|
|
|
|
bez t1, 1b
|
|
|
|
br 6b
|
|
|
|
|
|
|
|
7:
|
|
|
|
ldb a0, (a3, 0)
|
|
|
|
addi a3, 1
|
|
|
|
ldb a2, (a1, 0)
|
|
|
|
addi a1, 1
|
|
|
|
subu a0, a2
|
|
|
|
bnez a0, 4b
|
|
|
|
bnez a2, 7b
|
|
|
|
jmp r15
|
|
|
|
END (strcmp)
|
|
|
|
|
|
|
|
libc_hidden_def (strcmp)
|
|
|
|
.weak strcmp
|