diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-26 21:41:09 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-26 21:41:09 +0000 |
commit | e5828f1fa7c2691f747f5060ce11b8e55cea03ab (patch) | |
tree | b9334e44ca7630cc55600d097c560d02bc72b3e2 /lib/VMCore/iMemory.cpp | |
parent | 99c58f4910c898981f96f065065c3e47c94fec40 (diff) |
Refactor common initialization code in private init() functions.
This is a first step in supplying append to basic block constructors
for all instruction types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13793 91177308-0d34-0410-b5e6-96231b3b80d8
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. // |