16 #ifndef LLVM_ADT_PRIORITYWORKLIST_H 17 #define LLVM_ADT_PRIORITYWORKLIST_H 27 #include <type_traits> 55 template <
typename T,
typename VectorT = std::vector<T>,
56 typename MapT = DenseMap<T, ptrdiff_t>>
86 assert(!
empty() &&
"Cannot call back() on empty PriorityWorklist!");
93 assert(X !=
T() &&
"Cannot insert a null (default constructed) value!");
94 auto InsertResult = M.insert({
X, V.size()});
95 if (InsertResult.second) {
101 auto &
Index = InsertResult.first->second;
102 assert(V[
Index] == X &&
"Value not actually at index in map!");
113 template <
typename SequenceT>
114 typename std::enable_if<!std::is_convertible<SequenceT, T>::value>
::type 125 for (
ptrdiff_t i = V.size() - 1; i >= StartIndex; --i) {
126 auto InsertResult = M.insert({V[i], i});
127 if (InsertResult.second)
133 if (Index < StartIndex) {
147 assert(!
empty() &&
"Cannot remove an element when empty!");
148 assert(
back() !=
T() &&
"Cannot have a null element at the back!");
152 }
while (!V.empty() && V.back() ==
T());
169 assert(V[
I->second] == X &&
"Value not actually at index in map!");
173 }
while (!V.empty() && V.back() ==
T());
194 template <
typename UnaryPredicate>
196 typename VectorT::iterator
E =
197 remove_if(V, TestAndEraseFromMap<UnaryPredicate>(P, M));
200 for (
auto I = V.begin();
I !=
E; ++
I)
202 M[*
I] =
I - V.begin();
225 template <
typename UnaryPredicateT>
226 class TestAndEraseFromMap {
231 TestAndEraseFromMap(UnaryPredicateT P, MapT &M)
232 :
P(std::move(P)), M(M) {}
234 bool operator()(
const T &
Arg) {
256 template <
typename T,
unsigned N>
259 SmallDenseMap<T, ptrdiff_t>> {
266 #endif // LLVM_ADT_PRIORITYWORKLIST_H const_iterator end(StringRef path)
Get end iterator over path.
typename SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > ::size_type size_type
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
bool erase(const T &X)
Erase an item from the worklist.
bool insert(const T &X)
Insert a new element into the PriorityWorklist.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
LLVM_NODISCARD T pop_back_val()
bool erase_if(UnaryPredicate P)
Erase items from the set vector based on a predicate function.
size_type size() const
Returns the number of elements in the worklist.
bool empty() const
Determine if the PriorityWorklist is empty or not.
PriorityWorklist()=default
Construct an empty PriorityWorklist.
const T & back() const
Return the last element of the PriorityWorklist.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
void clear()
Reverse the items in the PriorityWorklist.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
size_type count(const key_type &key) const
Count the number of elements of a given key in the PriorityWorklist.
std::enable_if<!std::is_convertible< SequenceT, T >::value >::type insert(SequenceT &&Input)
Insert a sequence of new elements into the PriorityWorklist.
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
A FILO worklist that prioritizes on re-insertion without duplication.
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
amdgpu Simplify well known AMD library false Value Value * Arg
void pop_back()
Remove the last element of the PriorityWorklist.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
An SCC of the call graph.