15#ifndef LLVM_ADT_EQUIVALENCECLASSES_H
16#define LLVM_ADT_EQUIVALENCECLASSES_H
77 mutable const ECValue *Leader, *Next;
84 Next(reinterpret_cast<
ECValue *>(static_cast<intptr_t>(1))),
87 const ECValue *getLeader()
const {
93 return Leader = Leader->getLeader();
96 const ECValue *getEndOfList()
const {
97 assert(
isLeader() &&
"Cannot get the end of a list for a non-leader!");
101 void setNext(
const ECValue *NewNext)
const {
102 assert(
getNext() ==
nullptr &&
"Already has a next pointer!");
103 Next =
reinterpret_cast<const ECValue *
>(
104 reinterpret_cast<intptr_t
>(NewNext) |
111 Next(reinterpret_cast<
ECValue *>(static_cast<intptr_t>(1))),
114 assert(
RHS.isLeader() &&
RHS.getNext() ==
nullptr &&
"Not a singleton!");
117 bool isLeader()
const {
return (intptr_t)Next & 1; }
118 const ElemTy &
getData()
const {
return Data; }
121 return reinterpret_cast<ECValue *
>(
reinterpret_cast<intptr_t
>(Next) &
122 ~
static_cast<intptr_t
>(1));
143 for (
const auto &
E :
RHS)
166 class member_iterator;
184 return TheMapping.
find(V) != TheMapping.
end();
209 for (
const auto &
E : *
this)
236 const ECValue *Cur = TheMapping[V];
243 Next->Leader = Cur->Leader;
244 Next->Next =
reinterpret_cast<const ECValue *
>(
245 reinterpret_cast<intptr_t
>(Next->Next) |
static_cast<intptr_t
>(1));
247 const ECValue *NewLeader = Next;
248 while ((Next = Next->
getNext())) {
249 Next->Leader = NewLeader;
254 while (Pre->
getNext() != Cur) {
262 Leader->Leader = Pre;
266 Pre->Next =
reinterpret_cast<const ECValue *
>(
267 reinterpret_cast<intptr_t
>(Next) |
268 static_cast<intptr_t
>(Pre->
isLeader()));
274 assert(TheMapping.
contains(V) &&
"Can't find input in TheMapping!");
276 auto I =
find(Members, Cur);
277 assert(
I != Members.
end() &&
"Can't find input in members!");
287 auto I = TheMapping.
find(V);
288 if (
I == TheMapping.
end())
309 const ECValue &L1LV = *L1.Node, &L2LV = *L2.Node;
310 L1LV.getEndOfList()->setNext(&L2LV);
313 L1LV.Leader = L2LV.getEndOfList();
350 assert(
Node !=
nullptr &&
"Dereferencing end()!");
351 return Node->getData();
356 assert(
Node !=
nullptr &&
"++'d off the end of the list!");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the SmallVector class.
Allocate memory in an ever growing pool, as if by bump-pointer.
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
bool erase(const KeyT &Val)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
ECValue - The EquivalenceClasses data structure is just a set of these.
const ECValue * getNext() const
ECValue(const ECValue &RHS)
const ElemTy & getData() const
std::forward_iterator_tag iterator_category
member_iterator(const ECValue *N)
member_iterator & operator++()
member_iterator()=default
std::ptrdiff_t difference_type
pointer operator->() const
member_iterator operator++(int)
reference operator*() const
bool operator!=(const member_iterator &RHS) const
bool operator==(const member_iterator &RHS) const
EquivalenceClasses - This represents a collection of equivalence classes and supports three efficient...
EquivalenceClasses()=default
member_iterator member_begin(const ECValue &ECV) const
iterator_range< member_iterator > members(const ECValue &ECV) const
bool contains(const ElemTy &V) const
Returns true if V is contained an equivalence class.
member_iterator findLeader(const ECValue &ECV) const
const ElemTy & getOrInsertLeaderValue(const ElemTy &V)
getOrInsertLeaderValue - Return the leader for the specified value that is in the set.
const ECValue & insert(const ElemTy &Data)
insert - Insert a new value into the union/find set, ignoring the request if the value already exists...
bool isEquivalent(const ElemTy &V1, const ElemTy &V2) const
member_iterator member_end() const
const ElemTy & getLeaderValue(const ElemTy &V) const
getLeaderValue - Return the leader for the specified value that is in the set.
iterator_range< member_iterator > members(const ElemTy &V) const
EquivalenceClasses & operator=(const EquivalenceClasses &RHS)
typename SmallVector< const ECValue * >::const_iterator iterator
iterator* - Provides a way to iterate over all values in the set.
member_iterator findLeader(const ElemTy &V) const
findLeader - Given a value in the set, return a member iterator for the equivalence class it is in.
unsigned getNumClasses() const
getNumClasses - Return the number of equivalence classes in this set.
member_iterator unionSets(member_iterator L1, member_iterator L2)
member_iterator unionSets(const ElemTy &V1, const ElemTy &V2)
union - Merge the two equivalence sets for the specified values, inserting them if they do not alread...
bool erase(const ElemTy &V)
erase - Erase a value from the union/find set, return "true" if erase succeeded, or "false" when the ...
EquivalenceClasses(const EquivalenceClasses &RHS)
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.