14#ifndef LLVM_FUZZMUTATE_OPDESCRIPTOR_H
15#define LLVM_FUZZMUTATE_OPDESCRIPTOR_H
52 using MakeT = std::function<std::vector<Constant *>(
65 std::vector<Constant *> Result;
66 for (
Type *
T : BaseTypes) {
79 return Pred(Cur, New);
85 return Make(Cur, BaseTypes);
98 return V->getType() == Only;
108 return !V->getType()->isVoidTy();
110 auto Make = std::nullopt;
116 return V->getType()->isIntegerTy();
118 auto Make = std::nullopt;
124 return V->getType()->isIntOrIntVectorTy();
126 return {Pred, std::nullopt};
131 return V->getType()->isIntOrIntVectorTy(1);
133 return {Pred, std::nullopt};
138 return V->getType()->isFloatingPointTy();
140 auto Make = std::nullopt;
146 return V->getType()->isFPOrFPVectorTy();
148 return {Pred, std::nullopt};
153 return V->getType()->isPointerTy() && !V->isSwiftError();
156 std::vector<Constant *> Result;
168 if (V->isSwiftError())
171 return V->getType()->isPointerTy();
174 std::vector<Constant *> Result;
191 Type *This = V->getType(), *
First = Cur[0]->getType();
192 VectorType *ThisVec = dyn_cast<VectorType>(This);
194 if (ThisVec && FirstVec) {
197 return (ThisVec ==
nullptr) && (FirstVec ==
nullptr) && (!This->isVoidTy());
201 std::vector<Constant *> Result;
205 EC = VecTy->getElementCount();
208 for (
Type *
T : BaseTypes) {
217 assert(!Result.empty() &&
"No potential constants.");
226 assert((Cur.
size() > 1) &&
"No second source yet");
227 return V->getType() == Cur[1]->getType();
230 assert((Cur.
size() > 1) &&
"No second source yet");
239 if (isa<ArrayType>(V->getType()))
240 return V->getType()->getArrayNumElements() > 0;
243 if (isa<StructType>(V->getType()))
244 return V->getType()->getStructNumElements() > 0;
246 return V->getType()->isAggregateType();
250 auto Find = std::nullopt;
256 return V->getType()->isVectorTy();
261 auto Make = std::nullopt;
269 return V->getType() == Cur[0]->getType();
282 return V->getType() == Cur[0]->getType()->getScalarType();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
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.
InstListType::iterator iterator
Instruction iterators...
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...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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.
LLVM Value Representation.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
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()
LLVM_ABI 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.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
A description of some operation we can build while fuzzing IR.
std::function< Value *(ArrayRef< Value * >, BasicBlock::iterator)> BuilderFunc
SmallVector< SourcePred, 2 > SourcePreds