]>
Commit | Line | Data |
---|---|---|
88eefd34 | 1 | /* Vector optimized 32/64 bit S/390 version of rawmemchr. |
2b778ceb | 2 | Copyright (C) 2015-2021 Free Software Foundation, Inc. |
88eefd34 SL |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
88eefd34 | 18 | |
4c7b3cec SL |
19 | #include <ifunc-rawmemchr.h> |
20 | ||
21 | #if HAVE_RAWMEMCHR_Z13 | |
88eefd34 SL |
22 | |
23 | # include "sysdep.h" | |
24 | # include "asm-syntax.h" | |
25 | ||
26 | .text | |
27 | ||
28 | /* void *rawmemchr (const void *s, int c) | |
29 | Scans memory for character c | |
30 | and returns pointer to first c. | |
31 | ||
32 | Register usage: | |
33 | -r1=tmp | |
34 | -r2=s | |
35 | -r3=c | |
36 | -r4=tmp | |
37 | -r5=current_len | |
38 | -v16=part of s | |
39 | -v17=index of unequal | |
40 | -v18=c replicated | |
41 | */ | |
4c7b3cec | 42 | ENTRY(RAWMEMCHR_Z13) |
88eefd34 SL |
43 | .machine "z13" |
44 | .machinemode "zarch_nohighgprs" | |
45 | ||
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. */ | |
48 | ||
49 | vlvgb %v18,%r3,0 /* Generate vector which elements are all c. | |
50 | If c > 255, c will be truncated. */ | |
51 | vrepb %v18,%v18,0 | |
52 | ||
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. */ | |
56 | ||
57 | /* Align s to 16 byte. */ | |
58 | risbgn %r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */ | |
59 | lghi %r5,16 | |
60 | slr %r5,%r1 /* Compute bytes to 16bytes boundary. */ | |
61 | ||
62 | /* Find c in a 16byte aligned loop. */ | |
63 | .Lloop: | |
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. */ | |
67 | vl %v16,16(%r5,%r2) | |
68 | vfeebs %v17,%v16,%v18 | |
69 | jno .Lcharacter16 | |
70 | vl %v16,32(%r5,%r2) | |
71 | vfeebs %v17,%v16,%v18 | |
72 | jno .Lcharacter32 | |
73 | vl %v16,48(%r5,%r2) | |
74 | vfeebs %v17,%v16,%v18 | |
75 | jno .Lcharacter48 | |
76 | ||
77 | aghi %r5,64 | |
78 | j .Lloop /* No character found -> loop. */ | |
79 | ||
80 | /* Found character. */ | |
81 | .Lcharacter48: | |
82 | aghi %r5,16 | |
83 | .Lcharacter32: | |
84 | aghi %r5,16 | |
85 | .Lcharacter16: | |
86 | aghi %r5,16 | |
87 | .Lcharacter: | |
88 | vlgvb %r1,%v17,7 /* Load byte index of character. */ | |
89 | algr %r5,%r1 | |
90 | .Lend_found: | |
91 | la %r2,0(%r5,%r2) /* Return pointer to character. */ | |
92 | br %r14 | |
4c7b3cec SL |
93 | END(RAWMEMCHR_Z13) |
94 | ||
95 | # if ! HAVE_RAWMEMCHR_IFUNC | |
96 | strong_alias (RAWMEMCHR_Z13, __rawmemchr) | |
97 | weak_alias (__rawmemchr, rawmemchr) | |
98 | # endif | |
99 | ||
100 | # if ! HAVE_RAWMEMCHR_C && defined SHARED && IS_IN (libc) | |
101 | strong_alias (RAWMEMCHR_Z13, __GI___rawmemchr) | |
102 | # endif | |
103 | ||
104 | #endif /* HAVE_RAWMEMCHR_Z13 */ |