14#ifndef LLVM_FUZZMUTATE_OPDESCRIPTOR_H
15#define LLVM_FUZZMUTATE_OPDESCRIPTOR_H
51 using MakeT = std::function<std::vector<Constant *>(
64 std::vector<Constant *> Result;
65 for (
Type *
T : BaseTypes) {
78 return Pred(Cur, New);
84 return Make(Cur, BaseTypes);
97 return V->getType() == Only;
107 return !V->getType()->isVoidTy();
109 auto Make = std::nullopt;
115 return V->getType()->isIntegerTy();
117 auto Make = std::nullopt;
123 return V->getType()->isIntOrIntVectorTy();
125 return {Pred, std::nullopt};
130 return V->getType()->isIntOrIntVectorTy(1);
132 return {Pred, std::nullopt};
137 return V->getType()->isFloatingPointTy();
139 auto Make = std::nullopt;
145 return V->getType()->isFPOrFPVectorTy();
147 return {Pred, std::nullopt};
152 return V->getType()->isPointerTy() && !V->isSwiftError();
155 std::vector<Constant *> Result;
166 if (V->isSwiftError())
169 if (
const auto *PtrT = dyn_cast<PointerType>(V->getType()))
170 return PtrT->isOpaque() ||
171 PtrT->getNonOpaquePointerElementType()->isSized();
175 std::vector<Constant *> Result;
189 Type *This = V->getType(), *First = Cur[0]->getType();
190 VectorType *ThisVec = dyn_cast<VectorType>(This);
191 VectorType *FirstVec = dyn_cast<VectorType>(First);
192 if (ThisVec && FirstVec) {
195 return (ThisVec ==
nullptr) && (FirstVec ==
nullptr) && (!This->isVoidTy());
199 std::vector<Constant *> Result;
203 EC = VecTy->getElementCount();
206 for (
Type *
T : BaseTypes) {
215 assert(!Result.empty() &&
"No potential constants.");
224 assert((Cur.
size() > 1) &&
"No second source yet");
225 return V->getType() == Cur[1]->getType();
228 assert((Cur.
size() > 1) &&
"No second source yet");
237 if (isa<ArrayType>(V->getType()))
238 return V->getType()->getArrayNumElements() > 0;
241 if (isa<StructType>(V->getType()))
242 return V->getType()->getStructNumElements() > 0;
244 return V->getType()->isAggregateType();
248 auto Find = std::nullopt;
254 return V->getType()->isVectorTy();
259 auto Make = std::nullopt;
267 return V->getType() == Cur[0]->getType();
280 return V->getType() == Cur[0]->getType()->getScalarType();
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static const T * Find(StringRef S, ArrayRef< T > A)
Find KV in array using binary search.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
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.
This is an important base class in LLVM.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVM Value Representation.
Base class of all SIMD vector types.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
A matcher/generator for finding suitable values for the next source in an operation's partially compl...
bool matches(ArrayRef< Value * > Cur, const Value *New)
Returns true if New is compatible for the argument after Cur.
std::function< std::vector< Constant * >(ArrayRef< Value * > Cur, ArrayRef< Type * > BaseTypes)> MakeT
Given a list of already selected operands and a set of valid base types for a fuzzer,...
SourcePred(PredT Pred, MakeT Make)
Create a fully general source predicate.
SourcePred(PredT Pred, std::nullopt_t)
std::vector< Constant * > generate(ArrayRef< Value * > Cur, ArrayRef< Type * > BaseTypes)
Generates a list of potential values for the argument after Cur.
std::function< bool(ArrayRef< Value * > Cur, const Value *New)> PredT
Given a list of already selected operands, returns whether a given new operand is suitable for the ne...
static SourcePred matchFirstLengthWAnyType()
static SourcePred anyFloatOrVecFloatType()
static SourcePred sizedPtrType()
void makeConstantsWithType(Type *T, std::vector< Constant * > &Cs)
static SourcePred anyAggregateType()
static SourcePred anyIntType()
static SourcePred matchScalarOfFirstType()
Match values that have the first source's scalar type.
static SourcePred onlyType(Type *Only)
static SourcePred anyIntOrVecIntType()
static SourcePred anyVectorType()
static SourcePred boolOrVecBoolType()
static SourcePred anyFloatType()
static SourcePred matchFirstType()
Match values that have the same type as the first source.
static SourcePred anyPtrType()
static SourcePred anyType()
static SourcePred matchSecondType()
Match values that have the same type as the first source.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
A description of some operation we can build while fuzzing IR.
SmallVector< SourcePred, 2 > SourcePreds
std::function< Value *(ArrayRef< Value * >, Instruction *)> BuilderFunc