|
Packit |
6c4009 |
/* Vector optimized 32/64 bit S/390 version of strncmp.
|
|
Packit |
6c4009 |
Copyright (C) 2015-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 Service |
a09d4d |
#include <ifunc-strncmp.h>
|
|
Packit Service |
a09d4d |
|
|
Packit Service |
a09d4d |
#if HAVE_STRNCMP_Z13
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# include "sysdep.h"
|
|
Packit |
6c4009 |
# include "asm-syntax.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* int strncmp (const char *s1, const char *s2, size_t n)
|
|
Packit |
6c4009 |
Compare at most n characters of two strings.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Register usage:
|
|
Packit |
6c4009 |
-r0=tmp
|
|
Packit |
6c4009 |
-r1=tmp
|
|
Packit |
6c4009 |
-r2=s1
|
|
Packit |
6c4009 |
-r3=s2
|
|
Packit |
6c4009 |
-r4=n
|
|
Packit |
6c4009 |
-r5=current_len
|
|
Packit |
6c4009 |
-v16=part of s1
|
|
Packit |
6c4009 |
-v17=part of s2
|
|
Packit |
6c4009 |
-v18=index of unequal
|
|
Packit |
6c4009 |
*/
|
|
Packit Service |
a09d4d |
ENTRY(STRNCMP_Z13)
|
|
Packit |
6c4009 |
.machine "z13"
|
|
Packit |
6c4009 |
.machinemode "zarch_nohighgprs"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# if !defined __s390x__
|
|
Packit |
6c4009 |
llgfr %r4,%r4
|
|
Packit |
6c4009 |
# endif /* !defined __s390x__ */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
clgije %r4,0,.Lend_equal /* Nothing to do if n == 0, */
|
|
Packit |
6c4009 |
lghi %r5,0 /* current_len = 0. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lloop:
|
|
Packit |
6c4009 |
vlbb %v16,0(%r5,%r2),6 /* Load s1 to block boundary. */
|
|
Packit |
6c4009 |
vlbb %v17,0(%r5,%r3),6 /* Load s2 to block boundary. */
|
|
Packit |
6c4009 |
lcbb %r0,0(%r5,%r2),6 /* Get loaded byte count of s1. */
|
|
Packit |
6c4009 |
jo .Llt16_1 /* Jump away if vr is not fully loaded. */
|
|
Packit |
6c4009 |
lcbb %r1,0(%r5,%r3),6 /* Get loaded byte count of s2. */
|
|
Packit |
6c4009 |
jo .Llt16_2 /* Jump away if vr is not fully loaded. */
|
|
Packit |
6c4009 |
aghi %r5,16 /* Both vrs are fully loaded. */
|
|
Packit |
6c4009 |
clgrjhe %r5,%r4,.Llastcmp /* If current_len >= n ->last compare. */
|
|
Packit |
6c4009 |
vfenezbs %v18,%v16,%v17 /* Compare not equal with zero search. */
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
vlbb %v16,0(%r5,%r2),6
|
|
Packit |
6c4009 |
vlbb %v17,0(%r5,%r3),6
|
|
Packit |
6c4009 |
lcbb %r0,0(%r5,%r2),6
|
|
Packit |
6c4009 |
jo .Llt16_1
|
|
Packit |
6c4009 |
lcbb %r1,0(%r5,%r3),6
|
|
Packit |
6c4009 |
jo .Llt16_2
|
|
Packit |
6c4009 |
aghi %r5,16
|
|
Packit |
6c4009 |
clgrjhe %r5,%r4,.Llastcmp
|
|
Packit |
6c4009 |
vfenezbs %v18,%v16,%v17
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
vlbb %v16,0(%r5,%r2),6
|
|
Packit |
6c4009 |
vlbb %v17,0(%r5,%r3),6
|
|
Packit |
6c4009 |
lcbb %r0,0(%r5,%r2),6
|
|
Packit |
6c4009 |
jo .Llt16_1
|
|
Packit |
6c4009 |
lcbb %r1,0(%r5,%r3),6
|
|
Packit |
6c4009 |
jo .Llt16_2
|
|
Packit |
6c4009 |
aghi %r5,16
|
|
Packit |
6c4009 |
clgrjhe %r5,%r4,.Llastcmp
|
|
Packit |
6c4009 |
vfenezbs %v18,%v16,%v17
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
vlbb %v16,0(%r5,%r2),6
|
|
Packit |
6c4009 |
vlbb %v17,0(%r5,%r3),6
|
|
Packit |
6c4009 |
lcbb %r0,0(%r5,%r2),6
|
|
Packit |
6c4009 |
jo .Llt16_1
|
|
Packit |
6c4009 |
lcbb %r1,0(%r5,%r3),6
|
|
Packit |
6c4009 |
jo .Llt16_2
|
|
Packit |
6c4009 |
aghi %r5,16
|
|
Packit |
6c4009 |
clgrjhe %r5,%r4,.Llastcmp
|
|
Packit |
6c4009 |
vfenezbs %v18,%v16,%v17
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
j .Lloop
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Llt16_1:
|
|
Packit |
6c4009 |
lcbb %r1,0(%r5,%r3),6 /* Get loaded byte count ofs2. */
|
|
Packit |
6c4009 |
.Llt16_2:
|
|
Packit |
6c4009 |
clr %r0,%r1 /* Compare logical. */
|
|
Packit |
6c4009 |
locrh %r0,%r1 /* Compute minimum of bytes loaded. */
|
|
Packit |
6c4009 |
algfr %r5,%r0 /* Add smallest loaded bytes to current_len. */
|
|
Packit |
6c4009 |
clgrj %r5,%r4,10,.Llastcmp /* If current_len >= n ->last compare. */
|
|
Packit |
6c4009 |
vfenezbs %v18,%v16,%v17 /* Compare not equal with zero search. */
|
|
Packit |
6c4009 |
vlgvb %r1,%v18,7 /* Get not equal index or 16 if all equal. */
|
|
Packit |
6c4009 |
clrjl %r1,%r0,.Lfound /* Jump away if miscompare is within
|
|
Packit |
6c4009 |
loaded bytes (index < loaded-bytes) */
|
|
Packit |
6c4009 |
j .Lloop
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Llastcmp:
|
|
Packit |
6c4009 |
/* Use comparision result only if located within first n characters.
|
|
Packit |
6c4009 |
%r0: loaded byte count in vreg;
|
|
Packit |
6c4009 |
%r5: current_len;
|
|
Packit |
6c4009 |
%r4: n;
|
|
Packit |
6c4009 |
(current_len - n): [0...16[
|
|
Packit |
6c4009 |
First ignored match index: loaded bytes - (current_len-n): ]0...16]
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
slgr %r5,%r4 /* %r5 = current_len - n. */
|
|
Packit |
6c4009 |
slr %r0,%r5 /* %r0 = first ignored match index. */
|
|
Packit |
6c4009 |
vfenezbs %v18,%v16,%v17 /* Compare not equal with zero search. */
|
|
Packit |
6c4009 |
vlgvb %r1,%v18,7 /* Get not equal index or 16 if all equal. */
|
|
Packit |
6c4009 |
clrjl %r1,%r0,.Lfound /* Jump away if miscompare is within
|
|
Packit |
6c4009 |
loaded bytes and below n bytes. */
|
|
Packit |
6c4009 |
j .Lend_equal /* Miscompare after n-bytes -> end equal. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lfound:
|
|
Packit |
6c4009 |
/* Difference or end of string. */
|
|
Packit |
6c4009 |
je .Lend_equal
|
|
Packit |
6c4009 |
lghi %r2,1
|
|
Packit |
6c4009 |
lghi %r1,-1
|
|
Packit |
6c4009 |
locgrl %r2,%r1
|
|
Packit |
6c4009 |
br %r14
|
|
Packit |
6c4009 |
.Lend_equal:
|
|
Packit |
6c4009 |
lghi %r2,0
|
|
Packit |
6c4009 |
br %r14
|
|
Packit Service |
a09d4d |
END(STRNCMP_Z13)
|
|
Packit Service |
a09d4d |
|
|
Packit Service |
a09d4d |
# if ! HAVE_STRNCMP_IFUNC
|
|
Packit Service |
a09d4d |
strong_alias (STRNCMP_Z13, strncmp)
|
|
Packit Service |
a09d4d |
# endif
|
|
Packit Service |
a09d4d |
|
|
Packit Service |
a09d4d |
# if ! HAVE_STRNCMP_C && defined SHARED && IS_IN (libc)
|
|
Packit Service |
a09d4d |
strong_alias (STRNCMP_Z13, __GI_strncmp)
|
|
Packit Service |
a09d4d |
# endif
|
|
Packit Service |
a09d4d |
|
|
Packit Service |
a09d4d |
#endif /* HAVE_STRNCMP_Z13 */
|