1326938Sdim//===-- OpDescriptor.cpp --------------------------------------------------===// 2326938Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6326938Sdim// 7326938Sdim//===----------------------------------------------------------------------===// 8326938Sdim 9326938Sdim#include "llvm/FuzzMutate/OpDescriptor.h" 10326938Sdim#include "llvm/IR/Constants.h" 11326938Sdim 12326938Sdimusing namespace llvm; 13326938Sdimusing namespace fuzzerop; 14326938Sdim 15326938Sdimvoid fuzzerop::makeConstantsWithType(Type *T, std::vector<Constant *> &Cs) { 16326938Sdim if (auto *IntTy = dyn_cast<IntegerType>(T)) { 17326938Sdim uint64_t W = IntTy->getBitWidth(); 18326938Sdim Cs.push_back(ConstantInt::get(IntTy, APInt::getMaxValue(W))); 19326938Sdim Cs.push_back(ConstantInt::get(IntTy, APInt::getMinValue(W))); 20326938Sdim Cs.push_back(ConstantInt::get(IntTy, APInt::getSignedMaxValue(W))); 21326938Sdim Cs.push_back(ConstantInt::get(IntTy, APInt::getSignedMinValue(W))); 22326938Sdim Cs.push_back(ConstantInt::get(IntTy, APInt::getOneBitSet(W, W / 2))); 23326938Sdim } else if (T->isFloatingPointTy()) { 24326938Sdim auto &Ctx = T->getContext(); 25326938Sdim auto &Sem = T->getFltSemantics(); 26326938Sdim Cs.push_back(ConstantFP::get(Ctx, APFloat::getZero(Sem))); 27326938Sdim Cs.push_back(ConstantFP::get(Ctx, APFloat::getLargest(Sem))); 28326938Sdim Cs.push_back(ConstantFP::get(Ctx, APFloat::getSmallest(Sem))); 29326938Sdim } else 30326938Sdim Cs.push_back(UndefValue::get(T)); 31326938Sdim} 32326938Sdim 33326938Sdimstd::vector<Constant *> fuzzerop::makeConstantsWithType(Type *T) { 34326938Sdim std::vector<Constant *> Result; 35326938Sdim makeConstantsWithType(T, Result); 36326938Sdim return Result; 37326938Sdim} 38