Add CRC32 detection to arm32

armv8 has 32-bit mode, but it can use crc32 instruction sets even if 32-bit.
This commit is contained in:
Makoto Kato
2019-11-30 15:16:19 +09:00
committed by gnzlbg
parent 7c56404f1a
commit cca9a86637
3 changed files with 6 additions and 1 deletions

View File

@@ -14,4 +14,6 @@ features! {
/// ARM Advanced SIMD (NEON) - Aarch32 /// ARM Advanced SIMD (NEON) - Aarch32
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull"; @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
/// Polynomial Multiply /// Polynomial Multiply
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
/// CRC32 (Cyclic Redundancy Check)
} }

View File

@@ -15,10 +15,11 @@ pub(crate) fn detect_features() -> cache::Initializer {
// The values are part of the platform-specific [asm/hwcap.h][hwcap] // The values are part of the platform-specific [asm/hwcap.h][hwcap]
// //
// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h // [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm/include/uapi/asm/hwcap.h
if let Ok(auxv) = auxvec::auxv() { if let Ok(auxv) = auxvec::auxv() {
enable_feature(&mut value, Feature::neon, bit::test(auxv.hwcap, 12)); enable_feature(&mut value, Feature::neon, bit::test(auxv.hwcap, 12));
enable_feature(&mut value, Feature::pmull, bit::test(auxv.hwcap2, 1)); enable_feature(&mut value, Feature::pmull, bit::test(auxv.hwcap2, 1));
enable_feature(&mut value, Feature::crc, bit::test(auxv.hwcap2, 4));
return value; return value;
} }
@@ -29,6 +30,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
c.field("Features").has("neon") && !has_broken_neon(&c), c.field("Features").has("neon") && !has_broken_neon(&c),
); );
enable_feature(&mut value, Feature::pmull, c.field("Features").has("pmull")); enable_feature(&mut value, Feature::pmull, c.field("Features").has("pmull"));
enable_feature(&mut value, Feature::crc, c.field("Features").has("crc32"));
return value; return value;
} }
value value

View File

@@ -24,6 +24,7 @@ fn all() {
fn arm_linux() { fn arm_linux() {
println!("neon: {}", is_arm_feature_detected!("neon")); println!("neon: {}", is_arm_feature_detected!("neon"));
println!("pmull: {}", is_arm_feature_detected!("pmull")); println!("pmull: {}", is_arm_feature_detected!("pmull"));
println!("crc: {}", is_arm_feature_detected!("crc"));
} }
#[test] #[test]