Add some useful accessors
authorChris Lattner <sabre@nondot.org>
Thu, 1 Nov 2001 02:39:36 +0000 (02:39 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 1 Nov 2001 02:39:36 +0000 (02:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1069 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/iMemory.h
include/llvm/iOther.h

index 9e7267d69e51530b40a4e99e93128c37c1dfc54f..5ce03ef73656e2a37ee3d5d5a49bd38552617d23 100644 (file)
@@ -41,11 +41,29 @@ public:
     }
   }
 
+  // isArrayAllocation - Return true if there is an allocation size parameter
+  // to the allocation instruction.
+  //
+  inline bool isArrayAllocation() const { return Operands.size() == 1; }
+
+  inline const Value *getArraySize() const {
+    assert(isArrayAllocation()); return Operands[0];
+  }
+  inline Value *getArraySize() {
+    assert(isArrayAllocation()); return Operands[0];
+  }
+
   // getType - Overload to return most specific pointer type...
   inline const PointerType *getType() const {
     return (const PointerType*)Instruction::getType(); 
   }
 
+  // getAllocatedType - Return the type that is being allocated by the
+  // instruction.
+  inline const Type *getAllocatedType() const {
+    return getType()->getValueType();
+  }
+
   virtual Instruction *clone() const = 0;
 };
 
index 52d75629e7cb92a220cadd8894f7cbac185feeae..a566566377adcb645984ab4eed1b2e1fee789d20 100644 (file)
@@ -188,6 +188,8 @@ public:
     Operands.push_back(Use(SA, this));
   }
 
+  OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
+
   virtual Instruction *clone() const { return new ShiftInst(*this); }
   virtual const char *getOpcodeName() const {
     return getOpcode() == Shl ? "shl" : "shr";