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