2001-06-06 20:29:01 +00:00
|
|
|
//===-- Instruction.cpp - Implement the Instruction class --------*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This file implements the Instruction class for the VMCore library.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Instruction.h"
|
|
|
|
#include "llvm/BasicBlock.h"
|
|
|
|
#include "llvm/Method.h"
|
|
|
|
#include "llvm/SymbolTable.h"
|
2001-07-21 20:58:30 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
Instruction::Instruction(const Type *ty, unsigned it, const string &Name)
|
2001-07-21 20:09:07 +00:00
|
|
|
: User(ty, Value::InstructionVal, Name),
|
|
|
|
machineInstrVec(new MachineCodeForVMInstr) {
|
2001-06-06 20:29:01 +00:00
|
|
|
Parent = 0;
|
|
|
|
iType = it;
|
|
|
|
}
|
|
|
|
|
|
|
|
Instruction::~Instruction() {
|
2001-07-20 21:05:02 +00:00
|
|
|
assert(getParent() == 0 && "Instruction still embedded in basic block!");
|
|
|
|
delete machineInstrVec;
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Specialize setName to take care of symbol table majik
|
|
|
|
void Instruction::setName(const string &name) {
|
|
|
|
BasicBlock *P = 0; Method *PP = 0;
|
|
|
|
if ((P = getParent()) && (PP = P->getParent()) && hasName())
|
|
|
|
PP->getSymbolTable()->remove(this);
|
|
|
|
Value::setName(name);
|
|
|
|
if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
|
|
|
|
}
|
2001-07-20 21:05:02 +00:00
|
|
|
|
2001-07-21 20:09:07 +00:00
|
|
|
void Instruction::addMachineInstruction(MachineInstr* minstr) {
|
2001-07-20 21:05:02 +00:00
|
|
|
machineInstrVec->push_back(minstr);
|
|
|
|
}
|
|
|
|
|
2001-07-21 20:04:10 +00:00
|
|
|
#if 0
|
2001-07-20 21:05:02 +00:00
|
|
|
// Dont make this inline because you would need to include
|
|
|
|
// MachineInstr.h in Instruction.h, which creates a circular
|
|
|
|
// sequence of forward declarations. Trying to fix that will
|
|
|
|
// cause a serious circularity in link order.
|
|
|
|
//
|
2001-07-21 20:09:07 +00:00
|
|
|
const vector<Value*> &Instruction::getTempValuesForMachineCode() const {
|
2001-07-20 21:05:02 +00:00
|
|
|
return machineInstrVec->getTempValues();
|
|
|
|
}
|
2001-07-21 20:04:10 +00:00
|
|
|
#endif
|
2001-07-20 21:05:02 +00:00
|
|
|
|
2001-07-21 20:09:07 +00:00
|
|
|
void Instruction::dropAllReferences() {
|
2001-07-20 21:05:02 +00:00
|
|
|
machineInstrVec->dropAllReferences();
|
|
|
|
User::dropAllReferences();
|
|
|
|
}
|