20 #ifndef LLVM_ADT_CACHED_HASH_STRING_H
21 #define LLVM_ADT_CACHED_HASH_STRING_H
41 : P(S.data()), Size(S.
size()), Hash(Hash) {
42 assert(S.
size() <= std::numeric_limits<uint32_t>::max());
58 assert(!
isEqual(S, getEmptyKey()) &&
"Cannot hash the empty key!");
59 assert(!
isEqual(S, getTombstoneKey()) &&
"Cannot hash the tombstone key!");
80 static char *getTombstoneKeyPtr() {
84 bool isEmptyOrTombstone()
const {
85 return P == getEmptyKeyPtr() ||
P == getTombstoneKeyPtr();
88 struct ConstructEmptyOrTombstoneTy {};
90 CachedHashString(ConstructEmptyOrTombstoneTy,
char *EmptyOrTombstonePtr)
91 : P(EmptyOrTombstonePtr), Size(0), Hash(0) {
92 assert(isEmptyOrTombstone());
105 : P(new char[S.
size()]), Size(S.
size()), Hash(Hash) {
112 : Size(Other.Size), Hash(Other.Hash) {
113 if (Other.isEmptyOrTombstone()) {
117 memcpy(P, Other.P, Size);
127 : P(Other.P), Size(Other.Size), Hash(Other.Hash) {
128 Other.P = getEmptyKeyPtr();
132 if (!isEmptyOrTombstone())
148 swap(LHS.Size, RHS.Size);
149 swap(LHS.Hash, RHS.Hash);
156 CachedHashString::getEmptyKeyPtr());
160 CachedHashString::getTombstoneKeyPtr());
163 assert(!
isEqual(S, getEmptyKey()) &&
"Cannot hash the empty key!");
164 assert(!
isEqual(S, getTombstoneKey()) &&
"Cannot hash the tombstone key!");
171 if (LHS.P == CachedHashString::getEmptyKeyPtr())
172 return RHS.P == CachedHashString::getEmptyKeyPtr();
173 if (LHS.P == CachedHashString::getTombstoneKeyPtr())
174 return RHS.P == CachedHashString::getTombstoneKeyPtr();
178 return LHS.
val() == RHS.
val();
A container which contains a StringRef plus a precomputed hash.
CachedHashString(const CachedHashString &Other)
static bool isEqual(const CachedHashStringRef &LHS, const CachedHashStringRef &RHS)
static bool isEqual(const CachedHashString &LHS, const CachedHashString &RHS)
CachedHashStringRef(StringRef S, uint32_t Hash)
CachedHashString(StringRef S, uint32_t Hash)
CachedHashString & operator=(CachedHashString Other)
static CachedHashString getTombstoneKey()
static bool isEqual(const Function &Caller, const Function &Callee)
static CachedHashStringRef getTombstoneKey()
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
CachedHashString(CachedHashString &&Other) noexcept
CachedHashStringRef(StringRef S)
static CachedHashString getEmptyKey()
static unsigned getHashValue(const CachedHashStringRef &S)
static unsigned getHashValue(const CachedHashString &S)
CachedHashString(StringRef S)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container which contains a string, which it owns, plus a precomputed hash.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
std::string Hash(const Unit &U)
StringRef - Represent a constant reference to a string, i.e.
static CachedHashStringRef getEmptyKey()
CachedHashString(const char *S)
friend void swap(CachedHashString &LHS, CachedHashString &RHS)