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 | 9f0fdf748243844ae04aa3561b591edb2d9283e4 (patch) | |
tree | 8c3f95b238481a3fa6ca9d7c08cefdc4d464b60f /llvm/lib/VMCore/Instruction.cpp | |
parent | 9e84b503f0364b9b76fb40b89ddcdbad635a8847 (diff) | |
download | bcm5719-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/Instruction.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instruction.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp index 0de34b5bd54..5ddf2843540 100644 --- a/llvm/lib/VMCore/Instruction.cpp +++ b/llvm/lib/VMCore/Instruction.cpp @@ -17,14 +17,18 @@ #include "Support/LeakDetector.h" using namespace llvm; -Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, - Instruction *InsertBefore) - : User(ty, Value::InstructionVal, Name) { - Parent = 0; - iType = it; - +void Instruction::init() +{ // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); +} + +Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, + Instruction *InsertBefore) + : User(ty, Value::InstructionVal, Name), + Parent(0), + iType(it) { + init(); // If requested, insert this instruction into a basic block... if (InsertBefore) { @@ -34,6 +38,18 @@ Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, } } +Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, + BasicBlock *InsertAtEnd) + : User(ty, Value::InstructionVal, Name), + Parent(0), + iType(it) { + init(); + + // append this instruction into the basic block + assert(InsertAtEnd && "Basic block to append to may not be NULL!"); + InsertAtEnd->getInstList().push_back(this); +} + void Instruction::setParent(BasicBlock *P) { if (getParent()) { if (!P) LeakDetector::addGarbageObject(this); |