LLVM: include/llvm/FuzzMutate/OpDescriptor.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_FUZZMUTATE_OPDESCRIPTOR_H

15#define LLVM_FUZZMUTATE_OPDESCRIPTOR_H

16

25#include

26

27namespace llvm {

30

31

32

35

36

37

38

39

40

41

42

43

45public:

46

47

49

50

51

52 using MakeT = std::function<std::vector<Constant *>(

54

55private:

58

59public:

60

64

65 std::vector<Constant *> Result;

66 for (Type *T : BaseTypes) {

68 if (Pred(Cur, V))

70 }

71 if (Result.empty())

73 return Result;

74 };

75 }

76

77

79 return Pred(Cur, New);

80 }

81

82

85 return Make(Cur, BaseTypes);

86 }

87};

88

89

95

98 return V->getType() == Only;

99 };

102 };

103 return {Pred, Make};

104}

105

108 return !V->getType()->isVoidTy();

109 };

110 auto Make = std::nullopt;

111 return {Pred, Make};

112}

113

116 return V->getType()->isIntegerTy();

117 };

118 auto Make = std::nullopt;

119 return {Pred, Make};

120}

121

124 return V->getType()->isIntOrIntVectorTy();

125 };

126 return {Pred, std::nullopt};

127}

128

131 return V->getType()->isIntOrIntVectorTy(1);

132 };

133 return {Pred, std::nullopt};

134}

135

138 return V->getType()->isFloatingPointTy();

139 };

140 auto Make = std::nullopt;

141 return {Pred, Make};

142}

143

146 return V->getType()->isFPOrFPVectorTy();

147 };

148 return {Pred, std::nullopt};

149}

150

153 return V->getType()->isPointerTy() && !V->isSwiftError();

154 };

156 std::vector<Constant *> Result;

157

158 for (Type *T : Ts)

159 Result.push_back(

161 return Result;

162 };

163 return {Pred, Make};

164}

165

168 if (V->isSwiftError())

169 return false;

170

171 return V->getType()->isPointerTy();

172 };

174 std::vector<Constant *> Result;

175

176

177

178 for (Type *T : Ts)

179 if (T->isSized())

180 Result.push_back(

182

183 return Result;

184 };

185 return {Pred, Make};

186}

187

190 assert(!Cur.empty() && "No first source yet");

191 Type *This = V->getType(), *First = Cur[0]->getType();

194 if (ThisVec && FirstVec) {

196 }

197 return (ThisVec == nullptr) && (FirstVec == nullptr) && (!This->isVoidTy());

198 };

200 assert(!Cur.empty() && "No first source yet");

201 std::vector<Constant *> Result;

203 bool isVec = false;

205 EC = VecTy->getElementCount();

206 isVec = true;

207 }

208 for (Type *T : BaseTypes) {

210 if (isVec)

211

213 else

215 }

216 }

217 assert(!Result.empty() && "No potential constants.");

218 return Result;

219 };

220 return {Pred, Make};

221}

222

223

226 assert((Cur.size() > 1) && "No second source yet");

227 return V->getType() == Cur[1]->getType();

228 };

230 assert((Cur.size() > 1) && "No second source yet");

232 };

233 return {Pred, Make};

234}

235

238

240 return V->getType()->getArrayNumElements() > 0;

241

242

244 return V->getType()->getStructNumElements() > 0;

245

246 return V->getType()->isAggregateType();

247 };

248

249

250 auto Find = std::nullopt;

251 return {Pred, Find};

252}

253

256 return V->getType()->isVectorTy();

257 };

258

259

260

261 auto Make = std::nullopt;

262 return {Pred, Make};

263}

264

265

268 assert(!Cur.empty() && "No first source yet");

269 return V->getType() == Cur[0]->getType();

270 };

272 assert(!Cur.empty() && "No first source yet");

274 };

275 return {Pred, Make};

276}

277

278

281 assert(!Cur.empty() && "No first source yet");

282 return V->getType() == Cur[0]->getType()->getScalarType();

283 };

285 assert(!Cur.empty() && "No first source yet");

287 };

288 return {Pred, Make};

289}

290

291}

292}

293

294#endif

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...

Definition OpDescriptor.h:44

bool matches(ArrayRef< Value * > Cur, const Value *New)

Returns true if New is compatible for the argument after Cur.

Definition OpDescriptor.h:78

SourcePred(PredT Pred, MakeT Make)

Create a fully general source predicate.

Definition OpDescriptor.h:61

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,...

Definition OpDescriptor.h:52

SourcePred(PredT Pred, std::nullopt_t)

Definition OpDescriptor.h:62

std::vector< Constant * > generate(ArrayRef< Value * > Cur, ArrayRef< Type * > BaseTypes)

Generates a list of potential values for the argument after Cur.

Definition OpDescriptor.h:83

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...

Definition OpDescriptor.h:48

Definition OpDescriptor.h:29

static SourcePred matchFirstLengthWAnyType()

Definition OpDescriptor.h:188

static SourcePred anyFloatOrVecFloatType()

Definition OpDescriptor.h:144

static SourcePred sizedPtrType()

Definition OpDescriptor.h:166

LLVM_ABI void makeConstantsWithType(Type *T, std::vector< Constant * > &Cs)

static SourcePred anyAggregateType()

Definition OpDescriptor.h:236

static SourcePred anyIntType()

Definition OpDescriptor.h:114

static SourcePred matchScalarOfFirstType()

Match values that have the first source's scalar type.

Definition OpDescriptor.h:279

static SourcePred onlyType(Type *Only)

Definition OpDescriptor.h:96

static SourcePred anyIntOrVecIntType()

Definition OpDescriptor.h:122

static SourcePred anyVectorType()

Definition OpDescriptor.h:254

static SourcePred boolOrVecBoolType()

Definition OpDescriptor.h:129

static SourcePred anyFloatType()

Definition OpDescriptor.h:136

static SourcePred matchFirstType()

Match values that have the same type as the first source.

Definition OpDescriptor.h:266

static SourcePred anyPtrType()

Definition OpDescriptor.h:151

static SourcePred anyType()

Definition OpDescriptor.h:106

static SourcePred matchSecondType()

Match values that have the same type as the first source.

Definition OpDescriptor.h:224

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

@ First

Helpers to iterate all locations in the MemoryEffectsBase class.

A description of some operation we can build while fuzzing IR.

Definition OpDescriptor.h:90

std::function< Value *(ArrayRef< Value * >, BasicBlock::iterator)> BuilderFunc

Definition OpDescriptor.h:93

unsigned Weight

Definition OpDescriptor.h:91

SmallVector< SourcePred, 2 > SourcePreds

Definition OpDescriptor.h:92