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

Gabor Greif ggreif at gmail.com
Tue May 13 00:09:09 PDT 2008


Author: ggreif
Date: Tue May 13 02:09:08 2008
New Revision: 51023

URL: http://llvm.org/viewvc/llvm-project?rev=51023&view=rev
Log:
Derive GetResultInst from UnaryInstruction, this simplifies code and removes a FIXME.

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=51023&r1=51022&r2=51023&view=diff

==============================================================================
--- llvm/trunk/include/llvm/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/InstrTypes.h Tue May 13 02:09:08 2008
@@ -85,8 +85,9 @@
 //===----------------------------------------------------------------------===//
 
 class UnaryInstruction : public Instruction {
-  void *operator new(size_t, unsigned); // Do not implement
-  
+  void *operator new(size_t, unsigned);      // Do not implement
+  UnaryInstruction(const UnaryInstruction&); // Do not implement
+
 protected:
   UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB = 0)
     : Instruction(Ty, iType, &Op<0>(), 1, IB) {
@@ -116,6 +117,7 @@
            I->getOpcode() == Instruction::Free ||
            I->getOpcode() == Instruction::Load ||
            I->getOpcode() == Instruction::VAArg ||
+           I->getOpcode() == Instruction::GetResult ||
            (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=51023&r1=51022&r2=51023&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Tue May 13 02:09:08 2008
@@ -2761,20 +2761,14 @@
 /// GetResultInst - This instruction extracts individual result value from
 /// aggregate value, where aggregate value is returned by CallInst.
 ///
-class GetResultInst : public /*FIXME: Unary*/Instruction {
-  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
+class GetResultInst : public UnaryInstruction {
   unsigned Idx;
   GetResultInst(const GetResultInst &GRI) :
-    Instruction(GRI.getType(), Instruction::GetResult, &Op<0>(), 1) {
-    Op<0>().init(GRI.Op<0>(), this);
-    Idx = GRI.Idx;
+    UnaryInstruction(GRI.getType(), Instruction::GetResult, GRI.getOperand(0)),
+    Idx(GRI.Idx) {
   }
 
 public:
-  // allocate space for exactly one operand
-  void *operator new(size_t s) {
-    return User::operator new(s, 1);
-  }
   GetResultInst(Value *Aggr, unsigned index,
                 const std::string &Name = "",
                 Instruction *InsertBefore = 0);
@@ -2797,9 +2791,6 @@
     return Idx;
   }
 
-  /// Provide fast operand accessors
-  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
-
   // 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) {
@@ -2810,14 +2801,6 @@
   }
 };
 
-// FIXME: these are redundant if GetResultInst < UnaryInstruction
-template <>
-struct OperandTraits<GetResultInst> : FixedNumOperandTraits<1> {
-};
-
-DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetResultInst, Value)
-
-
 } // End llvm namespace
 
 #endif

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

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Tue May 13 02:09:08 2008
@@ -2734,14 +2734,12 @@
 GetResultInst::GetResultInst(Value *Aggregate, unsigned Index,
                              const std::string &Name,
                              Instruction *InsertBef)
-  : Instruction(cast<StructType>(Aggregate->getType())->getElementType(Index),
-                GetResult,
-                OperandTraits<GetResultInst>::op_begin(this),
-                OperandTraits<GetResultInst>::operands(this),
-                InsertBef) {
-  assert(isValidOperands(Aggregate, Index) && "Invalid GetResultInst operands!");
-  Op<0>().init(Aggregate, this);
-  Idx = Index;
+  : UnaryInstruction(cast<StructType>(Aggregate->getType())
+                       ->getElementType(Index),
+                     GetResult, Aggregate, InsertBef),
+    Idx(Index) {
+  assert(isValidOperands(Aggregate, Index)
+         && "Invalid GetResultInst operands!");
   setName(Name);
 }
 





More information about the llvm-commits mailing list