Go to the documentation of this file.
15 #ifndef LLVM_ADT_PRIORITYWORKLIST_H
16 #define LLVM_ADT_PRIORITYWORKLIST_H
25 #include <type_traits>
53 template <
typename T,
typename VectorT = std::vector<T>,
54 typename MapT = DenseMap<T, ptrdiff_t>>
84 assert(!
empty() &&
"Cannot call back() on empty PriorityWorklist!");
91 assert(
X !=
T() &&
"Cannot insert a null (default constructed) value!");
92 auto InsertResult = M.insert({
X, V.size()});
93 if (InsertResult.second) {
99 auto &Index = InsertResult.first->second;
100 assert(V[Index] ==
X &&
"Value not actually at index in map!");
101 if (Index != (
ptrdiff_t)(V.size() - 1)) {
111 template <
typename SequenceT>
112 std::enable_if_t<!std::is_convertible<SequenceT, T>::value>
123 for (
ptrdiff_t i = V.size() - 1;
i >= StartIndex; --
i) {
124 auto InsertResult = M.insert({V[
i],
i});
125 if (InsertResult.second)
130 ptrdiff_t &Index = InsertResult.first->second;
131 if (Index < StartIndex) {
145 assert(!
empty() &&
"Cannot remove an element when empty!");
146 assert(
back() !=
T() &&
"Cannot have a null element at the back!");
150 }
while (!V.empty() && V.back() ==
T());
167 assert(V[
I->second] ==
X &&
"Value not actually at index in map!");
171 }
while (!V.empty() && V.back() ==
T());
192 template <
typename UnaryPredicate>
194 typename VectorT::iterator
E =
195 remove_if(V, TestAndEraseFromMap<UnaryPredicate>(
P, M));
198 for (
auto I = V.begin();
I !=
E; ++
I)
200 M[*
I] =
I - V.begin();
223 template <
typename UnaryPredicateT>
224 class TestAndEraseFromMap {
229 TestAndEraseFromMap(UnaryPredicateT
P, MapT &M)
232 bool operator()(
const T &
Arg) {
254 template <
typename T,
unsigned N>
257 SmallDenseMap<T, ptrdiff_t>> {
264 #endif // LLVM_ADT_PRIORITYWORKLIST_H
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
void pop_back()
Remove the last element of the PriorityWorklist.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
bool insert(const T &X)
Insert a new element into the PriorityWorklist.
size_type size() const
Returns the number of elements in the worklist.
SmallPriorityWorklist()=default
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
A FILO worklist that prioritizes on re-insertion without duplication.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
auto remove_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly.
An SCC of the call graph.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool erase_if(UnaryPredicate P)
Erase items from the set vector based on a predicate function.
LLVM_NODISCARD T pop_back_val()
typename SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > ::size_type size_type
const T & back() const
Return the last element of the PriorityWorklist.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
bool erase(const T &X)
Erase an item from the worklist.
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
bool empty() const
Determine if the PriorityWorklist is empty or not.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
PriorityWorklist()=default
Construct an empty PriorityWorklist.
void clear()
Reverse the items in the PriorityWorklist.
std::enable_if_t<!std::is_convertible< SequenceT, T >::value > insert(SequenceT &&Input)
Insert a sequence of new elements into the PriorityWorklist.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
size_type count(const key_type &key) const
Count the number of elements of a given key in the PriorityWorklist.