summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/iMemory.cpp
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-05-26 21:41:09 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-05-26 21:41:09 +0000
commit9f0fdf748243844ae04aa3561b591edb2d9283e4 (patch)
tree8c3f95b238481a3fa6ca9d7c08cefdc4d464b60f /llvm/lib/VMCore/iMemory.cpp
parent9e84b503f0364b9b76fb40b89ddcdbad635a8847 (diff)
downloadbcm5719-llvm-9f0fdf748243844ae04aa3561b591edb2d9283e4.tar.gz
bcm5719-llvm-9f0fdf748243844ae04aa3561b591edb2d9283e4.zip
Refactor common initialization code in private init() functions.
This is a first step in supplying append to basic block constructors for all instruction types. llvm-svn: 13793
Diffstat (limited to 'llvm/lib/VMCore/iMemory.cpp')
-rw-r--r--llvm/lib/VMCore/iMemory.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/llvm/lib/VMCore/iMemory.cpp b/llvm/lib/VMCore/iMemory.cpp
index da4cc7483f0..2b731b45c5a 100644
--- a/llvm/lib/VMCore/iMemory.cpp
+++ b/llvm/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.
//
OpenPOWER on IntegriCloud