10 #ifndef LLVM_ADT_TINYPTRVECTOR_H 11 #define LLVM_ADT_TINYPTRVECTOR_H 20 #include <type_traits> 30 template <
typename EltTy>
44 if (
VecTy *V = Val.template dyn_cast<VecTy*>())
49 if (
VecTy *V = Val.template dyn_cast<VecTy*>())
63 if (Val.template is<EltTy>()) {
67 Val =
new VecTy(*RHS.Val.template get<VecTy*>());
72 if (RHS.Val.template is<EltTy>()) {
73 Val.template get<VecTy*>()->
clear();
76 *Val.template get<VecTy*>() = *RHS.Val.template get<VecTy*>();
82 RHS.Val = (EltTy)
nullptr;
96 if (
VecTy *V = Val.template dyn_cast<VecTy*>()) {
97 if (RHS.Val.template is<EltTy>()) {
99 V->push_back(RHS.front());
100 RHS.Val = (EltTy)
nullptr;
107 RHS.Val = (EltTy)
nullptr;
131 if (Val.template is<EltTy>())
133 return *Val.template get<VecTy*>();
140 if (Val.template is<EltTy>())
142 return *Val.template get<VecTy*>();
147 typename std::enable_if<
148 std::is_convertible<ArrayRef<EltTy>,
ArrayRef<U>>::value,
157 if (Val.
isNull())
return true;
158 if (
VecTy *Vec = Val.template dyn_cast<VecTy*>())
166 if (Val.template is<EltTy>())
168 return Val.template get<VecTy*>()->
size();
177 if (Val.template is<EltTy>())
180 return Val.template get<VecTy *>()->
begin();
184 if (Val.template is<EltTy>())
187 return Val.template get<VecTy *>()->
end();
210 assert(!Val.
isNull() &&
"can't index into an empty vector");
211 if (EltTy V = Val.template dyn_cast<EltTy>()) {
212 assert(i == 0 &&
"tinyvector index out of range");
216 assert(i < Val.template get<VecTy*>()->size() &&
217 "tinyvector index out of range");
218 return (*Val.template get<VecTy*>())[i];
223 if (EltTy V = Val.template dyn_cast<EltTy>())
225 return Val.template get<VecTy*>()->
front();
230 if (EltTy V = Val.template dyn_cast<EltTy>())
232 return Val.template get<VecTy*>()->
back();
236 assert(NewVal &&
"Can't add a null value");
245 if (EltTy V = Val.template dyn_cast<EltTy>()) {
247 Val.template get<VecTy*>()->
push_back(V);
251 Val.template get<VecTy*>()->
push_back(NewVal);
256 if (Val.template is<EltTy>())
257 Val = (EltTy)
nullptr;
258 else if (
VecTy *Vec = Val.template get<VecTy*>())
264 if (Val.template is<EltTy>()) {
265 Val = (EltTy)
nullptr;
266 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
274 assert(I >=
begin() &&
"Iterator to erase is out of bounds.");
275 assert(I <
end() &&
"Erasing at past-the-end iterator.");
278 if (Val.template is<EltTy>()) {
280 Val = (EltTy)
nullptr;
281 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
284 return Vec->erase(I);
290 assert(S >=
begin() &&
"Range to erase is out of bounds.");
291 assert(S <= E &&
"Trying to erase invalid range.");
292 assert(E <=
end() &&
"Trying to erase past the end.");
294 if (Val.template is<EltTy>()) {
295 if (S ==
begin() && S != E)
296 Val = (EltTy)
nullptr;
297 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
298 return Vec->erase(S, E);
304 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
305 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
308 return std::prev(
end());
310 assert(!Val.
isNull() &&
"Null value with non-end insert iterator.");
311 if (EltTy V = Val.template dyn_cast<EltTy>()) {
318 return Val.template get<VecTy*>()->
insert(I, Elt);
321 template<
typename ItTy>
323 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
324 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
331 if (std::next(From) == To) {
337 }
else if (EltTy V = Val.template dyn_cast<EltTy>()) {
339 Val.template get<VecTy*>()->
push_back(V);
347 #endif // LLVM_ADT_TINYPTRVECTOR_H
Compute iterated dominance frontiers using a linear time algorithm.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
TinyPtrVector(const TinyPtrVector &RHS)
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
const_reverse_iterator rbegin() const
iterator erase(iterator I)
PT1 const * getAddrOfPtr1() const
If the union is set to the first pointer type get an address pointing to it.
TinyPtrVector & operator=(const TinyPtrVector &RHS)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
reverse_iterator rbegin()
std::reverse_iterator< iterator > reverse_iterator
TinyPtrVector(ArrayRef< EltTy > Elts)
Constructor from an ArrayRef.
iterator insert(iterator I, const EltTy &Elt)
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
void push_back(EltTy NewVal)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
TinyPtrVector(TinyPtrVector &&RHS)
TinyPtrVector(size_t Count, EltTy Value)
TinyPtrVector & operator=(TinyPtrVector &&RHS)
const_reverse_iterator rend() const
const_iterator begin() const
const_iterator end() const
typename VecTy::value_type value_type
EltTy operator[](unsigned i) const
SmallVector< EltTy, 4 > VecTy
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
std::reverse_iterator< const_iterator > const_reverse_iterator
iterator erase(iterator S, iterator E)
iterator insert(iterator I, ItTy From, ItTy To)