4
4
use core:: arch:: x86:: * ;
5
5
#[ cfg( target_arch = "x86_64" ) ]
6
6
use core:: arch:: x86_64:: * ;
7
-
8
7
use core:: mem;
9
8
10
9
use crate :: detect:: { Feature , bit, cache} ;
@@ -42,12 +41,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
42
41
// 0x8000_0000]. - The vendor ID is stored in 12 u8 ascii chars,
43
42
// returned in EBX, EDX, and ECX (in that order):
44
43
let ( max_basic_leaf, vendor_id) = unsafe {
45
- let CpuidResult {
46
- eax : max_basic_leaf,
47
- ebx,
48
- ecx,
49
- edx,
50
- } = __cpuid ( 0 ) ;
44
+ let CpuidResult { eax : max_basic_leaf, ebx, ecx, edx } = __cpuid ( 0 ) ;
51
45
let vendor_id: [ [ u8 ; 4 ] ; 3 ] = [ ebx. to_ne_bytes ( ) , edx. to_ne_bytes ( ) , ecx. to_ne_bytes ( ) ] ;
52
46
let vendor_id: [ u8 ; 12 ] = mem:: transmute ( vendor_id) ;
53
47
( max_basic_leaf, vendor_id)
@@ -60,11 +54,8 @@ pub(crate) fn detect_features() -> cache::Initializer {
60
54
61
55
// EAX = 1, ECX = 0: Queries "Processor Info and Feature Bits";
62
56
// Contains information about most x86 features.
63
- let CpuidResult {
64
- ecx : proc_info_ecx,
65
- edx : proc_info_edx,
66
- ..
67
- } = unsafe { __cpuid ( 0x0000_0001_u32 ) } ;
57
+ let CpuidResult { ecx : proc_info_ecx, edx : proc_info_edx, .. } =
58
+ unsafe { __cpuid ( 0x0000_0001_u32 ) } ;
68
59
69
60
// EAX = 7: Queries "Extended Features";
70
61
// Contains information about bmi,bmi2, and avx2 support.
@@ -76,11 +67,8 @@ pub(crate) fn detect_features() -> cache::Initializer {
76
67
extended_features_edx_leaf_1,
77
68
) = if max_basic_leaf >= 7 {
78
69
let CpuidResult { ebx, ecx, edx, .. } = unsafe { __cpuid ( 0x0000_0007_u32 ) } ;
79
- let CpuidResult {
80
- eax : eax_1,
81
- edx : edx_1,
82
- ..
83
- } = unsafe { __cpuid_count ( 0x0000_0007_u32 , 0x0000_0001_u32 ) } ;
70
+ let CpuidResult { eax : eax_1, edx : edx_1, .. } =
71
+ unsafe { __cpuid_count ( 0x0000_0007_u32 , 0x0000_0001_u32 ) } ;
84
72
( ebx, ecx, edx, eax_1, edx_1)
85
73
} else {
86
74
( 0 , 0 , 0 , 0 , 0 ) // CPUID does not support "Extended Features"
@@ -89,10 +77,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
89
77
// EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported
90
78
// - EAX returns the max leaf value for extended information, that is,
91
79
// `cpuid` calls in range [0x8000_0000; u32::MAX]:
92
- let CpuidResult {
93
- eax : extended_max_basic_leaf,
94
- ..
95
- } = unsafe { __cpuid ( 0x8000_0000_u32 ) } ;
80
+ let CpuidResult { eax : extended_max_basic_leaf, .. } = unsafe { __cpuid ( 0x8000_0000_u32 ) } ;
96
81
97
82
// EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature
98
83
// Bits"
@@ -208,10 +193,8 @@ pub(crate) fn detect_features() -> cache::Initializer {
208
193
// Processor Extended State Enumeration Sub-leaf (EAX = 0DH,
209
194
// ECX = 1):
210
195
if max_basic_leaf >= 0xd {
211
- let CpuidResult {
212
- eax : proc_extended_state1_eax,
213
- ..
214
- } = unsafe { __cpuid_count ( 0xd_u32 , 1 ) } ;
196
+ let CpuidResult { eax : proc_extended_state1_eax, .. } =
197
+ unsafe { __cpuid_count ( 0xd_u32 , 1 ) } ;
215
198
enable ( proc_extended_state1_eax, 0 , Feature :: xsaveopt) ;
216
199
enable ( proc_extended_state1_eax, 1 , Feature :: xsavec) ;
217
200
enable ( proc_extended_state1_eax, 3 , Feature :: xsaves) ;
@@ -269,10 +252,8 @@ pub(crate) fn detect_features() -> cache::Initializer {
269
252
enable ( extended_features_edx_leaf_1, 8 , Feature :: amx_complex) ;
270
253
271
254
if max_basic_leaf >= 0x1e {
272
- let CpuidResult {
273
- eax : amx_feature_flags_eax,
274
- ..
275
- } = unsafe { __cpuid_count ( 0x1e_u32 , 1 ) } ;
255
+ let CpuidResult { eax : amx_feature_flags_eax, .. } =
256
+ unsafe { __cpuid_count ( 0x1e_u32 , 1 ) } ;
276
257
277
258
enable ( amx_feature_flags_eax, 4 , Feature :: amx_fp8) ;
278
259
enable ( amx_feature_flags_eax, 5 , Feature :: amx_transpose) ;
0 commit comments