PowerPC: Influence cpu/arch hwcap features via GLIBC_TUNABLES
[glibc.git] / sysdeps / powerpc / powerpc32 / power4 / multiarch / ifunc-impl-list.c
blob986c37d71ee201ea0b1cfff6f385a954bc7367d5
1 /* Enumerate available IFUNC implementations of a function. PowerPC32 version.
2 Copyright (C) 2013-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 <assert.h>
20 #include <string.h>
21 #include <wchar.h>
22 #include <ldsodefs.h>
23 #include <ifunc-impl-list.h>
24 #include <cpu-features.h>
26 size_t
27 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
28 size_t max)
30 size_t i = max;
32 const struct cpu_features *features = &GLRO(dl_powerpc_cpu_features);
33 unsigned long int hwcap = features->hwcap;
34 /* hwcap contains only the latest supported ISA, the code checks which is
35 and fills the previous supported ones. */
36 if (hwcap & PPC_FEATURE_ARCH_2_06)
37 hwcap |= PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_POWER5_PLUS |
38 PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
39 else if (hwcap & PPC_FEATURE_ARCH_2_05)
40 hwcap |= PPC_FEATURE_POWER5_PLUS | PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
41 else if (hwcap & PPC_FEATURE_POWER5_PLUS)
42 hwcap |= PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
43 else if (hwcap & PPC_FEATURE_POWER5)
44 hwcap |= PPC_FEATURE_POWER4;
46 #ifdef SHARED
47 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c. */
48 IFUNC_IMPL (i, name, memcpy,
49 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
50 __memcpy_power7)
51 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
52 __memcpy_a2)
53 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
54 __memcpy_power6)
55 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_CELL_BE,
56 __memcpy_cell)
57 IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
59 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memmove.c. */
60 IFUNC_IMPL (i, name, memmove,
61 IFUNC_IMPL_ADD (array, i, memmove, hwcap & PPC_FEATURE_HAS_VSX,
62 __memmove_power7)
63 IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ppc))
65 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memset.c. */
66 IFUNC_IMPL (i, name, memset,
67 IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_HAS_VSX,
68 __memset_power7)
69 IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_05,
70 __memset_power6)
71 IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc))
73 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strlen.c. */
74 IFUNC_IMPL (i, name, strlen,
75 IFUNC_IMPL_ADD (array, i, strlen, hwcap & PPC_FEATURE_HAS_VSX,
76 __strlen_power7)
77 IFUNC_IMPL_ADD (array, i, strlen, 1,
78 __strlen_ppc))
80 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strnlen.c. */
81 IFUNC_IMPL (i, name, strnlen,
82 IFUNC_IMPL_ADD (array, i, strnlen, hwcap & PPC_FEATURE_HAS_VSX,
83 __strnlen_power7)
84 IFUNC_IMPL_ADD (array, i, strnlen, 1,
85 __strnlen_ppc))
86 #endif
88 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memcmp.c. */
89 IFUNC_IMPL (i, name, memcmp,
90 IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
91 __memcmp_power7)
92 IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ppc))
94 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c. */
95 IFUNC_IMPL (i, name, mempcpy,
96 IFUNC_IMPL_ADD (array, i, mempcpy,
97 hwcap & PPC_FEATURE_HAS_VSX,
98 __mempcpy_power7)
99 IFUNC_IMPL_ADD (array, i, mempcpy, 1,
100 __mempcpy_ppc))
102 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memchr.c. */
103 IFUNC_IMPL (i, name, memchr,
104 IFUNC_IMPL_ADD (array, i, memchr,
105 hwcap & PPC_FEATURE_HAS_VSX,
106 __memchr_power7)
107 IFUNC_IMPL_ADD (array, i, memchr, 1,
108 __memchr_ppc))
110 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memrchr.c. */
111 IFUNC_IMPL (i, name, memrchr,
112 IFUNC_IMPL_ADD (array, i, memrchr,
113 hwcap & PPC_FEATURE_HAS_VSX,
114 __memrchr_power7)
115 IFUNC_IMPL_ADD (array, i, memrchr, 1,
116 __memrchr_ppc))
118 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr.c. */
119 IFUNC_IMPL (i, name, rawmemchr,
120 IFUNC_IMPL_ADD (array, i, rawmemchr,
121 hwcap & PPC_FEATURE_HAS_VSX,
122 __rawmemchr_power7)
123 IFUNC_IMPL_ADD (array, i, rawmemchr, 1,
124 __rawmemchr_ppc))
126 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strcasecmp.c. */
127 IFUNC_IMPL (i, name, strcasecmp,
128 IFUNC_IMPL_ADD (array, i, strcasecmp,
129 hwcap & PPC_FEATURE_HAS_VSX,
130 __strcasecmp_power7)
131 IFUNC_IMPL_ADD (array, i, strcasecmp, 1, __strcasecmp_ppc))
133 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strcasecmp_l.c. */
134 IFUNC_IMPL (i, name, strcasecmp_l,
135 IFUNC_IMPL_ADD (array, i, strcasecmp_l,
136 hwcap & PPC_FEATURE_HAS_VSX,
137 __strcasecmp_l_power7)
138 IFUNC_IMPL_ADD (array, i, strcasecmp_l, 1,
139 __strcasecmp_l_ppc))
141 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strncase.c. */
142 IFUNC_IMPL (i, name, strncasecmp,
143 IFUNC_IMPL_ADD (array, i, strncasecmp,
144 hwcap & PPC_FEATURE_HAS_VSX,
145 __strncasecmp_power7)
146 IFUNC_IMPL_ADD (array, i, strncasecmp, 1, __strncasecmp_ppc))
148 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strncase_l.c. */
149 IFUNC_IMPL (i, name, strncasecmp_l,
150 IFUNC_IMPL_ADD (array, i, strncasecmp_l,
151 hwcap & PPC_FEATURE_HAS_VSX,
152 __strncasecmp_l_power7)
153 IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
154 __strncasecmp_l_ppc))
156 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul.c. */
157 IFUNC_IMPL (i, name, strchrnul,
158 IFUNC_IMPL_ADD (array, i, strchrnul,
159 hwcap & PPC_FEATURE_HAS_VSX,
160 __strchrnul_power7)
161 IFUNC_IMPL_ADD (array, i, strchrnul, 1,
162 __strchrnul_ppc))
164 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strchr.c. */
165 IFUNC_IMPL (i, name, strchr,
166 IFUNC_IMPL_ADD (array, i, strchr,
167 hwcap & PPC_FEATURE_HAS_VSX,
168 __strchr_power7)
169 IFUNC_IMPL_ADD (array, i, strchr, 1,
170 __strchr_ppc))
172 return 0;