Reverting r215966, r215965, r215964, r215963, r215960, r215959, r215958, and r215957...
[oota-llvm.git] / include / llvm / IR / Constants.h
index 4c99e74173f1e2305b293fd35e0a265f5a45d564..0e72f040d3e052244aec67d941ceb6ab7e938562 100644 (file)
@@ -37,8 +37,12 @@ class PointerType;
 class VectorType;
 class SequentialType;
 
-struct ConstantExprKeyType;
-template <class ConstantClass> struct ConstantAggrKeyType;
+template<class ConstantClass, class TypeClass, class ValType>
+struct ConstantCreator;
+template<class ConstantClass, class TypeClass>
+struct ConstantArrayCreator;
+template<class ConstantClass, class TypeClass>
+struct ConvertConstantType;
 
 //===----------------------------------------------------------------------===//
 /// This is the shared class of boolean and integer constants. This class
@@ -334,7 +338,7 @@ public:
 /// ConstantArray - Constant Array Declarations
 ///
 class ConstantArray : public Constant {
-  friend struct ConstantAggrKeyType<ConstantArray>;
+  friend struct ConstantArrayCreator<ConstantArray, ArrayType>;
   ConstantArray(const ConstantArray &) LLVM_DELETED_FUNCTION;
 protected:
   ConstantArray(ArrayType *T, ArrayRef<Constant *> Val);
@@ -342,10 +346,6 @@ public:
   // ConstantArray accessors
   static Constant *get(ArrayType *T, ArrayRef<Constant*> V);
 
-private:
-  static Constant *getImpl(ArrayType *T, ArrayRef<Constant *> V);
-
-public:
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
 
@@ -376,7 +376,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantArray, Constant)
 // ConstantStruct - Constant Struct Declarations
 //
 class ConstantStruct : public Constant {
-  friend struct ConstantAggrKeyType<ConstantStruct>;
+  friend struct ConstantArrayCreator<ConstantStruct, StructType>;
   ConstantStruct(const ConstantStruct &) LLVM_DELETED_FUNCTION;
 protected:
   ConstantStruct(StructType *T, ArrayRef<Constant *> Val);
@@ -435,7 +435,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantStruct, Constant)
 /// ConstantVector - Constant Vector Declarations
 ///
 class ConstantVector : public Constant {
-  friend struct ConstantAggrKeyType<ConstantVector>;
+  friend struct ConstantArrayCreator<ConstantVector, VectorType>;
   ConstantVector(const ConstantVector &) LLVM_DELETED_FUNCTION;
 protected:
   ConstantVector(VectorType *T, ArrayRef<Constant *> Val);
@@ -443,10 +443,6 @@ public:
   // ConstantVector accessors
   static Constant *get(ArrayRef<Constant*> V);
 
-private:
-  static Constant *getImpl(ArrayRef<Constant *> V);
-
-public:
   /// getSplat - Return a ConstantVector with the specified constant in each
   /// element.
   static Constant *getSplat(unsigned NumElts, Constant *Elt);
@@ -798,7 +794,9 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value)
 /// constant expressions.  The Opcode field for the ConstantExpr class is
 /// maintained in the Value::SubclassData field.
 class ConstantExpr : public Constant {
-  friend struct ConstantExprKeyType;
+  friend struct ConstantCreator<ConstantExpr,Type,
+                            std::pair<unsigned, std::vector<Constant*> > >;
+  friend struct ConvertConstantType<ConstantExpr, Type>;
 
 protected:
   ConstantExpr(Type *ty, unsigned Opcode, Use *Ops, unsigned NumOps)
@@ -1115,12 +1113,6 @@ private:
   void setValueSubclassData(unsigned short D) {
     Value::setValueSubclassData(D);
   }
-
-  /// \brief Check whether this can become its replacement.
-  ///
-  /// For use during \a replaceUsesOfWithOnConstant(), check whether we know
-  /// how to turn this into \a Replacement, thereby reducing RAUW traffic.
-  bool canBecomeReplacement(const Constant *Replacement) const;
 };
 
 template <>