Go to the documentation of this file.
13 #ifndef LLVM_FUZZMUTATE_RANDOM_H
14 #define LLVM_FUZZMUTATE_RANDOM_H
21 template <
typename T,
typename GenT>
T uniform(GenT &Gen, T Min, T Max) {
22 return std::uniform_int_distribution<T>(Min, Max)(Gen);
26 template <
typename T,
typename GenT>
T uniform(GenT &Gen) {
35 std::remove_const_t<T> Selection = {};
42 bool isEmpty()
const {
return TotalWeight == 0; }
49 explicit operator bool()
const {
return !
isEmpty(); }
64 TotalWeight += Weight;
66 if (uniform<uint64_t>(RandGen, 1, TotalWeight) <= Weight)
72 template <
typename GenT,
typename RangeT,
73 typename ElT = std::remove_reference_t<
74 decltype(*
std::begin(std::declval<RangeT>()))>>
81 template <
typename GenT,
typename T>
89 template <
typename T,
typename GenT>
96 #endif // LLVM_FUZZMUTATE_RANDOM_H
This is an optimization pass for GlobalISel generic memory operations.
uint64_t totalWeight() const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
ReservoirSampler & sample(RangeT &&Items)
Sample each item in Items with unit weight.
ReservoirSampler(GenT &RandGen)
const T & getSelection() const
T uniform(GenT &Gen, T Min, T Max)
Return a uniformly distributed random value between Min and Max.
const T & operator*() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
ReservoirSampler< ElT, GenT > makeSampler(GenT &RandGen, RangeT &&Items)
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
ReservoirSampler & sample(const T &Item, uint64_t Weight)
Sample a single item with the given weight.
Randomly selects an item by sampling into a set with an unknown number of elements,...