blob: 9cb493aa21e3a1d0ae05a12bba31788c223b8d34 [file] [log] [blame]
Chris Lattner2f7c9632001-06-06 20:29:01 +00001//===-- 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"
Chris Lattner60a65912002-02-12 21:07:25 +00008#include "llvm/BasicBlock.h"
Chris Lattner62b7fd12002-04-07 20:49:59 +00009#include "llvm/Function.h"
Chris Lattner2f7c9632001-06-06 20:29:01 +000010#include "llvm/SymbolTable.h"
Chris Lattner2f7c9632001-06-06 20:29:01 +000011
Chris Lattner7f74a562002-01-20 22:54:45 +000012Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name)
Chris Lattner4b361372002-02-03 07:52:58 +000013 : User(ty, Value::InstructionVal, Name) {
Chris Lattner2f7c9632001-06-06 20:29:01 +000014 Parent = 0;
15 iType = it;
16}
17
Chris Lattner2f7c9632001-06-06 20:29:01 +000018// Specialize setName to take care of symbol table majik
Chris Lattner7f74a562002-01-20 22:54:45 +000019void Instruction::setName(const std::string &name, SymbolTable *ST) {
Chris Lattner62b7fd12002-04-07 20:49:59 +000020 BasicBlock *P = 0; Function *PP = 0;
Chris Lattnere8dd6ad2001-09-07 16:47:03 +000021 assert((ST == 0 || !getParent() || !getParent()->getParent() ||
22 ST == getParent()->getParent()->getSymbolTable()) &&
23 "Invalid symtab argument!");
Chris Lattner2f7c9632001-06-06 20:29:01 +000024 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}