20 #ifndef LLVM_ADT_SETVECTOR_H 21 #define LLVM_ADT_SETVECTOR_H 39 template <
typename T,
typename Vector = std::vector<T>,
40 typename Set = DenseSet<T>>
49 using iterator =
typename vector_type::const_iterator;
69 return std::move(vector_);
74 return vector_.empty();
79 return vector_.size();
84 return vector_.begin();
89 return vector_.begin();
104 return vector_.rbegin();
109 return vector_.rbegin();
114 return vector_.rend();
119 return vector_.rend();
124 assert(!
empty() &&
"Cannot call front() on empty SetVector!");
125 return vector_.front();
130 assert(!
empty() &&
"Cannot call back() on empty SetVector!");
131 return vector_.back();
136 assert(n < vector_.size() &&
"SetVector access out of range!");
143 bool result = set_.insert(X).second;
145 vector_.push_back(X);
150 template<
typename It>
152 for (; Start != End; ++Start)
153 if (set_.insert(*Start).second)
154 vector_.push_back(*Start);
160 typename vector_type::iterator
I =
find(vector_,
X);
161 assert(I != vector_.end() &&
"Corrupted SetVector instances!");
174 assert(set_.count(V) &&
"Corrupted SetVector instances!");
180 auto NI = vector_.begin();
181 std::advance(NI, std::distance<iterator>(NI, I));
183 return vector_.erase(NI);
199 template <
typename UnaryPredicate>
201 typename vector_type::iterator
I =
202 llvm::remove_if(vector_, TestAndEraseFromSet<UnaryPredicate>(P, set_));
203 if (I == vector_.end())
205 vector_.erase(I, vector_.end());
212 return set_.count(key);
223 assert(!
empty() &&
"Cannot remove an element from an empty SetVector!");
235 return vector_ == that.vector_;
239 return vector_ != that.vector_;
247 bool Changed =
false;
249 for (
typename STy::const_iterator
SI = S.begin(), SE = S.end();
SI != SE;
262 for (
typename STy::const_iterator
SI = S.begin(), SE = S.end();
SI != SE;
272 template <
typename UnaryPredicate>
273 class TestAndEraseFromSet {
278 TestAndEraseFromSet(UnaryPredicate P,
set_type &set_)
279 :
P(std::move(P)), set_(set_) {}
281 template <
typename ArgumentT>
282 bool operator()(
const ArgumentT &
Arg) {
297 template <
typename T,
unsigned N>
299 :
public SetVector<T, SmallVector<T, N>, SmallDenseSet<T, N>> {
304 template<
typename It>
312 #endif // LLVM_ADT_SETVECTOR_H typename vector_type::const_reverse_iterator reverse_iterator
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
LLVM_NODISCARD T pop_back_val()
const T & front() const
Return the first element of the SetVector.
This class represents lattice values for constants.
ArrayRef< T > getArrayRef() const
size_type size() const
Determine the number of elements in the SetVector.
bool erase(const ValueT &V)
iterator erase(iterator I)
Erase a single element from the set vector.
iterator end()
Get an iterator to the end of the SetVector.
const T & back() const
Return the last element of the SetVector.
SetVector()=default
Construct an empty SetVector.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
const_iterator end() const
Get a const_iterator to the end of the SetVector.
std::vector< llvm::SUnit *> vector_type
typename vector_type::size_type size_type
reverse_iterator rbegin()
Get an reverse_iterator to the end of the SetVector.
void pop_back()
Remove the last element of the SetVector.
const_reference operator[](size_type n) const
Index into the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
typename vector_type::const_reverse_iterator const_reverse_iterator
iterator begin()
Get an iterator to the beginning of the SetVector.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const_reverse_iterator rbegin() const
Get a const_reverse_iterator to the end of the SetVector.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
bool set_union(const STy &S)
Compute This := This u S, return whether 'This' changed.
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...
void insert(It Start, It End)
Insert a range of elements into the SetVector.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
typename vector_type::const_iterator const_iterator
bool operator==(const SetVector &that) const
SetVector(It Start, It End)
Initialize a SetVector with a range of elements.
bool operator!=(const SetVector &that) const
typename vector_type::const_iterator iterator
A SetVector that performs no allocations if smaller than a certain size.
Vector takeVector()
Clear the SetVector and return the underlying vector.
void set_subtract(const STy &S)
Compute This := This - B TODO: We should be able to use set_subtract from SetOperations.h, but SetVector interface is inconsistent with DenseSet.
void clear()
Completely clear the SetVector.
amdgpu Simplify well known AMD library false Value Value * Arg
reverse_iterator rend()
Get a reverse_iterator to the beginning of the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallSetVector(It Start, It End)
Initialize a SmallSetVector with a range of elements.
A vector that has set insertion semantics.
bool remove_if(UnaryPredicate P)
Remove items from the set vector based on a predicate function.
const_reverse_iterator rend() const
Get a const_reverse_iterator to the beginning of the SetVector.
const_iterator begin() const
Get a const_iterator to the beginning of the SetVector.
Scheduling unit. This is a node in the scheduling DAG.