Implemented runtime detection of xop target-feature

This commit is contained in:
sayantn 2024-07-01 21:24:11 +05:30 committed by Amanieu d'Antras
parent d67ca1fe09
commit 94153c46e9
4 changed files with 8 additions and 2 deletions

View file

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

View file

@ -279,6 +279,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
// These features are available on AMD arch CPUs:
enable(extended_proc_info_ecx, 6, Feature::sse4a);
enable(extended_proc_info_ecx, 21, Feature::tbm);
enable(extended_proc_info_ecx, 11, Feature::xop);
}
}

View file

@ -5,7 +5,7 @@
#![cfg_attr(target_arch = "powerpc64", feature(stdarch_powerpc_feature_detection))]
#![cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
feature(sha512_sm_x86, x86_amx_intrinsics)
feature(sha512_sm_x86, x86_amx_intrinsics, xop_target_feature)
)]
#![allow(clippy::unwrap_used, clippy::use_debug, clippy::print_stdout)]
@ -264,6 +264,7 @@ fn x86_all() {
println!("amx-int8: {:?}", is_x86_feature_detected!("amx-int8"));
println!("amx-fp16: {:?}", is_x86_feature_detected!("amx-fp16"));
println!("amx-complex: {:?}", is_x86_feature_detected!("amx-complex"));
println!("xop: {:?}", is_x86_feature_detected!("xop"));
}
#[test]

View file

@ -4,7 +4,8 @@
stdarch_internal,
avx512_target_feature,
sha512_sm_x86,
x86_amx_intrinsics
x86_amx_intrinsics,
xop_target_feature
)]
extern crate cupid;
@ -92,6 +93,7 @@ fn dump() {
println!("amx-int8: {:?}", is_x86_feature_detected!("amx-int8"));
println!("amx-fp16: {:?}", is_x86_feature_detected!("amx-fp16"));
println!("amx-complex: {:?}", is_x86_feature_detected!("amx-complex"));
println!("xop: {:?}", is_x86_feature_detected!("xop"));
}
#[cfg(feature = "std_detect_env_override")]