Debian Codegraph @

ext/zlib-ng/arch/arm/chunkset_neon.c

raw symbols SCIP
1 /* chunkset_neon.c -- NEON inline functions to copy small data chunks.
2 * For conditions of distribution and use, see copyright notice in zlib.h
3 */
4
5 #ifdef ARM_NEON_CHUNKSET
6 #ifdef _M_ARM64
7 # include <arm64_neon.h>
8 #else
9 # include <arm_neon.h>
10 #endif
11 #include "../../zbuild.h"
12 #include "../generic/chunk_permute_table.h"
13
14 typedef uint8x16_t chunk_t;
15
16 #define CHUNK_SIZE 16
17
18 #define HAVE_CHUNKMEMSET_2
19 #define HAVE_CHUNKMEMSET_4
20 #define HAVE_CHUNKMEMSET_8
21 #define HAVE_CHUNK_MAG
22
23 static const lut_rem_pair perm_idx_lut[13] = {
24 {0, 1}, /* 3 */
25 {0, 0}, /* don't care */
26 {1 * 32, 1}, /* 5 */
27 {2 * 32, 4}, /* 6 */
28 {3 * 32, 2}, /* 7 */
29 {0 * 32, 0}, /* don't care */
30 {4 * 32, 7}, /* 9 */
31 {5 * 32, 6}, /* 10 */
32 {6 * 32, 5}, /* 11 */
33 {7 * 32, 4}, /* 12 */
34 {8 * 32, 3}, /* 13 */
35 {9 * 32, 2}, /* 14 */
36 {10 * 32, 1},/* 15 */
37 };
38
39 static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) {
40 uint16_t tmp;
41 memcpy(&tmp, from, sizeof(tmp));
42 *chunk = vreinterpretq_u8_u16(vdupq_n_u16(tmp));
43 }
44
45 static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) {
46 uint32_t tmp;
47 memcpy(&tmp, from, sizeof(tmp));
48 *chunk = vreinterpretq_u8_u32(vdupq_n_u32(tmp));
49 }
50
51 static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) {
52 uint64_t tmp;
53 memcpy(&tmp, from, sizeof(tmp));
54 *chunk = vreinterpretq_u8_u64(vdupq_n_u64(tmp));
55 }
56
57 #define CHUNKSIZE chunksize_neon
58 #define CHUNKCOPY chunkcopy_neon
59 #define CHUNKUNROLL chunkunroll_neon
60 #define CHUNKMEMSET chunkmemset_neon
61 #define CHUNKMEMSET_SAFE chunkmemset_safe_neon
62
63 static inline void loadchunk(uint8_t const *s, chunk_t *chunk) {
64 *chunk = vld1q_u8(s);
65 }
66
67 static inline void storechunk(uint8_t *out, chunk_t *chunk) {
68 vst1q_u8(out, *chunk);
69 }
70
71 static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t dist) {
72 lut_rem_pair lut_rem = perm_idx_lut[dist - 3];
73 *chunk_rem = lut_rem.remval;
74
75 #ifdef Z_MEMORY_SANITIZER
76 /* See note in chunkset_sse41.c for why this is ok */
77 __msan_unpoison(buf + dist, 16 - dist);
78 #endif
79
80 /* This version of table is only available on aarch64 */
81 #if defined(_M_ARM64) || defined(__aarch64__)
82 uint8x16_t ret_vec = vld1q_u8(buf);
83
84 uint8x16_t perm_vec = vld1q_u8(permute_table + lut_rem.idx);
85 return vqtbl1q_u8(ret_vec, perm_vec);
86 #else
87 uint8x8_t ret0, ret1, a, b, perm_vec0, perm_vec1;
88 perm_vec0 = vld1_u8(permute_table + lut_rem.idx);
89 perm_vec1 = vld1_u8(permute_table + lut_rem.idx + 8);
90 a = vld1_u8(buf);
91 b = vld1_u8(buf + 8);
92 ret0 = vtbl1_u8(a, perm_vec0);
93 uint8x8x2_t ab = {{a, b}};
94 ret1 = vtbl2_u8(ab, perm_vec1);
95 return vcombine_u8(ret0, ret1);
96 #endif
97 }
98
99 #include "chunkset_tpl.h"
100
101 #endif