9 #ifndef LLVM_ADT_TINYPTRVECTOR_H 10 #define LLVM_ADT_TINYPTRVECTOR_H 19 #include <type_traits> 29 template <
typename EltTy>
47 if (
VecTy *V = Val.template dyn_cast<VecTy*>())
52 if (
VecTy *V = Val.template dyn_cast<VecTy*>())
66 if (Val.template is<EltTy>()) {
70 Val =
new VecTy(*RHS.Val.template get<VecTy*>());
75 if (RHS.Val.template is<EltTy>()) {
76 Val.template get<VecTy*>()->
clear();
79 *Val.template get<VecTy*>() = *RHS.Val.template get<VecTy*>();
85 RHS.Val = (EltTy)
nullptr;
99 if (
VecTy *V = Val.template dyn_cast<VecTy*>()) {
100 if (RHS.Val.template is<EltTy>()) {
102 V->push_back(RHS.front());
140 if (Val.template is<EltTy>())
142 return *Val.template get<VecTy*>();
149 if (Val.template is<EltTy>())
151 return *Val.template get<VecTy*>();
156 typename std::enable_if<
157 std::is_convertible<ArrayRef<EltTy>,
ArrayRef<U>>::value,
166 if (Val.
isNull())
return true;
167 if (
VecTy *Vec = Val.template dyn_cast<VecTy*>())
175 if (Val.template is<EltTy>())
177 return Val.template get<VecTy*>()->
size();
186 if (Val.template is<EltTy>())
189 return Val.template get<VecTy *>()->
begin();
193 if (Val.template is<EltTy>())
196 return Val.template get<VecTy *>()->
end();
219 assert(!Val.
isNull() &&
"can't index into an empty vector");
220 if (Val.template is<EltTy>()) {
221 assert(i == 0 &&
"tinyvector index out of range");
222 return Val.template get<EltTy>();
225 assert(i < Val.template get<VecTy*>()->size() &&
226 "tinyvector index out of range");
227 return (*Val.template get<VecTy*>())[i];
232 if (Val.template is<EltTy>())
233 return Val.template get<EltTy>();
234 return Val.template get<VecTy*>()->
front();
239 if (Val.template is<EltTy>())
240 return Val.template get<EltTy>();
241 return Val.template get<VecTy*>()->
back();
253 if (Val.template is<EltTy>()) {
254 EltTy V = Val.template get<EltTy>();
256 Val.template get<VecTy*>()->
push_back(V);
260 Val.template get<VecTy*>()->
push_back(NewVal);
265 if (Val.template is<EltTy>())
266 Val = (EltTy)
nullptr;
267 else if (
VecTy *Vec = Val.template get<VecTy*>())
273 if (Val.template is<EltTy>()) {
275 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
283 assert(I >=
begin() &&
"Iterator to erase is out of bounds.");
284 assert(I <
end() &&
"Erasing at past-the-end iterator.");
287 if (Val.template is<EltTy>()) {
290 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
293 return Vec->erase(I);
299 assert(S >=
begin() &&
"Range to erase is out of bounds.");
300 assert(S <= E &&
"Trying to erase invalid range.");
301 assert(E <=
end() &&
"Trying to erase past the end.");
303 if (Val.template is<EltTy>()) {
304 if (S ==
begin() && S != E)
306 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
307 return Vec->erase(S, E);
313 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
314 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
317 return std::prev(
end());
319 assert(!Val.
isNull() &&
"Null value with non-end insert iterator.");
320 if (Val.template is<EltTy>()) {
321 EltTy V = Val.template get<EltTy>();
328 return Val.template get<VecTy*>()->
insert(I, Elt);
331 template<
typename ItTy>
333 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
334 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
341 if (std::next(From) == To) {
347 }
else if (Val.template is<EltTy>()) {
348 EltTy V = Val.template get<EltTy>();
350 Val.template get<VecTy*>()->
push_back(V);
358 #endif // LLVM_ADT_TINYPTRVECTOR_H
First const * getAddrOfPtr1() const
If the union is set to the first pointer type get an address pointing to it.
This class represents lattice values for constants.
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...
const_reverse_iterator rbegin() const
iterator erase(iterator I)
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
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)
BlockVerifier::State From
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
TinyPtrVector(std::initializer_list< EltTy > IL)
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)