]>
Commit | Line | Data |
---|---|---|
f267e1c9 | 1 | /* Architecture-specific glibc-hwcaps subdirectories. x86 version. |
2b778ceb | 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. |
f267e1c9 FW |
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 | |
17 | <https://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #include <dl-hwcaps.h> | |
20 | #include <cpu-features.h> | |
21 | ||
22 | const char _dl_hwcaps_subdirs[] = "x86-64-v4:x86-64-v3:x86-64-v2"; | |
23 | enum { subdirs_count = 3 }; /* Number of components in _dl_hwcaps_subdirs. */ | |
24 | ||
25 | uint32_t | |
26 | _dl_hwcaps_subdirs_active (void) | |
27 | { | |
28 | int active = 0; | |
29 | ||
30 | /* Test in reverse preference order. */ | |
31 | ||
32 | /* x86-64-v2. */ | |
33 | if (!(CPU_FEATURE_USABLE (CMPXCHG16B) | |
34 | && CPU_FEATURE_USABLE (LAHF64_SAHF64) | |
35 | && CPU_FEATURE_USABLE (POPCNT) | |
36 | && CPU_FEATURE_USABLE (SSE3) | |
37 | && CPU_FEATURE_USABLE (SSE4_1) | |
38 | && CPU_FEATURE_USABLE (SSE4_2) | |
39 | && CPU_FEATURE_USABLE (SSSE3))) | |
40 | return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active); | |
41 | ++active; | |
42 | ||
43 | /* x86-64-v3. */ | |
44 | if (!(CPU_FEATURE_USABLE (AVX) | |
45 | && CPU_FEATURE_USABLE (AVX2) | |
46 | && CPU_FEATURE_USABLE (BMI1) | |
47 | && CPU_FEATURE_USABLE (BMI2) | |
48 | && CPU_FEATURE_USABLE (F16C) | |
49 | && CPU_FEATURE_USABLE (FMA) | |
50 | && CPU_FEATURE_USABLE (LZCNT) | |
51 | && CPU_FEATURE_USABLE (MOVBE) | |
52 | && CPU_FEATURE_USABLE (OSXSAVE))) | |
53 | return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active); | |
54 | ++active; | |
55 | ||
56 | /* x86-64-v4. */ | |
57 | if (!(CPU_FEATURE_USABLE (AVX512F) | |
58 | && CPU_FEATURE_USABLE (AVX512BW) | |
59 | && CPU_FEATURE_USABLE (AVX512CD) | |
60 | && CPU_FEATURE_USABLE (AVX512DQ) | |
61 | && CPU_FEATURE_USABLE (AVX512VL))) | |
62 | return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active); | |
63 | ++active; | |
64 | ||
65 | return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active); | |
66 | } |