80#ifndef LLVM_ADT_SEQUENCE_H
81#define LLVM_ADT_SEQUENCE_H
115template <
typename T,
typename U>
117 const intmax_t BotT = intmax_t(std::numeric_limits<T>::min());
118 const intmax_t BotU = intmax_t(std::numeric_limits<U>::min());
119 const uintmax_t TopT = uintmax_t(std::numeric_limits<T>::max());
120 const uintmax_t TopU = uintmax_t(std::numeric_limits<U>::max());
122 (TopT < TopU && Value >
static_cast<U
>(TopT)));
131 template <
typename Integral,
132 std::enable_if_t<std::is_integral<Integral>::value,
bool> = 0>
137 Result.Value =
static_cast<intmax_t
>(FromValue);
142 template <
typename Enum,
143 std::enable_if_t<std::is_enum<Enum>::value,
bool> = 0>
150 return Value == O.Value;
153 return Value != O.Value;
171 template <
typename Integral,
172 std::enable_if_t<std::is_integral<Integral>::value,
bool> = 0>
173 constexpr Integral
to()
const {
176 return static_cast<Integral
>(Value);
181 template <
typename Enum,
182 std::enable_if_t<std::is_enum<Enum>::value,
bool> = 0>
183 constexpr Enum
to()
const {
184 using type = std::underlying_type_t<Enum>;
190 [[noreturn]]
static void assertOutOfBounds() {
194 static constexpr void assertOutOfBounds() {}
230 return (*
this - O) < 0;
233 return (*
this - O) > 0;
236 return (*
this - O) <= 0;
239 return (*
this - O) >= 0;
248 const auto Copy = *
this;
253 const auto Copy = *
this;
272 return IsReverse ? O.SI - SI : SI - O.SI;
282 constexpr CheckedInt add(intmax_t
Offset)
const {
286 constexpr void offset(intmax_t
Offset) { SI = SI + getOffset(
Offset); }
308 : BeginValue(Begin), PastEndValue(End) {
309 assert(Begin <= End &&
"Begin must be less or equal to End.");
314 constexpr size_t size()
const {
return PastEndValue - BeginValue; }
315 constexpr bool empty()
const {
return BeginValue == PastEndValue; }
326 static_assert(std::is_integral<T>::value || std::is_enum<T>::value,
327 "T must be an integral or enum type");
328 static_assert(std::is_same<T, std::remove_cv_t<T>>::value,
329 "T must not be const nor volatile");
339template <typename T, typename = std::enable_if_t<std::is_integral<T>::value &&
340 !std::is_enum<T>::value>>
349template <typename T, typename = std::enable_if_t<std::is_integral<T>::value &&
350 !std::is_enum<T>::value>>
359template <typename T, typename = std::enable_if_t<std::is_integral<T>::value &&
360 !std::is_enum<T>::value>>
371template <
typename EnumT,
372 typename = std::enable_if_t<std::is_enum<EnumT>::value>>
375 "Enum type is not marked as iterable.");
386template <
typename EnumT,
387 typename = std::enable_if_t<std::is_enum<EnumT>::value>>
399template <
typename EnumT,
400 typename = std::enable_if_t<std::is_enum<EnumT>::value>>
403 "Enum type is not marked as iterable.");
414template <
typename EnumT,
415 typename = std::enable_if_t<std::is_enum<EnumT>::value>>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
static std::optional< int32_t > getOffset(ArrayRef< int32_t > Offsets, size_t Idx)
This file contains library features backported from future STL versions.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr bool canTypeFitValue(const U Value)
This is an optimization pass for GlobalISel generic memory operations.
constexpr auto seq_inclusive(T Begin, T End)
Iterate over an integral type from Begin to End inclusive.
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
constexpr std::enable_if_t< std::is_signed_v< T >, std::pair< T, bool > > AddOverflow(T X, T Y)
Add two signed integers, computing the two's complement truncated result, returning a pair {result,...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
constexpr std::enable_if_t< std::is_signed_v< T >, std::pair< T, bool > > SubOverflow(T X, T Y)
Subtract two signed integers, computing the two's complement truncated result, returning a pair {resu...
constexpr auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
constexpr auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
static constexpr CheckedInt from(Enum FromValue)
constexpr bool operator!=(const CheckedInt &O) const
constexpr Integral to() const
static constexpr CheckedInt from(Integral FromValue)
constexpr CheckedInt operator+(intmax_t Offset) const
constexpr intmax_t operator-(CheckedInt Other) const
constexpr Enum to() const
constexpr bool operator==(const CheckedInt &O) const
constexpr bool operator>=(const SafeIntIterator &O) const
constexpr SafeIntIterator operator++(int)
constexpr bool operator==(const SafeIntIterator &O) const
constexpr SafeIntIterator operator+(intmax_t Offset) const
constexpr bool operator>(const SafeIntIterator &O) const
constexpr void operator-=(intmax_t Offset)
constexpr SafeIntIterator operator--(int)
constexpr SafeIntIterator(T Value)
constexpr bool operator<=(const SafeIntIterator &O) const
constexpr reference operator*() const
constexpr void operator++()
constexpr bool operator!=(const SafeIntIterator &O) const
constexpr void operator--()
constexpr void operator+=(intmax_t Offset)
constexpr bool operator<(const SafeIntIterator &O) const
friend struct SafeIntIterator
constexpr intmax_t operator-(const SafeIntIterator &O) const
constexpr SafeIntIterator operator-(intmax_t Offset) const
std::random_access_iterator_tag iterator_category
constexpr SafeIntIterator(const SafeIntIterator< T, !IsReverse > &O)
constexpr reference operator[](intmax_t Offset) const
static constexpr bool is_iterable
constexpr force_iteration_on_noniterable_enum_t()=default
constexpr auto end() const
constexpr iota_range(T Begin, T End, bool Inclusive)
constexpr auto begin() const
reverse_iterator const_reverse_iterator
detail::SafeIntIterator< value_type, false > iterator
detail::SafeIntIterator< value_type, true > reverse_iterator
constexpr size_t size() const
constexpr auto rbegin() const
constexpr bool empty() const
constexpr auto rend() const
const T & const_reference