From 01b2c857ed4371214c36eaa6e3650add5b12cbaa Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2009 23:00:48 +0000 Subject: [PATCH] Add a ConstantFP::getInf utility function for creating infinity ConstantFPs. llvm-svn: 82818 --- include/llvm/Constants.h | 1 + lib/VMCore/Constants.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 90cf55daace..9098cdc187b 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -258,6 +258,7 @@ public: static Constant* get(const Type* Ty, const StringRef& Str); static ConstantFP* get(LLVMContext &Context, const APFloat& V); static ConstantFP* getNegativeZero(const Type* Ty); + static ConstantFP* getInf(const Type* Ty, bool negative = false); /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 743462a4ed3..33edf7adf9e 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -436,6 +436,12 @@ ConstantFP* ConstantFP::get(LLVMContext &Context, const APFloat& V) { return Slot; } +ConstantFP *ConstantFP::getInf(const Type *Ty, bool Negative) { + const fltSemantics &Semantics = *TypeToFloatSemantics(Ty); + return ConstantFP::get(Ty->getContext(), + APFloat::getInf(Semantics, Negative)); +} + ConstantFP::ConstantFP(const Type *Ty, const APFloat& V) : Constant(Ty, ConstantFPVal, 0, 0), Val(V) { assert(&V.getSemantics() == TypeToFloatSemantics(Ty) &&