Moved UnaryOperator::create to InstrTypes.cpp until there is an iUnaryOps.cpp
[oota-llvm.git] / lib / VMCore / Instruction.cpp
1 //===-- Instruction.cpp - Implement the Instruction class --------*- C++ -*--=//
2 //
3 // This file implements the Instruction class for the VMCore library.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "llvm/Instruction.h"
8 #include "llvm/BasicBlock.h"
9 #include "llvm/Method.h"
10 #include "llvm/SymbolTable.h"
11
12 Instruction::Instruction(const Type *ty, unsigned it, const string &Name) 
13   : User(ty, Value::InstructionVal, Name) {
14   Parent = 0;
15   iType = it;
16 }
17
18 Instruction::~Instruction() {
19   assert(getParent() == 0 && "Instruction still embeded in basic block!");
20 }
21
22 // Specialize setName to take care of symbol table majik
23 void Instruction::setName(const string &name) {
24   BasicBlock *P = 0; Method *PP = 0;
25   if ((P = getParent()) && (PP = P->getParent()) && hasName())
26     PP->getSymbolTable()->remove(this);
27   Value::setName(name);
28   if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
29 }