| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#ifndef CPU_FEATURES_H_ |
| 7 |
#define CPU_FEATURES_H_ |
| 8 |
|
| 9 |
#include "adler32_fold.h" |
| 10 |
#include "crc32_fold.h" |
| 11 |
|
| 12 |
#if defined(X86_FEATURES) |
| 13 |
# include "arch/x86/x86_features.h" |
| 14 |
# include "fallback_builtins.h" |
| 15 |
#elif defined(ARM_FEATURES) |
| 16 |
# include "arch/arm/arm_features.h" |
| 17 |
#elif defined(PPC_FEATURES) || defined(POWER_FEATURES) |
| 18 |
# include "arch/power/power_features.h" |
| 19 |
#elif defined(S390_FEATURES) |
| 20 |
# include "arch/s390/s390_features.h" |
| 21 |
#endif |
| 22 |
|
| 23 |
extern void cpu_check_features(void); |
| 24 |
|
| 25 |
|
| 26 |
typedef uint32_t (*adler32_func)(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 27 |
|
| 28 |
extern uint32_t adler32_c(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 29 |
#ifdef ARM_NEON_ADLER32 |
| 30 |
extern uint32_t adler32_neon(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 31 |
#endif |
| 32 |
#ifdef PPC_VMX_ADLER32 |
| 33 |
extern uint32_t adler32_vmx(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 34 |
#endif |
| 35 |
#ifdef X86_SSSE3_ADLER32 |
| 36 |
extern uint32_t adler32_ssse3(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 37 |
#endif |
| 38 |
#ifdef X86_AVX2_ADLER32 |
| 39 |
extern uint32_t adler32_avx2(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 40 |
#endif |
| 41 |
#ifdef X86_AVX512_ADLER32 |
| 42 |
extern uint32_t adler32_avx512(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 43 |
#endif |
| 44 |
#ifdef X86_AVX512VNNI_ADLER32 |
| 45 |
extern uint32_t adler32_avx512_vnni(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 46 |
#endif |
| 47 |
#ifdef POWER8_VSX_ADLER32 |
| 48 |
extern uint32_t adler32_power8(uint32_t adler, const uint8_t *buf, uint64_t len); |
| 49 |
#endif |
| 50 |
|
| 51 |
|
| 52 |
#ifdef X86_SSE42_ADLER32 |
| 53 |
extern uint32_t adler32_fold_copy_sse42(uint32_t adler, uint8_t *dst, const uint8_t *src, uint64_t len); |
| 54 |
#endif |
| 55 |
#ifdef X86_AVX2_ADLER32 |
| 56 |
extern uint32_t adler32_fold_copy_avx2(uint32_t adler, uint8_t *dst, const uint8_t *src, uint64_t len); |
| 57 |
#endif |
| 58 |
#ifdef X86_AVX512_ADLER32 |
| 59 |
extern uint32_t adler32_fold_copy_avx512(uint32_t adler, uint8_t *dst, const uint8_t *src, uint64_t len); |
| 60 |
#endif |
| 61 |
#ifdef X86_AVX512VNNI_ADLER32 |
| 62 |
extern uint32_t adler32_fold_copy_avx512_vnni(uint32_t adler, uint8_t *dst, const uint8_t *src, uint64_t len); |
| 63 |
#endif |
| 64 |
|
| 65 |
|
| 66 |
#ifdef X86_PCLMULQDQ_CRC |
| 67 |
extern uint32_t crc32_fold_pclmulqdq_reset(crc32_fold *crc); |
| 68 |
extern void crc32_fold_pclmulqdq_copy(crc32_fold *crc, uint8_t *dst, const uint8_t *src, uint64_t len); |
| 69 |
extern void crc32_fold_pclmulqdq(crc32_fold *crc, const uint8_t *src, uint64_t len, uint32_t init_crc); |
| 70 |
extern uint32_t crc32_fold_pclmulqdq_final(crc32_fold *crc); |
| 71 |
extern uint32_t crc32_pclmulqdq(uint32_t crc32, const uint8_t *buf, uint64_t len); |
| 72 |
#endif |
| 73 |
|
| 74 |
|
| 75 |
extern uint32_t chunksize_c(void); |
| 76 |
extern uint8_t* chunkcopy_c(uint8_t *out, uint8_t const *from, unsigned len); |
| 77 |
extern uint8_t* chunkunroll_c(uint8_t *out, unsigned *dist, unsigned *len); |
| 78 |
extern uint8_t* chunkmemset_c(uint8_t *out, unsigned dist, unsigned len); |
| 79 |
extern uint8_t* chunkmemset_safe_c(uint8_t *out, unsigned dist, unsigned len, unsigned left); |
| 80 |
#ifdef X86_SSE2_CHUNKSET |
| 81 |
extern uint32_t chunksize_sse2(void); |
| 82 |
extern uint8_t* chunkcopy_sse2(uint8_t *out, uint8_t const *from, unsigned len); |
| 83 |
extern uint8_t* chunkunroll_sse2(uint8_t *out, unsigned *dist, unsigned *len); |
| 84 |
extern uint8_t* chunkmemset_sse2(uint8_t *out, unsigned dist, unsigned len); |
| 85 |
extern uint8_t* chunkmemset_safe_sse2(uint8_t *out, unsigned dist, unsigned len, unsigned left); |
| 86 |
#endif |
| 87 |
#ifdef X86_SSE41 |
| 88 |
extern uint8_t* chunkmemset_sse41(uint8_t *out, unsigned dist, unsigned len); |
| 89 |
extern uint8_t* chunkmemset_safe_sse41(uint8_t *out, unsigned dist, unsigned len, unsigned left); |
| 90 |
#endif |
| 91 |
#ifdef X86_AVX_CHUNKSET |
| 92 |
extern uint32_t chunksize_avx(void); |
| 93 |
extern uint8_t* chunkcopy_avx(uint8_t *out, uint8_t const *from, unsigned len); |
| 94 |
extern uint8_t* chunkunroll_avx(uint8_t *out, unsigned *dist, unsigned *len); |
| 95 |
extern uint8_t* chunkmemset_avx(uint8_t *out, unsigned dist, unsigned len); |
| 96 |
extern uint8_t* chunkmemset_safe_avx(uint8_t *out, unsigned dist, unsigned len, unsigned left); |
| 97 |
#endif |
| 98 |
#ifdef ARM_NEON_CHUNKSET |
| 99 |
extern uint32_t chunksize_neon(void); |
| 100 |
extern uint8_t* chunkcopy_neon(uint8_t *out, uint8_t const *from, unsigned len); |
| 101 |
extern uint8_t* chunkunroll_neon(uint8_t *out, unsigned *dist, unsigned *len); |
| 102 |
extern uint8_t* chunkmemset_neon(uint8_t *out, unsigned dist, unsigned len); |
| 103 |
extern uint8_t* chunkmemset_safe_neon(uint8_t *out, unsigned dist, unsigned len, unsigned left); |
| 104 |
#endif |
| 105 |
#ifdef POWER8_VSX_CHUNKSET |
| 106 |
extern uint32_t chunksize_power8(void); |
| 107 |
extern uint8_t* chunkcopy_power8(uint8_t *out, uint8_t const *from, unsigned len); |
| 108 |
extern uint8_t* chunkunroll_power8(uint8_t *out, unsigned *dist, unsigned *len); |
| 109 |
extern uint8_t* chunkmemset_power8(uint8_t *out, unsigned dist, unsigned len); |
| 110 |
extern uint8_t* chunkmemset_safe_power8(uint8_t *out, unsigned dist, unsigned len, unsigned left); |
| 111 |
#endif |
| 112 |
|
| 113 |
|
| 114 |
typedef uint32_t (*crc32_func)(uint32_t crc32, const uint8_t *buf, uint64_t len); |
| 115 |
|
| 116 |
extern uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, uint64_t len); |
| 117 |
#ifdef ARM_ACLE_CRC_HASH |
| 118 |
extern uint32_t crc32_acle(uint32_t crc, const uint8_t *buf, uint64_t len); |
| 119 |
#elif defined(POWER8_VSX_CRC32) |
| 120 |
extern uint32_t crc32_power8(uint32_t crc, const uint8_t *buf, uint64_t len); |
| 121 |
#elif defined(S390_CRC32_VX) |
| 122 |
extern uint32_t PREFIX(s390_crc32_vx)(uint32_t crc, const uint8_t *buf, uint64_t len); |
| 123 |
#endif |
| 124 |
|
| 125 |
|
| 126 |
typedef uint32_t (*compare256_func)(const uint8_t *src0, const uint8_t *src1); |
| 127 |
|
| 128 |
extern uint32_t compare256_c(const uint8_t *src0, const uint8_t *src1); |
| 129 |
#ifdef UNALIGNED_OK |
| 130 |
extern uint32_t compare256_unaligned_16(const uint8_t *src0, const uint8_t *src1); |
| 131 |
#ifdef HAVE_BUILTIN_CTZ |
| 132 |
extern uint32_t compare256_unaligned_32(const uint8_t *src0, const uint8_t *src1); |
| 133 |
#endif |
| 134 |
#if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL) |
| 135 |
extern uint32_t compare256_unaligned_64(const uint8_t *src0, const uint8_t *src1); |
| 136 |
#endif |
| 137 |
#endif |
| 138 |
#if defined(X86_SSE2) && defined(HAVE_BUILTIN_CTZ) |
| 139 |
extern uint32_t compare256_sse2(const uint8_t *src0, const uint8_t *src1); |
| 140 |
#endif |
| 141 |
#if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) |
| 142 |
extern uint32_t compare256_avx2(const uint8_t *src0, const uint8_t *src1); |
| 143 |
#endif |
| 144 |
#if defined(ARM_NEON) && defined(HAVE_BUILTIN_CTZLL) |
| 145 |
extern uint32_t compare256_neon(const uint8_t *src0, const uint8_t *src1); |
| 146 |
#endif |
| 147 |
#ifdef POWER9 |
| 148 |
extern uint32_t compare256_power9(const uint8_t *src0, const uint8_t *src1); |
| 149 |
#endif |
| 150 |
|
| 151 |
#ifdef DEFLATE_H_ |
| 152 |
|
| 153 |
extern void insert_string_c(deflate_state *const s, const uint32_t str, uint32_t count); |
| 154 |
#ifdef X86_SSE42_CRC_HASH |
| 155 |
extern void insert_string_sse4(deflate_state *const s, const uint32_t str, uint32_t count); |
| 156 |
#elif defined(ARM_ACLE_CRC_HASH) |
| 157 |
extern void insert_string_acle(deflate_state *const s, const uint32_t str, uint32_t count); |
| 158 |
#endif |
| 159 |
|
| 160 |
|
| 161 |
extern uint32_t longest_match_c(deflate_state *const s, Pos cur_match); |
| 162 |
#ifdef UNALIGNED_OK |
| 163 |
extern uint32_t longest_match_unaligned_16(deflate_state *const s, Pos cur_match); |
| 164 |
#ifdef HAVE_BUILTIN_CTZ |
| 165 |
extern uint32_t longest_match_unaligned_32(deflate_state *const s, Pos cur_match); |
| 166 |
#endif |
| 167 |
#if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL) |
| 168 |
extern uint32_t longest_match_unaligned_64(deflate_state *const s, Pos cur_match); |
| 169 |
#endif |
| 170 |
#endif |
| 171 |
#if defined(X86_SSE2) && defined(HAVE_BUILTIN_CTZ) |
| 172 |
extern uint32_t longest_match_sse2(deflate_state *const s, Pos cur_match); |
| 173 |
#endif |
| 174 |
#if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) |
| 175 |
extern uint32_t longest_match_avx2(deflate_state *const s, Pos cur_match); |
| 176 |
#endif |
| 177 |
#if defined(ARM_NEON) && defined(HAVE_BUILTIN_CTZLL) |
| 178 |
extern uint32_t longest_match_neon(deflate_state *const s, Pos cur_match); |
| 179 |
#endif |
| 180 |
#ifdef POWER9 |
| 181 |
extern uint32_t longest_match_power9(deflate_state *const s, Pos cur_match); |
| 182 |
#endif |
| 183 |
|
| 184 |
|
| 185 |
extern uint32_t longest_match_slow_c(deflate_state *const s, Pos cur_match); |
| 186 |
#ifdef UNALIGNED_OK |
| 187 |
extern uint32_t longest_match_slow_unaligned_16(deflate_state *const s, Pos cur_match); |
| 188 |
extern uint32_t longest_match_slow_unaligned_32(deflate_state *const s, Pos cur_match); |
| 189 |
#ifdef UNALIGNED64_OK |
| 190 |
extern uint32_t longest_match_slow_unaligned_64(deflate_state *const s, Pos cur_match); |
| 191 |
#endif |
| 192 |
#endif |
| 193 |
#if defined(X86_SSE2) && defined(HAVE_BUILTIN_CTZ) |
| 194 |
extern uint32_t longest_match_slow_sse2(deflate_state *const s, Pos cur_match); |
| 195 |
#endif |
| 196 |
#if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) |
| 197 |
extern uint32_t longest_match_slow_avx2(deflate_state *const s, Pos cur_match); |
| 198 |
#endif |
| 199 |
#if defined(ARM_NEON) && defined(HAVE_BUILTIN_CTZLL) |
| 200 |
extern uint32_t longest_match_slow_neon(deflate_state *const s, Pos cur_match); |
| 201 |
#endif |
| 202 |
#ifdef POWER9 |
| 203 |
extern uint32_t longest_match_slow_power9(deflate_state *const s, Pos cur_match); |
| 204 |
#endif |
| 205 |
|
| 206 |
|
| 207 |
extern Pos quick_insert_string_c(deflate_state *const s, const uint32_t str); |
| 208 |
#ifdef X86_SSE42_CRC_HASH |
| 209 |
extern Pos quick_insert_string_sse4(deflate_state *const s, const uint32_t str); |
| 210 |
#elif defined(ARM_ACLE_CRC_HASH) |
| 211 |
extern Pos quick_insert_string_acle(deflate_state *const s, const uint32_t str); |
| 212 |
#endif |
| 213 |
|
| 214 |
|
| 215 |
typedef void (*slide_hash_func)(deflate_state *s); |
| 216 |
|
| 217 |
#ifdef X86_SSE2 |
| 218 |
extern void slide_hash_sse2(deflate_state *s); |
| 219 |
#elif defined(ARM_NEON_SLIDEHASH) |
| 220 |
extern void slide_hash_neon(deflate_state *s); |
| 221 |
#endif |
| 222 |
#if defined(PPC_VMX_SLIDEHASH) |
| 223 |
extern void slide_hash_vmx(deflate_state *s); |
| 224 |
#endif |
| 225 |
#if defined(POWER8_VSX_SLIDEHASH) |
| 226 |
extern void slide_hash_power8(deflate_state *s); |
| 227 |
#endif |
| 228 |
#ifdef X86_AVX2 |
| 229 |
extern void slide_hash_avx2(deflate_state *s); |
| 230 |
#endif |
| 231 |
|
| 232 |
|
| 233 |
extern uint32_t update_hash_c(deflate_state *const s, uint32_t h, uint32_t val); |
| 234 |
#ifdef X86_SSE42_CRC_HASH |
| 235 |
extern uint32_t update_hash_sse4(deflate_state *const s, uint32_t h, uint32_t val); |
| 236 |
#elif defined(ARM_ACLE_CRC_HASH) |
| 237 |
extern uint32_t update_hash_acle(deflate_state *const s, uint32_t h, uint32_t val); |
| 238 |
#endif |
| 239 |
#endif |
| 240 |
|
| 241 |
#endif |