make ExtractValueInst derived from UnaryInstruction
authorGabor Greif <ggreif@gmail.com>
Fri, 6 Jun 2008 20:28:12 +0000 (20:28 +0000)
committerGabor Greif <ggreif@gmail.com>
Fri, 6 Jun 2008 20:28:12 +0000 (20:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52061 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/InstrTypes.h
include/llvm/Instructions.h
lib/VMCore/Instructions.cpp

index 386c00118fac3e2e070ca9b33d12afb653cf1deb..0a3fbed804f0604b0d5160db13116ad15188a9fe 100644 (file)
@@ -118,6 +118,7 @@ public:
            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) {
index 5bd029644be43f6139cbfc861905d3d91b30bdce..6a599d3fceba9bf5ff187b759e55ab2ed6a6647a 100644 (file)
@@ -1453,7 +1453,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorInst, Value)
 /// 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 @@ class ExtractValueInst : public Instruction {
                     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 @@ public:
 
   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 @@ public:
   }
 };
 
-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 @@ ExtractValueInst::ExtractValueInst(Value *Agg,
                                    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
index f66076d24e864730f53c40478c455149477d0334..4a297b3345b2f39e155199564979d45257a341d0 100644 (file)
@@ -999,7 +999,8 @@ static unsigned retrieveAddrSpace(const Value *Val) {
   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 @@ InsertValueInst::InsertValueInst(Value *Agg,
 //                             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 @@ void ExtractValueInst::init(Value *Agg, unsigned Idx, const std::string &Name) {
 }
 
 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 @@ ExtractValueInst::ExtractValueInst(Value *Agg,
                                    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 @@ ExtractValueInst::ExtractValueInst(Value *Agg,
                                    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);
 }