Skip to content

Commit 2227b97

Browse files
sayantnAmanieu
authored andcommitted
Implemented runtime detection of xop target-feature
1 parent d5c4073 commit 2227b97

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

crates/std_detect/src/detect/arch/x86.rs

+2
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,6 @@ features! {
245245
/// MOVBE (Move Data After Swapping Bytes)
246246
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ermsb: "ermsb";
247247
/// ERMSB, Enhanced REP MOVSB and STOSB
248+
@FEATURE: #[unstable(feature = "xop_target_feature", issue = "127208")] xop: "xop";
249+
/// XOP: eXtended Operations (AMD)
248250
}

crates/std_detect/src/detect/os/x86.rs

+1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
279279
// These features are available on AMD arch CPUs:
280280
enable(extended_proc_info_ecx, 6, Feature::sse4a);
281281
enable(extended_proc_info_ecx, 21, Feature::tbm);
282+
enable(extended_proc_info_ecx, 11, Feature::xop);
282283
}
283284
}
284285

crates/std_detect/tests/cpu-detection.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![cfg_attr(target_arch = "powerpc64", feature(stdarch_powerpc_feature_detection))]
66
#![cfg_attr(
77
any(target_arch = "x86", target_arch = "x86_64"),
8-
feature(sha512_sm_x86, x86_amx_intrinsics)
8+
feature(sha512_sm_x86, x86_amx_intrinsics, xop_target_feature)
99
)]
1010
#![allow(clippy::unwrap_used, clippy::use_debug, clippy::print_stdout)]
1111

@@ -264,6 +264,7 @@ fn x86_all() {
264264
println!("amx-int8: {:?}", is_x86_feature_detected!("amx-int8"));
265265
println!("amx-fp16: {:?}", is_x86_feature_detected!("amx-fp16"));
266266
println!("amx-complex: {:?}", is_x86_feature_detected!("amx-complex"));
267+
println!("xop: {:?}", is_x86_feature_detected!("xop"));
267268
}
268269

269270
#[test]

crates/std_detect/tests/x86-specific.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
stdarch_internal,
55
avx512_target_feature,
66
sha512_sm_x86,
7-
x86_amx_intrinsics
7+
x86_amx_intrinsics,
8+
xop_target_feature
89
)]
910

1011
extern crate cupid;
@@ -92,6 +93,7 @@ fn dump() {
9293
println!("amx-int8: {:?}", is_x86_feature_detected!("amx-int8"));
9394
println!("amx-fp16: {:?}", is_x86_feature_detected!("amx-fp16"));
9495
println!("amx-complex: {:?}", is_x86_feature_detected!("amx-complex"));
96+
println!("xop: {:?}", is_x86_feature_detected!("xop"));
9597
}
9698

9799
#[cfg(feature = "std_detect_env_override")]

0 commit comments

Comments
 (0)