Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve feature detect for combined aarch64 features #1527

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions crates/std_detect/src/detect/arch/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ features! {
/// * `"fhm"` - FEAT_FHM
/// * `"dit"` - FEAT_DIT
/// * `"flagm"` - FEAT_FLAGM
/// * `"ssbs"` - FEAT_SSBS
/// * `"ssbs"` - FEAT_SSBS & FEAT_SSBS2
/// * `"sb"` - FEAT_SB
/// * `"paca"` - FEAT_PAuth (address authentication)
/// * `"pacg"` - FEAT_Pauth (generic authentication)
Expand All @@ -48,10 +48,10 @@ features! {
/// * `"bf16"` - FEAT_BF16
/// * `"rand"` - FEAT_RNG
/// * `"bti"` - FEAT_BTI
/// * `"mte"` - FEAT_MTE
/// * `"mte"` - FEAT_MTE & FEAT_MTE2
/// * `"jsconv"` - FEAT_JSCVT
/// * `"fcma"` - FEAT_FCMA
/// * `"aes"` - FEAT_AES
/// * `"aes"` - FEAT_AES & FEAT_PMULL
/// * `"sha2"` - FEAT_SHA1 & FEAT_SHA256
/// * `"sha3"` - FEAT_SHA512 & FEAT_SHA3
/// * `"sm4"` - FEAT_SM3 & FEAT_SM4
Expand All @@ -70,7 +70,8 @@ features! {
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] asimd: "neon";
/// FEAT_AdvSIMD (Advanced SIMD/NEON)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] pmull: "pmull";
/// FEAT_PMULL (Polynomial Multiply)
implied by target_features: ["aes"];
/// FEAT_PMULL (Polynomial Multiply) - Implied by `aes` target_feature
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fp: "fp";
implied by target_features: ["neon"];
/// FEAT_FP (Floating point support) - Implied by `neon` target_feature
Expand Down Expand Up @@ -101,7 +102,7 @@ features! {
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] flagm: "flagm";
/// FEAT_FLAGM (flag manipulation instructions)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] ssbs: "ssbs";
/// FEAT_SSBS (speculative store bypass safe)
/// FEAT_SSBS & FEAT_SSBS2 (speculative store bypass safe)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sb: "sb";
/// FEAT_SB (speculation barrier)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] paca: "paca";
Expand Down Expand Up @@ -137,13 +138,13 @@ features! {
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] bti: "bti";
/// FEAT_BTI (Branch Target Identification)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] mte: "mte";
/// FEAT_MTE (Memory Tagging Extension)
/// FEAT_MTE & FEAT_MTE2 (Memory Tagging Extension)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] jsconv: "jsconv";
/// FEAT_JSCVT (JavaScript float conversion instructions)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fcma: "fcma";
/// FEAT_FCMA (float complex number operations)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] aes: "aes";
/// FEAT_AES (AES instructions)
/// FEAT_AES (AES SIMD instructions) & FEAT_PMULL (PMULL{2}, 64-bit operand variants)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sha2: "sha2";
/// FEAT_SHA1 & FEAT_SHA256 (SHA1 & SHA2-256 instructions)
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sha3: "sha3";
Expand Down
2 changes: 1 addition & 1 deletion crates/std_detect/src/detect/os/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(crate) fn parse_system_registers(
// supported, it also requires half-float support:
enable_feature(Feature::asimd, fp && asimd && (!fphp | asimdhp));
// SIMD extensions require SIMD support:
enable_feature(Feature::aes, asimd && bits_shift(aa64isar0, 7, 4) >= 1);
enable_feature(Feature::aes, asimd && bits_shift(aa64isar0, 7, 4) >= 2);
let sha1 = bits_shift(aa64isar0, 11, 8) >= 1;
let sha2 = bits_shift(aa64isar0, 15, 12) >= 1;
enable_feature(Feature::sha2, asimd && sha1 && sha2);
Expand Down
3 changes: 2 additions & 1 deletion crates/std_detect/src/detect/os/linux/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ impl AtHwcap {
let asimd = self.fp && self.asimd && (!self.fphp | self.asimdhp);
enable_feature(Feature::asimd, asimd);
// Cryptographic extensions require ASIMD
enable_feature(Feature::aes, self.aes && asimd);
// AES also covers FEAT_PMULL
enable_feature(Feature::aes, self.aes && self.pmull && asimd);
enable_feature(Feature::sha2, self.sha1 && self.sha2 && asimd);
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/std_detect/src/detect/os/macos/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
enable_feature(Feature::bf16, bf16);
enable_feature(Feature::bti, bti);
enable_feature(Feature::fcma, fcma);
enable_feature(Feature::aes, aes);
enable_feature(Feature::aes, aes && pmull);
enable_feature(Feature::jsconv, jsconv);
enable_feature(Feature::sha2, sha1 && sha2 && asimd);
enable_feature(Feature::sha3, sha512 && sha3 && asimd);
Expand Down