X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FVMCore%2FConstants.cpp;h=12483cd9c99782491d5cb418b1520fe1bff45b41;hp=f820033932d5fa396bed1c4bfb1be0343301c85b;hb=0e81f660dbb7c437a3c95427bb495eb18822e42c;hpb=a15d890c34b5e3a6373c410ebc58453f2d52f43b diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index f820033932d..12483cd9c99 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -314,6 +314,11 @@ Constant* ConstantInt::get(const Type* Ty, const APInt& V) { return C; } +ConstantInt* ConstantInt::get(const IntegerType* Ty, const StringRef& Str, + uint8_t radix) { + return get(Ty->getContext(), APInt(Ty->getBitWidth(), Str, radix)); +} + //===----------------------------------------------------------------------===// // ConstantFP //===----------------------------------------------------------------------===// @@ -352,6 +357,22 @@ Constant* ConstantFP::get(const Type* Ty, double V) { return C; } + +Constant* ConstantFP::get(const Type* Ty, const StringRef& Str) { + LLVMContext &Context = Ty->getContext(); + + APFloat FV(*TypeToFloatSemantics(Ty->getScalarType()), Str); + Constant *C = get(Context, FV); + + // For vectors, broadcast the value. + if (const VectorType *VTy = dyn_cast(Ty)) + return ConstantVector::get( + std::vector(VTy->getNumElements(), C)); + + return C; +} + + ConstantFP* ConstantFP::getNegativeZero(const Type* Ty) { LLVMContext &Context = Ty->getContext(); APFloat apf = cast (Constant::getNullValue(Ty))->getValueAPF();