1 /* Optimized strcspn implementation for PowerPC64.
2 Copyright (C) 2014-2015 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 <http://www.gnu.org/licenses/>. */
21 /* size_t [r3] strcspn (const char [r4] *s, const char [r5] *reject) */
23 EALIGN (strcspn, 4, 0)
26 /* The idea to speed up the algorithm is to create a lookup table
27 for fast check if input character should be considered. For ASCII
28 or ISO-8859-X character sets it has 256 positions. */
30 /* PPC64 ELF ABI stack is aligned to 16 bytes. */
32 /* Clear the table with 0 values */
51 cmpdi cr7,r10,0 /* reject[0] == '\0' ? */
53 beq cr7,L(finish_table) /* If reject[0] == '\0' skip */
55 /* Initialize the table as:
56 for (i=0; reject[i]; i++
57 table[reject[i]]] = 1 */
62 cmpdi cr7,r10,0 /* If reject[0] == '\0' finish */
65 /* set table[0] = 1 */
71 /* Unrool the loop 4 times and check using the table as:
75 if (table[input[i++]] == 1)
77 if (table[input[i++]] == 1)
79 if (table[input[i++]] == 1)
81 if (table[input[i++]] == 1)
127 libc_hidden_builtin_def (strcspn)