//===-- OpDescriptor.h ------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Provides the fuzzerop::Descriptor class and related tools for describing // operations an IR fuzzer can work with. // //===----------------------------------------------------------------------===// #ifndef LLVM_FUZZMUTATE_OPDESCRIPTOR_H #define LLVM_FUZZMUTATE_OPDESCRIPTOR_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" #include <functional> namespace llvm { class Instruction; namespace fuzzerop { /// @{ /// Populate a small list of potentially interesting constants of a given type. void makeConstantsWithType(Type *T, std::vector<Constant *> &Cs); std::vector<Constant *> makeConstantsWithType(Type *T); /// @} /// A matcher/generator for finding suitable values for the next source in an /// operation's partially completed argument list. /// /// Given that we're building some operation X and may have already filled some /// subset of its operands, this predicate determines if some value New is /// suitable for the next operand or generates a set of values that are /// suitable. class SourcePred { … }; /// A description of some operation we can build while fuzzing IR. struct OpDescriptor { … }; static inline SourcePred onlyType(Type *Only) { … } static inline SourcePred anyType() { … } static inline SourcePred anyIntType() { … } static inline SourcePred anyIntOrVecIntType() { … } static inline SourcePred boolOrVecBoolType() { … } static inline SourcePred anyFloatType() { … } static inline SourcePred anyFloatOrVecFloatType() { … } static inline SourcePred anyPtrType() { … } static inline SourcePred sizedPtrType() { … } static inline SourcePred matchFirstLengthWAnyType() { … } /// Match values that have the same type as the first source. static inline SourcePred matchSecondType() { … } static inline SourcePred anyAggregateType() { … } static inline SourcePred anyVectorType() { … } /// Match values that have the same type as the first source. static inline SourcePred matchFirstType() { … } /// Match values that have the first source's scalar type. static inline SourcePred matchScalarOfFirstType() { … } } // namespace fuzzerop } // namespace llvm #endif // LLVM_FUZZMUTATE_OPDESCRIPTOR_H