LLVM 20.0.0git
|
A FILO worklist that prioritizes on re-insertion without duplication. More...
#include "llvm/ADT/PriorityWorklist.h"
Public Types | |
using | value_type = T |
using | key_type = T |
using | reference = T & |
using | const_reference = const T & |
using | size_type = typename MapT::size_type |
Public Member Functions | |
PriorityWorklist ()=default | |
Construct an empty PriorityWorklist. | |
bool | empty () const |
Determine if the PriorityWorklist is empty or not. | |
size_type | size () const |
Returns the number of elements in the worklist. | |
size_type | count (const key_type &key) const |
Count the number of elements of a given key in the PriorityWorklist. | |
const T & | back () const |
Return the last element of the PriorityWorklist. | |
bool | insert (const T &X) |
Insert a new element into the PriorityWorklist. | |
template<typename SequenceT > | |
std::enable_if_t<!std::is_convertible< SequenceT, T >::value > | insert (SequenceT &&Input) |
Insert a sequence of new elements into the PriorityWorklist. | |
void | pop_back () |
Remove the last element of the PriorityWorklist. | |
T | pop_back_val () |
bool | erase (const T &X) |
Erase an item from the worklist. | |
template<typename UnaryPredicate > | |
bool | erase_if (UnaryPredicate P) |
Erase items from the set vector based on a predicate function. | |
void | clear () |
Reverse the items in the PriorityWorklist. | |
A FILO worklist that prioritizes on re-insertion without duplication.
This is very similar to a SetVector
with the primary difference that while re-insertion does not create a duplicate, it does adjust the visitation order to respect the last insertion point. This can be useful when the visit order needs to be prioritized based on insertion point without actually having duplicate visits.
Note that this doesn't prevent re-insertion of elements which have been visited – if you need to break cycles, a set will still be necessary.
The type T
must be default constructable to a null value that will be ignored. It is an error to insert such a value, and popping elements will never produce such a value. It is expected to be used with common nullable types like pointers or optionals.
Internally this uses a vector to store the worklist and a map to identify existing elements in the worklist. Both of these may be customized, but the map must support the basic DenseMap API for mapping from a T to an integer index into the vector.
A partial specialization is provided to automatically select a SmallVector and a SmallDenseMap if custom data structures are not provided.
Definition at line 55 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::const_reference = const T& |
Definition at line 60 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::key_type = T |
Definition at line 58 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::reference = T& |
Definition at line 59 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::size_type = typename MapT::size_type |
Definition at line 61 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::value_type = T |
Definition at line 57 of file PriorityWorklist.h.
|
default |
Construct an empty PriorityWorklist.
|
inline |
Return the last element of the PriorityWorklist.
Definition at line 83 of file PriorityWorklist.h.
References assert(), and llvm::PriorityWorklist< T, VectorT, MapT >::empty().
Referenced by llvm::PriorityWorklist< T, VectorT, MapT >::pop_back(), and llvm::PriorityWorklist< T, VectorT, MapT >::pop_back_val().
|
inline |
Reverse the items in the PriorityWorklist.
This does an in-place reversal. Other kinds of reverse aren't easy to support in the face of the worklist semantics. Completely clear the PriorityWorklist
Definition at line 211 of file PriorityWorklist.h.
Count the number of elements of a given key in the PriorityWorklist.
Definition at line 78 of file PriorityWorklist.h.
|
inline |
Determine if the PriorityWorklist is empty or not.
Definition at line 67 of file PriorityWorklist.h.
Referenced by llvm::PriorityWorklist< T, VectorT, MapT >::back(), llvm::PriorityWorklist< T, VectorT, MapT >::pop_back(), llvm::IRCEPass::run(), llvm::LoopAccessInfoPrinterPass::run(), llvm::FunctionToLoopPassAdaptor::run(), llvm::LoopUnrollPass::run(), llvm::ModuleToPostOrderCGSCCPassAdaptor::run(), llvm::sinkRegionForLoopNest(), and tryToUnrollAndJamLoop().
|
inline |
Erase items from the set vector based on a predicate function.
This is intended to be equivalent to the following code, if we could write it:
However, PriorityWorklist doesn't expose non-const iterators, making any algorithm like remove_if impossible to use.
Definition at line 193 of file PriorityWorklist.h.
References E, I, P, llvm::remove_if(), and T.
Insert a new element into the PriorityWorklist.
Definition at line 90 of file PriorityWorklist.h.
References assert(), T, and X.
Referenced by llvm::appendReversedLoopsToWorklist(), llvm::FunctionToLoopPassAdaptor::run(), llvm::ModuleToPostOrderCGSCCPassAdaptor::run(), and llvm::sinkRegionForLoopNest().
|
inline |
Insert a sequence of new elements into the PriorityWorklist.
Definition at line 113 of file PriorityWorklist.h.
References T.
|
inline |
Remove the last element of the PriorityWorklist.
Definition at line 144 of file PriorityWorklist.h.
References assert(), llvm::PriorityWorklist< T, VectorT, MapT >::back(), llvm::PriorityWorklist< T, VectorT, MapT >::empty(), and T.
Referenced by llvm::PriorityWorklist< T, VectorT, MapT >::pop_back_val().
|
inline |
Definition at line 153 of file PriorityWorklist.h.
References llvm::PriorityWorklist< T, VectorT, MapT >::back(), and llvm::PriorityWorklist< T, VectorT, MapT >::pop_back().
Referenced by llvm::IRCEPass::run(), llvm::LoopAccessInfoPrinterPass::run(), llvm::FunctionToLoopPassAdaptor::run(), llvm::LoopUnrollPass::run(), llvm::ModuleToPostOrderCGSCCPassAdaptor::run(), llvm::sinkRegionForLoopNest(), and tryToUnrollAndJamLoop().
|
inline |
Returns the number of elements in the worklist.
Definition at line 72 of file PriorityWorklist.h.