Go to the documentation of this file.
9 #ifndef LLVM_ADT_ITERATOR_H
10 #define LLVM_ADT_ITERATOR_H
15 #include <type_traits>
77 template <
typename DerivedT,
typename IteratorCategoryT,
typename T,
78 typename DifferenceTypeT = std::ptrdiff_t,
typename PointerT =
T *,
79 typename ReferenceT =
T &>
91 IteratorCategoryT>::value,
93 IteratorCategoryT>::value,
109 operator ReferenceT()
const {
return *
I; }
121 template <
typename RefT>
130 static_assert(std::is_base_of<iterator_facade_base, DerivedT>::value,
131 "Must pass the derived type to this template!");
134 "The '+' operator is only defined for random access iterators.");
135 DerivedT
tmp = *
static_cast<const DerivedT *
>(
this);
142 "The '+' operator is only defined for random access iterators.");
148 "The '-' operator is only defined for random access iterators.");
149 DerivedT
tmp = *
static_cast<const DerivedT *
>(
this);
155 static_assert(std::is_base_of<iterator_facade_base, DerivedT>::value,
156 "Must pass the derived type to this template!");
157 return static_cast<DerivedT *
>(
this)->
operator+=(1);
160 DerivedT
tmp = *
static_cast<DerivedT *
>(
this);
161 ++*
static_cast<DerivedT *
>(
this);
167 "The decrement operator is only defined for bidirectional iterators.");
168 return static_cast<DerivedT *
>(
this)->
operator-=(1);
173 "The decrement operator is only defined for bidirectional iterators.");
174 DerivedT
tmp = *
static_cast<DerivedT *
>(
this);
175 --*
static_cast<DerivedT *
>(
this);
179 #ifndef __cpp_impl_three_way_comparison
181 return !(
static_cast<const DerivedT &
>(*this) ==
RHS);
188 "Relational operators are only defined for random access iterators.");
189 return !(
static_cast<const DerivedT &
>(*this) <
RHS) &&
190 !(
static_cast<const DerivedT &
>(*
this) ==
RHS);
195 "Relational operators are only defined for random access iterators.");
196 return !(
static_cast<const DerivedT &
>(*this) >
RHS);
201 "Relational operators are only defined for random access iterators.");
202 return !(
static_cast<const DerivedT &
>(*this) <
RHS);
206 return static_cast<const DerivedT *
>(
this)->
operator*();
210 "Subscripting is only defined for random access iterators.");
211 return static_cast<const DerivedT *
>(
this)->
operator+(
n);
222 typename IteratorCategoryT =
223 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
224 typename T =
typename std::iterator_traits<WrappedIteratorT>::value_type,
225 typename DifferenceTypeT =
226 typename std::iterator_traits<WrappedIteratorT>::difference_type,
227 typename PointerT = std::conditional_t<
228 std::is_same<
T,
typename std::iterator_traits<
231 typename ReferenceT = std::conditional_t<
232 std::is_same<
T,
typename std::iterator_traits<
234 typename std::iterator_traits<WrappedIteratorT>::reference,
T &>>
237 DifferenceTypeT, PointerT, ReferenceT> {
238 using BaseT =
typename iterator_adaptor_base::iterator_facade_base;
246 static_assert(std::is_base_of<iterator_adaptor_base, DerivedT>::value,
247 "Must pass the derived type to this template!");
257 BaseT::IsRandomAccess,
258 "The '+=' operator is only defined for random access iterators.");
260 return *
static_cast<DerivedT *
>(
this);
264 BaseT::IsRandomAccess,
265 "The '-=' operator is only defined for random access iterators.");
267 return *
static_cast<DerivedT *
>(
this);
269 using BaseT::operator-;
272 BaseT::IsRandomAccess,
273 "The '-' operator is only defined for random access iterators.");
279 using BaseT::operator++;
282 return *
static_cast<DerivedT *
>(
this);
284 using BaseT::operator--;
287 BaseT::IsBidirectional,
288 "The decrement operator is only defined for bidirectional iterators.");
290 return *
static_cast<DerivedT *
>(
this);
300 BaseT::IsRandomAccess,
301 "Relational operators are only defined for random access iterators.");
318 typename T = std::remove_reference_t<decltype(
319 **std::declval<WrappedIteratorT>())>>
322 pointee_iterator<WrappedIteratorT, T>, WrappedIteratorT,
323 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
326 template <
typename U>
335 iterator_range<pointee_iterator<WrappedIteratorT>>
339 PointeeIteratorT(
std::end(std::forward<RangeT>(Range))));
343 typename T = decltype(&*std::declval<WrappedIteratorT>())>
346 pointer_iterator<WrappedIteratorT, T>, WrappedIteratorT,
347 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
362 iterator_range<pointer_iterator<WrappedIteratorT>>
366 PointerIteratorT(
std::end(std::forward<RangeT>(Range))));
370 typename T1 = std::remove_reference_t<decltype(
371 **std::declval<WrappedIteratorT>())>,
372 typename T2 = std::add_pointer_t<T1>>
378 #endif // LLVM_ADT_ITERATOR_H
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Replace within non kernel function use of LDS with pointer
PointerProxy operator->() const
DerivedT & operator-=(difference_type n)
ReferenceProxy operator[](DifferenceTypeT n) const
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
CRTP base class for adapting an iterator to a different type.
iterator_adaptor_base()=default
const WrappedIteratorT & wrapped() const
alloca< 16 x float >, align 16 %tmp2=alloca< 16 x float >, align 16 store< 16 x float > %A,< 16 x float > *%tmp %s=bitcast< 16 x float > *%tmp to i8 *%s2=bitcast< 16 x float > *%tmp2 to i8 *call void @llvm.memcpy.i64(i8 *%s, i8 *%s2, i64 64, i32 16) %R=load< 16 x float > *%tmp2 ret< 16 x float > %R } declare void @llvm.memcpy.i64(i8 *nocapture, i8 *nocapture, i64, i32) nounwind which compiles to:_foo:subl $140, %esp movaps %xmm3, 112(%esp) movaps %xmm2, 96(%esp) movaps %xmm1, 80(%esp) movaps %xmm0, 64(%esp) movl 60(%esp), %eax movl %eax, 124(%esp) movl 56(%esp), %eax movl %eax, 120(%esp) movl 52(%esp), %eax< many many more 32-bit copies > movaps(%esp), %xmm0 movaps 16(%esp), %xmm1 movaps 32(%esp), %xmm2 movaps 48(%esp), %xmm3 addl $140, %esp ret On Nehalem, it may even be cheaper to just use movups when unaligned than to fall back to lower-granularity chunks. Implement processor-specific optimizations for parity with GCC on these processors. GCC does two optimizations:1. ix86_pad_returns inserts a noop before ret instructions if immediately preceded by a conditional branch or is the target of a jump. 2. ix86_avoid_jump_misspredicts inserts noops in cases where a 16-byte block of code contains more than 3 branches. The first one is done for all AMDs, Core2, and "Generic" The second one is done for:Atom, Pentium Pro, all AMDs, Pentium 4, Nocona, Core 2, and "Generic" Testcase:int x(int a) { return(a &0xf0)> >4 tmp
DerivedT & operator+=(difference_type n)
pointer_iterator< pointee_iterator< WrappedIteratorT, T1 >, T2 > raw_pointer_iterator
pointee_iterator()=default
DerivedT operator+(DifferenceTypeT n) const
friend DerivedT operator+(DifferenceTypeT n, const DerivedT &i)
friend bool operator==(const iterator_adaptor_base &LHS, const iterator_adaptor_base &RHS)
PointerT operator->() const
bool operator!=(const DerivedT &RHS) const
bool operator>(const DerivedT &RHS) const
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
A proxy object for computing a pointer via indirecting a copy of a reference.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
DerivedT operator-(DifferenceTypeT n) const
iterator_adaptor_base(WrappedIteratorT u)
iterator_range< pointee_iterator< WrappedIteratorT > > make_pointee_range(RangeT &&Range)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
std::ptrdiff_t difference_type
friend bool operator<(const iterator_adaptor_base &LHS, const iterator_adaptor_base &RHS)
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
bool operator>=(const DerivedT &RHS) const
difference_type operator-(const DerivedT &RHS) const
bool operator<=(const DerivedT &RHS) const
ReferenceT operator*() const
An iterator type that allows iterating over the pointees via some other iterator.
std::forward_iterator_tag iterator_category
The same transformation can work with an even modulo with the addition of a and shrink the compare RHS by the same amount Unless the target supports that transformation probably isn t worthwhile The transformation can also easily be made to work with non zero equality for n
pointer_iterator()=default
pointer_iterator(WrappedIteratorT u)
A proxy object for computing a reference via indirecting a copy of an iterator.