* AllocationInst ctor moved here from iMemory.h
authorChris Lattner <sabre@nondot.org>
Thu, 21 Mar 2002 22:37:48 +0000 (22:37 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 21 Mar 2002 22:37:48 +0000 (22:37 +0000)
* AllocationInst now always has an array size operand

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1939 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/iMemory.cpp

index 7280998a17daf80bbf563cd9de85544c4b8f94f0..cf80909d8b4bcefe1b4a6d07bde0a85d0374849e 100644 (file)
@@ -12,6 +12,21 @@ static inline const Type *checkType(const Type *Ty) {
   return Ty;
 }
 
+AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, 
+                               const std::string &Name = "")
+  : Instruction(Ty, iTy, Name) {
+  assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
+
+  // ArraySize defaults to 1.
+  if (!ArraySize) ArraySize = ConstantUInt::get(Type::UIntTy, 1);
+
+  Operands.reserve(1);
+  assert(ArraySize->getType() == Type::UIntTy &&
+         "Malloc/Allocation array size != UIntTy!");
+
+  Operands.push_back(Use(ArraySize, this));
+}
+
 bool AllocationInst::isArrayAllocation() const {
   return getNumOperands() == 1 &&
          getOperand(0) != ConstantUInt::get(Type::UIntTy, 1);