1 //===-- Instruction.cpp - Implement the Instruction class --------*- C++ -*--=//
3 // This file implements the Instruction class for the VMCore library.
5 //===----------------------------------------------------------------------===//
7 #include "llvm/Instruction.h"
8 #include "llvm/BasicBlock.h"
9 #include "llvm/Method.h"
10 #include "llvm/SymbolTable.h"
11 #include "llvm/Codegen/MachineInstr.h"
13 Instruction::Instruction(const Type *ty, unsigned it, const string &Name)
14 : User(ty, Value::InstructionVal, Name),
15 machineInstrVec(new MachineCodeForVMInstr)
21 Instruction::~Instruction() {
22 assert(getParent() == 0 && "Instruction still embedded in basic block!");
23 delete machineInstrVec;
26 // Specialize setName to take care of symbol table majik
27 void Instruction::setName(const string &name) {
28 BasicBlock *P = 0; Method *PP = 0;
29 if ((P = getParent()) && (PP = P->getParent()) && hasName())
30 PP->getSymbolTable()->remove(this);
32 if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
36 Instruction::addMachineInstruction(MachineInstr* minstr)
38 machineInstrVec->push_back(minstr);
42 // Dont make this inline because you would need to include
43 // MachineInstr.h in Instruction.h, which creates a circular
44 // sequence of forward declarations. Trying to fix that will
45 // cause a serious circularity in link order.
48 Instruction::getTempValuesForMachineCode() const
50 return machineInstrVec->getTempValues();
55 Instruction::dropAllReferences() {
56 machineInstrVec->dropAllReferences();
57 User::dropAllReferences();