1 //===-- OpDescriptor.cpp --------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/FuzzMutate/OpDescriptor.h"
11 #include "llvm/IR/Constants.h"
14 using namespace fuzzerop
;
16 void fuzzerop::makeConstantsWithType(Type
*T
, std::vector
<Constant
*> &Cs
) {
17 if (auto *IntTy
= dyn_cast
<IntegerType
>(T
)) {
18 uint64_t W
= IntTy
->getBitWidth();
19 Cs
.push_back(ConstantInt::get(IntTy
, APInt::getMaxValue(W
)));
20 Cs
.push_back(ConstantInt::get(IntTy
, APInt::getMinValue(W
)));
21 Cs
.push_back(ConstantInt::get(IntTy
, APInt::getSignedMaxValue(W
)));
22 Cs
.push_back(ConstantInt::get(IntTy
, APInt::getSignedMinValue(W
)));
23 Cs
.push_back(ConstantInt::get(IntTy
, APInt::getOneBitSet(W
, W
/ 2)));
24 } else if (T
->isFloatingPointTy()) {
25 auto &Ctx
= T
->getContext();
26 auto &Sem
= T
->getFltSemantics();
27 Cs
.push_back(ConstantFP::get(Ctx
, APFloat::getZero(Sem
)));
28 Cs
.push_back(ConstantFP::get(Ctx
, APFloat::getLargest(Sem
)));
29 Cs
.push_back(ConstantFP::get(Ctx
, APFloat::getSmallest(Sem
)));
31 Cs
.push_back(UndefValue::get(T
));
34 std::vector
<Constant
*> fuzzerop::makeConstantsWithType(Type
*T
) {
35 std::vector
<Constant
*> Result
;
36 makeConstantsWithType(T
, Result
);