1 /* Vector optimized 32/64 bit S/390 version of rawmemchr.
2 Copyright (C) 2015-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <ifunc-rawmemchr.h>
21 #if HAVE_RAWMEMCHR_Z13
24 # include "asm-syntax.h"
28 /* void *rawmemchr (const void *s, int c)
29 Scans memory for character c
30 and returns pointer to first c.
44 .machinemode "zarch_nohighgprs"
46 vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
47 lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
49 vlvgb %v18,%r3,0 /* Generate vector which elements are all c.
50 If c > 255, c will be truncated. */
53 vfeeb %v17,%v16,%v18 /* Vector find element equal. */
54 vlgvb %r5,%v17,7 /* Load byte index of character or zero. */
55 clrjl %r5,%r1,.Lend_found /* If found c is in loaded bytes, end. */
57 /* Align s to 16 byte. */
58 risbgn %r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
60 slr %r5,%r1 /* Compute bytes to 16bytes boundary. */
62 /* Find c in a 16byte aligned loop. */
64 vl %v16,0(%r5,%r2) /* Load s. */
65 vfeebs %v17,%v16,%v18 /* Vector find element equal. */
66 jno .Lcharacter /* Jump away if element found. */
78 j .Lloop /* No character found -> loop. */
80 /* Found character. */
88 vlgvb %r1,%v17,7 /* Load byte index of character. */
91 la %r2,0(%r5,%r2) /* Return pointer to character. */
95 # if ! HAVE_RAWMEMCHR_IFUNC
96 strong_alias (RAWMEMCHR_Z13, __rawmemchr)
97 weak_alias (__rawmemchr, rawmemchr)
100 # if ! HAVE_RAWMEMCHR_C && defined SHARED && IS_IN (libc)
101 strong_alias (RAWMEMCHR_Z13, __GI___rawmemchr)
104 #endif /* HAVE_RAWMEMCHR_Z13 */