LLVM 22.0.0git
xxhash.cpp File Reference
#include "llvm/Support/xxhash.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Endian.h"
#include <stdlib.h>

Go to the source code of this file.

Macros

#define LLVM_XXH_USE_NEON   0
#define XXH3_accumulate_512   XXH3_accumulate_512_scalar
#define XXH3_scrambleAcc   XXH3_scrambleAcc_scalar
#define XXH_rotl32(x, r)
#define XXH_rotl64(x, r)
#define XXH_mult32to64(x, y)

Functions

static uint64_t rotl64 (uint64_t X, size_t R)
static uint64_t round (uint64_t Acc, uint64_t Input)
static uint64_t mergeRound (uint64_t Acc, uint64_t Val)
static uint64_t XXH64_avalanche (uint64_t hash)
static uint64_t XXH3_mul128_fold64 (uint64_t lhs, uint64_t rhs)
static uint64_t XXH3_avalanche (uint64_t hash)
static uint64_t XXH3_len_1to3_64b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t seed)
static uint64_t XXH3_len_4to8_64b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t seed)
static uint64_t XXH3_len_9to16_64b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t const seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE uint64_t XXH3_len_0to16_64b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t const seed)
static uint64_t XXH3_mix16B (const uint8_t *input, uint8_t const *secret, uint64_t seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE uint64_t XXH3_len_17to128_64b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t const seed)
static LLVM_ATTRIBUTE_NOINLINE uint64_t XXH3_len_129to240_64b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE void XXH3_accumulate_512_scalar (uint64_t *acc, const uint8_t *input, const uint8_t *secret)
static LLVM_ATTRIBUTE_ALWAYS_INLINE void XXH3_scrambleAcc_scalar (uint64_t *acc, const uint8_t *secret)
static LLVM_ATTRIBUTE_ALWAYS_INLINE void XXH3_accumulate (uint64_t *acc, const uint8_t *input, const uint8_t *secret, size_t nbStripes)
static uint64_t XXH3_mix2Accs (const uint64_t *acc, const uint8_t *secret)
static uint64_t XXH3_mergeAccs (const uint64_t *acc, const uint8_t *key, uint64_t start)
static LLVM_ATTRIBUTE_NOINLINE uint64_t XXH3_hashLong_64b (const uint8_t *input, size_t len, const uint8_t *secret, size_t secretSize)
static XXH128_hash_t XXH_mult64to128 (uint64_t lhs, uint64_t rhs)
 Calculates a 64->128-bit long multiply.
LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr uint64_t XXH_xorshift64 (uint64_t v64, int shift)
 Seems to produce slightly better code on GCC for some reason.
static LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH3_len_1to3_128b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH3_len_4to8_128b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH3_len_9to16_128b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH3_len_0to16_128b (const uint8_t *input, size_t len, const uint8_t *secret, uint64_t seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH128_mix32B (XXH128_hash_t acc, const uint8_t *input_1, const uint8_t *input_2, const uint8_t *secret, uint64_t seed)
static LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH3_len_17to128_128b (const uint8_t *input, size_t len, const uint8_t *secret, size_t secretSize, uint64_t seed)
static LLVM_ATTRIBUTE_NOINLINE XXH128_hash_t XXH3_len_129to240_128b (const uint8_t *input, size_t len, const uint8_t *secret, size_t secretSize, uint64_t seed)
LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH3_hashLong_128b (const uint8_t *input, size_t len, const uint8_t *secret, size_t secretSize)

Variables

constexpr uint32_t PRIME32_1 = 0x9E3779B1
constexpr uint32_t PRIME32_2 = 0x85EBCA77
constexpr uint32_t PRIME32_3 = 0xC2B2AE3D
static const uint64_t PRIME64_1 = 11400714785074694791ULL
static const uint64_t PRIME64_2 = 14029467366897019727ULL
static const uint64_t PRIME64_3 = 1609587929392839161ULL
static const uint64_t PRIME64_4 = 9650029242287828579ULL
static const uint64_t PRIME64_5 = 2870177450012600261ULL
constexpr size_t XXH3_SECRETSIZE_MIN = 136
constexpr size_t XXH_SECRET_DEFAULT_SIZE = 192
constexpr uint8_t kSecret [XXH_SECRET_DEFAULT_SIZE]
constexpr uint64_t PRIME_MX1 = 0x165667919E3779F9
constexpr uint64_t PRIME_MX2 = 0x9FB21C651E98DF25
constexpr size_t XXH_STRIPE_LEN = 64
constexpr size_t XXH_SECRET_CONSUME_RATE = 8
constexpr size_t XXH_ACC_NB = XXH_STRIPE_LEN / sizeof(uint64_t)
constexpr size_t XXH3_MIDSIZE_MAX = 240
constexpr size_t XXH3_MIDSIZE_STARTOFFSET = 3
constexpr size_t XXH3_MIDSIZE_LASTOFFSET = 17

Macro Definition Documentation

◆ LLVM_XXH_USE_NEON

#define LLVM_XXH_USE_NEON   0

Definition at line 55 of file xxhash.cpp.

◆ XXH3_accumulate_512

#define XXH3_accumulate_512   XXH3_accumulate_512_scalar

Definition at line 474 of file xxhash.cpp.

Referenced by XXH3_accumulate(), XXH3_hashLong_128b(), and XXH3_hashLong_64b().

◆ XXH3_scrambleAcc

#define XXH3_scrambleAcc   XXH3_scrambleAcc_scalar

Definition at line 475 of file xxhash.cpp.

Referenced by XXH3_hashLong_128b(), and XXH3_hashLong_64b().

◆ XXH_mult32to64

#define XXH_mult32to64 ( x,
y )
Value:

Definition at line 609 of file xxhash.cpp.

Referenced by XXH3_len_9to16_128b(), and XXH_mult64to128().

◆ XXH_rotl32

#define XXH_rotl32 ( x,
r )
Value:
(((x) << (r)) | ((x) >> (32 - (r))))

Definition at line 605 of file xxhash.cpp.

Referenced by XXH3_len_1to3_128b().

◆ XXH_rotl64

#define XXH_rotl64 ( x,
r )
Value:
(((x) << (r)) | ((x) >> (64 - (r))))

Definition at line 606 of file xxhash.cpp.

Function Documentation

◆ mergeRound()

uint64_t mergeRound ( uint64_t Acc,
uint64_t Val )
static

Definition at line 87 of file xxhash.cpp.

References PRIME64_1, PRIME64_4, and round().

Referenced by llvm::xxHash64().

◆ rotl64()

uint64_t rotl64 ( uint64_t X,
size_t R )
static

Definition at line 66 of file xxhash.cpp.

References X.

Referenced by round(), XXH3_len_4to8_64b(), and llvm::xxHash64().

◆ round()

◆ XXH128_mix32B()

◆ XXH3_accumulate()

LLVM_ATTRIBUTE_ALWAYS_INLINE void XXH3_accumulate ( uint64_t * acc,
const uint8_t * input,
const uint8_t * secret,
size_t nbStripes )
static

Definition at line 499 of file xxhash.cpp.

References XXH3_accumulate_512, XXH_SECRET_CONSUME_RATE, and XXH_STRIPE_LEN.

Referenced by XXH3_hashLong_128b(), and XXH3_hashLong_64b().

◆ XXH3_accumulate_512_scalar()

LLVM_ATTRIBUTE_ALWAYS_INLINE void XXH3_accumulate_512_scalar ( uint64_t * acc,
const uint8_t * input,
const uint8_t * secret )
static

Definition at line 478 of file xxhash.cpp.

References llvm::support::endian::read64le(), and XXH_ACC_NB.

◆ XXH3_avalanche()

◆ XXH3_hashLong_128b()

◆ XXH3_hashLong_64b()

◆ XXH3_len_0to16_128b()

◆ XXH3_len_0to16_64b()

◆ XXH3_len_129to240_128b()

◆ XXH3_len_129to240_64b()

LLVM_ATTRIBUTE_NOINLINE uint64_t XXH3_len_129to240_64b ( const uint8_t * input,
size_t len,
const uint8_t * secret,
uint64_t seed )
static

◆ XXH3_len_17to128_128b()

LLVM_ATTRIBUTE_ALWAYS_INLINE XXH128_hash_t XXH3_len_17to128_128b ( const uint8_t * input,
size_t len,
const uint8_t * secret,
size_t secretSize,
uint64_t seed )
static

◆ XXH3_len_17to128_64b()

LLVM_ATTRIBUTE_ALWAYS_INLINE uint64_t XXH3_len_17to128_64b ( const uint8_t * input,
size_t len,
const uint8_t * secret,
uint64_t const seed )
static

Definition at line 294 of file xxhash.cpp.

References PRIME64_1, XXH3_avalanche(), and XXH3_mix16B().

Referenced by llvm::xxh3_64bits().

◆ XXH3_len_1to3_128b()

◆ XXH3_len_1to3_64b()

uint64_t XXH3_len_1to3_64b ( const uint8_t * input,
size_t len,
const uint8_t * secret,
uint64_t seed )
static

Definition at line 225 of file xxhash.cpp.

References llvm::support::endian::read32le(), and XXH64_avalanche().

Referenced by XXH3_len_0to16_64b().

◆ XXH3_len_4to8_128b()

◆ XXH3_len_4to8_64b()

uint64_t XXH3_len_4to8_64b ( const uint8_t * input,
size_t len,
const uint8_t * secret,
uint64_t seed )
static

◆ XXH3_len_9to16_128b()

◆ XXH3_len_9to16_64b()

uint64_t XXH3_len_9to16_64b ( const uint8_t * input,
size_t len,
const uint8_t * secret,
uint64_t const seed )
static

◆ XXH3_mergeAccs()

uint64_t XXH3_mergeAccs ( const uint64_t * acc,
const uint8_t * key,
uint64_t start )
static

Definition at line 512 of file xxhash.cpp.

References XXH3_avalanche(), and XXH3_mix2Accs().

Referenced by XXH3_hashLong_128b(), and XXH3_hashLong_64b().

◆ XXH3_mix16B()

uint64_t XXH3_mix16B ( const uint8_t * input,
uint8_t const * secret,
uint64_t seed )
static

◆ XXH3_mix2Accs()

uint64_t XXH3_mix2Accs ( const uint64_t * acc,
const uint8_t * secret )
static

Definition at line 507 of file xxhash.cpp.

References llvm::support::endian::read64le(), and XXH3_mul128_fold64().

Referenced by XXH3_mergeAccs().

◆ XXH3_mul128_fold64()

uint64_t XXH3_mul128_fold64 ( uint64_t lhs,
uint64_t rhs )
static

Definition at line 192 of file xxhash.cpp.

Referenced by XXH3_len_9to16_64b(), XXH3_mix16B(), and XXH3_mix2Accs().

◆ XXH3_scrambleAcc_scalar()

LLVM_ATTRIBUTE_ALWAYS_INLINE void XXH3_scrambleAcc_scalar ( uint64_t * acc,
const uint8_t * secret )
static

Definition at line 489 of file xxhash.cpp.

References PRIME32_1, llvm::support::endian::read64le(), and XXH_ACC_NB.

◆ XXH64_avalanche()

uint64_t XXH64_avalanche ( uint64_t hash)
static

◆ XXH_mult64to128()

XXH128_hash_t XXH_mult64to128 ( uint64_t lhs,
uint64_t rhs )
static

Calculates a 64->128-bit long multiply.

Uses __uint128_t and _umul128 if available, otherwise uses a scalar version.

Parameters
lhs,rhsThe 64-bit integers to be multiplied
Returns
The 128-bit result represented in an XXH128_hash_t.

Definition at line 620 of file xxhash.cpp.

References llvm::XXH128_hash_t::high64, llvm::XXH128_hash_t::low64, and XXH_mult32to64.

Referenced by XXH3_len_4to8_128b(), and XXH3_len_9to16_128b().

◆ XXH_xorshift64()

LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr uint64_t XXH_xorshift64 ( uint64_t v64,
int shift )
constexpr

Seems to produce slightly better code on GCC for some reason.

Definition at line 744 of file xxhash.cpp.

References LLVM_ATTRIBUTE_ALWAYS_INLINE.

Referenced by XXH3_len_4to8_128b().

Variable Documentation

◆ kSecret

uint8_t kSecret[XXH_SECRET_DEFAULT_SIZE]
constexpr
Initial value:
= {
0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c,
0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f,
0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21,
0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c,
0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3,
0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8,
0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d,
0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64,
0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb,
0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e,
0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce,
0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e,
}

Definition at line 172 of file xxhash.cpp.

Referenced by llvm::xxh3_128bits(), and llvm::xxh3_64bits().

◆ PRIME32_1

uint32_t PRIME32_1 = 0x9E3779B1
constexpr

Definition at line 70 of file xxhash.cpp.

Referenced by XXH3_hashLong_128b(), XXH3_hashLong_64b(), and XXH3_scrambleAcc_scalar().

◆ PRIME32_2

uint32_t PRIME32_2 = 0x85EBCA77
constexpr

Definition at line 71 of file xxhash.cpp.

Referenced by XXH3_hashLong_128b(), XXH3_hashLong_64b(), and XXH3_len_9to16_128b().

◆ PRIME32_3

uint32_t PRIME32_3 = 0xC2B2AE3D
constexpr

Definition at line 72 of file xxhash.cpp.

Referenced by XXH3_hashLong_128b(), and XXH3_hashLong_64b().

◆ PRIME64_1

◆ PRIME64_2

◆ PRIME64_3

const uint64_t PRIME64_3 = 1609587929392839161ULL
static

Definition at line 76 of file xxhash.cpp.

Referenced by XXH3_hashLong_128b(), XXH3_hashLong_64b(), XXH64_avalanche(), and llvm::xxHash64().

◆ PRIME64_4

const uint64_t PRIME64_4 = 9650029242287828579ULL
static

◆ PRIME64_5

const uint64_t PRIME64_5 = 2870177450012600261ULL
static

Definition at line 78 of file xxhash.cpp.

Referenced by XXH3_hashLong_128b(), XXH3_hashLong_64b(), and llvm::xxHash64().

◆ PRIME_MX1

uint64_t PRIME_MX1 = 0x165667919E3779F9
constexpr

Definition at line 188 of file xxhash.cpp.

Referenced by XXH3_avalanche().

◆ PRIME_MX2

uint64_t PRIME_MX2 = 0x9FB21C651E98DF25
constexpr

Definition at line 189 of file xxhash.cpp.

Referenced by XXH3_len_4to8_128b(), and XXH3_len_4to8_64b().

◆ XXH3_MIDSIZE_LASTOFFSET

size_t XXH3_MIDSIZE_LASTOFFSET = 17
constexpr

Definition at line 317 of file xxhash.cpp.

Referenced by XXH3_len_129to240_128b(), and XXH3_len_129to240_64b().

◆ XXH3_MIDSIZE_MAX

size_t XXH3_MIDSIZE_MAX = 240
constexpr

Definition at line 315 of file xxhash.cpp.

Referenced by llvm::xxh3_128bits(), and llvm::xxh3_64bits().

◆ XXH3_MIDSIZE_STARTOFFSET

size_t XXH3_MIDSIZE_STARTOFFSET = 3
constexpr

Definition at line 316 of file xxhash.cpp.

Referenced by XXH3_len_129to240_128b(), and XXH3_len_129to240_64b().

◆ XXH3_SECRETSIZE_MIN

size_t XXH3_SECRETSIZE_MIN = 136
constexpr

Definition at line 167 of file xxhash.cpp.

Referenced by XXH3_len_129to240_128b(), and XXH3_len_129to240_64b().

◆ XXH_ACC_NB

size_t XXH_ACC_NB = XXH_STRIPE_LEN / sizeof(uint64_t)
constexpr

◆ XXH_SECRET_CONSUME_RATE

size_t XXH_SECRET_CONSUME_RATE = 8
constexpr

Definition at line 215 of file xxhash.cpp.

Referenced by XXH3_accumulate(), XXH3_hashLong_128b(), and XXH3_hashLong_64b().

◆ XXH_SECRET_DEFAULT_SIZE

size_t XXH_SECRET_DEFAULT_SIZE = 192
constexpr

Definition at line 168 of file xxhash.cpp.

◆ XXH_STRIPE_LEN

size_t XXH_STRIPE_LEN = 64
constexpr

Definition at line 214 of file xxhash.cpp.

Referenced by XXH3_accumulate(), XXH3_hashLong_128b(), and XXH3_hashLong_64b().