[llvm-commits] [llvm] r52061 - in /llvm/trunk: include/llvm/InstrTypes.h include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Gabor Greif ggreif at gmail.com
Fri Jun 6 13:28:13 PDT 2008


Author: ggreif
Date: Fri Jun  6 15:28:12 2008
New Revision: 52061

URL: http://llvm.org/viewvc/llvm-project?rev=52061&view=rev
Log:
make ExtractValueInst derived from UnaryInstruction

Modified:
    llvm/trunk/include/llvm/InstrTypes.h
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/include/llvm/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=52061&r1=52060&r2=52061&view=diff

==============================================================================
--- llvm/trunk/include/llvm/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/InstrTypes.h Fri Jun  6 15:28:12 2008
@@ -118,6 +118,7 @@
            I->getOpcode() == Instruction::Load ||
            I->getOpcode() == Instruction::VAArg ||
            I->getOpcode() == Instruction::GetResult ||
+           I->getOpcode() == Instruction::ExtractValue ||
            (I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
   }
   static inline bool classof(const Value *V) {

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=52061&r1=52060&r2=52061&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Fri Jun  6 15:28:12 2008
@@ -1453,7 +1453,7 @@
 /// ExtractValueInst - This instruction extracts a struct member or array
 /// element value from an aggregate value.
 ///
-class ExtractValueInst : public Instruction {
+class ExtractValueInst : public UnaryInstruction {
   SmallVector<unsigned, 4> Indices;
 
   ExtractValueInst(const ExtractValueInst &EVI);
@@ -1526,12 +1526,13 @@
                     Instruction *InsertBefore = 0);
   ExtractValueInst(Value *Agg, unsigned Idx,
                     const std::string &Name, BasicBlock *InsertAtEnd);
-public:
+
   // allocate space for exactly one operand
   void *operator new(size_t s) {
     return User::operator new(s, 1);
   }
 
+public:
   template<typename InputIterator>
   static ExtractValueInst *Create(Value *Agg, InputIterator IdxBegin, 
                                   InputIterator IdxEnd,
@@ -1564,9 +1565,6 @@
 
   virtual ExtractValueInst *clone() const;
 
-  /// Transparently provide more efficient getOperand methods.
-  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
-
   // getType - Overload to return most specific pointer type...
   const PointerType *getType() const {
     return reinterpret_cast<const PointerType*>(Instruction::getType());
@@ -1619,20 +1617,15 @@
   }
 };
 
-template <>
-struct OperandTraits<ExtractValueInst> : FixedNumOperandTraits<1> {
-};
-
 template<typename InputIterator>
 ExtractValueInst::ExtractValueInst(Value *Agg,
                                    InputIterator IdxBegin, 
                                    InputIterator IdxEnd,
                                    const std::string &Name,
                                    Instruction *InsertBefore)
-  : Instruction(checkType(getIndexedType(Agg->getType(), IdxBegin, IdxEnd)),
-                ExtractValue,
-                OperandTraits<ExtractValueInst>::op_begin(this),
-                1, InsertBefore) {
+  : UnaryInstruction(checkType(getIndexedType(Agg->getType(),
+					      IdxBegin, IdxEnd)),
+		     ExtractValue, Agg, InsertBefore) {
   init(Agg, IdxBegin, IdxEnd, Name,
        typename std::iterator_traits<InputIterator>::iterator_category());
 }
@@ -1642,16 +1635,13 @@
                                    InputIterator IdxEnd,
                                    const std::string &Name,
                                    BasicBlock *InsertAtEnd)
-  : Instruction(checkType(getIndexedType(Agg->getType(), IdxBegin, IdxEnd)),
-                ExtractValue,
-                OperandTraits<ExtractValueInst>::op_begin(this),
-                1, InsertAtEnd) {
+  : UnaryInstruction(checkType(getIndexedType(Agg->getType(),
+					      IdxBegin, IdxEnd)),
+		     ExtractValue, Agg, InsertAtEnd) {
   init(Agg, IdxBegin, IdxEnd, Name,
        typename std::iterator_traits<InputIterator>::iterator_category());
 }
 
-DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueInst, Value)
-
 
 //===----------------------------------------------------------------------===//
 //                                InsertValueInst Class

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=52061&r1=52060&r2=52061&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Jun  6 15:28:12 2008
@@ -999,7 +999,8 @@
   return cast<PointerType>(Val->getType())->getAddressSpace();
 }
 
-void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx, const std::string &Name) {
+void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
+			     const std::string &Name) {
   assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
   Use *OL = OperandList;
   OL[0] = Ptr;
@@ -1411,7 +1412,8 @@
 //                             ExtractValueInst Class
 //===----------------------------------------------------------------------===//
 
-void ExtractValueInst::init(Value *Agg, const unsigned *Idx, unsigned NumIdx, const std::string &Name) {
+void ExtractValueInst::init(Value *Agg, const unsigned *Idx, unsigned NumIdx,
+			    const std::string &Name) {
   assert(NumOperands == 1 && "NumOperands not initialized?");
   Op<0>() = Agg;
 
@@ -1428,8 +1430,7 @@
 }
 
 ExtractValueInst::ExtractValueInst(const ExtractValueInst &EVI)
-  : Instruction(reinterpret_cast<const Type*>(EVI.getType()), ExtractValue,
-                OperandTraits<ExtractValueInst>::op_begin(this), 1),
+  : UnaryInstruction(EVI.getType(), ExtractValue, EVI.getOperand(0)),
     Indices(EVI.Indices) {
 }
 
@@ -1464,10 +1465,8 @@
                                    unsigned Idx,
                                    const std::string &Name,
                                    BasicBlock *InsertAtEnd)
-  : Instruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
-                ExtractValue,
-                OperandTraits<ExtractValueInst>::op_begin(this),
-                1, InsertAtEnd) {
+  : UnaryInstruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
+		     ExtractValue, Agg, InsertAtEnd) {
   init(Agg, Idx, Name);
 }
 
@@ -1475,10 +1474,8 @@
                                    unsigned Idx,
                                    const std::string &Name,
                                    Instruction *InsertBefore)
-  : Instruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
-                ExtractValue,
-                OperandTraits<ExtractValueInst>::op_begin(this),
-                1, InsertBefore) {
+  : UnaryInstruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
+		     ExtractValue, Agg, InsertBefore) {
   init(Agg, Idx, Name);
 }
 





More information about the llvm-commits mailing list