LLVM  10.0.0svn
Sequence.h
Go to the documentation of this file.
1 //===- Sequence.h - Utility for producing sequences of values ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 /// This routine provides some synthesis utilities to produce sequences of
10 /// values. The names are intentionally kept very short as they tend to occur
11 /// in common and widely used contexts.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_ADT_SEQUENCE_H
16 #define LLVM_ADT_SEQUENCE_H
17 
18 #include "llvm/ADT/iterator.h"
20 #include <algorithm>
21 #include <iterator>
22 #include <utility>
23 
24 namespace llvm {
25 
26 namespace detail {
27 
28 template <typename ValueT>
30  : public iterator_facade_base<value_sequence_iterator<ValueT>,
31  std::random_access_iterator_tag,
32  const ValueT> {
33  using BaseT = typename value_sequence_iterator::iterator_facade_base;
34 
35  ValueT Value;
36 
37 public:
38  using difference_type = typename BaseT::difference_type;
39  using reference = typename BaseT::reference;
40 
41  value_sequence_iterator() = default;
44  : Value(std::move(Arg.Value)) {}
45 
46  template <typename U, typename Enabler = decltype(ValueT(std::declval<U>()))>
47  value_sequence_iterator(U &&Value) : Value(std::forward<U>(Value)) {}
48 
50  Value += N;
51  return *this;
52  }
54  Value -= N;
55  return *this;
56  }
57  using BaseT::operator-;
59  return Value - RHS.Value;
60  }
61 
62  bool operator==(const value_sequence_iterator &RHS) const {
63  return Value == RHS.Value;
64  }
65  bool operator<(const value_sequence_iterator &RHS) const {
66  return Value < RHS.Value;
67  }
68 
69  reference operator*() const { return Value; }
70 };
71 
72 } // end namespace detail
73 
74 template <typename ValueT>
76  ValueT End) {
79 }
80 
81 } // end namespace llvm
82 
83 #endif // LLVM_ADT_SEQUENCE_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Definition: BitVector.h:937
difference_type operator-(const value_sequence_iterator &RHS) const
Definition: Sequence.h:58
typename BaseT::reference reference
Definition: Sequence.h:39
value_sequence_iterator(value_sequence_iterator &&Arg)
Definition: Sequence.h:43
bool operator==(const value_sequence_iterator &RHS) const
Definition: Sequence.h:62
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:67
value_sequence_iterator & operator-=(difference_type N)
Definition: Sequence.h:53
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
value_sequence_iterator & operator+=(difference_type N)
Definition: Sequence.h:49
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:65
iterator_range< detail::value_sequence_iterator< ValueT > > seq(ValueT Begin, ValueT End)
Definition: Sequence.h:75
A range adaptor for a pair of iterators.
#define N
LLVM Value Representation.
Definition: Value.h:73
typename BaseT::difference_type difference_type
Definition: Sequence.h:38