2001-06-07 04:29:01 +08: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-22 04:58:30 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2001-06-07 04:29:01 +08:00
|
|
|
|
|
|
|
Instruction::Instruction(const Type *ty, unsigned it, const string &Name)
|
2001-07-22 04:09:07 +08:00
|
|
|
: User(ty, Value::InstructionVal, Name),
|
|
|
|
machineInstrVec(new MachineCodeForVMInstr) {
|
2001-06-07 04:29:01 +08:00
|
|
|
Parent = 0;
|
|
|
|
iType = it;
|
|
|
|
}
|
|
|
|
|
|
|
|
Instruction::~Instruction() {
|
2001-07-21 05:05:02 +08:00
|
|
|
assert(getParent() == 0 && "Instruction still embedded in basic block!");
|
|
|
|
delete machineInstrVec;
|
2001-06-07 04:29:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Specialize setName to take care of symbol table majik
|
2001-09-08 00:47:03 +08:00
|
|
|
void Instruction::setName(const string &name, SymbolTable *ST) {
|
2001-06-07 04:29:01 +08:00
|
|
|
BasicBlock *P = 0; Method *PP = 0;
|
2001-09-08 00:47:03 +08:00
|
|
|
assert((ST == 0 || !getParent() || !getParent()->getParent() ||
|
|
|
|
ST == getParent()->getParent()->getSymbolTable()) &&
|
|
|
|
"Invalid symtab argument!");
|
2001-06-07 04:29:01 +08:00
|
|
|
if ((P = getParent()) && (PP = P->getParent()) && hasName())
|
|
|
|
PP->getSymbolTable()->remove(this);
|
|
|
|
Value::setName(name);
|
|
|
|
if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
|
|
|
|
}
|
2001-07-21 05:05:02 +08:00
|
|
|
|
2001-07-22 04:09:07 +08:00
|
|
|
void Instruction::addMachineInstruction(MachineInstr* minstr) {
|
2001-07-21 05:05:02 +08:00
|
|
|
machineInstrVec->push_back(minstr);
|
|
|
|
}
|
|
|
|
|
2001-07-22 04:04:10 +08:00
|
|
|
#if 0
|
2001-07-21 05:05:02 +08: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-22 04:09:07 +08:00
|
|
|
const vector<Value*> &Instruction::getTempValuesForMachineCode() const {
|
2001-07-21 05:05:02 +08:00
|
|
|
return machineInstrVec->getTempValues();
|
|
|
|
}
|
2001-07-22 04:04:10 +08:00
|
|
|
#endif
|
2001-07-21 05:05:02 +08:00
|
|
|
|
2001-07-22 04:09:07 +08:00
|
|
|
void Instruction::dropAllReferences() {
|
2001-07-21 05:05:02 +08:00
|
|
|
machineInstrVec->dropAllReferences();
|
|
|
|
User::dropAllReferences();
|
|
|
|
}
|