Add a chain to FORMAL_ARGUMENTS.
[oota-llvm.git] / include / llvm / Constants.h
index 1a9d87d68a1aeb4a0d5f88a23b978f5a6f657a39..ef2c839adc22cd6eb264e8eb730e3f6c1b0e683d 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "llvm/Constant.h"
 #include "llvm/Type.h"
-#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/MathExtras.h"
 
 namespace llvm {
 
@@ -48,14 +46,28 @@ protected:
     int64_t  Signed;
     uint64_t Unsigned;
   } Val;
-  ConstantIntegral(const Type *Ty, uint64_t V);
+  ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V);
 public:
 
   /// getRawValue - return the underlying value of this constant as a 64-bit
   /// unsigned integer value.
   ///
   inline uint64_t getRawValue() const { return Val.Unsigned; }
+  
+  /// getZExtValue - Return the constant zero extended as appropriate for this
+  /// type.
+  inline uint64_t getZExtValue() const {
+    unsigned Size = getType()->getPrimitiveSizeInBits();
+    return Val.Unsigned & (~0ULL >> (64-Size));
+  }
 
+  /// getSExtValue - Return the constant sign extended as appropriate for this
+  /// type.
+  inline int64_t getSExtValue() const {
+    unsigned Size = getType()->getPrimitiveSizeInBits();
+    return (Val.Signed << (64-Size)) >> (64-Size);
+  }
+  
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
   ///
@@ -85,8 +97,9 @@ public:
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantIntegral *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->isIntegral();
+    return V->getValueType() == ConstantBoolVal ||
+           V->getValueType() == ConstantSIntVal ||
+           V->getValueType() == ConstantUIntVal;
   }
 };
 
@@ -121,7 +134,7 @@ public:
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantBool *) { return true; }
   static bool classof(const Value *V) {
-    return (V == True) | (V == False);
+    return V->getValueType() == ConstantBoolVal;
   }
 };
 
@@ -133,7 +146,7 @@ public:
 class ConstantInt : public ConstantIntegral {
 protected:
   ConstantInt(const ConstantInt &);      // DO NOT IMPLEMENT
-  ConstantInt(const Type *Ty, uint64_t V);
+  ConstantInt(const Type *Ty, ValueTy VT, uint64_t V);
 public:
   /// equalsInt - Provide a helper method that can be used to determine if the
   /// constant contained within is equal to a constant.  This only works for
@@ -160,8 +173,8 @@ public:
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantInt *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->isInteger();
+    return V->getValueType() == ConstantSIntVal ||
+           V->getValueType() == ConstantUIntVal;
   }
 };
 
@@ -214,8 +227,7 @@ public:
   ///
   static inline bool classof(const ConstantSInt *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->isSigned();
+    return V->getValueType() == ConstantSIntVal;
   }
 };
 
@@ -250,8 +262,7 @@ public:
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantUInt *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->isUnsigned();
+    return V->getValueType() == ConstantUIntVal;
   }
 };
 
@@ -277,23 +288,18 @@ public:
   /// 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 {
-    return DoubleToBits(Val) == 0;
-  }
+  virtual bool isNullValue() const;
 
   /// 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 {
-    return DoubleToBits(V) == DoubleToBits(Val);
-  }
+  bool isExactlyValue(double V) const;
 
   /// 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) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->isFloatingPoint();
+    return V->getValueType() == ConstantFPVal;
   }
 };
 
@@ -316,8 +322,6 @@ public:
   virtual bool isNullValue() const { return true; }
 
   virtual void destroyConstant();
-  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
-                                           bool DisableChecking = false);
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   ///
@@ -365,14 +369,12 @@ public:
   virtual bool isNullValue() const { return false; }
 
   virtual void destroyConstant();
-  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
-                                           bool DisableChecking = false);
+  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantArray *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->getTypeID() == Type::ArrayTyID;
+    return V->getValueType() == ConstantArrayVal;
   }
 };
 
@@ -407,14 +409,12 @@ public:
   }
 
   virtual void destroyConstant();
-  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
-                                           bool DisableChecking = false);
+  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantStruct *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->getTypeID() == Type::StructTyID;
+    return V->getValueType() == ConstantStructVal;
   }
 };
 
@@ -446,14 +446,12 @@ public:
   virtual bool isNullValue() const { return false; }
 
   virtual void destroyConstant();
-  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
-                                           bool DisableChecking = false);
+  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantPacked *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           V->getType()->getTypeID() == Type::PackedTyID;
+    return V->getValueType() == ConstantPackedVal;
   }
 };
 
@@ -466,7 +464,7 @@ class ConstantPointerNull : public Constant {
 protected:
   ConstantPointerNull(const PointerType *T)
     : Constant(reinterpret_cast<const Type*>(T),
-               Value::SimpleConstantVal, 0, 0) {}
+               Value::ConstantPointerNullVal, 0, 0) {}
 
 public:
 
@@ -489,8 +487,7 @@ public:
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantPointerNull *) { return true; }
   static bool classof(const Value *V) {
-    return V->getValueType() == SimpleConstantVal &&
-           isa<PointerType>(V->getType());
+    return V->getValueType() == ConstantPointerNullVal;
   }
 };
 
@@ -523,6 +520,12 @@ protected:
                                Constant *C1, Constant *C2, Constant *C3);
   static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
                                       const std::vector<Value*> &IdxList);
+  static Constant *getExtractElementTy(const Type *Ty, Constant *Val,
+                                       Constant *Idx);
+  static Constant *getInsertElementTy(const Type *Ty, Constant *Val,
+                                      Constant *Elt, Constant *Idx);
+  static Constant *getShuffleVectorTy(const Type *Ty, Constant *V1,
+                                      Constant *V2, Constant *Mask);
 
 public:
   // Static methods to construct a ConstantExpr of different kinds.  Note that
@@ -590,6 +593,10 @@ public:
   static Constant *getGetElementPtr(Constant *C,
                                     const std::vector<Value*> &IdxList);
 
+  static Constant *getExtractElement(Constant *Vec, Constant *Idx);
+  static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
+  static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
+  
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
   virtual bool isNullValue() const { return false; }
@@ -601,8 +608,7 @@ public:
   const char *getOpcodeName() const;
 
   virtual void destroyConstant();
-  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
-                                           bool DisableChecking = false);
+  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
 
   /// Override methods to provide more type information...
   inline Constant *getOperand(unsigned i) {