diff options
Diffstat (limited to 'lib/VMCore/iMemory.cpp')
-rw-r--r-- | lib/VMCore/iMemory.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp index da4cc7483f..2b731b45c5 100644 --- a/lib/VMCore/iMemory.cpp +++ b/lib/VMCore/iMemory.cpp @@ -67,16 +67,14 @@ FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore) LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) : Instruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Name, InsertBef), Volatile(false) { - Operands.reserve(1); - Operands.push_back(Use(Ptr, this)); + init(Ptr); } LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, Instruction *InsertBef) : Instruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Name, InsertBef), Volatile(isVolatile) { - Operands.reserve(1); - Operands.push_back(Use(Ptr, this)); + init(Ptr); } //===----------------------------------------------------------------------===// @@ -85,19 +83,13 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, StoreInst::StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore) : Instruction(Type::VoidTy, Store, "", InsertBefore), Volatile(false) { - - Operands.reserve(2); - Operands.push_back(Use(Val, this)); - Operands.push_back(Use(Ptr, this)); + init(Val, Ptr); } StoreInst::StoreInst(Value *Val, Value *Ptr, bool isVolatile, Instruction *InsertBefore) : Instruction(Type::VoidTy, Store, "", InsertBefore), Volatile(isVolatile) { - - Operands.reserve(2); - Operands.push_back(Use(Val, this)); - Operands.push_back(Use(Ptr, this)); + init(Val, Ptr); } @@ -113,11 +105,8 @@ static inline const Type *checkType(const Type *Ty) { return Ty; } -GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx, - const std::string &Name, Instruction *InBe) - : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), - Idx, true))), - GetElementPtr, Name, InBe) { +void GetElementPtrInst::init(Value *Ptr, const std::vector<Value*> &Idx) +{ Operands.reserve(1+Idx.size()); Operands.push_back(Use(Ptr, this)); @@ -125,6 +114,14 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx, Operands.push_back(Use(Idx[i], this)); } +GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx, + const std::string &Name, Instruction *InBe) + : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), + Idx, true))), + GetElementPtr, Name, InBe) { + init(Ptr, Idx); +} + // getIndexedType - Returns the type of the element that would be loaded with // a load instruction with the specified parameters. // |