Skip to content

Commit 3d56d93

Browse files
committed
remove support for XCR0 registers
1 parent 498518f commit 3d56d93

File tree

10 files changed

+2
-378
lines changed

10 files changed

+2
-378
lines changed

Include/internal/pycore_cpuinfo.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ extern "C" {
2525

2626
#include "Python.h"
2727
#include "pycore_cpuinfo_cpuid_features.h"
28-
#include "pycore_cpuinfo_xsave_features.h"
2928

3029
typedef struct _Py_cpuid_features_s {
3130
uint32_t maxleaf;
@@ -101,21 +100,11 @@ typedef struct _Py_cpuid_features_s {
101100
_Py_CPUID_DECL_FLAG(xsave); // XSAVE/XRSTOR/XSETBV/XGETBV
102101
_Py_CPUID_DECL_FLAG(osxsave); // XSAVE is enabled by the OS
103102

104-
// --- XCR0 register bits -------------------------------------------------
105-
_Py_CPUID_DECL_FLAG(xcr0_sse);
106-
// On some Intel CPUs, it is possible for the CPU to support AVX2
107-
// instructions even though the underlying OS does not know about
108-
// AVX. In particular, only (SSE) XMM registers will be saved and
109-
// restored on context-switch, but not (AVX) YMM registers.
110-
_Py_CPUID_DECL_FLAG(xcr0_avx);
111-
_Py_CPUID_DECL_FLAG(xcr0_avx512_opmask);
112-
_Py_CPUID_DECL_FLAG(xcr0_avx512_zmm_hi256);
113-
_Py_CPUID_DECL_FLAG(xcr0_avx512_hi16_zmm);
114103
#undef _Py_CPUID_DECL_FLAG
115104
// Whenever a field is added or removed above, update the
116-
// number of fields (40) and adjust the bitsize of 'ready'
105+
// number of fields (35) and adjust the bitsize of 'ready'
117106
// so that the size of this structure is a multiple of 8.
118-
uint8_t ready; // set if the structure is ready for usage
107+
uint8_t ready: 5; // set if the structure is ready for usage
119108
} _Py_cpuid_features;
120109

121110
/*

Include/internal/pycore_cpuinfo_xsave_features.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

Makefile.pre.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,6 @@ PYTHON_HEADERS= \
12971297
$(srcdir)/Include/internal/pycore_context.h \
12981298
$(srcdir)/Include/internal/pycore_cpuinfo.h \
12991299
$(srcdir)/Include/internal/pycore_cpuinfo_cpuid_features.h \
1300-
$(srcdir)/Include/internal/pycore_cpuinfo_xsave_features.h \
13011300
$(srcdir)/Include/internal/pycore_critical_section.h \
13021301
$(srcdir)/Include/internal/pycore_crossinterp.h \
13031302
$(srcdir)/Include/internal/pycore_crossinterp_data_registry.h \
@@ -1938,9 +1937,6 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydt
19381937
$(MULTIARCH_CPPFLAGS) \
19391938
-o $@ $(srcdir)/Python/sysmodule.c
19401939

1941-
Python/cpuinfo.o: $(srcdir)/Python/cpuinfo.c Makefile
1942-
$(CC) -c $(PY_CORE_CFLAGS) @CORE_CPUINFO_CFLAGS@ -o $@ $(srcdir)/Python/cpuinfo.c
1943-
19441940
$(IO_OBJS): $(IO_H)
19451941

19461942
.PHONY: regen-pegen-metaparser

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@
231231
<ClInclude Include="..\Include\internal\pycore_context.h" />
232232
<ClInclude Include="..\Include\internal\pycore_cpuinfo.h" />
233233
<ClInclude Include="..\Include\internal\pycore_cpuinfo_cpuid_features.h" />
234-
<ClInclude Include="..\Include\internal\pycore_cpuinfo_xsave_features.h" />
235234
<ClInclude Include="..\Include\internal\pycore_critical_section.h" />
236235
<ClInclude Include="..\Include\internal\pycore_crossinterp.h" />
237236
<ClInclude Include="..\Include\internal\pycore_crossinterp_data_registry.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,6 @@
606606
<ClInclude Include="..\Include\internal\pycore_cpuinfo_cpuid_features.h">
607607
<Filter>Include\internal</Filter>
608608
</ClInclude>
609-
<ClInclude Include="..\Include\internal\pycore_cpuinfo_xsave_features.h">
610-
<Filter>Include\internal</Filter>
611-
</ClInclude>
612609
<ClInclude Include="..\Include\internal\pycore_critical_section.h">
613610
<Filter>Include\internal</Filter>
614611
</ClInclude>

Python/cpuinfo.c

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
#define HAS_CPUID_SUPPORT
1212
#if defined(__x86_64__) && defined(__GNUC__)
1313
# include <cpuid.h> // __cpuid_count()
14-
# include <immintrin.h> // _xgetbv()
1514
#elif defined(_M_X64) || defined(__amd64__) || defined(_M_AMD64)
1615
# include <intrin.h> // __cpuidex()
17-
# include <immintrin.h> // _xgetbv()
1816
#else
1917
# undef HAS_CPUID_SUPPORT
2018
#endif
@@ -24,13 +22,6 @@
2422
// corresponding flags or if we are not on an 64-bit platform we do not
2523
// even try to inspect the output of CPUID for those specific features.
2624
#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-
3425
#if defined(_Py_CAN_COMPILE_SIMD_SSE_INSTRUCTIONS) \
3526
|| defined(_Py_CAN_COMPILE_SIMD_SSE2_INSTRUCTIONS) \
3627
|| defined(_Py_CAN_COMPILE_SIMD_SSE3_INSTRUCTIONS) \
@@ -155,34 +146,6 @@ get_cpuid_info(uint32_t level /* input eax */,
155146
#endif
156147
}
157148

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-
186149
/* Highest Function Parameter and Manufacturer ID (LEAF=0, SUBLEAF=0). */
187150
static uint32_t
188151
detect_cpuid_maxleaf(void)
@@ -349,23 +312,6 @@ detect_cpuid_extended_features_L7S1(_Py_cpuid_features *flags,
349312
}
350313
#endif
351314

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-
369315
static void
370316
cpuid_features_finalize(_Py_cpuid_features *flags)
371317
{
@@ -460,12 +406,6 @@ _Py_cpuid_check_features(const _Py_cpuid_features *flags)
460406
\
461407
MACRO(xsave); \
462408
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); \
469409
} while (0)
470410

471411
void
@@ -530,7 +470,6 @@ cpuid_detect_l1_features(_Py_cpuid_features *flags)
530470
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
531471
get_cpuid_info(1, 0, &eax, &ebx, &ecx, &edx);
532472
detect_cpuid_features(flags, ecx, edx);
533-
detect_cpuid_xsave_state(flags);
534473
}
535474
}
536475
#else

Tools/cpuinfo/libcpuinfo/features/xsave.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)