|
Packit |
6c4009 |
/* Vector Optimized 32/64 bit S/390 version of wmemcmp.
|
|
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 |
e44d5e |
#include <ifunc-wmemcmp.h>
|
|
Packit Service |
e44d5e |
#if HAVE_WMEMCMP_Z13
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# include "sysdep.h"
|
|
Packit |
6c4009 |
# include "asm-syntax.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* int wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
|
|
Packit |
6c4009 |
Compare at most n characters of two wchar_t-arrays.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Register usage:
|
|
Packit |
6c4009 |
-r0=tmp
|
|
Packit |
6c4009 |
-r1=number of blocks
|
|
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 |
e44d5e |
ENTRY(WMEMCMP_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 |
clgije %r4,0,.Lend_equal /* Nothing to do if n == 0. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Check range of maxlen and convert to byte-count. */
|
|
Packit |
6c4009 |
# ifdef __s390x__
|
|
Packit |
6c4009 |
tmhh %r4,49152 /* Test bit 0 or 1 of maxlen. */
|
|
Packit |
6c4009 |
lghi %r1,-4 /* Max byte-count is 18446744073709551612. */
|
|
Packit |
6c4009 |
# else
|
|
Packit |
6c4009 |
tmlh %r4,49152 /* Test bit 0 or 1 of maxlen. */
|
|
Packit |
6c4009 |
llilf %r1,4294967292 /* Max byte-count is 4294967292. */
|
|
Packit |
6c4009 |
# endif /* !__s390x__ */
|
|
Packit |
6c4009 |
sllg %r4,%r4,2 /* Convert character-count to byte-count. */
|
|
Packit |
6c4009 |
locgrne %r4,%r1 /* Use max byte-count, if bit 0/1 was one. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
lghi %r5,0 /* current_len = 0. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
clgijh %r4,16,.Lgt16
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lremaining:
|
|
Packit |
6c4009 |
aghi %r4,-1 /* vstl needs highest index. */
|
|
Packit |
6c4009 |
vll %v16,%r4,0(%r2)
|
|
Packit |
6c4009 |
vll %v17,%r4,0(%r3)
|
|
Packit |
6c4009 |
vfenef %v18,%v16,%v17 /* Compare not equal. */
|
|
Packit |
6c4009 |
vlgvb %r1,%v18,7 /* Load unequal index or 16 if not found. */
|
|
Packit |
6c4009 |
clrj %r1,%r4,12,.Lfound2 /* r1 <= r4 -> unequal within loaded
|
|
Packit |
6c4009 |
bytes. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lend_equal:
|
|
Packit |
6c4009 |
lghi %r2,0
|
|
Packit |
6c4009 |
br %r14
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lfound:
|
|
Packit |
6c4009 |
/* vfenezf found an unequal element or zero.
|
|
Packit |
6c4009 |
This instruction compares unsigned words, but wchar_t is signed.
|
|
Packit |
6c4009 |
Thus we have to compare the found element again. */
|
|
Packit |
6c4009 |
vlgvb %r1,%v18,7 /* Extract not equal byte-index. */
|
|
Packit |
6c4009 |
.Lfound2:
|
|
Packit |
6c4009 |
srl %r1,2 /* And convert it to character-index. */
|
|
Packit |
6c4009 |
vlgvf %r0,%v16,0(%r1) /* Load character-values. */
|
|
Packit |
6c4009 |
vlgvf %r1,%v17,0(%r1)
|
|
Packit |
6c4009 |
cr %r0,%r1
|
|
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 |
|
|
Packit |
6c4009 |
.Lgt16:
|
|
Packit |
6c4009 |
clgijh %r4,64,.Lpreloop64
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lpreloop16:
|
|
Packit |
6c4009 |
srlg %r1,%r4,4 /* Split into 16byte blocks */
|
|
Packit |
6c4009 |
.Lloop16:
|
|
Packit |
6c4009 |
vl %v16,0(%r5,%r2)
|
|
Packit |
6c4009 |
vl %v17,0(%r5,%r3)
|
|
Packit |
6c4009 |
aghi %r5,16
|
|
Packit |
6c4009 |
vfenefs %v18,%v16,%v17 /* Compare not equal. */
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
brctg %r1,.Lloop16 /* Loop until all blocks are processed. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
llgfr %r4,%r4
|
|
Packit |
6c4009 |
nilf %r4,15 /* Get remaining bytes */
|
|
Packit |
6c4009 |
locgre %r2,%r4
|
|
Packit |
6c4009 |
ber %r14
|
|
Packit |
6c4009 |
la %r2,0(%r5,%r2)
|
|
Packit |
6c4009 |
la %r3,0(%r5,%r3)
|
|
Packit |
6c4009 |
j .Lremaining
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lpreloop64:
|
|
Packit |
6c4009 |
srlg %r1,%r4,6 /* Split into 64byte blocks */
|
|
Packit |
6c4009 |
.Lloop64:
|
|
Packit |
6c4009 |
vl %v16,0(%r5,%r2)
|
|
Packit |
6c4009 |
vl %v17,0(%r5,%r3)
|
|
Packit |
6c4009 |
vfenefs %v18,%v16,%v17 /* Compare not equal. */
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
vl %v16,16(%r5,%r2)
|
|
Packit |
6c4009 |
vl %v17,16(%r5,%r3)
|
|
Packit |
6c4009 |
vfenefs %v18,%v16,%v17
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
vl %v16,32(%r5,%r2)
|
|
Packit |
6c4009 |
vl %v17,32(%r5,%r3)
|
|
Packit |
6c4009 |
vfenefs %v18,%v16,%v17
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
vl %v16,48(%r5,%r2)
|
|
Packit |
6c4009 |
vl %v17,48(%r5,%r3)
|
|
Packit |
6c4009 |
aghi %r5,64
|
|
Packit |
6c4009 |
vfenefs %v18,%v16,%v17
|
|
Packit |
6c4009 |
jno .Lfound
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
brctg %r1,.Lloop64 /* Loop until all blocks are processed. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
llgfr %r4,%r4
|
|
Packit |
6c4009 |
nilf %r4,63 /* Get remaining bytes */
|
|
Packit |
6c4009 |
locgre %r2,%r4
|
|
Packit |
6c4009 |
ber %r14
|
|
Packit |
6c4009 |
clgijh %r4,16,.Lpreloop16
|
|
Packit |
6c4009 |
la %r2,0(%r5,%r2)
|
|
Packit |
6c4009 |
la %r3,0(%r5,%r3)
|
|
Packit |
6c4009 |
j .Lremaining
|
|
Packit Service |
e44d5e |
END(WMEMCMP_Z13)
|
|
Packit Service |
e44d5e |
|
|
Packit Service |
e44d5e |
# if ! HAVE_WMEMCMP_IFUNC
|
|
Packit Service |
e44d5e |
strong_alias (WMEMCMP_Z13, wmemcmp)
|
|
Packit Service |
e44d5e |
# endif
|
|
Packit Service |
e44d5e |
#endif
|