__builtin_ia32_movntdqa reads memory
[oota-llvm.git] / include / llvm / Instructions.h
index e5a6c98067735af78ab42f14b58cb2efa0156f84..c80154c76d0a3804820078ed04dcf15b426fd7e8 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -30,7 +30,6 @@ class PointerType;
 class VectorType;
 class ConstantRange;
 class APInt;
-class ParamAttrsList;
 
 //===----------------------------------------------------------------------===//
 //                             AllocationInst Class
@@ -47,6 +46,9 @@ protected:
   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();
+
   /// isArrayAllocation - Return true if there is an allocation size parameter
   /// to the allocation instruction that is not 1.
   ///
@@ -55,12 +57,12 @@ public:
   /// getArraySize - Get the number of element allocated, for a simple
   /// allocation of a single element, this will return a constant 1 value.
   ///
-  inline const Value *getArraySize() const { return getOperand(0); }
-  inline Value *getArraySize() { return getOperand(0); }
+  const Value *getArraySize() const { return getOperand(0); }
+  Value *getArraySize() { return getOperand(0); }
 
   /// getType - Overload to return most specific pointer type
   ///
-  inline const PointerType *getType() const {
+  const PointerType *getType() const {
     return reinterpret_cast<const PointerType*>(Instruction::getType());
   }
 
@@ -187,11 +189,6 @@ public:
 ///
 class FreeInst : public UnaryInstruction {
   void AssertOK();
-protected:
-  static void destroyThis(FreeInst* v) {
-    UnaryInstruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
   FreeInst(Value *Ptr, BasicBlock *InsertAfter);
@@ -232,11 +229,6 @@ class LoadInst : public UnaryInstruction {
 #endif
   }
   void AssertOK();
-protected:
-  static void destroyThis(LoadInst* v) {
-    UnaryInstruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
   LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
@@ -312,11 +304,6 @@ class StoreInst : public Instruction {
 #endif
   }
   void AssertOK();
-protected:
-  static void destroyThis(StoreInst* v) {
-    Instruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
   StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
@@ -455,9 +442,6 @@ class GetElementPtrInst : public Instruction {
     }
   }
 
-protected:
-  static void destroyThis(GetElementPtrInst*v);
-  friend class Value;
 public:
   /// Constructors - Create a getelementptr instruction with a base pointer an
   /// list of indices.  The first ctor can optionally insert before an existing
@@ -470,7 +454,8 @@ public:
                     Instruction *InsertBefore =0)
       : Instruction(PointerType::get(
                       checkType(getIndexedType(Ptr->getType(),
-                                               IdxBegin, IdxEnd, true))),
+                                               IdxBegin, IdxEnd, true)),
+                      cast<PointerType>(Ptr->getType())->getAddressSpace()),
                     GetElementPtr, 0, 0, InsertBefore) {
     init(Ptr, IdxBegin, IdxEnd, Name,
          typename std::iterator_traits<InputIterator>::iterator_category());
@@ -480,7 +465,8 @@ public:
                     const std::string &Name, BasicBlock *InsertAtEnd)
       : Instruction(PointerType::get(
                       checkType(getIndexedType(Ptr->getType(),
-                                               IdxBegin, IdxEnd, true))),
+                                               IdxBegin, IdxEnd, true)),
+                      cast<PointerType>(Ptr->getType())->getAddressSpace()),
                     GetElementPtr, 0, 0, InsertAtEnd) {
     init(Ptr, IdxBegin, IdxEnd, Name,
          typename std::iterator_traits<InputIterator>::iterator_category());
@@ -492,11 +478,12 @@ public:
                     const std::string &Name = "", Instruction *InsertBefore =0);
   GetElementPtrInst(Value *Ptr, Value *Idx,
                     const std::string &Name, BasicBlock *InsertAtEnd);
+  ~GetElementPtrInst();
 
   virtual GetElementPtrInst *clone() const;
 
   // getType - Overload to return most specific pointer type...
-  inline const PointerType *getType() const {
+  const PointerType *getType() const {
     return reinterpret_cast<const PointerType*>(Instruction::getType());
   }
 
@@ -532,11 +519,11 @@ public:
     return 0U;                      // get index for modifying correct operand
   }
 
-  inline unsigned getNumIndices() const {  // Note: always non-negative
+  unsigned getNumIndices() const {  // Note: always non-negative
     return getNumOperands() - 1;
   }
 
-  inline bool hasIndices() const {
+  bool hasIndices() const {
     return getNumOperands() > 1;
   }
   
@@ -570,11 +557,6 @@ public:
 /// vectors of integrals. The two operands must be the same type.
 /// @brief Represent an integer comparison operator.
 class ICmpInst: public CmpInst {
-protected:
-  static void destroyThis(ICmpInst* v) {
-    CmpInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// This enumeration lists the possible predicates for the ICmpInst. The
   /// values in the range 0-31 are reserved for FCmpInst while values in the
@@ -660,6 +642,18 @@ public:
   /// @brief Return the signed version of the predicate.
   static Predicate getSignedPredicate(Predicate pred);
 
+  /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
+  /// @returns the predicate that would be the result if the operand were
+  /// regarded as unsigned.
+  /// @brief Return the unsigned version of the predicate
+  Predicate getUnsignedPredicate() const {
+    return getUnsignedPredicate(getPredicate());
+  }
+
+  /// This is a static version that you can use without an instruction.
+  /// @brief Return the unsigned version of the predicate.
+  static Predicate getUnsignedPredicate(Predicate pred);
+
   /// isEquality - Return true if this predicate is either EQ or NE.  This also
   /// tests for commutativity.
   static bool isEquality(Predicate P) {
@@ -731,11 +725,6 @@ public:
 /// vectors of floating point values. The operands must be identical types.
 /// @brief Represents a floating point comparison operator.
 class FCmpInst: public CmpInst {
-protected:
-  static void destroyThis(FCmpInst* v) {
-    CmpInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// This enumeration lists the possible predicates for the FCmpInst. Values
   /// in the range 0-31 are reserved for FCmpInst.
@@ -861,7 +850,7 @@ public:
 ///
 
 class CallInst : public Instruction {
-  const ParamAttrsList *ParamAttrs; ///< parameter attributes for call
+  PAListPtr ParamAttrs; ///< parameter attributes for call
   CallInst(const CallInst &CI);
   void init(Value *Func, Value* const *Params, unsigned NumParams);
   void init(Value *Func, Value *Actual1, Value *Actual2);
@@ -881,9 +870,6 @@ class CallInst : public Instruction {
     setName(Name);
   }
 
-protected:
-  static void destroyThis(CallInst*v);
-  friend class Value;
 public:
   /// Construct a CallInst given a range of arguments.  InputIterator
   /// must be a random-access iterator pointing to contiguous storage
@@ -924,6 +910,7 @@ public:
   explicit CallInst(Value *F, const std::string &Name = "",
                     Instruction *InsertBefore = 0);
   CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd);
+  ~CallInst();
 
   virtual CallInst *clone() const;
   
@@ -939,41 +926,54 @@ public:
     SubclassData = (SubclassData & 1) | (CC << 1);
   }
 
-  /// Obtains a pointer to the ParamAttrsList object which holds the
-  /// parameter attributes information, if any.
-  /// @returns 0 if no attributes have been set.
-  /// @brief Get the parameter attributes.
-  const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+  /// getParamAttrs - Return the parameter attributes for this call.
+  ///
+  const PAListPtr &getParamAttrs() const { return ParamAttrs; }
 
-  /// Sets the parameter attributes for this CallInst. To construct a 
-  /// ParamAttrsList, see ParameterAttributes.h
-  /// @brief Set the parameter attributes.
-  void setParamAttrs(const ParamAttrsList *attrs);
+  /// setParamAttrs - Sets the parameter attributes for this call.
+  void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
 
   /// @brief Determine whether the call or the callee has the given attribute.
-  bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+  bool paramHasAttr(unsigned i, unsigned attr) const;
+
+  /// @brief Extract the alignment for a call or parameter (0=unknown).
+  unsigned getParamAlignment(unsigned i) const {
+    return ParamAttrs.getParamAlignment(i);
+  }
 
   /// @brief Determine if the call does not access memory.
   bool doesNotAccessMemory() const {
     return paramHasAttr(0, ParamAttr::ReadNone);
   }
-
+  
   /// @brief Determine if the call does not access or only reads memory.
   bool onlyReadsMemory() const {
     return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
   }
+  
+  /// @brief Determine if the call cannot return.
+  bool doesNotReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
 
   /// @brief Determine if the call cannot unwind.
-  bool isNoUnwind() const {
+  bool doesNotThrow() const {
     return paramHasAttr(0, ParamAttr::NoUnwind);
   }
+  void setDoesNotThrow(bool doesNotThrow = true);
 
-  /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const {
+  /// @brief Determine if the call returns a structure through first 
+  /// pointer argument.
+  bool hasStructRetAttr() const {
     // Be friendly and also check the callee.
     return paramHasAttr(1, ParamAttr::StructRet);
   }
 
+  /// @brief Determine if any call argument is an aggregate passed by value.
+  bool hasByValArgument() const {
+    return ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal);
+  }
+
   /// getCalledFunction - Return the function being called by this instruction
   /// if it is a direct call.  If it is a call through a function pointer,
   /// return null.
@@ -983,8 +983,8 @@ public:
 
   /// getCalledValue - Get a pointer to the function that is invoked by this 
   /// instruction
-  inline const Value *getCalledValue() const { return getOperand(0); }
-  inline       Value *getCalledValue()       { return getOperand(0); }
+  const Value *getCalledValue() const { return getOperand(0); }
+        Value *getCalledValue()       { return getOperand(0); }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const CallInst *) { return true; }
@@ -1015,11 +1015,6 @@ class SelectInst : public Instruction {
     : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) {
     init(SI.Ops[0], SI.Ops[1], SI.Ops[2]);
   }
-protected:
-  static void destroyThis(SelectInst* v) {
-    Instruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
              Instruction *InsertBefore = 0)
@@ -1075,11 +1070,6 @@ public:
 class VAArgInst : public UnaryInstruction {
   VAArgInst(const VAArgInst &VAA)
     : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
-protected:
-  static void destroyThis(VAArgInst* v) {
-    UnaryInstruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
              Instruction *InsertBefore = 0)
@@ -1119,11 +1109,6 @@ class ExtractElementInst : public Instruction {
     Ops[1].init(EE.Ops[1], this);
   }
 
-protected:
-  static void destroyThis(ExtractElementInst* v) {
-    Instruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name = "",
                      Instruction *InsertBefore = 0);
@@ -1171,11 +1156,6 @@ public:
 class InsertElementInst : public Instruction {
   Use Ops[3];
   InsertElementInst(const InsertElementInst &IE);
-protected:
-  static void destroyThis(InsertElementInst* v) {
-    Instruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
                     const std::string &Name = "",Instruction *InsertBefore = 0);
@@ -1195,7 +1175,7 @@ public:
 
   /// getType - Overload to return most specific vector type.
   ///
-  inline const VectorType *getType() const {
+  const VectorType *getType() const {
     return reinterpret_cast<const VectorType*>(Instruction::getType());
   }
 
@@ -1230,11 +1210,6 @@ public:
 class ShuffleVectorInst : public Instruction {
   Use Ops[3];
   ShuffleVectorInst(const ShuffleVectorInst &IE);
-protected:
-  static void destroyThis(ShuffleVectorInst* v) {
-    Instruction::destroyThis(v);
-  }
-  friend class Value;
 public:
   ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
                     const std::string &Name = "", Instruction *InsertBefor = 0);
@@ -1250,12 +1225,16 @@ public:
 
   /// getType - Overload to return most specific vector type.
   ///
-  inline const VectorType *getType() const {
+  const VectorType *getType() const {
     return reinterpret_cast<const VectorType*>(Instruction::getType());
   }
 
   /// Transparently provide more efficient getOperand methods.
-  Value *getOperand(unsigned i) const {
+  const Value *getOperand(unsigned i) const {
+    assert(i < 3 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  Value *getOperand(unsigned i) {
     assert(i < 3 && "getOperand() out of range!");
     return Ops[i];
   }
@@ -1264,6 +1243,11 @@ public:
     Ops[i] = Val;
   }
   unsigned getNumOperands() const { return 3; }
+  
+  /// getMaskValue - Return the index from the shuffle mask for the specified
+  /// output result.  This is either -1 if the element is undef or a number less
+  /// than 2*numelements.
+  int getMaskValue(unsigned i) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ShuffleVectorInst *) { return true; }
@@ -1289,9 +1273,6 @@ class PHINode : public Instruction {
   /// the number actually in use.
   unsigned ReservedSpace;
   PHINode(const PHINode &PN);
-protected:
-  static void destroyThis(PHINode*);
-  friend class Value;
 public:
   explicit PHINode(const Type *Ty, const std::string &Name = "",
                    Instruction *InsertBefore = 0)
@@ -1306,6 +1287,8 @@ public:
     setName(Name);
   }
 
+  ~PHINode();
+
   /// reserveOperandSpace - This method can be used to avoid repeated
   /// reallocation of PHI operand lists by reserving space for the correct
   /// number of operands before adding them.  Unlike normal vector reserves,
@@ -1349,6 +1332,8 @@ public:
   /// addIncoming - Add an incoming value to the end of the PHI list
   ///
   void addIncoming(Value *V, BasicBlock *BB) {
+    assert(V && "PHI node got a null value!");
+    assert(BB && "PHI node got a null basic block!");
     assert(getType() == V->getType() &&
            "All operands to PHI node must be the same type as the PHI node!");
     unsigned OpNo = NumOperands;
@@ -1416,9 +1401,9 @@ public:
 /// does not continue in this function any longer.
 ///
 class ReturnInst : public TerminatorInst {
-  Use RetVal;  // Return Value: null if 'void'.
+  Use RetVal;
   ReturnInst(const ReturnInst &RI);
-  void init(Value *RetVal);
+  void init(Value * const* retVals, unsigned N);
 
 public:
   // ReturnInst constructors:
@@ -1429,26 +1414,32 @@ public:
   // ReturnInst(Value* X, Inst *I) - 'ret X'    instruction, insert before I
   // ReturnInst(    null, BB *B)   - 'ret void' instruction, insert @ end of BB
   // ReturnInst(Value* X, BB *B)   - 'ret X'    instruction, insert @ end of BB
+  // ReturnInst(Value* X, N)          - 'ret X,X+1...X+N-1' instruction
+  // ReturnInst(Value* X, N, Inst *)  - 'ret X,X+1...X+N-1', insert before I
+  // ReturnInst(Value* X, N, BB *)    - 'ret X,X+1...X+N-1', insert @ end of BB
   //
   // NOTE: If the Value* passed is of type void then the constructor behaves as
   // if it was passed NULL.
   explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
   ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
+  ReturnInst(Value * const* retVals, unsigned N);
+  ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore);
+  ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd);
   explicit ReturnInst(BasicBlock *InsertAtEnd);
+  virtual ~ReturnInst();
 
   virtual ReturnInst *clone() const;
 
-  // Transparently provide more efficient getOperand methods.
-  Value *getOperand(unsigned i) const {
-    assert(i < getNumOperands() && "getOperand() out of range!");
-    return RetVal;
-  }
-  void setOperand(unsigned i, Value *Val) {
-    assert(i < getNumOperands() && "setOperand() out of range!");
-    RetVal = Val;
+  Value *getOperand(unsigned n = 0) const {
+    if (getNumOperands() > 1)
+      return TerminatorInst::getOperand(n);
+    else
+      return RetVal;
   }
 
-  Value *getReturnValue() const { return RetVal; }
+  Value *getReturnValue(unsigned n = 0) const {
+    return getOperand(n);
+  }
 
   unsigned getNumSuccessors() const { return 0; }
 
@@ -1507,10 +1498,10 @@ public:
 
   virtual BranchInst *clone() const;
 
-  inline bool isUnconditional() const { return getNumOperands() == 1; }
-  inline bool isConditional()   const { return getNumOperands() == 3; }
+  bool isUnconditional() const { return getNumOperands() == 1; }
+  bool isConditional()   const { return getNumOperands() == 3; }
 
-  inline Value *getCondition() const {
+  Value *getCondition() const {
     assert(isConditional() && "Cannot get condition of an uncond branch!");
     return getOperand(2);
   }
@@ -1574,9 +1565,6 @@ class SwitchInst : public TerminatorInst {
   SwitchInst(const SwitchInst &RI);
   void init(Value *Value, BasicBlock *Default, unsigned NumCases);
   void resizeOperands(unsigned No);
-protected:
-  static void destroyThis(SwitchInst*v);
-  friend class Value;
 public:
   /// SwitchInst ctor - Create a new switch instruction, specifying a value to
   /// switch on and a default destination.  The number of additional cases can
@@ -1591,13 +1579,14 @@ public:
   /// constructor also autoinserts at the end of the specified BasicBlock.
   SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
              BasicBlock *InsertAtEnd);
+  ~SwitchInst();
 
 
   // Accessor Methods for Switch stmt
-  inline Value *getCondition() const { return getOperand(0); }
+  Value *getCondition() const { return getOperand(0); }
   void setCondition(Value *V) { setOperand(0, V); }
 
-  inline BasicBlock *getDefaultDest() const {
+  BasicBlock *getDefaultDest() const {
     return cast<BasicBlock>(getOperand(1));
   }
 
@@ -1670,7 +1659,7 @@ public:
 
   // getSuccessorValue - Return the value associated with the specified
   // successor.
-  inline ConstantInt *getSuccessorValue(unsigned idx) const {
+  ConstantInt *getSuccessorValue(unsigned idx) const {
     assert(idx < getNumSuccessors() && "Successor # out of range!");
     return reinterpret_cast<ConstantInt*>(getOperand(idx*2));
   }
@@ -1699,7 +1688,7 @@ private:
 /// calling convention of the call.
 ///
 class InvokeInst : public TerminatorInst {
-  const ParamAttrsList *ParamAttrs;
+  PAListPtr ParamAttrs;
   InvokeInst(const InvokeInst &BI);
   void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
             Value* const *Args, unsigned NumArgs);
@@ -1718,9 +1707,6 @@ class InvokeInst : public TerminatorInst {
     setName(Name);
   }
 
-protected:
-  static void destroyThis(InvokeInst*v);
-  friend class Value;
 public:
   /// Construct an InvokeInst given a range of arguments.
   /// InputIterator must be a random-access iterator pointing to
@@ -1758,6 +1744,8 @@ public:
          typename std::iterator_traits<InputIterator>::iterator_category());
   }
 
+  ~InvokeInst();
+
   virtual InvokeInst *clone() const;
 
   /// getCallingConv/setCallingConv - Get or set the calling convention of this
@@ -1767,19 +1755,21 @@ public:
     SubclassData = CC;
   }
 
-  /// Obtains a pointer to the ParamAttrsList object which holds the
-  /// parameter attributes information, if any.
-  /// @returns 0 if no attributes have been set.
-  /// @brief Get the parameter attributes.
-  const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+  /// getParamAttrs - Return the parameter attributes for this invoke.
+  ///
+  const PAListPtr &getParamAttrs() const { return ParamAttrs; }
 
-  /// Sets the parameter attributes for this InvokeInst. To construct a 
-  /// ParamAttrsList, see ParameterAttributes.h
-  /// @brief Set the parameter attributes.
-  void setParamAttrs(const ParamAttrsList *attrs);
+  /// setParamAttrs - Set the parameter attributes for this invoke.
+  ///
+  void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
 
   /// @brief Determine whether the call or the callee has the given attribute.
-  bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+  bool paramHasAttr(unsigned i, ParameterAttributes attr) const;
+
+  /// @brief Extract the alignment for a call or parameter (0=unknown).
+  unsigned getParamAlignment(unsigned i) const {
+    return ParamAttrs.getParamAlignment(i);
+  }
 
   /// @brief Determine if the call does not access memory.
   bool doesNotAccessMemory() const {
@@ -1791,13 +1781,20 @@ public:
     return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
   }
 
+  /// @brief Determine if the call cannot return.
+  bool doesNotReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
+
   /// @brief Determine if the call cannot unwind.
-  bool isNoUnwind() const {
+  bool doesNotThrow() const {
     return paramHasAttr(0, ParamAttr::NoUnwind);
   }
+  void setDoesNotThrow(bool doesNotThrow = true);
 
-  /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const {
+  /// @brief Determine if the call returns a structure through first 
+  /// pointer argument.
+  bool hasStructRetAttr() const {
     // Be friendly and also check the callee.
     return paramHasAttr(1, ParamAttr::StructRet);
   }
@@ -1810,7 +1807,7 @@ public:
   }
 
   // getCalledValue - Get a pointer to a function that is invoked by this inst.
-  inline Value *getCalledValue() const { return getOperand(0); }
+  Value *getCalledValue() const { return getOperand(0); }
 
   // get*Dest - Return the destination basic blocks...
   BasicBlock *getNormalDest() const {
@@ -1827,7 +1824,7 @@ public:
     setOperand(2, reinterpret_cast<Value*>(B));
   }
 
-  inline BasicBlock *getSuccessor(unsigned i) const {
+  BasicBlock *getSuccessor(unsigned i) const {
     assert(i < 2 && "Successor # out of range for invoke!");
     return i == 0 ? getNormalDest() : getUnwindDest();
   }
@@ -1927,11 +1924,6 @@ class TruncInst : public CastInst {
   TruncInst(const TruncInst &CI)
     : CastInst(CI.getType(), Trunc, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(TruncInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   TruncInst(
@@ -1972,11 +1964,6 @@ class ZExtInst : public CastInst {
   ZExtInst(const ZExtInst &CI)
     : CastInst(CI.getType(), ZExt, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(ZExtInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   ZExtInst(
@@ -2017,11 +2004,6 @@ class SExtInst : public CastInst {
   SExtInst(const SExtInst &CI)
     : CastInst(CI.getType(), SExt, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(SExtInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   SExtInst(
@@ -2061,11 +2043,6 @@ class FPTruncInst : public CastInst {
   FPTruncInst(const FPTruncInst &CI)
     : CastInst(CI.getType(), FPTrunc, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(FPTruncInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   FPTruncInst(
@@ -2105,11 +2082,6 @@ class FPExtInst : public CastInst {
   FPExtInst(const FPExtInst &CI)
     : CastInst(CI.getType(), FPExt, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(FPExtInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   FPExtInst(
@@ -2149,11 +2121,6 @@ class UIToFPInst : public CastInst {
   UIToFPInst(const UIToFPInst &CI)
     : CastInst(CI.getType(), UIToFP, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(UIToFPInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   UIToFPInst(
@@ -2193,11 +2160,6 @@ class SIToFPInst : public CastInst {
   SIToFPInst(const SIToFPInst &CI)
     : CastInst(CI.getType(), SIToFP, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(SIToFPInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   SIToFPInst(
@@ -2237,11 +2199,6 @@ class FPToUIInst  : public CastInst {
   FPToUIInst(const FPToUIInst &CI)
     : CastInst(CI.getType(), FPToUI, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(FPToUIInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   FPToUIInst(
@@ -2281,11 +2238,6 @@ class FPToSIInst  : public CastInst {
   FPToSIInst(const FPToSIInst &CI)
     : CastInst(CI.getType(), FPToSI, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(FPToSIInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   FPToSIInst(
@@ -2325,11 +2277,6 @@ class IntToPtrInst : public CastInst {
   IntToPtrInst(const IntToPtrInst &CI)
     : CastInst(CI.getType(), IntToPtr, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(IntToPtrInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   IntToPtrInst(
@@ -2369,11 +2316,6 @@ class PtrToIntInst : public CastInst {
   PtrToIntInst(const PtrToIntInst &CI)
     : CastInst(CI.getType(), PtrToInt, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(PtrToIntInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   PtrToIntInst(
@@ -2413,11 +2355,6 @@ class BitCastInst : public CastInst {
   BitCastInst(const BitCastInst &CI)
     : CastInst(CI.getType(), BitCast, CI.getOperand(0)) {
   }
-protected:
-  static void destroyThis(BitCastInst* v) {
-    CastInst::destroyThis(v);
-  }
-  friend class Value;
 public:
   /// @brief Constructor with insert-before-instruction semantics
   BitCastInst(
@@ -2448,6 +2385,57 @@ public:
   }
 };
 
+//===----------------------------------------------------------------------===//
+//                             GetResultInst Class
+//===----------------------------------------------------------------------===//
+
+/// GetResultInst - This instruction extracts individual result value from
+/// aggregate value, where aggregate value is returned by CallInst.
+///
+class GetResultInst : public Instruction {
+  Use Aggr;
+  unsigned Idx;
+  GetResultInst(const GetResultInst &GRI) :
+    Instruction(GRI.getType(), Instruction::GetResult, &Aggr, 1) {
+    Aggr.init(GRI.Aggr, this);
+    Idx = GRI.Idx;
+  }
+
+public:
+  explicit GetResultInst(Value *Aggr, unsigned index,
+                         const std::string &Name = "",
+                         Instruction *InsertBefore = 0);
+
+  /// isValidOperands - Return true if an getresult instruction can be
+  /// formed with the specified operands.
+  static bool isValidOperands(const Value *Aggr, unsigned index);
+  
+  virtual GetResultInst *clone() const;
+  
+  Value *getAggregateValue() {
+    return getOperand(0);
+  }
+
+  const Value *getAggregateValue() const {
+    return getOperand(0);
+  }
+
+  unsigned getIndex() const {
+    return Idx;
+  }
+
+  unsigned getNumOperands() const { return 1; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const GetResultInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return (I->getOpcode() == Instruction::GetResult);
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
 } // End llvm namespace
 
 #endif