uint64_t b = fetch64(s + 8);
uint64_t c = fetch64(s + len - 8) * k2;
uint64_t d = fetch64(s + len - 16) * k0;
- return hash_16_bytes(rotate(a - b, 43) + rotate(c ^ seed, 30) + d,
- a + rotate(b ^ k3, 20) - c + len + seed);
+ return hash_16_bytes(llvm::rotr<uint64_t>(a - b, 43) +
+ llvm::rotr<uint64_t>(c ^ seed, 30) + d,
+ a + llvm::rotr<uint64_t>(b ^ k3, 20) - c + len + seed);
}
inline uint64_t hash_33to64_bytes(const char *s, size_t len, uint64_t seed) {
uint64_t z = fetch64(s + 24);
uint64_t a = fetch64(s) + (len + fetch64(s + len - 16)) * k0;
- uint64_t b = rotate(a + z, 52);
- uint64_t c = rotate(a, 37);
+ uint64_t b = llvm::rotr<uint64_t>(a + z, 52);
+ uint64_t c = llvm::rotr<uint64_t>(a, 37);
a += fetch64(s + 8);
- c += rotate(a, 7);
+ c += llvm::rotr<uint64_t>(a, 7);
a += fetch64(s + 16);
uint64_t vf = a + z;
- uint64_t vs = b + rotate(a, 31) + c;
+ uint64_t vs = b + llvm::rotr<uint64_t>(a, 31) + c;
a = fetch64(s + 16) + fetch64(s + len - 32);
z = fetch64(s + len - 8);
- b = rotate(a + z, 52);
- c = rotate(a, 37);
+ b = llvm::rotr<uint64_t>(a + z, 52);
+ c = llvm::rotr<uint64_t>(a, 37);
a += fetch64(s + len - 24);
- c += rotate(a, 7);
+ c += llvm::rotr<uint64_t>(a, 7);
a += fetch64(s + len - 16);
uint64_t wf = a + z;
- uint64_t ws = b + rotate(a, 31) + c;
+ uint64_t ws = b + llvm::rotr<uint64_t>(a, 31) + c;
uint64_t r = shift_mix((vf + ws) * k2 + (wf + vs) * k0);
return shift_mix((seed ^ (r * k0)) + vs) * k2;
}
/// seed and the first 64-byte chunk.
/// This effectively performs the initial mix.
static hash_state create(const char *s, uint64_t seed) {
- hash_state state = {
- 0, seed, hash_16_bytes(seed, k1), rotate(seed ^ k1, 49),
- seed * k1, shift_mix(seed), 0 };
+ hash_state state = {0,
+ seed,
+ hash_16_bytes(seed, k1),
+ llvm::rotr<uint64_t>(seed ^ k1, 49),
+ seed * k1,
+ shift_mix(seed),
+ 0};
state.h6 = hash_16_bytes(state.h4, state.h5);
state.mix(s);
return state;
static void mix_32_bytes(const char *s, uint64_t &a, uint64_t &b) {
a += fetch64(s);
uint64_t c = fetch64(s + 24);
- b = rotate(b + a + c, 21);
+ b = llvm::rotr<uint64_t>(b + a + c, 21);
uint64_t d = a;
a += fetch64(s + 8) + fetch64(s + 16);
- b += rotate(a, 44) + d;
+ b += llvm::rotr<uint64_t>(a, 44) + d;
a += c;
}
/// We mix all 64 bytes even when the chunk length is smaller, but we
/// record the actual length.
void mix(const char *s) {
- h0 = rotate(h0 + h1 + h3 + fetch64(s + 8), 37) * k1;
- h1 = rotate(h1 + h4 + fetch64(s + 48), 42) * k1;
+ h0 = llvm::rotr<uint64_t>(h0 + h1 + h3 + fetch64(s + 8), 37) * k1;
+ h1 = llvm::rotr<uint64_t>(h1 + h4 + fetch64(s + 48), 42) * k1;
h0 ^= h6;
h1 += h3 + fetch64(s + 40);
- h2 = rotate(h2 + h5, 33) * k1;
+ h2 = llvm::rotr<uint64_t>(h2 + h5, 33) * k1;
h3 = h4 * k1;
h4 = h0 + h5;
mix_32_bytes(s, h3, h4);