]>
git.proxmox.com Git - rustc.git/blob - src/stdsimd/crates/core_arch/src/aarch64/crc.rs
2 #[link_name = "llvm.aarch64.crc32b"]
3 fn crc32b_(crc
: u32, data
: u32) -> u32;
4 #[link_name = "llvm.aarch64.crc32h"]
5 fn crc32h_(crc
: u32, data
: u32) -> u32;
6 #[link_name = "llvm.aarch64.crc32w"]
7 fn crc32w_(crc
: u32, data
: u32) -> u32;
8 #[link_name = "llvm.aarch64.crc32x"]
9 fn crc32x_(crc
: u32, data
: u64) -> u32;
11 #[link_name = "llvm.aarch64.crc32cb"]
12 fn crc32cb_(crc
: u32, data
: u32) -> u32;
13 #[link_name = "llvm.aarch64.crc32ch"]
14 fn crc32ch_(crc
: u32, data
: u32) -> u32;
15 #[link_name = "llvm.aarch64.crc32cw"]
16 fn crc32cw_(crc
: u32, data
: u32) -> u32;
17 #[link_name = "llvm.aarch64.crc32cx"]
18 fn crc32cx_(crc
: u32, data
: u64) -> u32;
22 use stdsimd_test
::assert_instr
;
24 /// CRC32 single round checksum for bytes (8 bits).
26 #[target_feature(enable = "crc")]
27 #[cfg_attr(test, assert_instr(crc32b))]
28 pub unsafe fn __crc32b(crc
: u32, data
: u8) -> u32 {
29 crc32b_(crc
, data
as u32)
32 /// CRC32 single round checksum for half words (16 bits).
34 #[target_feature(enable = "crc")]
35 #[cfg_attr(test, assert_instr(crc32h))]
36 pub unsafe fn __crc32h(crc
: u32, data
: u16) -> u32 {
37 crc32h_(crc
, data
as u32)
40 /// CRC32 single round checksum for words (32 bits).
42 #[target_feature(enable = "crc")]
43 #[cfg_attr(test, assert_instr(crc32w))]
44 pub unsafe fn __crc32w(crc
: u32, data
: u32) -> u32 {
48 /// CRC32 single round checksum for quad words (64 bits).
50 #[target_feature(enable = "crc")]
51 #[cfg_attr(test, assert_instr(crc32x))]
52 pub unsafe fn __crc32d(crc
: u32, data
: u64) -> u32 {
56 /// CRC32-C single round checksum for bytes (8 bits).
58 #[target_feature(enable = "crc")]
59 #[cfg_attr(test, assert_instr(crc32cb))]
60 pub unsafe fn __crc32cb(crc
: u32, data
: u8) -> u32 {
61 crc32cb_(crc
, data
as u32)
64 /// CRC32-C single round checksum for half words (16 bits).
66 #[target_feature(enable = "crc")]
67 #[cfg_attr(test, assert_instr(crc32ch))]
68 pub unsafe fn __crc32ch(crc
: u32, data
: u16) -> u32 {
69 crc32ch_(crc
, data
as u32)
72 /// CRC32-C single round checksum for words (32 bits).
74 #[target_feature(enable = "crc")]
75 #[cfg_attr(test, assert_instr(crc32cw))]
76 pub unsafe fn __crc32cw(crc
: u32, data
: u32) -> u32 {
80 /// CRC32-C single round checksum for quad words (64 bits).
82 #[target_feature(enable = "crc")]
83 #[cfg_attr(test, assert_instr(crc32cx))]
84 pub unsafe fn __crc32cd(crc
: u32, data
: u64) -> u32 {
90 use crate::core_arch
::{aarch64::*, simd::*}
;
92 use stdsimd_test
::simd_test
;
94 #[simd_test(enable = "crc")]
95 unsafe fn test_crc32b() {
96 assert_eq
!(__crc32b(0, 0), 0);
97 assert_eq
!(__crc32b(0, 255), 755167117);
100 #[simd_test(enable = "crc")]
101 unsafe fn test_crc32h() {
102 assert_eq
!(__crc32h(0, 0), 0);
103 assert_eq
!(__crc32h(0, 16384), 1994146192);
106 #[simd_test(enable = "crc")]
107 unsafe fn test_crc32w() {
108 assert_eq
!(__crc32w(0, 0), 0);
109 assert_eq
!(__crc32w(0, 4294967295), 3736805603);
112 #[simd_test(enable = "crc")]
113 unsafe fn test_crc32d() {
114 assert_eq
!(__crc32d(0, 0), 0);
115 assert_eq
!(__crc32d(0, 18446744073709551615), 1147535477);
118 #[simd_test(enable = "crc")]
119 unsafe fn test_crc32cb() {
120 assert_eq
!(__crc32cb(0, 0), 0);
121 assert_eq
!(__crc32cb(0, 255), 2910671697);
124 #[simd_test(enable = "crc")]
125 unsafe fn test_crc32ch() {
126 assert_eq
!(__crc32ch(0, 0), 0);
127 assert_eq
!(__crc32ch(0, 16384), 1098587580);
130 #[simd_test(enable = "crc")]
131 unsafe fn test_crc32cw() {
132 assert_eq
!(__crc32cw(0, 0), 0);
133 assert_eq
!(__crc32cw(0, 4294967295), 3080238136);
136 #[simd_test(enable = "crc")]
137 unsafe fn test_crc32cd() {
138 assert_eq
!(__crc32cd(0, 0), 0);
139 assert_eq
!(__crc32cd(0, 18446744073709551615), 3293575501);