Add a ConstantFP::getInf utility function for creating infinity ConstantFPs.
authorDan Gohman <gohman@apple.com>
Fri, 25 Sep 2009 23:00:48 +0000 (23:00 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 25 Sep 2009 23:00:48 +0000 (23:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82818 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
lib/VMCore/Constants.cpp

index 90cf55daace1b364a9844726e1b3de2250c27c5d..9098cdc187b981168a2bced63b7ec79566a86cef 100644 (file)
@@ -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);
index 743462a4ed3f33e8e992b634571fa4d714d26421..33edf7adf9e49d15dd4401e3ef02d5a967f393b5 100644 (file)
@@ -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) &&