LLVM  14.0.0git
Classes | Namespaces | Functions | Variables
Sequence.h File Reference
#include <cassert>
#include <iterator>
#include <limits>
#include <type_traits>
#include "llvm/Support/MathExtras.h"
Include dependency graph for Sequence.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  llvm::enum_iteration_traits< EnumT >
 
struct  llvm::force_iteration_on_noniterable_enum_t
 
struct  llvm::detail::CheckedInt
 
struct  llvm::detail::SafeIntIterator< T, IsReverse >
 
struct  llvm::iota_range< T >
 

Namespaces

 llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
 llvm::detail
 

Functions

template<typename T , typename U >
bool llvm::detail::canTypeFitValue (const U Value)
 
template<typename T , typename = std::enable_if_t<std::is_integral<T>::value && !std::is_enum<T>::value>>
auto llvm::seq (T Begin, T End)
 Iterate over an integral type from Begin up to - but not including - End. More...
 
template<typename T , typename = std::enable_if_t<std::is_integral<T>::value && !std::is_enum<T>::value>>
auto llvm::seq_inclusive (T Begin, T End)
 Iterate over an integral type from Begin to End inclusive. More...
 
template<typename EnumT , typename = std::enable_if_t<std::is_enum<EnumT>::value>>
auto llvm::enum_seq (EnumT Begin, EnumT End)
 Iterate over an enum type from Begin up to - but not including - End. More...
 
template<typename EnumT , typename = std::enable_if_t<std::is_enum<EnumT>::value>>
auto llvm::enum_seq (EnumT Begin, EnumT End, force_iteration_on_noniterable_enum_t)
 Iterate over an enum type from Begin up to - but not including - End, even when EnumT is not marked as safely iterable by enum_iteration_traits. More...
 
template<typename EnumT , typename = std::enable_if_t<std::is_enum<EnumT>::value>>
auto llvm::enum_seq_inclusive (EnumT Begin, EnumT End)
 Iterate over an enum type from Begin to End inclusive. More...
 
template<typename EnumT , typename = std::enable_if_t<std::is_enum<EnumT>::value>>
auto llvm::enum_seq_inclusive (EnumT Begin, EnumT End, force_iteration_on_noniterable_enum_t)
 Iterate over an enum type from Begin to End inclusive, even when EnumT is not marked as safely iterable by enum_iteration_traits. More...
 

Variables

constexpr force_iteration_on_noniterable_enum_t llvm::force_iteration_on_noniterable_enum
 

Detailed Description

Provides some synthesis utilities to produce sequences of values. The names are intentionally kept very short as they tend to occur in common and widely used contexts.

The seq(A, B) function produces a sequence of values from A to up to (but not including) B, i.e., [A, B), that can be safely iterated over. seq supports both integral (e.g., int, char, uint32_t) and enum types. seq_inclusive(A, B) produces a sequence of values from A to B, including B.

Examples with integral types:

for (int x : seq(0, 3))
outs() << x << " ";

Prints: 0 1 2.

for (int x : seq_inclusive(0, 3))
outs() << x << " ";

Prints: 0 1 2 3.

Similar to seq and seq_inclusive, the enum_seq and enum_seq_inclusive functions produce sequences of enum values that can be iterated over. To enable iteration with enum types, you need to either mark enums as safe to iterate on by specializing enum_iteration_traits, or opt into potentially unsafe iteration at every callsite by passing force_iteration_on_noniterable_enum.

Examples with enum types:

namespace X {
enum class MyEnum : unsigned {A = 0, B, C};
} // namespace X
template <> struct enum_iteration_traits<X::MyEnum> {
static contexpr bool is_iterable = true;
};
class MyClass {
public:
enum Safe { D = 3, E, F };
enum MaybeUnsafe { G = 1, H = 2, I = 4 };
};
template <> struct enum_iteration_traits<MyClass::Safe> {
static contexpr bool is_iterable = true;
};
outs() << int(v) << " ";

Prints: 3 4.

Prints: 2 3.

Definition in file Sequence.h.

llvm::seq_inclusive
auto seq_inclusive(T Begin, T End)
Iterate over an integral type from Begin to End inclusive.
Definition: Sequence.h:316
F
#define F(x, y, z)
Definition: MD5.cpp:55
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::seq
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
Definition: Sequence.h:306
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
I
#define I(x, y, z)
Definition: MD5.cpp:58
outs
So we should use XX3Form_Rcr to implement instrinsic Convert DP outs ins xscvdpsp No builtin are required Round &Convert QP DP(dword[1] is set to zero) No builtin are required Round to Quad Precision because you need to assign rounding mode in instruction Provide builtin(set f128:$vT,(int_ppc_vsx_xsrqpi f128:$vB))(set f128 yields< n x< ty > >< result > yields< ty >< result > No builtin are required Load Store load store see def memrix16 in PPCInstrInfo td Load Store Vector load store outs ins lxsdx set load store with conversion from to outs ins lxsspx set load store outs ins lxsiwzx set PPClfiwzx outs
This returns a reference to a raw_fd_ostream for standard output.
Definition: README_P9.txt:537
A
* A
Definition: README_ALTIVEC.txt:89
H
#define H(x, y, z)
Definition: MD5.cpp:57
llvm::enum_seq
auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
Definition: Sequence.h:328
x
TODO unsigned x
Definition: README.txt:10
llvm::force_iteration_on_noniterable_enum
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
Definition: Sequence.h:109