Add an unwind_to field to basic blocks, making them Users instead of Values.
[oota-llvm.git] / include / llvm / Constants.h
index bb32a1b73006f59a756a8a1455ec0c6225fe9c18..c69bad4b3be90ee31d648ccf2cb313494d22ea13 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -23,6 +23,7 @@
 #include "llvm/Constant.h"
 #include "llvm/Type.h"
 #include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APFloat.h"
 
 namespace llvm {
 
@@ -213,29 +214,42 @@ private:
 /// ConstantFP - Floating Point Values [float, double]
 ///
 class ConstantFP : public Constant {
-  double Val;
+  APFloat Val;
   ConstantFP(const ConstantFP &);      // DO NOT IMPLEMENT
 protected:
-  ConstantFP(const Type *Ty, double V);
+  ConstantFP(const Type *Ty, const APFloat& V);
 public:
   /// get() - Static factory methods - Return objects of the specified value
-  static ConstantFP *get(const Type *Ty, double V);
+  static ConstantFP *get(const Type *Ty, const APFloat& V);
 
   /// isValueValidForType - return true if Ty is big enough to represent V.
-  static bool isValueValidForType(const Type *Ty, double V);
-  inline double getValue() const { return Val; }
+  static bool isValueValidForType(const Type *Ty, const APFloat& V);
+  inline const APFloat& getValueAPF() const { return Val; }
 
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.  Don't depend on == for doubles to tell us it's zero, it
   /// considers -0.0 to be null as well as 0.0.  :(
   virtual bool isNullValue() const;
 
+  // Get a negative zero.
+  static ConstantFP *getNegativeZero(const Type* Ty);
+
   /// isExactlyValue - We don't rely on operator== working on double values, as
   /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
   /// As such, this method can be used to do an exact bit-for-bit comparison of
-  /// two floating point values.
-  bool isExactlyValue(double V) const;
-
+  /// two floating point values.  The version with a double operand is retained
+  /// because it's so convenient to write isExactlyValue(2.0), but please use
+  /// it only for constants.
+  bool isExactlyValue(const APFloat& V) const;
+
+  bool isExactlyValue(double V) const {
+    if (&Val.getSemantics() == &APFloat::IEEEdouble)
+      return isExactlyValue(APFloat(V));
+    else if (&Val.getSemantics() == &APFloat::IEEEsingle)
+      return isExactlyValue(APFloat((float)V));
+    assert(0);
+    return false;
+  }
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantFP *) { return true; }
   static bool classof(const Value *V) {
@@ -424,6 +438,10 @@ public:
   /// @brief Determine if the value is all ones.
   bool isAllOnesValue() const;
 
+  /// getSplatValue - If this is a splat constant, meaning that all of the
+  /// elements have the same value, return that value. Otherwise return NULL.
+  Constant *getSplatValue();
+
   virtual void destroyConstant();
   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
 
@@ -585,7 +603,7 @@ public:
   }
 
   /// getSizeOf constant expr - computes the size of a type in a target
-  /// independent way (Note: the return type is a ULong).
+  /// independent way (Note: the return type is an i64).
   ///
   static Constant *getSizeOf(const Type *Ty);
 
@@ -614,8 +632,8 @@ public:
   static Constant *getAnd(Constant *C1, Constant *C2);
   static Constant *getOr(Constant *C1, Constant *C2);
   static Constant *getXor(Constant *C1, Constant *C2);
-  static Constant* getICmp(unsigned short pred, Constant* LHS, Constant* RHS);
-  static Constant* getFCmp(unsigned short pred, Constant* LHS, Constant* RHS);
+  static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS);
+  static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS);
   static Constant *getShl(Constant *C1, Constant *C2);
   static Constant *getLShr(Constant *C1, Constant *C2);
   static Constant *getAShr(Constant *C1, Constant *C2);