Faster strlen on x64.
[glibc.git] / sysdeps / x86_64 / multiarch / ifunc-impl-list.c
blob05315fdd7a95e2f6441fc9c1f76cdb4ebbe9c44c
1 /* Enumerate available IFUNC implementations of a function. x86-64 version.
2 Copyright (C) 2012-2013 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/>. */
19 #include <assert.h>
20 #include <string.h>
21 #include <wchar.h>
22 #include <ifunc-impl-list.h>
23 #include "init-arch.h"
25 /* Maximum number of IFUNC implementations. */
26 #define MAX_IFUNC 4
28 /* Fill ARRAY of MAX elements with IFUNC implementations for function
29 NAME supported on target machine and return the number of valid
30 entries. */
32 size_t
33 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
34 size_t max)
36 assert (max >= MAX_IFUNC);
38 size_t i = 0;
40 /* Support sysdeps/x86_64/multiarch/memcmp.S. */
41 IFUNC_IMPL (i, name, memcmp,
42 IFUNC_IMPL_ADD (array, i, memcmp, HAS_SSE4_1,
43 __memcmp_sse4_1)
44 IFUNC_IMPL_ADD (array, i, memcmp, HAS_SSSE3, __memcmp_ssse3)
45 IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_sse2))
47 /* Support sysdeps/x86_64/multiarch/memmove_chk.S. */
48 IFUNC_IMPL (i, name, __memmove_chk,
49 IFUNC_IMPL_ADD (array, i, __memmove_chk, HAS_SSSE3,
50 __memmove_chk_ssse3_back)
51 IFUNC_IMPL_ADD (array, i, __memmove_chk, HAS_SSSE3,
52 __memmove_chk_ssse3)
53 IFUNC_IMPL_ADD (array, i, __memmove_chk, 1,
54 __memmove_chk_sse2))
56 /* Support sysdeps/x86_64/multiarch/memmove.S. */
57 IFUNC_IMPL (i, name, memmove,
58 IFUNC_IMPL_ADD (array, i, memmove, HAS_SSSE3,
59 __memmove_ssse3_back)
60 IFUNC_IMPL_ADD (array, i, memmove, HAS_SSSE3,
61 __memmove_ssse3)
62 IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_sse2))
64 /* Support sysdeps/x86_64/multiarch/rawmemchr.S. */
65 IFUNC_IMPL (i, name, rawmemchr,
66 IFUNC_IMPL_ADD (array, i, rawmemchr, HAS_SSE4_2,
67 __rawmemchr_sse42)
68 IFUNC_IMPL_ADD (array, i, rawmemchr, 1, __rawmemchr_sse2))
70 /* Support sysdeps/x86_64/multiarch/stpncpy.S. */
71 IFUNC_IMPL (i, name, stpncpy,
72 IFUNC_IMPL_ADD (array, i, stpncpy, HAS_SSSE3,
73 __stpncpy_ssse3)
74 IFUNC_IMPL_ADD (array, i, stpncpy, 1,
75 __stpncpy_sse2_unaligned)
76 IFUNC_IMPL_ADD (array, i, stpncpy, 1, __stpncpy_sse2))
78 /* Support sysdeps/x86_64/multiarch/stpcpy.S. */
79 IFUNC_IMPL (i, name, stpcpy,
80 IFUNC_IMPL_ADD (array, i, stpcpy, HAS_SSSE3, __stpcpy_ssse3)
81 IFUNC_IMPL_ADD (array, i, stpcpy, 1, __stpcpy_sse2_unaligned)
82 IFUNC_IMPL_ADD (array, i, stpcpy, 1, __stpcpy_sse2))
84 /* Support sysdeps/x86_64/multiarch/strcasecmp_l.S. */
85 IFUNC_IMPL (i, name, strcasecmp,
86 IFUNC_IMPL_ADD (array, i, strcasecmp, HAS_AVX,
87 __strcasecmp_avx)
88 IFUNC_IMPL_ADD (array, i, strcasecmp, HAS_SSE4_2,
89 __strcasecmp_sse42)
90 IFUNC_IMPL_ADD (array, i, strcasecmp, HAS_SSSE3,
91 __strcasecmp_ssse3)
92 IFUNC_IMPL_ADD (array, i, strcasecmp, 1, __strcasecmp_sse2))
94 /* Support sysdeps/x86_64/multiarch/strcasecmp_l.S. */
95 IFUNC_IMPL (i, name, strcasecmp_l,
96 IFUNC_IMPL_ADD (array, i, strcasecmp_l, HAS_AVX,
97 __strcasecmp_l_avx)
98 IFUNC_IMPL_ADD (array, i, strcasecmp_l, HAS_SSE4_2,
99 __strcasecmp_l_sse42)
100 IFUNC_IMPL_ADD (array, i, strcasecmp_l, HAS_SSSE3,
101 __strcasecmp_l_ssse3)
102 IFUNC_IMPL_ADD (array, i, strcasecmp_l, 1,
103 __strcasecmp_l_sse2))
105 /* Support sysdeps/x86_64/multiarch/strcasestr.c. */
106 IFUNC_IMPL (i, name, strcasestr,
107 IFUNC_IMPL_ADD (array, i, strcasestr, HAS_SSE4_2,
108 __strcasestr_sse42)
109 IFUNC_IMPL_ADD (array, i, strcasestr, 1, __strcasestr_sse2))
111 /* Support sysdeps/x86_64/multiarch/strcat.S. */
112 IFUNC_IMPL (i, name, strcat,
113 IFUNC_IMPL_ADD (array, i, strcat, HAS_SSSE3, __strcat_ssse3)
114 IFUNC_IMPL_ADD (array, i, strcat, 1, __strcat_sse2_unaligned)
115 IFUNC_IMPL_ADD (array, i, strcat, 1, __strcat_sse2))
117 /* Support sysdeps/x86_64/multiarch/strchr.S. */
118 IFUNC_IMPL (i, name, strchr,
119 IFUNC_IMPL_ADD (array, i, strchr, HAS_SSE4_2, __strchr_sse42)
120 IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_sse2_no_bsf)
121 IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_sse2))
123 /* Support sysdeps/x86_64/multiarch/strcmp.S. */
124 IFUNC_IMPL (i, name, strcmp,
125 IFUNC_IMPL_ADD (array, i, strcmp, HAS_SSE4_2, __strcmp_sse42)
126 IFUNC_IMPL_ADD (array, i, strcmp, HAS_SSSE3, __strcmp_ssse3)
127 IFUNC_IMPL_ADD (array, i, strcmp, 1, __strcmp_sse2))
129 /* Support sysdeps/x86_64/multiarch/strcpy.S. */
130 IFUNC_IMPL (i, name, strcpy,
131 IFUNC_IMPL_ADD (array, i, strcpy, HAS_SSSE3, __strcpy_ssse3)
132 IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcpy_sse2_unaligned)
133 IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcpy_sse2))
135 /* Support sysdeps/x86_64/multiarch/strcspn.S. */
136 IFUNC_IMPL (i, name, strcspn,
137 IFUNC_IMPL_ADD (array, i, strcspn, HAS_SSE4_2,
138 __strcspn_sse42)
139 IFUNC_IMPL_ADD (array, i, strcspn, 1, __strcspn_sse2))
141 /* Support sysdeps/x86_64/multiarch/strncase_l.S. */
142 IFUNC_IMPL (i, name, strncasecmp,
143 IFUNC_IMPL_ADD (array, i, strncasecmp, HAS_AVX,
144 __strncasecmp_avx)
145 IFUNC_IMPL_ADD (array, i, strncasecmp, HAS_SSE4_2,
146 __strncasecmp_sse42)
147 IFUNC_IMPL_ADD (array, i, strncasecmp, HAS_SSSE3,
148 __strncasecmp_ssse3)
149 IFUNC_IMPL_ADD (array, i, strncasecmp, 1,
150 __strncasecmp_sse2))
152 /* Support sysdeps/x86_64/multiarch/strncase_l.S. */
153 IFUNC_IMPL (i, name, strncasecmp_l,
154 IFUNC_IMPL_ADD (array, i, strncasecmp_l, HAS_AVX,
155 __strncasecmp_l_avx)
156 IFUNC_IMPL_ADD (array, i, strncasecmp_l, HAS_SSE4_2,
157 __strncasecmp_l_sse42)
158 IFUNC_IMPL_ADD (array, i, strncasecmp_l, HAS_SSSE3,
159 __strncasecmp_l_ssse3)
160 IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
161 __strncasecmp_l_sse2))
163 /* Support sysdeps/x86_64/multiarch/strncat.S. */
164 IFUNC_IMPL (i, name, strncat,
165 IFUNC_IMPL_ADD (array, i, strncat, HAS_SSSE3,
166 __strncat_ssse3)
167 IFUNC_IMPL_ADD (array, i, strncat, 1,
168 __strncat_sse2_unaligned)
169 IFUNC_IMPL_ADD (array, i, strncat, 1, __strncat_sse2))
171 /* Support sysdeps/x86_64/multiarch/strncpy.S. */
172 IFUNC_IMPL (i, name, strncpy,
173 IFUNC_IMPL_ADD (array, i, strncpy, HAS_SSSE3,
174 __strncpy_ssse3)
175 IFUNC_IMPL_ADD (array, i, strncpy, 1,
176 __strncpy_sse2_unaligned)
177 IFUNC_IMPL_ADD (array, i, strncpy, 1, __strncpy_sse2))
179 /* Support sysdeps/x86_64/multiarch/strpbrk.S. */
180 IFUNC_IMPL (i, name, strpbrk,
181 IFUNC_IMPL_ADD (array, i, strpbrk, HAS_SSE4_2,
182 __strpbrk_sse42)
183 IFUNC_IMPL_ADD (array, i, strpbrk, 1, __strpbrk_sse2))
185 /* Support sysdeps/x86_64/multiarch/strrchr.S. */
186 IFUNC_IMPL (i, name, strrchr,
187 IFUNC_IMPL_ADD (array, i, strrchr, HAS_SSE4_2,
188 __strrchr_sse42)
189 IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_sse2_no_bsf)
190 IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_sse2))
192 /* Support sysdeps/x86_64/multiarch/strspn.S. */
193 IFUNC_IMPL (i, name, strspn,
194 IFUNC_IMPL_ADD (array, i, strspn, HAS_SSE4_2, __strspn_sse42)
195 IFUNC_IMPL_ADD (array, i, strspn, 1, __strspn_sse2))
197 /* Support sysdeps/x86_64/multiarch/strstr-c.c. */
198 IFUNC_IMPL (i, name, strstr,
199 IFUNC_IMPL_ADD (array, i, strstr, HAS_SSE4_2, __strstr_sse42)
200 IFUNC_IMPL_ADD (array, i, strstr, 1, __strstr_sse2))
202 /* Support sysdeps/x86_64/multiarch/wcscpy.S. */
203 IFUNC_IMPL (i, name, wcscpy,
204 IFUNC_IMPL_ADD (array, i, wcscpy, HAS_SSSE3, __wcscpy_ssse3)
205 IFUNC_IMPL_ADD (array, i, wcscpy, 1, __wcscpy_sse2))
207 /* Support sysdeps/x86_64/multiarch/wmemcmp.S. */
208 IFUNC_IMPL (i, name, wmemcmp,
209 IFUNC_IMPL_ADD (array, i, wmemcmp, HAS_SSE4_1,
210 __wmemcmp_sse4_1)
211 IFUNC_IMPL_ADD (array, i, wmemcmp, HAS_SSSE3,
212 __wmemcmp_ssse3)
213 IFUNC_IMPL_ADD (array, i, wmemcmp, 1, __wmemcmp_sse2))
215 #ifdef SHARED
216 /* Support sysdeps/x86_64/multiarch/memcpy_chk.S. */
217 IFUNC_IMPL (i, name, __memcpy_chk,
218 IFUNC_IMPL_ADD (array, i, __memcpy_chk, HAS_SSSE3,
219 __memcpy_chk_ssse3_back)
220 IFUNC_IMPL_ADD (array, i, __memcpy_chk, HAS_SSSE3,
221 __memcpy_chk_ssse3)
222 IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1,
223 __memcpy_chk_sse2))
225 /* Support sysdeps/x86_64/multiarch/memcpy.S. */
226 IFUNC_IMPL (i, name, memcpy,
227 IFUNC_IMPL_ADD (array, i, memcpy, HAS_SSSE3,
228 __memcpy_ssse3_back)
229 IFUNC_IMPL_ADD (array, i, memcpy, HAS_SSSE3, __memcpy_ssse3)
230 IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_sse2))
232 /* Support sysdeps/x86_64/multiarch/mempcpy_chk.S. */
233 IFUNC_IMPL (i, name, __mempcpy_chk,
234 IFUNC_IMPL_ADD (array, i, __mempcpy_chk, HAS_SSSE3,
235 __mempcpy_chk_ssse3_back)
236 IFUNC_IMPL_ADD (array, i, __mempcpy_chk, HAS_SSSE3,
237 __mempcpy_chk_ssse3)
238 IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1,
239 __mempcpy_chk_sse2))
241 /* Support sysdeps/x86_64/multiarch/mempcpy.S. */
242 IFUNC_IMPL (i, name, mempcpy,
243 IFUNC_IMPL_ADD (array, i, mempcpy, HAS_SSSE3,
244 __mempcpy_ssse3_back)
245 IFUNC_IMPL_ADD (array, i, mempcpy, HAS_SSSE3,
246 __mempcpy_ssse3)
247 IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_sse2))
249 /* Support sysdeps/x86_64/multiarch/strncmp.S. */
250 IFUNC_IMPL (i, name, strncmp,
251 IFUNC_IMPL_ADD (array, i, strncmp, HAS_SSE4_2,
252 __strncmp_sse42)
253 IFUNC_IMPL_ADD (array, i, strncmp, HAS_SSSE3,
254 __strncmp_ssse3)
255 IFUNC_IMPL_ADD (array, i, strncmp, 1, __strncmp_sse2))
256 #endif
258 return i;