LLVM  8.0.1
Sequence.h
Go to the documentation of this file.
1 //===- Sequence.h - Utility for producing sequences of values ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This routine provides some synthesis utilities to produce sequences of
11 /// values. The names are intentionally kept very short as they tend to occur
12 /// in common and widely used contexts.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_ADT_SEQUENCE_H
17 #define LLVM_ADT_SEQUENCE_H
18 
19 #include "llvm/ADT/iterator.h"
21 #include <algorithm>
22 #include <iterator>
23 #include <utility>
24 
25 namespace llvm {
26 
27 namespace detail {
28 
29 template <typename ValueT>
31  : public iterator_facade_base<value_sequence_iterator<ValueT>,
32  std::random_access_iterator_tag,
33  const ValueT> {
34  using BaseT = typename value_sequence_iterator::iterator_facade_base;
35 
36  ValueT Value;
37 
38 public:
39  using difference_type = typename BaseT::difference_type;
40  using reference = typename BaseT::reference;
41 
42  value_sequence_iterator() = default;
45  : Value(std::move(Arg.Value)) {}
46 
47  template <typename U, typename Enabler = decltype(ValueT(std::declval<U>()))>
48  value_sequence_iterator(U &&Value) : Value(std::forward<U>(Value)) {}
49 
51  Value += N;
52  return *this;
53  }
55  Value -= N;
56  return *this;
57  }
58  using BaseT::operator-;
60  return Value - RHS.Value;
61  }
62 
63  bool operator==(const value_sequence_iterator &RHS) const {
64  return Value == RHS.Value;
65  }
66  bool operator<(const value_sequence_iterator &RHS) const {
67  return Value < RHS.Value;
68  }
69 
70  reference operator*() const { return Value; }
71 };
72 
73 } // end namespace detail
74 
75 template <typename ValueT>
77  ValueT End) {
80 }
81 
82 } // end namespace llvm
83 
84 #endif // LLVM_ADT_SEQUENCE_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Definition: BitVector.h:938
difference_type operator-(const value_sequence_iterator &RHS) const
Definition: Sequence.h:59
typename BaseT::reference reference
Definition: Sequence.h:40
value_sequence_iterator(value_sequence_iterator &&Arg)
Definition: Sequence.h:44
bool operator==(const value_sequence_iterator &RHS) const
Definition: Sequence.h:63
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:68
value_sequence_iterator & operator-=(difference_type N)
Definition: Sequence.h:54
value_sequence_iterator & operator+=(difference_type N)
Definition: Sequence.h:50
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool operator<(const value_sequence_iterator &RHS) const
Definition: Sequence.h:66
iterator_range< detail::value_sequence_iterator< ValueT > > seq(ValueT Begin, ValueT End)
Definition: Sequence.h:76
A range adaptor for a pair of iterators.
amdgpu Simplify well known AMD library false Value Value * Arg
#define N
LLVM Value Representation.
Definition: Value.h:73
typename BaseT::difference_type difference_type
Definition: Sequence.h:39