diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h index 9e7267d69e5..5ce03ef7365 100644 --- a/include/llvm/iMemory.h +++ b/include/llvm/iMemory.h @@ -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; }; diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h index 52d75629e7c..a566566377a 100644 --- a/include/llvm/iOther.h +++ b/include/llvm/iOther.h @@ -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";