|
Packit |
6c4009 |
/* Vector Optimized 32/64 bit S/390 version of wmemset.
|
|
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 |
03af52 |
#include <ifunc-wmemset.h>
|
|
Packit Service |
03af52 |
#if HAVE_WMEMSET_Z13
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# include "sysdep.h"
|
|
Packit |
6c4009 |
# include "asm-syntax.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* wchar_t *wmemset(wchar_t *dest, wchar_t wc, size_t n)
|
|
Packit |
6c4009 |
Fill an array of wide-characters with a constant wide character
|
|
Packit |
6c4009 |
and returns dest.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Register usage:
|
|
Packit |
6c4009 |
-r0=tmp
|
|
Packit |
6c4009 |
-r1=tmp
|
|
Packit |
6c4009 |
-r2=dest or current-pointer
|
|
Packit |
6c4009 |
-r3=wc
|
|
Packit |
6c4009 |
-r4=n
|
|
Packit |
6c4009 |
-r5=tmp
|
|
Packit |
6c4009 |
-v16=replicated wc
|
|
Packit |
6c4009 |
-v17,v18,v19=copy of v16 for vstm
|
|
Packit |
6c4009 |
-v31=saved dest for return
|
|
Packit |
6c4009 |
*/
|
|
Packit Service |
03af52 |
ENTRY(WMEMSET_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 |
vlvgg %v31,%r2,0 /* Save destination pointer for return. */
|
|
Packit |
6c4009 |
clgije %r4,0,.Lend
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
vlvgf %v16,%r3,0 /* Generate vector with wchar_t wc. */
|
|
Packit |
6c4009 |
vrepf %v16,%v16,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 %r5,-4 /* Max byte-count is 18446744073709551612. */
|
|
Packit |
6c4009 |
# else
|
|
Packit |
6c4009 |
tmlh %r4,49152 /* Test bit 0 or 1 of maxlen. */
|
|
Packit |
6c4009 |
llilf %r5,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,%r5 /* Use max byte-count, if bit 0/1 was one. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Align dest to 16 byte. */
|
|
Packit |
6c4009 |
risbg %r0,%r2,60,128+63,0 /* Test if s is aligned and
|
|
Packit |
6c4009 |
%r3 = bits 60-63 'and' 15. */
|
|
Packit |
6c4009 |
je .Lpreloop /* If s is aligned, loop aligned. */
|
|
Packit |
6c4009 |
tmll %r2,3 /* Test if s is 4-byte aligned? */
|
|
Packit |
6c4009 |
jne .Lfallback /* And use common-code variant if not. */
|
|
Packit |
6c4009 |
lghi %r1,16
|
|
Packit |
6c4009 |
slr %r1,%r0 /* Compute byte count to load (16-x). */
|
|
Packit |
6c4009 |
clgr %r1,%r4
|
|
Packit |
6c4009 |
locgrh %r1,%r4 /* min (byte count, n) */
|
|
Packit |
6c4009 |
aghik %r5,%r1,-1 /* vstl needs highest index. */
|
|
Packit |
6c4009 |
vstl %v16,%r5,0(%r2) /* Store remaining bytes. */
|
|
Packit |
6c4009 |
clgrje %r1,%r4,.Lend /* Return if n bytes where set. */
|
|
Packit |
6c4009 |
slgr %r4,%r1 /* Compute remaining byte count. */
|
|
Packit |
6c4009 |
la %r2,0(%r1,%r2)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lpreloop:
|
|
Packit |
6c4009 |
/* Now we are 16-byte aligned. */
|
|
Packit |
6c4009 |
clgijl %r4,17,.Lremaining
|
|
Packit |
6c4009 |
srlg %r1,%r4,8 /* Split into 256byte blocks */
|
|
Packit |
6c4009 |
clgije %r1,0,.Lpreloop64
|
|
Packit |
6c4009 |
vlr %v17,%v16
|
|
Packit |
6c4009 |
vlr %v18,%v16
|
|
Packit |
6c4009 |
vlr %v19,%v16
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lloop256:
|
|
Packit |
6c4009 |
vstm %v16,%v19,0(%r2)
|
|
Packit |
6c4009 |
vstm %v16,%v19,64(%r2)
|
|
Packit |
6c4009 |
vstm %v16,%v19,128(%r2)
|
|
Packit |
6c4009 |
vstm %v16,%v19,192(%r2)
|
|
Packit |
6c4009 |
la %r2,256(%r2)
|
|
Packit |
6c4009 |
brctg %r1,.Lloop256 /* Loop until all blocks are processed. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
llgfr %r4,%r4
|
|
Packit |
6c4009 |
nilf %r4,255 /* Get remaining bytes */
|
|
Packit |
6c4009 |
je .Lend /* Skip store remaining bytes if zero. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lpreloop64:
|
|
Packit |
6c4009 |
clgijl %r4,17,.Lremaining
|
|
Packit |
6c4009 |
clgijl %r4,33,.Lpreloop16
|
|
Packit |
6c4009 |
srlg %r1,%r4,5 /* Split into 32byte blocks */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lloop32:
|
|
Packit |
6c4009 |
vst %v16,0(%r2)
|
|
Packit |
6c4009 |
vst %v16,16(%r2)
|
|
Packit |
6c4009 |
la %r2,32(%r2)
|
|
Packit |
6c4009 |
brctg %r1,.Lloop32 /* Loop until all blocks are processed. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
llgfr %r4,%r4
|
|
Packit |
6c4009 |
nilf %r4,31 /* Get remaining bytes */
|
|
Packit |
6c4009 |
je .Lend /* Skip store remaining bytes if zero. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lpreloop16:
|
|
Packit |
6c4009 |
clgijl %r4,17,.Lremaining
|
|
Packit |
6c4009 |
srlg %r1,%r4,4 /* Split into 16byte blocks */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lloop16:
|
|
Packit |
6c4009 |
vst %v16,0(%r2)
|
|
Packit |
6c4009 |
la %r2,16(%r2)
|
|
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 |
je .Lend /* Skip store remaining bytes if zero. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lremaining:
|
|
Packit |
6c4009 |
aghi %r4,-1 /* vstl needs highest index. */
|
|
Packit |
6c4009 |
vstl %v16,%r4,0(%r2)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.Lend:
|
|
Packit |
6c4009 |
vlgvg %r2,%v31,0 /* Load saved dest for return value. */
|
|
Packit |
6c4009 |
br %r14
|
|
Packit |
6c4009 |
.Lfallback:
|
|
Packit |
6c4009 |
srlg %r4,%r4,2 /* Convert byte-count to character-count. */
|
|
Packit Service |
03af52 |
jg WMEMSET_C
|
|
Packit Service |
03af52 |
END(WMEMSET_Z13)
|
|
Packit Service |
03af52 |
|
|
Packit Service |
03af52 |
# if ! HAVE_WMEMSET_IFUNC
|
|
Packit Service |
03af52 |
strong_alias (WMEMSET_Z13, __wmemset)
|
|
Packit Service |
03af52 |
weak_alias (__wmemset, wmemset)
|
|
Packit Service |
03af52 |
# endif
|
|
Packit Service |
03af52 |
|
|
Packit Service |
03af52 |
# if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT \
|
|
Packit Service |
03af52 |
&& defined SHARED && IS_IN (libc)
|
|
Packit Service |
03af52 |
strong_alias (WMEMSET_Z13, __GI___wmemset)
|
|
Packit Service |
03af52 |
weak_alias (WMEMSET_Z13, __GI_wmemset)
|
|
Packit Service |
03af52 |
# endif
|
|
Packit Service |
03af52 |
#endif
|