19 #ifndef LLVM_ADT_SETVECTOR_H 20 #define LLVM_ADT_SETVECTOR_H 38 template <
typename T,
typename Vector = std::vector<T>,
39 typename Set = DenseSet<T>>
48 using iterator =
typename vector_type::const_iterator;
68 return std::move(vector_);
73 return vector_.empty();
78 return vector_.size();
83 return vector_.begin();
88 return vector_.begin();
103 return vector_.rbegin();
108 return vector_.rbegin();
113 return vector_.rend();
118 return vector_.rend();
123 assert(!
empty() &&
"Cannot call front() on empty SetVector!");
124 return vector_.front();
129 assert(!
empty() &&
"Cannot call back() on empty SetVector!");
130 return vector_.back();
135 assert(n < vector_.size() &&
"SetVector access out of range!");
142 bool result = set_.insert(X).second;
144 vector_.push_back(X);
149 template<
typename It>
151 for (; Start != End; ++Start)
152 if (set_.insert(*Start).second)
153 vector_.push_back(*Start);
159 typename vector_type::iterator
I =
find(vector_,
X);
160 assert(I != vector_.end() &&
"Corrupted SetVector instances!");
173 assert(set_.count(V) &&
"Corrupted SetVector instances!");
179 auto NI = vector_.begin();
180 std::advance(NI, std::distance<iterator>(NI, I));
182 return vector_.erase(NI);
198 template <
typename UnaryPredicate>
200 typename vector_type::iterator
I =
201 llvm::remove_if(vector_, TestAndEraseFromSet<UnaryPredicate>(P, set_));
202 if (I == vector_.end())
204 vector_.erase(I, vector_.end());
211 return set_.count(key);
222 assert(!
empty() &&
"Cannot remove an element from an empty SetVector!");
234 return vector_ == that.vector_;
238 return vector_ != that.vector_;
246 bool Changed =
false;
248 for (
typename STy::const_iterator
SI = S.begin(), SE = S.end();
SI != SE;
261 for (
typename STy::const_iterator
SI = S.begin(), SE = S.end();
SI != SE;
271 template <
typename UnaryPredicate>
272 class TestAndEraseFromSet {
277 TestAndEraseFromSet(UnaryPredicate P,
set_type &set_)
278 :
P(std::move(P)), set_(set_) {}
280 template <
typename ArgumentT>
281 bool operator()(
const ArgumentT &
Arg) {
296 template <
typename T,
unsigned N>
298 :
public SetVector<T, SmallVector<T, N>, SmallDenseSet<T, N>> {
303 template<
typename It>
311 #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.
const_iterator end() const
Get a const_iterator to the end of the SetVector.
std::vector< llvm::AbstractAttribute *> 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.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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.
Base struct for all "concrete attribute" deductions.
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.
reverse_iterator rend()
Get a reverse_iterator to the beginning of the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
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.