Remove getTempValuesForMachineCode from the Instruction interface
[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 #include "llvm/Codegen/MachineInstr.h"
12
13 Instruction::Instruction(const Type *ty, unsigned it, const string &Name) 
14   : User(ty, Value::InstructionVal, Name),
15     machineInstrVec(new MachineCodeForVMInstr)
16 {
17   Parent = 0;
18   iType = it;
19 }
20
21 Instruction::~Instruction() {
22   assert(getParent() == 0 && "Instruction still embedded in basic block!");
23   delete machineInstrVec;
24 }
25
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);
31   Value::setName(name);
32   if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
33 }
34
35 void
36 Instruction::addMachineInstruction(MachineInstr* minstr)
37 {
38   machineInstrVec->push_back(minstr);
39 }
40
41 #if 0
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.
46 // 
47 const vector<Value*>&
48 Instruction::getTempValuesForMachineCode() const
49 {
50   return machineInstrVec->getTempValues();
51 }
52 #endif
53
54 void
55 Instruction::dropAllReferences() {
56   machineInstrVec->dropAllReferences();
57   User::dropAllReferences();
58 }