Skip to content

Commit 7dc6b15

Browse files
committed
Implemented runtime detection of xop target-feature
1 parent d5ba463 commit 7dc6b15

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,6 @@ features! {
221221
/// MOVBE (Move Data After Swapping Bytes)
222222
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ermsb: "ermsb";
223223
/// ERMSB, Enhanced REP MOVSB and STOSB
224+
@FEATURE: #[unstable(feature = "xop_target_feature", issue = "127208")] xop: "xop";
225+
/// XOP: eXtended Operations (AMD)
224226
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
264264
// These features are available on AMD arch CPUs:
265265
enable(extended_proc_info_ecx, 6, Feature::sse4a);
266266
enable(extended_proc_info_ecx, 21, Feature::tbm);
267+
enable(extended_proc_info_ecx, 11, Feature::xop);
267268
}
268269
}
269270

crates/std_detect/tests/cpu-detection.rs

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#![cfg_attr(target_arch = "arm", feature(stdarch_arm_feature_detection))]
44
#![cfg_attr(target_arch = "powerpc", feature(stdarch_powerpc_feature_detection))]
55
#![cfg_attr(target_arch = "powerpc64", feature(stdarch_powerpc_feature_detection))]
6+
#![cfg_attr(
7+
any(target_arch = "x86", target_arch = "x86_64"),
8+
feature(xop_target_feature)
9+
)]
610
#![allow(clippy::unwrap_used, clippy::use_debug, clippy::print_stdout)]
711

812
#[cfg_attr(
@@ -252,6 +256,7 @@ fn x86_all() {
252256
println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt"));
253257
println!("xsaves: {:?}", is_x86_feature_detected!("xsaves"));
254258
println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
259+
println!("xop: {:?}", is_x86_feature_detected!("xop"));
255260
}
256261

257262
#[test]

crates/std_detect/tests/x86-specific.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]
22
#![allow(internal_features)]
3-
#![feature(stdarch_internal, avx512_target_feature)]
3+
#![feature(stdarch_internal, avx512_target_feature, xop_target_feature)]
44

55
extern crate cupid;
66
#[macro_use]
@@ -79,6 +79,7 @@ fn dump() {
7979
"avxvnniint16: {:?}",
8080
is_x86_feature_detected!("avxvnniint16")
8181
);
82+
println!("xop: {:?}", is_x86_feature_detected!("xop"));
8283
}
8384

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

0 commit comments

Comments
 (0)