*** empty log message ***
[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/Function.h"
10 #include "llvm/SymbolTable.h"
11
12 Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name) 
13   : User(ty, Value::InstructionVal, Name) {
14   Parent = 0;
15   iType = it;
16 }
17
18 // Specialize setName to take care of symbol table majik
19 void Instruction::setName(const std::string &name, SymbolTable *ST) {
20   BasicBlock *P = 0; Function *PP = 0;
21   assert((ST == 0 || !getParent() || !getParent()->getParent() || 
22           ST == getParent()->getParent()->getSymbolTable()) &&
23          "Invalid symtab argument!");
24   if ((P = getParent()) && (PP = P->getParent()) && hasName())
25     PP->getSymbolTable()->remove(this);
26   Value::setName(name);
27   if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
28 }