Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Support] Add llvm::xxh3_128bits #95863

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion llvm/include/llvm/Support/xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,38 @@
#include "llvm/ADT/StringRef.h"

namespace llvm {

uint64_t xxHash64(llvm::StringRef Data);
uint64_t xxHash64(llvm::ArrayRef<uint8_t> Data);

uint64_t xxh3_64bits(ArrayRef<uint8_t> data);
inline uint64_t xxh3_64bits(StringRef data) {
return xxh3_64bits(ArrayRef(data.bytes_begin(), data.size()));
}
}

/*-**********************************************************************
* XXH3 128-bit variant
************************************************************************/

/*!
* @brief The return value from 128-bit hashes.
*
* Stored in little endian order, although the fields themselves are in native
* endianness.
*/
struct XXH128_hash_t {
uint64_t low64; /*!< `value & 0xFFFFFFFFFFFFFFFF` */
uint64_t high64; /*!< `value >> 64` */

/// Convenience equality check operator.
bool operator==(const XXH128_hash_t rhs) const {
return low64 == rhs.low64 && high64 == rhs.high64;
}
};

/// XXH3's 128-bit variant.
XXH128_hash_t xxh3_128bits(ArrayRef<uint8_t> data);

} // namespace llvm

#endif
Loading
Loading