Add capability to insert an instruction into a basic block immediately after
it is created, as part of the ctor call.
Eliminate the GenericBinaryInst class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3653 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 4368b7e..2084e69 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -9,13 +9,21 @@
#include "llvm/Type.h"
#include "Support/LeakDetector.h"
-Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name)
+Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
+ Instruction *InsertBefore)
: User(ty, Value::InstructionVal, Name) {
Parent = 0;
iType = it;
// Make sure that we get added to a basicblock
LeakDetector::addGarbageObject(this);
+
+ // If requested, insert this instruction into a basic block...
+ if (InsertBefore) {
+ assert(InsertBefore->getParent() &&
+ "Instruction to insert before is not in a basic block!");
+ InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
+ }
}
void Instruction::setParent(BasicBlock *P) {