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());
106 RHS.Val = (EltTy)
nullptr;
130 if (Val.template is<EltTy>())
132 return *Val.template get<VecTy*>();
139 if (Val.template is<EltTy>())
141 return *Val.template get<VecTy*>();
146 typename std::enable_if<
147 std::is_convertible<ArrayRef<EltTy>,
ArrayRef<U>>::value,
156 if (Val.
isNull())
return true;
157 if (
VecTy *Vec = Val.template dyn_cast<VecTy*>())
165 if (Val.template is<EltTy>())
167 return Val.template get<VecTy*>()->
size();
176 if (Val.template is<EltTy>())
179 return Val.template get<VecTy *>()->
begin();
183 if (Val.template is<EltTy>())
186 return Val.template get<VecTy *>()->
end();
209 assert(!Val.
isNull() &&
"can't index into an empty vector");
210 if (EltTy V = Val.template dyn_cast<EltTy>()) {
211 assert(i == 0 &&
"tinyvector index out of range");
215 assert(i < Val.template get<VecTy*>()->size() &&
216 "tinyvector index out of range");
217 return (*Val.template get<VecTy*>())[i];
222 if (EltTy V = Val.template dyn_cast<EltTy>())
224 return Val.template get<VecTy*>()->
front();
229 if (EltTy V = Val.template dyn_cast<EltTy>())
231 return Val.template get<VecTy*>()->
back();
235 assert(NewVal &&
"Can't add a null value");
244 if (EltTy V = Val.template dyn_cast<EltTy>()) {
246 Val.template get<VecTy*>()->
push_back(V);
250 Val.template get<VecTy*>()->
push_back(NewVal);
255 if (Val.template is<EltTy>())
256 Val = (EltTy)
nullptr;
257 else if (
VecTy *Vec = Val.template get<VecTy*>())
263 if (Val.template is<EltTy>()) {
264 Val = (EltTy)
nullptr;
265 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
273 assert(I >=
begin() &&
"Iterator to erase is out of bounds.");
274 assert(I <
end() &&
"Erasing at past-the-end iterator.");
277 if (Val.template is<EltTy>()) {
279 Val = (EltTy)
nullptr;
280 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
283 return Vec->erase(I);
289 assert(S >=
begin() &&
"Range to erase is out of bounds.");
290 assert(S <= E &&
"Trying to erase invalid range.");
291 assert(E <=
end() &&
"Trying to erase past the end.");
293 if (Val.template is<EltTy>()) {
294 if (S ==
begin() && S != E)
295 Val = (EltTy)
nullptr;
296 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
297 return Vec->erase(S, E);
303 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
304 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
307 return std::prev(
end());
309 assert(!Val.
isNull() &&
"Null value with non-end insert iterator.");
310 if (EltTy V = Val.template dyn_cast<EltTy>()) {
317 return Val.template get<VecTy*>()->
insert(I, Elt);
320 template<
typename ItTy>
322 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
323 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
330 if (std::next(From) == To) {
336 }
else if (EltTy V = Val.template dyn_cast<EltTy>()) {
338 Val.template get<VecTy*>()->
push_back(V);
346 #endif // LLVM_ADT_TINYPTRVECTOR_H
const_iterator end() const
std::reverse_iterator< const_iterator > const_reverse_iterator
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
TinyPtrVector(const TinyPtrVector &RHS)
const EltTy * const_iterator
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
iterator erase(iterator I)
EltTy operator[](unsigned i) const
const_reverse_iterator rbegin() const
TinyPtrVector & operator=(const TinyPtrVector &RHS)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
reverse_iterator rbegin()
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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)
SmallVector< EltTy, 4 > VecTy
PointerUnion< EltTy, VecTy * > PtrUnion
PT1 const * getAddrOfPtr1() const
If the union is set to the first pointer type get an address pointing to it.
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
TinyPtrVector(TinyPtrVector &&RHS)
TinyPtrVector(size_t Count, EltTy Value)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
TinyPtrVector & operator=(TinyPtrVector &&RHS)
std::reverse_iterator< iterator > reverse_iterator
const_reverse_iterator rend() const
const_iterator begin() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
iterator erase(iterator S, iterator E)
VecTy::value_type value_type
iterator insert(iterator I, ItTy From, ItTy To)