LLVM  15.0.0git
Classes | Namespaces
CombinationGenerator.h File Reference
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallVector.h"
#include <cassert>
#include <cstring>
Include dependency graph for CombinationGenerator.h:

Go to the source code of this file.


class  llvm::CombinationGenerator< choice_type, choices_storage_type, variable_smallsize >


 This is an optimization pass for GlobalISel generic memory operations.

Detailed Description

Combination generator.

Example: given input {{0, 1}, {2}, {3, 4}} it will produce the following combinations: {0, 2, 3}, {0, 2, 4}, {1, 2, 3}, {1, 2, 4}.

It is useful to think of input as vector-of-vectors, where the outer vector is the variable space, and inner vector is choice space. The number of choices for each variable can be different.

As for implementation, it is useful to think of this as a weird number, where each digit (==variable) may have different base (==number of choices). Thus modelling of 'produce next combination' is exactly analogous to the incrementing of an number - increment lowest digit (pick next choice for the variable), and if it wrapped to the beginning then increment next digit.

Definition in file CombinationGenerator.h.