Enable AArch64 processor feature detection unconditionally (#4034)

std::arch::is_aarch64_feature_detected!() is now part of stable
Rust, so we can always use it.

Copyright (c) 2022, Arm Limited.
This commit is contained in:
Anton Kirilov
2022-04-28 15:27:32 +01:00
committed by GitHub
parent b69fede72f
commit a1e4b4b521
4 changed files with 43 additions and 18 deletions

View File

@@ -702,7 +702,7 @@ impl<'a> Arbitrary<'a> for CodegenSettings {
// print a warning and return an error because this fuzz
// input must be discarded.
#[cfg(target_arch = $arch)]
if enable && !std::$test!($std) {
if enable && !std::arch::$test!($std) {
log::warn!("want to enable clif `{}` but host doesn't support it",
$clif);
return Err(arbitrary::Error::EmptyChoose)
@@ -752,6 +752,11 @@ impl<'a> Arbitrary<'a> for CodegenSettings {
std:"avx512vl" => clif:"has_avx512vl" ratio: 1 in 1000,
std:"avx512vbmi" => clif:"has_avx512vbmi" ratio: 1 in 1000,
},
"aarch64" => {
test: is_aarch64_feature_detected,
std: "lse" => clif: "has_lse",
},
};
return Ok(CodegenSettings::Target {
target: target_lexicon::Triple::host().to_string(),

View File

@@ -388,9 +388,23 @@ impl Engine {
))
}
}
let enabled;
#[cfg(target_arch = "aarch64")]
{
enabled = match flag {
"has_lse" => Some(std::arch::is_aarch64_feature_detected!("lse")),
// fall through to the very bottom to indicate that support is
// not enabled to test whether this feature is enabled on the
// host.
_ => None,
};
}
#[cfg(target_arch = "x86_64")]
{
let enabled = match flag {
enabled = match flag {
"has_sse3" => Some(std::is_x86_feature_detected!("sse3")),
"has_ssse3" => Some(std::is_x86_feature_detected!("ssse3")),
"has_sse41" => Some(std::is_x86_feature_detected!("sse4.1")),
@@ -412,18 +426,25 @@ impl Engine {
// host.
_ => None,
};
match enabled {
Some(true) => return Ok(()),
Some(false) => {
return Err(format!(
"compilation setting {:?} is enabled but not available on the host",
flag
))
}
// fall through
None => {}
}
}
#[cfg(not(any(target_arch = "aarch64", target_arch = "x86_64")))]
{
enabled = None;
}
match enabled {
Some(true) => return Ok(()),
Some(false) => {
return Err(format!(
"compilation setting {:?} is enabled, but not available on the host",
flag
))
}
// fall through
None => {}
}
Err(format!(
"cannot test if target-specific flag {:?} is available at runtime",
flag