19 #ifndef LLVM_ADT_CACHED_HASH_STRING_H 20 #define LLVM_ADT_CACHED_HASH_STRING_H 39 :
P(S.
data()), Size(S.
size()), Hash(Hash) {
44 const char *
data()
const {
return P; }
57 assert(!
isEqual(S, getEmptyKey()) &&
"Cannot hash the empty key!");
58 assert(!
isEqual(S, getTombstoneKey()) &&
"Cannot hash the tombstone key!");
79 static char *getTombstoneKeyPtr() {
83 bool isEmptyOrTombstone()
const {
84 return P == getEmptyKeyPtr() ||
P == getTombstoneKeyPtr();
87 struct ConstructEmptyOrTombstoneTy {};
89 CachedHashString(ConstructEmptyOrTombstoneTy,
char *EmptyOrTombstonePtr)
90 :
P(EmptyOrTombstonePtr),
Size(0), Hash(0) {
91 assert(isEmptyOrTombstone());
112 if (
Other.isEmptyOrTombstone()) {
127 Other.P = getEmptyKeyPtr();
131 if (!isEmptyOrTombstone())
147 swap(LHS.Size, RHS.Size);
148 swap(LHS.Hash, RHS.Hash);
155 CachedHashString::getEmptyKeyPtr());
159 CachedHashString::getTombstoneKeyPtr());
162 assert(!
isEqual(S, getEmptyKey()) &&
"Cannot hash the empty key!");
163 assert(!
isEqual(S, getTombstoneKey()) &&
"Cannot hash the tombstone key!");
170 if (LHS.P == CachedHashString::getEmptyKeyPtr())
171 return RHS.P == CachedHashString::getEmptyKeyPtr();
172 if (LHS.P == CachedHashString::getTombstoneKeyPtr())
173 return RHS.P == CachedHashString::getTombstoneKeyPtr();
177 return LHS.
val() == RHS.
val();
A container which contains a StringRef plus a precomputed hash.
CachedHashString(const CachedHashString &Other)
This class represents lattice values for constants.
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)
LLVM_NODISCARD size_t size() const
size - Get the string size.
static CachedHashStringRef getTombstoneKey()
const char * data() const
CachedHashString(CachedHashString &&Other) noexcept
CachedHashStringRef(StringRef S)
static CachedHashString getEmptyKey()
static unsigned getHashValue(const CachedHashStringRef &S)
Align max(MaybeAlign Lhs, Align Rhs)
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.
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container which contains a string, which it owns, plus a precomputed hash.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
StringRef - Represent a constant reference to a string, i.e.
static CachedHashStringRef getEmptyKey()
CachedHashString(const char *S)
friend void swap(CachedHashString &LHS, CachedHashString &RHS)