Add some new methods to forward to
[oota-llvm.git] / include / llvm / Constants.h
index f36e28bd44bd93f3c44324fba661b8f42d52896e..bf88ef78f8af2913768dcd3f2326240403174f38 100644 (file)
@@ -1,4 +1,4 @@
-//===-- llvm/Constants.h - Constant class subclass definitions ---*- C++ -*--=//
+//===-- llvm/Constants.h - Constant class subclass definitions --*- C++ -*-===//
 //
 // This file contains the declarations for the subclasses of Constant, which
 // represent the different type of constant pool values
@@ -17,6 +17,9 @@ class PointerType;
 
 template<class ConstantClass, class TypeClass, class ValType>
 struct ConstantCreator;
+template<class ConstantClass, class TypeClass>
+struct ConvertConstantType;
+
 
 //===---------------------------------------------------------------------------
 /// ConstantIntegral - Shared superclass of boolean and integer constants.
@@ -280,7 +283,6 @@ class ConstantArray : public Constant {
   ConstantArray(const ConstantArray &);      // DO NOT IMPLEMENT
 protected:
   ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
-  void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
 public:
   /// get() - Static factory methods - Return objects of the specified value
   static ConstantArray *get(const ArrayType *T, const std::vector<Constant*> &);
@@ -336,7 +338,6 @@ class ConstantStruct : public Constant {
   ConstantStruct(const ConstantStruct &);      // DO NOT IMPLEMENT
 protected:
   ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
-  void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
 public:
   /// get() - Static factory methods - Return objects of the specified value
   static ConstantStruct *get(const StructType *T,
@@ -409,7 +410,6 @@ class ConstantPointerNull : public ConstantPointer {
   ConstantPointerNull(const ConstantPointerNull &);      // DO NOT IMPLEMENT
 protected:
   ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
-  void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
 
 public:
 
@@ -485,6 +485,7 @@ class ConstantExpr : public Constant {
   unsigned iType;      // Operation type (an Instruction opcode)
   friend struct ConstantCreator<ConstantExpr,Type,
                             std::pair<unsigned, std::vector<Constant*> > >;
+  friend struct ConvertConstantType<ConstantExpr, Type>;
   
 protected:
   // Cast creation ctor
@@ -494,7 +495,15 @@ protected:
   // GEP instruction creation ctor
   ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
                const Type *DestTy);
-  void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
+
+  // These private methods are used by the type resolution code to create
+  // ConstantExprs in intermediate forms.
+  static Constant *getTy(const Type *Ty, unsigned Opcode,
+                         Constant *C1, Constant *C2);
+  static Constant *getShiftTy(const Type *Ty,
+                              unsigned Opcode, Constant *C1, Constant *C2);
+  static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
+                                      const std::vector<Constant*> &IdxList);
   
 public:
   // Static methods to construct a ConstantExpr of different kinds.  Note that
@@ -503,15 +512,23 @@ public:
   // expression into something simpler if possible.
   
   /// Cast constant expr
+  ///
   static Constant *getCast(Constant *C, const Type *Ty);
 
   /// Binary constant expr - Use with binary operators...
-  static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
+  ///
+  static Constant *get(unsigned Opcode, Constant *C1, Constant *C2) {
+    return getTy(C1->getType(), Opcode, C1, C2);
+  }
 
   /// getShift - Return a shift left or shift right constant expr
-  static Constant *getShift(unsigned Opcode, Constant *C1, Constant *C2);
+  ///
+  static Constant *getShift(unsigned Opcode, Constant *C1, Constant *C2) {
+    return getShiftTy(C1->getType(), Opcode, C1, C2);
+  }
 
   /// Getelementptr form...
+  ///
   static Constant *getGetElementPtr(Constant *C,
                                     const std::vector<Constant*> &IdxList);