diff options
author | Chris Lattner <sabre@nondot.org> | 2002-03-21 22:37:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-03-21 22:37:01 +0000 |
commit | 05c0e9e562de11be51938ac3124330177ccc00ff (patch) | |
tree | 399ab182094618843a791b47f85bf185283b721c /include/llvm/iMemory.h | |
parent | 2e5c295100969bc85da753a36ea27a5ef6a1f3e3 (diff) | |
download | llvm-05c0e9e562de11be51938ac3124330177ccc00ff.tar.gz llvm-05c0e9e562de11be51938ac3124330177ccc00ff.tar.bz2 llvm-05c0e9e562de11be51938ac3124330177ccc00ff.tar.xz |
* Make AllocationInst ctor protected
* Move AllocationInst ctor to iMemory.cpp
* AllocationInst's always have one operand, even if it is a uint 1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/iMemory.h')
-rw-r--r-- | include/llvm/iMemory.h | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h index 7d919196de..35bce8ea3c 100644 --- a/include/llvm/iMemory.h +++ b/include/llvm/iMemory.h @@ -19,32 +19,21 @@ // AllocaInst. // class AllocationInst : public Instruction { -public: +protected: 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!"); - - if (ArraySize) { - assert(ArraySize->getType() == Type::UIntTy && - "Malloc/Allocation array size != UIntTy!"); - - Operands.reserve(1); - Operands.push_back(Use(ArraySize, this)); - } - } + const std::string &Name = ""); +public: // isArrayAllocation - Return true if there is an allocation size parameter // to the allocation instruction that is not 1. // bool isArrayAllocation() const; - inline const Value *getArraySize() const { - assert(isArrayAllocation()); return Operands[0]; - } - inline Value *getArraySize() { - assert(isArrayAllocation()); return Operands[0]; - } + // getArraySize - Get the number of element allocated, for a simple allocation + // of a single element, this will return a constant 1 value. + // + inline const Value *getArraySize() const { return Operands[0]; } + inline Value *getArraySize() { return Operands[0]; } // getType - Overload to return most specific pointer type... inline const PointerType *getType() const { @@ -81,8 +70,7 @@ public: : AllocationInst(Ty, ArraySize, Malloc, Name) {} virtual Instruction *clone() const { - return new MallocInst(getType(), - Operands.size() ? (Value*)Operands[0].get() : 0); + return new MallocInst(getType(), (Value*)Operands[0].get()); } virtual const char *getOpcodeName() const { return "malloc"; } @@ -108,8 +96,7 @@ public: : AllocationInst(Ty, ArraySize, Alloca, Name) {} virtual Instruction *clone() const { - return new AllocaInst(getType(), - Operands.size() ? (Value*)Operands[0].get() : 0); + return new AllocaInst(getType(), (Value*)Operands[0].get()); } virtual const char *getOpcodeName() const { return "alloca"; } |