18 assert(Entry &&
"null reference");
19 Bytes.push_back(RefMarker);
20 const char *EntryBytes =
reinterpret_cast<const char *
>(&Entry);
21 Bytes.append(EntryBytes, EntryBytes +
sizeof(Entry));
25 assert(!
Key.empty() &&
"no part to take");
26 if (
Key.front() != RefMarker) {
31 assert(
Key.size() >= RefSize &&
"truncated reference");
33 std::memcpy(&
Ref,
Key.data() + 1,
sizeof(
Ref));
34 Key =
Key.drop_front(RefSize);
40class ExpandedKeyCursor {
45 if (
const auto *
Text = std::get_if<StringRef>(&Head);
48 while (!Pending.empty() && Pending.back().empty())
60 void consumeText(
size_t N) {
66 void skipRef() { Head = {}; }
71 Pending.push_back(std::get<const TypeEntry *>(Head)->getKey());
87 while (!
LHS.empty() && !
RHS.empty()) {
90 if (L.index() != R.index())
91 return std::holds_alternative<const TypeEntry *>(L) ? -1 : 1;
94 if (
const auto *LText = std::get_if<StringRef>(&L))
95 return LText->compare(std::get<StringRef>(R));
98 std::get<const TypeEntry *>(R)->getKey()))
101 return LHS.empty() ==
RHS.empty() ? 0 : (
LHS.empty() ? -1 : 1);
105 ExpandedKeyCursor L(LHS), R(RHS);
107 bool LEnd = L.atEnd();
108 bool REnd = R.atEnd();
114 return LEnd ? -1 : 1;
118 bool LRef = std::holds_alternative<const TypeEntry *>(LPart);
119 bool RRef = std::holds_alternative<const TypeEntry *>(RPart);
121 if (LRef && LPart == RPart) {
134 StringRef LText = std::get<StringRef>(LPart);
135 StringRef RText = std::get<StringRef>(RPart);
136 size_t N = std::min(LText.
size(), RText.
size());
146 ExpandedKeyCursor Cursor(
Key);
147 while (!Cursor.atEnd()) {
148 const auto *
Text = std::get_if<StringRef>(&Cursor.peek());
154 Cursor.consumeText(
Text->size());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the SmallVector class.
static int compareTypeKeyStructure(StringRef LHS, StringRef RHS)
Order keys by their text runs and references, recursively.
static bool peek(struct InternalInstruction *insn, uint8_t &byte)
Represent a constant reference to a string, i.e.
constexpr size_t size() const
Get the string size.
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
int compare(StringRef RHS) const
Compare two strings; the result is negative, zero, or positive if this string is lexicographically le...
void appendRef(const TypeEntry *Entry)
static Part takePart(StringRef &Key)
Remove the first part of the non-empty key Key and return it.
static std::string expand(StringRef Key)
std::variant< StringRef, const TypeEntry * > Part
A maximal run of text, or a reference.
static int compare(StringRef LHS, StringRef RHS)
Compare LHS and RHS as if every reference were replaced by the key it refers to, so the result does n...
StringMapEntry< std::atomic< TypeEntryBody * > > TypeEntry
This is an optimization pass for GlobalISel generic memory operations.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Ref
The access may reference the value stored in memory.