27#ifndef LLVM_ADT_COMBINATIONGENERATOR_H
28#define LLVM_ADT_COMBINATIONGENERATOR_H
38template <
typename choice_type,
typename choices_storage_type,
39 int variable_smallsize>
41 template <
typename T>
struct WrappingIterator {
48 void rewind() { Position =
Range.begin(); }
54 bool Wrapped = Position ==
Range.end();
61 const value_type &
operator*()
const {
return *Position; }
64 assert(!
Range.empty() &&
"The range must not be empty.");
71 void performGeneration(
83 for (WrappingIterator<choice_type> &Variable :
85 bool Wrapped = Variable.advance();
101 CurrentCombination.
resize(VariablesState.
size());
105 for (
auto I :
llvm::zip(VariablesState, CurrentCombination))
106 std::get<1>(
I) = *std::get<0>(
I);
108 if (Callback(CurrentCombination))
111 if (IncrementState(VariablesState))
118 : VariablesChoices(VariablesChoices_) {
120 assert(!VariablesChoices.
empty() &&
"There should be some variables.");
123 "There must always be some choice, at least a placeholder one.");
131 size_t NumVariants = 1;
133 NumVariants *= VariableChoices.size();
134 assert(NumVariants >= 1 &&
135 "We should always end up producing at least one combination");
142 performGeneration(Callback);
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
void generate(const function_ref< bool(ArrayRef< choice_type >)> Callback)
size_t numCombinations() const
CombinationGenerator(ArrayRef< choices_storage_type > VariablesChoices_)
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
APInt operator*(APInt a, uint64_t RHS)
auto reverse(ContainerTy &&C)