Skip to content

Commit

Permalink
Remove asm for crc32cb instruction (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
zowens authored Feb 8, 2024
1 parent 4bd4615 commit 6b46ba3
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/hw_aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::hw_tables;
use crate::util::{self, U64Le};

use std::arch::aarch64 as simd;
use std::arch::asm;

pub unsafe fn crc32c(crci: u32, buffer: &[u8]) -> u32 {
let mut crc0 = !crci;
Expand Down Expand Up @@ -46,18 +44,10 @@ pub unsafe fn crc32c(crci: u32, buffer: &[u8]) -> u32 {

#[inline]
#[target_feature(enable = "crc")]
pub unsafe fn __crc32b(mut crc: u32, data: u8) -> u32 {
asm!(
"crc32cb {0:w}, {0:w}, {1:w}",
inout(reg) crc,
in(reg) data,
);
crc
}

#[inline]
unsafe fn crc_u8(crc: u32, buffer: &[u8]) -> u32 {
buffer.iter().fold(crc, |crc, &next| __crc32b(crc, next))
buffer
.iter()
.fold(crc, |crc, &next| simd::__crc32cb(crc, next))
}

#[inline(always)]
Expand Down

0 comments on commit 6b46ba3

Please sign in to comment.