Add logic to align instruction operands to columns for pretty-printing.
[oota-llvm.git] / include / llvm / Instructions.h
index 59ae6100d2cdc97830fad4fa98625f338ce0cac4..6fa434cccfad5ecaafb4d92abd833d15118d8ad7 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Attributes.h"
 #include "llvm/BasicBlock.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/ADT/SmallVector.h"
 #include <iterator>
 
@@ -28,6 +29,7 @@ namespace llvm {
 class ConstantInt;
 class ConstantRange;
 class APInt;
+class LLVMContext;
 
 //===----------------------------------------------------------------------===//
 //                             AllocationInst Class
@@ -38,10 +40,12 @@ class APInt;
 ///
 class AllocationInst : public UnaryInstruction {
 protected:
-  AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
-                 const std::string &Name = "", Instruction *InsertBefore = 0);
-  AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
-                 const std::string &Name, BasicBlock *InsertAtEnd);
+  AllocationInst(const Type *Ty, Value *ArraySize, 
+                 unsigned iTy, unsigned Align, const std::string &Name = "", 
+                 Instruction *InsertBefore = 0);
+  AllocationInst(const Type *Ty, Value *ArraySize,
+                 unsigned iTy, unsigned Align, const std::string &Name,
+                 BasicBlock *InsertAtEnd);
 public:
   // Out of line virtual method, so the vtable, etc. has a home.
   virtual ~AllocationInst();
@@ -51,7 +55,7 @@ public:
   ///
   bool isArrayAllocation() const;
 
-  /// getArraySize - Get the number of element allocated, for a simple
+  /// getArraySize - Get the number of elements allocated. For a simple
   /// allocation of a single element, this will return a constant 1 value.
   ///
   const Value *getArraySize() const { return getOperand(0); }
@@ -74,7 +78,7 @@ public:
   unsigned getAlignment() const { return (1u << SubclassData) >> 1; }
   void setAlignment(unsigned Align);
 
-  virtual Instruction *clone() const = 0;
+  virtual Instruction *clone(LLVMContext &Context) const = 0;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const AllocationInst *) { return true; }
@@ -100,9 +104,10 @@ public:
   explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
                       const std::string &NameStr = "",
                       Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertBefore) {}
-  MallocInst(const Type *Ty, Value *ArraySize, const std::string &NameStr,
-             BasicBlock *InsertAtEnd)
+    : AllocationInst(Ty, ArraySize, Malloc,
+                     0, NameStr, InsertBefore) {}
+  MallocInst(const Type *Ty, Value *ArraySize,
+             const std::string &NameStr, BasicBlock *InsertAtEnd)
     : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
 
   MallocInst(const Type *Ty, const std::string &NameStr,
@@ -112,15 +117,18 @@ public:
              BasicBlock *InsertAtEnd)
     : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
 
-  MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
-             const std::string &NameStr, BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertAtEnd) {}
-  MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
-                      const std::string &NameStr = "",
-                      Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertBefore) {}
+  MallocInst(const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr,
+             BasicBlock *InsertAtEnd)
+    : AllocationInst(Ty, ArraySize, Malloc,
+                     Align, NameStr, InsertAtEnd) {}
+  MallocInst(const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr = "", 
+             Instruction *InsertBefore = 0)
+    : AllocationInst(Ty, ArraySize,
+                     Malloc, Align, NameStr, InsertBefore) {}
 
-  virtual MallocInst *clone() const;
+  virtual MallocInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const MallocInst *) { return true; }
@@ -142,11 +150,14 @@ public:
 class AllocaInst : public AllocationInst {
   AllocaInst(const AllocaInst &);
 public:
-  explicit AllocaInst(const Type *Ty, Value *ArraySize = 0,
+  explicit AllocaInst(const Type *Ty,
+                      Value *ArraySize = 0,
                       const std::string &NameStr = "",
                       Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertBefore) {}
-  AllocaInst(const Type *Ty, Value *ArraySize, const std::string &NameStr,
+    : AllocationInst(Ty, ArraySize, Alloca,
+                     0, NameStr, InsertBefore) {}
+  AllocaInst(const Type *Ty,
+             Value *ArraySize, const std::string &NameStr,
              BasicBlock *InsertAtEnd)
     : AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
 
@@ -157,14 +168,18 @@ public:
              BasicBlock *InsertAtEnd)
     : AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
 
-  AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
-             const std::string &NameStr = "", Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertBefore) {}
-  AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
-             const std::string &NameStr, BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertAtEnd) {}
+  AllocaInst(const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr = "",
+             Instruction *InsertBefore = 0)
+    : AllocationInst(Ty, ArraySize, Alloca,
+                     Align, NameStr, InsertBefore) {}
+  AllocaInst(const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr,
+             BasicBlock *InsertAtEnd)
+    : AllocationInst(Ty, ArraySize, Alloca,
+                     Align, NameStr, InsertAtEnd) {}
 
-  virtual AllocaInst *clone() const;
+  virtual AllocaInst *clone(LLVMContext &Context) const;
 
   /// isStaticAlloca - Return true if this alloca is in the entry block of the
   /// function and is a constant size.  If so, the code generator will fold it
@@ -194,7 +209,7 @@ public:
   explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
   FreeInst(Value *Ptr, BasicBlock *InsertAfter);
 
-  virtual FreeInst *clone() const;
+  virtual FreeInst *clone(LLVMContext &Context) const;
 
   // Accessor methods for consistency with other memory operations
   Value *getPointerOperand() { return getOperand(0); }
@@ -260,7 +275,7 @@ public:
     SubclassData = (SubclassData & ~1) | (V ? 1 : 0);
   }
 
-  virtual LoadInst *clone() const;
+  virtual LoadInst *clone(LLVMContext &Context) const;
 
   /// getAlignment - Return the alignment of the access that is being performed
   ///
@@ -344,7 +359,7 @@ public:
 
   void setAlignment(unsigned Align);
 
-  virtual StoreInst *clone() const;
+  virtual StoreInst *clone(LLVMContext &Context) const;
 
   Value *getPointerOperand() { return getOperand(1); }
   const Value *getPointerOperand() const { return getOperand(1); }
@@ -485,7 +500,7 @@ public:
     return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
   }
 
-  virtual GetElementPtrInst *clone() const;
+  virtual GetElementPtrInst *clone(LLVMContext &Context) const;
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -626,12 +641,13 @@ class ICmpInst: public CmpInst {
 public:
   /// @brief Constructor with insert-before-instruction semantics.
   ICmpInst(
+    Instruction *InsertBefore,  ///< Where to insert
     Predicate pred,  ///< The predicate to use for the comparison
     Value *LHS,      ///< The left-hand-side of the expression
     Value *RHS,      ///< The right-hand-side of the expression
-    const std::string &NameStr = "",  ///< Name of the instruction
-    Instruction *InsertBefore = 0  ///< Where to insert
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertBefore->getParent()->getContext()->
+                makeCmpResultType(LHS->getType()),
               Instruction::ICmp, pred, LHS, RHS, NameStr,
               InsertBefore) {
     assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
@@ -645,16 +661,36 @@ public:
            "Invalid operand types for ICmp instruction");
   }
 
-  /// @brief Constructor with insert-at-block-end semantics.
+  /// @brief Constructor with insert-at-end semantics.
   ICmpInst(
+    BasicBlock &InsertAtEnd, ///< Block to insert into.
+    Predicate pred,  ///< The predicate to use for the comparison
+    Value *LHS,      ///< The left-hand-side of the expression
+    Value *RHS,      ///< The right-hand-side of the expression
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertAtEnd.getContext()->makeCmpResultType(LHS->getType()),
+              Instruction::ICmp, pred, LHS, RHS, NameStr,
+              &InsertAtEnd) {
+    assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
+          pred <= CmpInst::LAST_ICMP_PREDICATE &&
+          "Invalid ICmp predicate value");
+    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
+          "Both operands to ICmp instruction are not of the same type!");
+    // Check that the operands are the right type
+    assert((getOperand(0)->getType()->isIntOrIntVector() ||
+            isa<PointerType>(getOperand(0)->getType())) &&
+           "Invalid operand types for ICmp instruction");
+  }
+
+  /// @brief Constructor with no-insertion semantics
+  ICmpInst(
+    LLVMContext &Context, ///< Context to construct within
     Predicate pred, ///< The predicate to use for the comparison
     Value *LHS,     ///< The left-hand-side of the expression
     Value *RHS,     ///< The right-hand-side of the expression
-    const std::string &NameStr,  ///< Name of the instruction
-    BasicBlock *InsertAtEnd   ///< Block to insert into.
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
-              Instruction::ICmp, pred, LHS, RHS, NameStr,
-              InsertAtEnd) {
+    const std::string &NameStr = "" ///< Name of the instruction
+  ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
+              Instruction::ICmp, pred, LHS, RHS, NameStr) {
     assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
            pred <= CmpInst::LAST_ICMP_PREDICATE &&
            "Invalid ICmp predicate value");
@@ -756,7 +792,7 @@ public:
     Op<0>().swap(Op<1>());
   }
 
-  virtual ICmpInst *clone() const;
+  virtual ICmpInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ICmpInst *) { return true; }
@@ -781,12 +817,13 @@ class FCmpInst: public CmpInst {
 public:
   /// @brief Constructor with insert-before-instruction semantics.
   FCmpInst(
+    Instruction *InsertBefore, ///< Where to insert
     Predicate pred,  ///< The predicate to use for the comparison
     Value *LHS,      ///< The left-hand-side of the expression
     Value *RHS,      ///< The right-hand-side of the expression
-    const std::string &NameStr = "",  ///< Name of the instruction
-    Instruction *InsertBefore = 0  ///< Where to insert
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertBefore->getParent()->getContext()->
+                makeCmpResultType(LHS->getType()),
               Instruction::FCmp, pred, LHS, RHS, NameStr,
               InsertBefore) {
     assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
@@ -797,17 +834,35 @@ public:
     assert(getOperand(0)->getType()->isFPOrFPVector() &&
            "Invalid operand types for FCmp instruction");
   }
+  
+  /// @brief Constructor with insert-at-end semantics.
+  FCmpInst(
+    BasicBlock &InsertAtEnd, ///< Block to insert into.
+    Predicate pred,  ///< The predicate to use for the comparison
+    Value *LHS,      ///< The left-hand-side of the expression
+    Value *RHS,      ///< The right-hand-side of the expression
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertAtEnd.getContext()->makeCmpResultType(LHS->getType()),
+              Instruction::FCmp, pred, LHS, RHS, NameStr,
+              &InsertAtEnd) {
+    assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
+           "Invalid FCmp predicate value");
+    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
+           "Both operands to FCmp instruction are not of the same type!");
+    // Check that the operands are the right type
+    assert(getOperand(0)->getType()->isFPOrFPVector() &&
+           "Invalid operand types for FCmp instruction");
+  }
 
-  /// @brief Constructor with insert-at-block-end semantics.
+  /// @brief Constructor with no-insertion semantics
   FCmpInst(
+    LLVMContext &Context, ///< Context to build in
     Predicate pred, ///< The predicate to use for the comparison
     Value *LHS,     ///< The left-hand-side of the expression
     Value *RHS,     ///< The right-hand-side of the expression
-    const std::string &NameStr,  ///< Name of the instruction
-    BasicBlock *InsertAtEnd   ///< Block to insert into.
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
-              Instruction::FCmp, pred, LHS, RHS, NameStr,
-              InsertAtEnd) {
+    const std::string &NameStr = "" ///< Name of the instruction
+  ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
+              Instruction::FCmp, pred, LHS, RHS, NameStr) {
     assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
            "Invalid FCmp predicate value");
     assert(getOperand(0)->getType() == getOperand(1)->getType() &&
@@ -848,7 +903,7 @@ public:
     Op<0>().swap(Op<1>());
   }
 
-  virtual FCmpInst *clone() const;
+  virtual FCmpInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FCmpInst *) { return true; }
@@ -861,118 +916,6 @@ public:
 
 };
 
-//===----------------------------------------------------------------------===//
-//                               VICmpInst Class
-//===----------------------------------------------------------------------===//
-
-/// This instruction compares its operands according to the predicate given
-/// to the constructor. It only operates on vectors of integers.
-/// The operands must be identical types.
-/// @brief Represents a vector integer comparison operator.
-class VICmpInst: public CmpInst {
-public:
-  /// @brief Constructor with insert-before-instruction semantics.
-  VICmpInst(
-    Predicate pred,  ///< The predicate to use for the comparison
-    Value *LHS,      ///< The left-hand-side of the expression
-    Value *RHS,      ///< The right-hand-side of the expression
-    const std::string &NameStr = "",  ///< Name of the instruction
-    Instruction *InsertBefore = 0  ///< Where to insert
-  ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr,
-              InsertBefore) {
-    assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
-           pred <= CmpInst::LAST_ICMP_PREDICATE &&
-           "Invalid VICmp predicate value");
-    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
-          "Both operands to VICmp instruction are not of the same type!");
-  }
-
-  /// @brief Constructor with insert-at-block-end semantics.
-  VICmpInst(
-    Predicate pred, ///< The predicate to use for the comparison
-    Value *LHS,     ///< The left-hand-side of the expression
-    Value *RHS,     ///< The right-hand-side of the expression
-    const std::string &NameStr,  ///< Name of the instruction
-    BasicBlock *InsertAtEnd   ///< Block to insert into.
-  ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr,
-              InsertAtEnd) {
-    assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
-           pred <= CmpInst::LAST_ICMP_PREDICATE &&
-           "Invalid VICmp predicate value");
-    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
-          "Both operands to VICmp instruction are not of the same type!");
-  }
-
-  /// @brief Return the predicate for this instruction.
-  Predicate getPredicate() const { return Predicate(SubclassData); }
-
-  virtual VICmpInst *clone() const;
-
-  // Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const VICmpInst *) { return true; }
-  static inline bool classof(const Instruction *I) {
-    return I->getOpcode() == Instruction::VICmp;
-  }
-  static inline bool classof(const Value *V) {
-    return isa<Instruction>(V) && classof(cast<Instruction>(V));
-  }
-};
-
-//===----------------------------------------------------------------------===//
-//                               VFCmpInst Class
-//===----------------------------------------------------------------------===//
-
-/// This instruction compares its operands according to the predicate given
-/// to the constructor. It only operates on vectors of floating point values.
-/// The operands must be identical types.
-/// @brief Represents a vector floating point comparison operator.
-class VFCmpInst: public CmpInst {
-public:
-  /// @brief Constructor with insert-before-instruction semantics.
-  VFCmpInst(
-    Predicate pred,  ///< The predicate to use for the comparison
-    Value *LHS,      ///< The left-hand-side of the expression
-    Value *RHS,      ///< The right-hand-side of the expression
-    const std::string &NameStr = "",  ///< Name of the instruction
-    Instruction *InsertBefore = 0  ///< Where to insert
-  ) : CmpInst(VectorType::getInteger(cast<VectorType>(LHS->getType())),
-              Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertBefore) {
-    assert(pred <= CmpInst::LAST_FCMP_PREDICATE &&
-           "Invalid VFCmp predicate value");
-    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
-           "Both operands to VFCmp instruction are not of the same type!");
-  }
-
-  /// @brief Constructor with insert-at-block-end semantics.
-  VFCmpInst(
-    Predicate pred, ///< The predicate to use for the comparison
-    Value *LHS,     ///< The left-hand-side of the expression
-    Value *RHS,     ///< The right-hand-side of the expression
-    const std::string &NameStr,  ///< Name of the instruction
-    BasicBlock *InsertAtEnd   ///< Block to insert into.
-  ) : CmpInst(VectorType::getInteger(cast<VectorType>(LHS->getType())),
-              Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertAtEnd) {
-    assert(pred <= CmpInst::LAST_FCMP_PREDICATE &&
-           "Invalid VFCmp predicate value");
-    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
-           "Both operands to VFCmp instruction are not of the same type!");
-  }
-
-  /// @brief Return the predicate for this instruction.
-  Predicate getPredicate() const { return Predicate(SubclassData); }
-
-  virtual VFCmpInst *clone() const;
-
-  /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const VFCmpInst *) { return true; }
-  static inline bool classof(const Instruction *I) {
-    return I->getOpcode() == Instruction::VFCmp;
-  }
-  static inline bool classof(const Value *V) {
-    return isa<Instruction>(V) && classof(cast<Instruction>(V));
-  }
-};
-
 //===----------------------------------------------------------------------===//
 //                                 CallInst Class
 //===----------------------------------------------------------------------===//
@@ -1071,7 +1014,7 @@ public:
     SubclassData = (SubclassData & ~1) | unsigned(isTC);
   }
 
-  virtual CallInst *clone() const;
+  virtual CallInst *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1264,7 +1207,7 @@ public:
     return static_cast<OtherOps>(Instruction::getOpcode());
   }
 
-  virtual SelectInst *clone() const;
+  virtual SelectInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SelectInst *) { return true; }
@@ -1304,7 +1247,7 @@ public:
     setName(NameStr);
   }
 
-  virtual VAArgInst *clone() const;
+  virtual VAArgInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const VAArgInst *) { return true; }
@@ -1337,18 +1280,14 @@ public:
   }
   ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr = "",
                      Instruction *InsertBefore = 0);
-  ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr = "",
-                     Instruction *InsertBefore = 0);
   ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr,
                      BasicBlock *InsertAtEnd);
-  ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr,
-                     BasicBlock *InsertAtEnd);
 
   /// isValidOperands - Return true if an extractelement instruction can be
   /// formed with the specified operands.
   static bool isValidOperands(const Value *Vec, const Value *Idx);
 
-  virtual ExtractElementInst *clone() const;
+  virtual ExtractElementInst *clone(LLVMContext &Context) const;
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1381,13 +1320,8 @@ class InsertElementInst : public Instruction {
   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
                     const std::string &NameStr = "",
                     Instruction *InsertBefore = 0);
-  InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
-                    const std::string &NameStr = "",
-                    Instruction *InsertBefore = 0);
   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
                     const std::string &NameStr, BasicBlock *InsertAtEnd);
-  InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
-                    const std::string &NameStr, BasicBlock *InsertAtEnd);
 public:
   static InsertElementInst *Create(const InsertElementInst &IE) {
     return new(IE.getNumOperands()) InsertElementInst(IE);
@@ -1397,28 +1331,18 @@ public:
                                    Instruction *InsertBefore = 0) {
     return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
   }
-  static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
-                                   const std::string &NameStr = "",
-                                   Instruction *InsertBefore = 0) {
-    return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
-  }
   static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
                                    const std::string &NameStr,
                                    BasicBlock *InsertAtEnd) {
     return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
   }
-  static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
-                                   const std::string &NameStr,
-                                   BasicBlock *InsertAtEnd) {
-    return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
-  }
 
   /// isValidOperands - Return true if an insertelement instruction can be
   /// formed with the specified operands.
   static bool isValidOperands(const Value *Vec, const Value *NewElt,
                               const Value *Idx);
 
-  virtual InsertElementInst *clone() const;
+  virtual InsertElementInst *clone(LLVMContext &Context) const;
 
   /// getType - Overload to return most specific vector type.
   ///
@@ -1470,7 +1394,7 @@ public:
   static bool isValidOperands(const Value *V1, const Value *V2,
                               const Value *Mask);
 
-  virtual ShuffleVectorInst *clone() const;
+  virtual ShuffleVectorInst *clone(LLVMContext &Context) const;
 
   /// getType - Overload to return most specific vector type.
   ///
@@ -1614,7 +1538,7 @@ public:
     return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertAtEnd);
   }
 
-  virtual ExtractValueInst *clone() const;
+  virtual ExtractValueInst *clone(LLVMContext &Context) const;
 
   /// getIndexedType - Returns the type of the element that would be extracted
   /// with an extractvalue instruction with the specified parameters.
@@ -1784,7 +1708,7 @@ public:
     return new InsertValueInst(Agg, Val, Idx, NameStr, InsertAtEnd);
   }
 
-  virtual InsertValueInst *clone() const;
+  virtual InsertValueInst *clone(LLVMContext &Context) const;
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1913,7 +1837,7 @@ public:
     resizeOperands(NumValues*2);
   }
 
-  virtual PHINode *clone() const;
+  virtual PHINode *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -2072,7 +1996,7 @@ public:
   }
   virtual ~ReturnInst();
 
-  virtual ReturnInst *clone() const;
+  virtual ReturnInst *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -2154,7 +2078,7 @@ public:
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
-  virtual BranchInst *clone() const;
+  virtual BranchInst *clone(LLVMContext &Context) const;
 
   bool isUnconditional() const { return getNumOperands() == 1; }
   bool isConditional()   const { return getNumOperands() == 3; }
@@ -2324,7 +2248,7 @@ public:
   ///
   void removeCase(unsigned idx);
 
-  virtual SwitchInst *clone() const;
+  virtual SwitchInst *clone(LLVMContext &Context) const;
 
   unsigned getNumSuccessors() const { return getNumOperands()/2; }
   BasicBlock *getSuccessor(unsigned idx) const {
@@ -2438,7 +2362,7 @@ public:
                                   Values, NameStr, InsertAtEnd);
   }
 
-  virtual InvokeInst *clone() const;
+  virtual InvokeInst *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -2626,7 +2550,7 @@ public:
   explicit UnwindInst(Instruction *InsertBefore = 0);
   explicit UnwindInst(BasicBlock *InsertAtEnd);
 
-  virtual UnwindInst *clone() const;
+  virtual UnwindInst *clone(LLVMContext &Context) const;
 
   unsigned getNumSuccessors() const { return 0; }
 
@@ -2663,7 +2587,7 @@ public:
   explicit UnreachableInst(Instruction *InsertBefore = 0);
   explicit UnreachableInst(BasicBlock *InsertAtEnd);
 
-  virtual UnreachableInst *clone() const;
+  virtual UnreachableInst *clone(LLVMContext &Context) const;
 
   unsigned getNumSuccessors() const { return 0; }
 
@@ -2709,7 +2633,7 @@ public:
   );
 
   /// @brief Clone an identical TruncInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const TruncInst *) { return true; }
@@ -2749,7 +2673,7 @@ public:
   );
 
   /// @brief Clone an identical ZExtInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ZExtInst *) { return true; }
@@ -2789,7 +2713,7 @@ public:
   );
 
   /// @brief Clone an identical SExtInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SExtInst *) { return true; }
@@ -2828,7 +2752,7 @@ public:
   );
 
   /// @brief Clone an identical FPTruncInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPTruncInst *) { return true; }
@@ -2867,7 +2791,7 @@ public:
   );
 
   /// @brief Clone an identical FPExtInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPExtInst *) { return true; }
@@ -2906,7 +2830,7 @@ public:
   );
 
   /// @brief Clone an identical UIToFPInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const UIToFPInst *) { return true; }
@@ -2945,7 +2869,7 @@ public:
   );
 
   /// @brief Clone an identical SIToFPInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SIToFPInst *) { return true; }
@@ -2984,7 +2908,7 @@ public:
   );
 
   /// @brief Clone an identical FPToUIInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPToUIInst *) { return true; }
@@ -3023,7 +2947,7 @@ public:
   );
 
   /// @brief Clone an identical FPToSIInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPToSIInst *) { return true; }
@@ -3062,7 +2986,7 @@ public:
   );
 
   /// @brief Clone an identical IntToPtrInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const IntToPtrInst *) { return true; }
@@ -3101,7 +3025,7 @@ public:
   );
 
   /// @brief Clone an identical PtrToIntInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const PtrToIntInst *) { return true; }
@@ -3140,7 +3064,7 @@ public:
   );
 
   /// @brief Clone an identical BitCastInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const BitCastInst *) { return true; }