@@ -77,20 +77,6 @@ static const uint64_t PRIME64_3 = 1609587929392839161ULL;
7777static const uint64_t PRIME64_4 = 9650029242287828579ULL ;
7878static const uint64_t PRIME64_5 = 2870177450012600261ULL ;
7979
80- static uint64_t round (uint64_t Acc, uint64_t Input) {
81- Acc += Input * PRIME64_2;
82- Acc = rotl64 (Acc, 31 );
83- Acc *= PRIME64_1;
84- return Acc;
85- }
86-
87- static uint64_t mergeRound (uint64_t Acc, uint64_t Val) {
88- Val = round (0 , Val);
89- Acc ^= Val;
90- Acc = Acc * PRIME64_1 + PRIME64_4;
91- return Acc;
92- }
93-
9480static uint64_t XXH64_avalanche (uint64_t hash) {
9581 hash ^= hash >> 33 ;
9682 hash *= PRIME64_2;
@@ -100,70 +86,6 @@ static uint64_t XXH64_avalanche(uint64_t hash) {
10086 return hash;
10187}
10288
103- uint64_t llvm::xxHash64 (StringRef Data) {
104- size_t Len = Data.size ();
105- uint64_t Seed = 0 ;
106- const unsigned char *P = Data.bytes_begin ();
107- const unsigned char *const BEnd = Data.bytes_end ();
108- uint64_t H64;
109-
110- if (Len >= 32 ) {
111- const unsigned char *const Limit = BEnd - 32 ;
112- uint64_t V1 = Seed + PRIME64_1 + PRIME64_2;
113- uint64_t V2 = Seed + PRIME64_2;
114- uint64_t V3 = Seed + 0 ;
115- uint64_t V4 = Seed - PRIME64_1;
116-
117- do {
118- V1 = round (V1, endian::read64le (P));
119- P += 8 ;
120- V2 = round (V2, endian::read64le (P));
121- P += 8 ;
122- V3 = round (V3, endian::read64le (P));
123- P += 8 ;
124- V4 = round (V4, endian::read64le (P));
125- P += 8 ;
126- } while (P <= Limit);
127-
128- H64 = rotl64 (V1, 1 ) + rotl64 (V2, 7 ) + rotl64 (V3, 12 ) + rotl64 (V4, 18 );
129- H64 = mergeRound (H64, V1);
130- H64 = mergeRound (H64, V2);
131- H64 = mergeRound (H64, V3);
132- H64 = mergeRound (H64, V4);
133-
134- } else {
135- H64 = Seed + PRIME64_5;
136- }
137-
138- H64 += (uint64_t )Len;
139-
140- while (reinterpret_cast <uintptr_t >(P) + 8 <=
141- reinterpret_cast <uintptr_t >(BEnd)) {
142- uint64_t const K1 = round (0 , endian::read64le (P));
143- H64 ^= K1;
144- H64 = rotl64 (H64, 27 ) * PRIME64_1 + PRIME64_4;
145- P += 8 ;
146- }
147-
148- if (reinterpret_cast <uintptr_t >(P) + 4 <= reinterpret_cast <uintptr_t >(BEnd)) {
149- H64 ^= (uint64_t )(endian::read32le (P)) * PRIME64_1;
150- H64 = rotl64 (H64, 23 ) * PRIME64_2 + PRIME64_3;
151- P += 4 ;
152- }
153-
154- while (P < BEnd) {
155- H64 ^= (*P) * PRIME64_5;
156- H64 = rotl64 (H64, 11 ) * PRIME64_1;
157- P++;
158- }
159-
160- return XXH64_avalanche (H64);
161- }
162-
163- uint64_t llvm::xxHash64 (ArrayRef<uint8_t > Data) {
164- return xxHash64 ({(const char *)Data.data (), Data.size ()});
165- }
166-
16789constexpr size_t XXH3_SECRETSIZE_MIN = 136 ;
16890constexpr size_t XXH_SECRET_DEFAULT_SIZE = 192 ;
16991
0 commit comments