11cb0ef41Sopenharmony_ci/* crc32_simd.h 21cb0ef41Sopenharmony_ci * 31cb0ef41Sopenharmony_ci * Copyright 2017 The Chromium Authors 41cb0ef41Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 51cb0ef41Sopenharmony_ci * found in the Chromium source repository LICENSE file. 61cb0ef41Sopenharmony_ci */ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include <stdint.h> 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include "zconf.h" 111cb0ef41Sopenharmony_ci#include "zutil.h" 121cb0ef41Sopenharmony_ci#include "deflate.h" 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci/* 151cb0ef41Sopenharmony_ci * crc32_sse42_simd_(): compute the crc32 of the buffer, where the buffer 161cb0ef41Sopenharmony_ci * length must be at least 64, and a multiple of 16. 171cb0ef41Sopenharmony_ci */ 181cb0ef41Sopenharmony_ciuint32_t ZLIB_INTERNAL crc32_sse42_simd_(const unsigned char* buf, 191cb0ef41Sopenharmony_ci z_size_t len, 201cb0ef41Sopenharmony_ci uint32_t crc); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciuint32_t ZLIB_INTERNAL crc32_avx512_simd_(const unsigned char* buf, 231cb0ef41Sopenharmony_ci z_size_t len, 241cb0ef41Sopenharmony_ci uint32_t crc); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci/* 271cb0ef41Sopenharmony_ci * crc32_sse42_simd_ buffer size constraints: see the use in zlib/crc32.c 281cb0ef41Sopenharmony_ci * for computing the crc32 of an arbitrary length buffer. 291cb0ef41Sopenharmony_ci */ 301cb0ef41Sopenharmony_ci#define Z_CRC32_SSE42_MINIMUM_LENGTH 64 311cb0ef41Sopenharmony_ci#define Z_CRC32_SSE42_CHUNKSIZE_MASK 15 321cb0ef41Sopenharmony_ci#define Z_CRC32_AVX512_MINIMUM_LENGTH 256 331cb0ef41Sopenharmony_ci#define Z_CRC32_AVX512_CHUNKSIZE_MASK 63 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci/* 361cb0ef41Sopenharmony_ci * CRC32 checksums using ARMv8-a crypto instructions. 371cb0ef41Sopenharmony_ci */ 381cb0ef41Sopenharmony_ciuint32_t ZLIB_INTERNAL armv8_crc32_little(const unsigned char* buf, 391cb0ef41Sopenharmony_ci z_size_t len, 401cb0ef41Sopenharmony_ci uint32_t crc); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci/* aarch64 specific code. */ 431cb0ef41Sopenharmony_ci#if defined(__aarch64__) 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci/* 128 is the sweet spot at the time of coding (late 2020). */ 461cb0ef41Sopenharmony_ci#define Z_CRC32_PMULL_MINIMUM_LENGTH 128 471cb0ef41Sopenharmony_ci#define Z_CRC32_PMULL_CHUNKSIZE_MASK 15 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci/* 501cb0ef41Sopenharmony_ci * CRC32 checksums using ARMv8-a PMULL instructions, where the buffer 511cb0ef41Sopenharmony_ci * length must be at least 64, and a multiple of 16. 521cb0ef41Sopenharmony_ci */ 531cb0ef41Sopenharmony_ciuint32_t ZLIB_INTERNAL armv8_crc32_pmull_little(const unsigned char* buf, 541cb0ef41Sopenharmony_ci z_size_t len, 551cb0ef41Sopenharmony_ci uint32_t crc); 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci#endif 58