Remove extraneous #includes
[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/Method.h"
9 #include "llvm/SymbolTable.h"
10 #include "llvm/CodeGen/MachineInstr.h"
11
12 Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name) 
13   : User(ty, Value::InstructionVal, Name), 
14     machineInstrVec(new MachineCodeForVMInstr) {
15   Parent = 0;
16   iType = it;
17 }
18
19 Instruction::~Instruction() {
20   assert(getParent() == 0 && "Instruction still embedded in basic block!");
21   delete machineInstrVec;
22 }
23
24 // Specialize setName to take care of symbol table majik
25 void Instruction::setName(const std::string &name, SymbolTable *ST) {
26   BasicBlock *P = 0; Method *PP = 0;
27   assert((ST == 0 || !getParent() || !getParent()->getParent() || 
28           ST == getParent()->getParent()->getSymbolTable()) &&
29          "Invalid symtab argument!");
30   if ((P = getParent()) && (PP = P->getParent()) && hasName())
31     PP->getSymbolTable()->remove(this);
32   Value::setName(name);
33   if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
34 }
35
36 void Instruction::addMachineInstruction(MachineInstr* minstr) {
37   machineInstrVec->push_back(minstr);
38 }
39
40 #if 0
41 // Dont make this inline because you would need to include
42 // MachineInstr.h in Instruction.h, which creates a circular
43 // sequence of forward declarations.  Trying to fix that will
44 // cause a serious circularity in link order.
45 // 
46 const std::vector<Value*> &Instruction::getTempValuesForMachineCode() const {
47   return machineInstrVec->getTempValues();
48 }
49 #endif
50
51 void Instruction::dropAllReferences() {
52   machineInstrVec->dropAllReferences();
53   User::dropAllReferences();
54 }