| 1 | //! `x86_64`'s Streaming SIMD Extensions 4.2 (SSE4.2) |
| 2 | |
| 3 | #[cfg (test)] |
| 4 | use stdarch_test::assert_instr; |
| 5 | |
| 6 | #[allow (improper_ctypes)] |
| 7 | unsafe extern "C" { |
| 8 | #[link_name = "llvm.x86.sse42.crc32.64.64" ] |
| 9 | unsafefn crc32_64_64(crc: u64, v: u64) -> u64; |
| 10 | } |
| 11 | |
| 12 | /// Starting with the initial value in `crc`, return the accumulated |
| 13 | /// CRC32-C value for unsigned 64-bit integer `v`. |
| 14 | /// |
| 15 | /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_crc32_u64) |
| 16 | #[inline ] |
| 17 | #[target_feature (enable = "sse4.2" )] |
| 18 | #[cfg_attr (test, assert_instr(crc32))] |
| 19 | #[stable (feature = "simd_x86" , since = "1.27.0" )] |
| 20 | pub fn _mm_crc32_u64(crc: u64, v: u64) -> u64 { |
| 21 | unsafe { crc32_64_64(crc, v) } |
| 22 | } |
| 23 | |
| 24 | #[cfg (test)] |
| 25 | mod tests { |
| 26 | use crate::core_arch::arch::x86_64::*; |
| 27 | |
| 28 | use stdarch_test::simd_test; |
| 29 | |
| 30 | #[simd_test(enable = "sse4.2" )] |
| 31 | unsafe fn test_mm_crc32_u64() { |
| 32 | let crc = 0x7819dccd3e824; |
| 33 | let v = 0x2a22b845fed; |
| 34 | let i = _mm_crc32_u64(crc, v); |
| 35 | assert_eq!(i, 0xbb6cdc6c); |
| 36 | } |
| 37 | } |
| 38 | |