remove old piece of the V9 backend.
[oota-llvm.git] / include / llvm / Constants.h
index 4b5d883bbfac645af3aafbe135a6ed09b48ac56d..ef06c33ced98ebb665d1ca1d3a00839659eb086f 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "llvm/Constant.h"
 #include "llvm/Type.h"
-#include "llvm/Support/DataTypes.h"
 
 namespace llvm {
 
@@ -47,7 +46,7 @@ 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
@@ -59,7 +58,7 @@ public:
   /// type.
   inline uint64_t getZExtValue() const {
     unsigned Size = getType()->getPrimitiveSizeInBits();
-    return Val.Unsigned & (~0ULL >> (64-Size));
+    return Val.Unsigned & (~uint64_t(0UL) >> (64-Size));
   }
 
   /// getSExtValue - Return the constant sign extended as appropriate for this
@@ -98,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;
   }
 };
 
@@ -134,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;
   }
 };
 
@@ -146,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
@@ -173,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;
   }
 };
 
@@ -227,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;
   }
 };
 
@@ -263,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;
   }
 };
 
@@ -301,8 +299,7 @@ public:
   /// 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;
   }
 };
 
@@ -325,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:
   ///
@@ -350,7 +345,14 @@ protected:
 public:
   /// get() - Static factory methods - Return objects of the specified value
   static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
-  static Constant *get(const std::string &Initializer);
+
+  /// This method constructs a ConstantArray and initializes it with a text
+  /// string. The default behavior (AddNull==true) causes a null terminator to
+  /// be placed at the end of the array. This effectively increases the length
+  /// of the array by one (you've been warned).  However, in some situations 
+  /// this is not desired so if AddNull==false then the string is copied without
+  /// null termination. 
+  static Constant *get(const std::string &Initializer, bool AddNull = true);
 
   /// getType - Specialize the getType() method to always return an ArrayType,
   /// which reduces the amount of casting needed in parts of the compiler.
@@ -374,14 +376,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;
   }
 };
 
@@ -416,14 +416,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;
   }
 };
 
@@ -455,14 +453,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;
   }
 };
 
@@ -475,7 +471,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:
 
@@ -498,8 +494,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;
   }
 };
 
@@ -532,6 +527,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
@@ -599,6 +600,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; }
@@ -609,9 +614,17 @@ public:
   /// getOpcodeName - Return a string representation for an opcode.
   const char *getOpcodeName() const;
 
+  /// getWithOperandReplaced - Return a constant expression identical to this
+  /// one, but with the specified operand set to the specified value.
+  Constant *getWithOperandReplaced(unsigned OpNo, Constant *Op) const;
+  
+  /// getWithOperands - This returns the current constant expression with the
+  /// operands replaced with the specified values.  The specified operands must
+  /// match count and type with the existing ones.
+  Constant *getWithOperands(const std::vector<Constant*> &Ops) 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) {