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;
137 if (Val.template is<EltTy>())
139 return *Val.template get<VecTy*>();
146 if (Val.template is<EltTy>())
148 return *Val.template get<VecTy*>();
153 typename std::enable_if<
154 std::is_convertible<ArrayRef<EltTy>,
ArrayRef<U>>::value,
163 if (Val.
isNull())
return true;
164 if (
VecTy *Vec = Val.template dyn_cast<VecTy*>())
172 if (Val.template is<EltTy>())
174 return Val.template get<VecTy*>()->
size();
183 if (Val.template is<EltTy>())
186 return Val.template get<VecTy *>()->
begin();
190 if (Val.template is<EltTy>())
193 return Val.template get<VecTy *>()->
end();
216 assert(!Val.
isNull() &&
"can't index into an empty vector");
217 if (EltTy V = Val.template dyn_cast<EltTy>()) {
218 assert(i == 0 &&
"tinyvector index out of range");
222 assert(i < Val.template get<VecTy*>()->size() &&
223 "tinyvector index out of range");
224 return (*Val.template get<VecTy*>())[i];
229 if (EltTy V = Val.template dyn_cast<EltTy>())
231 return Val.template get<VecTy*>()->
front();
236 if (EltTy V = Val.template dyn_cast<EltTy>())
238 return Val.template get<VecTy*>()->
back();
242 assert(NewVal &&
"Can't add a null value");
251 if (EltTy V = Val.template dyn_cast<EltTy>()) {
253 Val.template get<VecTy*>()->
push_back(V);
257 Val.template get<VecTy*>()->
push_back(NewVal);
262 if (Val.template is<EltTy>())
263 Val = (EltTy)
nullptr;
264 else if (
VecTy *Vec = Val.template get<VecTy*>())
270 if (Val.template is<EltTy>()) {
271 Val = (EltTy)
nullptr;
272 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
280 assert(I >=
begin() &&
"Iterator to erase is out of bounds.");
281 assert(I <
end() &&
"Erasing at past-the-end iterator.");
284 if (Val.template is<EltTy>()) {
286 Val = (EltTy)
nullptr;
287 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
290 return Vec->erase(I);
296 assert(S >=
begin() &&
"Range to erase is out of bounds.");
297 assert(S <= E &&
"Trying to erase invalid range.");
298 assert(E <=
end() &&
"Trying to erase past the end.");
300 if (Val.template is<EltTy>()) {
301 if (S ==
begin() && S != E)
302 Val = (EltTy)
nullptr;
303 }
else if (
VecTy *Vec = Val.template dyn_cast<VecTy*>()) {
304 return Vec->erase(S, E);
310 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
311 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
314 return std::prev(
end());
316 assert(!Val.
isNull() &&
"Null value with non-end insert iterator.");
317 if (EltTy V = Val.template dyn_cast<EltTy>()) {
324 return Val.template get<VecTy*>()->
insert(I, Elt);
327 template<
typename ItTy>
329 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
330 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
337 if (std::next(From) == To) {
343 }
else if (EltTy V = Val.template dyn_cast<EltTy>()) {
345 Val.template get<VecTy*>()->
push_back(V);
353 #endif // LLVM_ADT_TINYPTRVECTOR_H
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...
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)
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)