std_detect: Support run-time detection of fp on aarch64 Windows
According to google/cpu_features, IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE)
returns whether fp is available.
a6bf4f9031/src/impl_aarch64_windows.c (L112-L113)
This commit is contained in:
parent
169d8d8c48
commit
8f9ed37be7
2 changed files with 12 additions and 13 deletions
|
|
@ -11,6 +11,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
|
|||
// The following Microsoft documents isn't updated for aarch64.
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
|
||||
// These are defined in winnt.h of Windows SDK
|
||||
const PF_ARM_VFP_32_REGISTERS_AVAILABLE: u32 = 18;
|
||||
const PF_ARM_NEON_INSTRUCTIONS_AVAILABLE: u32 = 19;
|
||||
const PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE: u32 = 30;
|
||||
const PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE: u32 = 31;
|
||||
|
|
@ -31,10 +32,14 @@ pub(crate) fn detect_features() -> cache::Initializer {
|
|||
}
|
||||
};
|
||||
|
||||
// Some features such Feature::fp may be supported on current CPU,
|
||||
// Some features may be supported on current CPU,
|
||||
// but no way to detect it by OS API.
|
||||
// Also, we require unsafe block for the extern "system" calls.
|
||||
unsafe {
|
||||
enable_feature(
|
||||
Feature::fp,
|
||||
IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE) != FALSE,
|
||||
);
|
||||
enable_feature(
|
||||
Feature::asimd,
|
||||
IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != FALSE,
|
||||
|
|
@ -61,18 +66,11 @@ pub(crate) fn detect_features() -> cache::Initializer {
|
|||
);
|
||||
// PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE means aes, sha1, sha2 and
|
||||
// pmull support
|
||||
enable_feature(
|
||||
Feature::aes,
|
||||
IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != FALSE,
|
||||
);
|
||||
enable_feature(
|
||||
Feature::pmull,
|
||||
IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != FALSE,
|
||||
);
|
||||
enable_feature(
|
||||
Feature::sha2,
|
||||
IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != FALSE,
|
||||
);
|
||||
let crypto =
|
||||
IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != FALSE;
|
||||
enable_feature(Feature::aes, crypto);
|
||||
enable_feature(Feature::pmull, crypto);
|
||||
enable_feature(Feature::sha2, crypto);
|
||||
}
|
||||
}
|
||||
value
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ fn aarch64_linux() {
|
|||
#[cfg(all(target_arch = "aarch64", target_os = "windows"))]
|
||||
fn aarch64_windows() {
|
||||
println!("asimd: {:?}", is_aarch64_feature_detected!("asimd"));
|
||||
println!("fp: {:?}", is_aarch64_feature_detected!("fp"));
|
||||
println!("crc: {:?}", is_aarch64_feature_detected!("crc"));
|
||||
println!("lse: {:?}", is_aarch64_feature_detected!("lse"));
|
||||
println!("dotprod: {:?}", is_aarch64_feature_detected!("dotprod"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue