1/* crc32_simd.h 2 * 3 * Copyright 2017 The Chromium Authors 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the Chromium source repository LICENSE file. 6 */ 7 8#include <stdint.h> 9 10#include "zconf.h" 11#include "zutil.h" 12#include "deflate.h" 13 14/* 15 * crc32_sse42_simd_(): compute the crc32 of the buffer, where the buffer 16 * length must be at least 64, and a multiple of 16. 17 */ 18uint32_t ZLIB_INTERNAL crc32_sse42_simd_(const unsigned char* buf, 19 z_size_t len, 20 uint32_t crc); 21 22uint32_t ZLIB_INTERNAL crc32_avx512_simd_(const unsigned char* buf, 23 z_size_t len, 24 uint32_t crc); 25 26/* 27 * crc32_sse42_simd_ buffer size constraints: see the use in zlib/crc32.c 28 * for computing the crc32 of an arbitrary length buffer. 29 */ 30#define Z_CRC32_SSE42_MINIMUM_LENGTH 64 31#define Z_CRC32_SSE42_CHUNKSIZE_MASK 15 32#define Z_CRC32_AVX512_MINIMUM_LENGTH 256 33#define Z_CRC32_AVX512_CHUNKSIZE_MASK 63 34 35/* 36 * CRC32 checksums using ARMv8-a crypto instructions. 37 */ 38uint32_t ZLIB_INTERNAL armv8_crc32_little(const unsigned char* buf, 39 z_size_t len, 40 uint32_t crc); 41 42/* aarch64 specific code. */ 43#if defined(__aarch64__) 44 45/* 128 is the sweet spot at the time of coding (late 2020). */ 46#define Z_CRC32_PMULL_MINIMUM_LENGTH 128 47#define Z_CRC32_PMULL_CHUNKSIZE_MASK 15 48 49/* 50 * CRC32 checksums using ARMv8-a PMULL instructions, where the buffer 51 * length must be at least 64, and a multiple of 16. 52 */ 53uint32_t ZLIB_INTERNAL armv8_crc32_pmull_little(const unsigned char* buf, 54 z_size_t len, 55 uint32_t crc); 56 57#endif 58