|
11 | 11 | #define HAS_CPUID_SUPPORT |
12 | 12 | #if defined(__x86_64__) && defined(__GNUC__) |
13 | 13 | # include <cpuid.h> // __cpuid_count() |
14 | | -# include <immintrin.h> // _xgetbv() |
15 | 14 | #elif defined(_M_X64) || defined(__amd64__) || defined(_M_AMD64) |
16 | 15 | # include <intrin.h> // __cpuidex() |
17 | | -# include <immintrin.h> // _xgetbv() |
18 | 16 | #else |
19 | 17 | # undef HAS_CPUID_SUPPORT |
20 | 18 | #endif |
|
24 | 22 | // corresponding flags or if we are not on an 64-bit platform we do not |
25 | 23 | // even try to inspect the output of CPUID for those specific features. |
26 | 24 | #ifdef HAS_CPUID_SUPPORT |
27 | | -#if defined(_Py_CPUINFO_USE_XGETBV_FUNC) \ |
28 | | - || defined(_Py_CPUINFO_USE_XGETBV_OPCODE) |
29 | | -# define HAS_XGETBV_SUPPORT |
30 | | -#endif |
31 | | - |
32 | | -#undef HAS_XGETBV_SUPPORT |
33 | | - |
34 | 25 | #if defined(_Py_CAN_COMPILE_SIMD_SSE_INSTRUCTIONS) \ |
35 | 26 | || defined(_Py_CAN_COMPILE_SIMD_SSE2_INSTRUCTIONS) \ |
36 | 27 | || defined(_Py_CAN_COMPILE_SIMD_SSE3_INSTRUCTIONS) \ |
@@ -155,34 +146,6 @@ get_cpuid_info(uint32_t level /* input eax */, |
155 | 146 | #endif |
156 | 147 | } |
157 | 148 |
|
158 | | -#if defined(HAS_XGETBV_SUPPORT) && defined(SHOULD_PARSE_CPUID_L1) |
159 | | -static uint64_t /* should only be used after calling cpuid(1, 0, ...) */ |
160 | | -get_xgetbv(uint32_t index) |
161 | | -{ |
162 | | - assert(index == 0); // only XCR0 is supported for now |
163 | | -#if defined(_Py_CPUINFO_USE_XGETBV_FUNC) |
164 | | - /* directly use the compiler's helper if -mxsave is available */ |
165 | | - return (uint64_t)_xgetbv(index); |
166 | | -#elif defined(__x86_64__) && defined(__GNUC__) |
167 | | - uint32_t eax = 0, edx = 0; |
168 | | - __asm__ volatile( |
169 | | - /* raw opcode for xgetbv for compatibility with older toolchains */ |
170 | | - ".byte 0x0f, 0x01, 0xd0" |
171 | | - : "=a" (eax), "=d" (edx) |
172 | | - : "c" (index) |
173 | | - ); |
174 | | - return ((uint64_t)edx << 32) | eax; |
175 | | -#elif defined(_M_X64) |
176 | | - return (uint64_t)_xgetbv(index); |
177 | | -#else |
178 | | - (void)index; |
179 | | - return 0; |
180 | | -#endif |
181 | | -} |
182 | | -#else |
183 | | -#define get_xgetbv(_INDEX) 0 |
184 | | -#endif |
185 | | - |
186 | 149 | /* Highest Function Parameter and Manufacturer ID (LEAF=0, SUBLEAF=0). */ |
187 | 150 | static uint32_t |
188 | 151 | detect_cpuid_maxleaf(void) |
@@ -349,23 +312,6 @@ detect_cpuid_extended_features_L7S1(_Py_cpuid_features *flags, |
349 | 312 | } |
350 | 313 | #endif |
351 | 314 |
|
352 | | -#ifdef SHOULD_PARSE_CPUID_L1 |
353 | | -static void /* should only be used after calling cpuid(1, 0, ...) */ |
354 | | -detect_cpuid_xsave_state(_Py_cpuid_features *flags) |
355 | | -{ |
356 | | - assert(flags->ready == 0); |
357 | | - assert(flags->maxleaf >= 1); |
358 | | - (void)flags; |
359 | | - // Keep the ordering and newlines as they are declared in the structure. |
360 | | - uint64_t xcr0 = flags->xsave && flags->osxsave ? get_xgetbv(0) : 0; |
361 | | - flags->xcr0_sse = XSAVE_CHECK_REG(xcr0, XCR0_SSE); |
362 | | - flags->xcr0_avx = XSAVE_CHECK_REG(xcr0, XCR0_AVX); |
363 | | - flags->xcr0_avx512_opmask = XSAVE_CHECK_REG(xcr0, XCR0_AVX512_OPMASK); |
364 | | - flags->xcr0_avx512_zmm_hi256 = XSAVE_CHECK_REG(xcr0, XCR0_AVX512_ZMM_HI256); |
365 | | - flags->xcr0_avx512_hi16_zmm = XSAVE_CHECK_REG(xcr0, XCR0_AVX512_HI16_ZMM); |
366 | | -} |
367 | | -#endif |
368 | | - |
369 | 315 | static void |
370 | 316 | cpuid_features_finalize(_Py_cpuid_features *flags) |
371 | 317 | { |
@@ -460,12 +406,6 @@ _Py_cpuid_check_features(const _Py_cpuid_features *flags) |
460 | 406 | \ |
461 | 407 | MACRO(xsave); \ |
462 | 408 | MACRO(osxsave); \ |
463 | | - \ |
464 | | - MACRO(xcr0_sse); \ |
465 | | - MACRO(xcr0_avx); \ |
466 | | - MACRO(xcr0_avx512_opmask); \ |
467 | | - MACRO(xcr0_avx512_zmm_hi256); \ |
468 | | - MACRO(xcr0_avx512_hi16_zmm); \ |
469 | 409 | } while (0) |
470 | 410 |
|
471 | 411 | void |
@@ -530,7 +470,6 @@ cpuid_detect_l1_features(_Py_cpuid_features *flags) |
530 | 470 | uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; |
531 | 471 | get_cpuid_info(1, 0, &eax, &ebx, &ecx, &edx); |
532 | 472 | detect_cpuid_features(flags, ecx, edx); |
533 | | - detect_cpuid_xsave_state(flags); |
534 | 473 | } |
535 | 474 | } |
536 | 475 | #else |
|
0 commit comments