OpenASIP
2.0
|
#include <POMDisassembler.hh>
Public Member Functions | |
POMDisassembler (bool indices=false) | |
POMDisassembler (const TTAProgram::Program &program, bool indices=false) | |
virtual | ~POMDisassembler () |
virtual DisassemblyInstruction * | createInstruction (Word instructionIndex) const |
virtual Word | startAddress () const |
virtual Word | instructionCount () const |
int | labelCount (Word address) const |
std::string | label (Word address, int index) const |
virtual TCEString | disassembleInstruction (const TTAProgram::Instruction &instruction, int addr=-1) |
"Template methods" that can be overridden in the derived assemblers. More... | |
virtual TCEString | disassembleProcedure (const TTAProgram::Procedure &proc) |
virtual TCEString | disassembleProcedures () |
virtual TCEString | disassembleProgram () |
virtual TCEString | codeSectionDescription (Word startAddress) |
virtual TCEString | dataSectionDescription (const TTAMachine::AddressSpace &aSpace, Word location) |
virtual TCEString | procedureDescription (const TTAProgram::Procedure &proc) |
virtual TCEString | destinationLabels (const TTAProgram::Procedure &proc, int instrIndex) const |
virtual TCEString | labelPositionDescription (TCEString labelStr) const |
virtual TCEString | dataDefDescription (const TTAProgram::DataDefinition &def) |
virtual size_t | instructionSize (const TTAProgram::Instruction &) |
Returns the size of the instruction in memory addresses, if known. Falls back to address per instruction. More... | |
virtual void | setPrintAddresses (bool addresses) |
virtual TCEString | printAddress (const TTAProgram::Instruction &instr) const |
Static Public Member Functions | |
static POMDisassembler * | disassembler (const TTAMachine::Machine &mach, const TTAProgram::Program &program) |
static std::string | disassemble (const TTAProgram::Move &move) |
static std::string | disassemble (const TTAProgram::Instruction &instruction, bool indices=false, int addr=-1) |
static std::string | disassemble (const TTAProgram::Procedure &proc, bool indices=false) |
static std::string | disassemble (const TTAProgram::Program &program, bool indices=false) |
static TCEString | disassembleFully (const TTAProgram::Program &program, bool indices=false) |
static DisassemblyImmediate * | createInlineImmediate (const TTAProgram::Terminal &terminal, bool signExtend) |
Protected Attributes | |
const TTAProgram::Program & | program_ |
Program object model to disassemble. More... | |
bool | printAddresses_ |
True if instruction indices (addresses) should be printed at the end of lines. More... | |
Static Private Member Functions | |
static int | labelCount (const TTAProgram::Program &program, Word address) |
static std::string | label (const TTAProgram::Program &, Word address, int index) |
static DisassemblyInstruction * | createInstruction (const TTAProgram::Program &program, const TTAProgram::Instruction &instruction) |
static DisassemblyMove * | createMove (const TTAProgram::Move &move) |
static DisassemblyImmediateAssignment * | createImmediateAssignment (const TTAProgram::Immediate &immediate) |
static DisassemblyGuard * | createGuard (const TTAProgram::MoveGuard &guard) |
static DisassemblyElement * | createTerminal (const TTAProgram::Terminal &terminal) |
static DisassemblyElement * | createFUPort (const TTAProgram::Terminal &terminal) |
static DisassemblyElement * | createRegister (const TTAProgram::Terminal &terminal) |
static DisassemblyImmediateRegister * | createImmediateRegister (const TTAProgram::Terminal &terminal) |
static bool | isCallOrJump (const TTAProgram::Terminal &terminal) |
Program object model disassembler.
Definition at line 70 of file POMDisassembler.hh.
|
explicit |
A constructor for disassembling pieces of a program which might not be attached to a Program object.
printAddresses | True in case instruction addresses should be printed at the end of instruction lines as comments. |
Definition at line 115 of file POMDisassembler.cc.
Referenced by disassembler().
|
explicit |
A constructor for disassembling whole programs.
program | Program to disassemble. |
printAddresses | True in case instruction addresses should be printed at the end of instruction lines as comments. |
Definition at line 104 of file POMDisassembler.cc.
|
virtual |
|
virtual |
Definition at line 917 of file POMDisassembler.cc.
References startAddress().
Referenced by disassembleProgram().
|
staticprivate |
Creates disassembly of a function unit port.
terminal | Function unit terminal to disassemble. |
Definition at line 320 of file POMDisassembler.cc.
References __func__, TTAProgram::Terminal::functionUnit(), TTAProgram::TerminalFUPort::hintOperation(), TTAProgram::TerminalFUPort::hwOperation(), NullOperation::instance(), TTAMachine::HWOperation::io(), TTAProgram::TerminalFUPort::isOpcodeSetting(), TTAMachine::Machine::isUniversalMachine(), TTAMachine::Component::machine(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), TTAMachine::Component::name(), Operation::name(), TTAProgram::TerminalFUPort::operation(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationPort(), TTAProgram::TerminalFUPort::port(), and TTAProgram::Terminal::port().
Referenced by createTerminal().
|
staticprivate |
Creates disassembly of a move guard.
guard | Move guard to disassemble. |
Definition at line 434 of file POMDisassembler.cc.
References assert, TTAProgram::MoveGuard::guard(), TTAProgram::MoveGuard::isInverted(), TTAProgram::MoveGuard::isUnconditional(), machine, TTAMachine::Component::machine(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::PortGuard::port(), TTAMachine::RegisterGuard::registerFile(), and TTAMachine::RegisterGuard::registerIndex().
Referenced by createMove().
|
staticprivate |
Creates disassembly of an immediate assignment.
Definition at line 246 of file POMDisassembler.cc.
References createTerminal(), TTAProgram::Immediate::destination(), TTAProgram::Terminal::immediateUnit(), TTAMachine::ImmediateUnit::signExtends(), TTAProgram::TerminalImmediate::value(), and TTAProgram::Immediate::value().
Referenced by createInstruction(), and disassemble().
|
staticprivate |
Creates disassembly of an immediate register.
terminal | Immediate register to disassemble. |
Definition at line 420 of file POMDisassembler.cc.
References TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), and TTAMachine::Component::name().
Referenced by createTerminal().
|
static |
Creates disassembly of an immediate value.
terminal | Immediate value to disassemble. |
signExtend | If the immediate should be considered signed or unsigned. |
Definition at line 296 of file POMDisassembler.cc.
References NullSimValue::instance(), and TTAProgram::Terminal::value().
Referenced by createMove(), TTAProgram::TerminalImmediate::toString(), and TTAProgram::TerminalLaneIDImmediate::toString().
|
staticprivate |
Returns disassembly of an instruction at the given index.
The client is responsible for destroying the instruction object.
program | Parent program of the instruction. |
index | Index of the instruction to disassemble. |
Definition at line 155 of file POMDisassembler.cc.
References DisassemblyInstruction::addLongImmediate(), DisassemblyInstruction::addMove(), TTAProgram::Move::bus(), TTAMachine::Machine::Navigator< ComponentType >::count(), createImmediateAssignment(), createMove(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAMachine::Component::name(), and program.
|
virtual |
Returns disassembly of an instruction at the given index.
The client is responsible for destroying the instruction object.
index | Index of the instruction to disassemble. |
Definition at line 137 of file POMDisassembler.cc.
References TTAProgram::Program::instructionAt(), and program_.
Referenced by disassemble(), and DisassemblyGridTable::GetValue().
|
staticprivate |
Creates disassembly of a move.
move | Move to disassemble. |
Definition at line 200 of file POMDisassembler.cc.
References TTAProgram::Move::bus(), createGuard(), createInlineImmediate(), createTerminal(), TTAProgram::Move::destination(), TTAProgram::Move::guard(), isCallOrJump(), TTAProgram::Terminal::isImmediate(), TTAProgram::Move::isInInstruction(), TTAProgram::Instruction::isInProcedure(), TTAProgram::CodeSnippet::isInProgram(), TTAProgram::Move::isUnconditional(), label(), labelCount(), TTAProgram::Move::parent(), TTAProgram::CodeSnippet::parent(), TTAProgram::Instruction::parent(), TTAMachine::Bus::signExtends(), TTAProgram::Move::source(), SimValue::uLongWordValue(), and TTAProgram::Terminal::value().
Referenced by createInstruction(), and disassemble().
|
staticprivate |
Creates disassembly of a register.
terminal | Register to disassemble. |
WrongSubclass | The terminal was not register. |
Definition at line 370 of file POMDisassembler.cc.
References __func__, TTAProgram::Terminal::index(), machine, TTAMachine::Component::machine(), TTAMachine::Component::name(), and TTAProgram::Terminal::registerFile().
Referenced by createTerminal().
|
staticprivate |
Creates disassembly of a move terminal.
Determines the terminal type, an uses appropriate function to create disassembly of the terminal.
terminal | Move terminal to disassemble. |
WrongSubclass | The terminal type was unknown. |
Definition at line 265 of file POMDisassembler.cc.
References __func__, assert, createFUPort(), createImmediateRegister(), createRegister(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediate(), and TTAProgram::Terminal::isImmediateRegister().
Referenced by createImmediateAssignment(), and createMove().
|
virtual |
Definition at line 933 of file POMDisassembler.cc.
References TTAProgram::DataDefinition::isInitialized(), TTAProgram::DataDefinition::MAU(), and TTAProgram::DataDefinition::size().
Referenced by disassembleProgram().
|
virtual |
Definition at line 924 of file POMDisassembler.cc.
References TTAMachine::Component::name().
Referenced by disassembleProgram().
|
virtual |
Definition at line 840 of file POMDisassembler.cc.
References label(), labelCount(), labelPositionDescription(), TTAProgram::Address::location(), TTAProgram::CodeSnippet::parent(), and TTAProgram::CodeSnippet::startAddress().
Referenced by disassembleProcedure().
|
static |
Static helper function to create disassembly string from an instruction.
instruction | Instruction to disassemble. |
printAddresses | Print the instruction's index as comment. |
Definition at line 688 of file POMDisassembler.cc.
References DisassemblyInstruction::addLongImmediate(), DisassemblyInstruction::addMove(), TTAProgram::Instruction::address(), TTAProgram::Move::bus(), createImmediateAssignment(), createInstruction(), createMove(), disassemble(), TTAProgram::Move::hasSourceFileName(), TTAProgram::Move::hasSourceLineNumber(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Instruction::instructionTemplate(), TTAProgram::Instruction::isInProcedure(), TTAProgram::CodeSnippet::isInProgram(), TTAProgram::Address::location(), TTAMachine::Component::machine(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAMachine::Component::name(), TTAProgram::CodeSnippet::parent(), TTAProgram::Instruction::parent(), program, TTAProgram::Move::sourceFileName(), TTAProgram::Move::sourceLineNumber(), Conversion::toString(), DisassemblyInstruction::toString(), and TTAMachine::InstructionTemplate::usesSlot().
|
static |
Static helper function to create disassembly string from a move.
move | Move to disassemble. |
Definition at line 629 of file POMDisassembler.cc.
References createMove(), TTAProgram::Move::destination(), TTAProgram::Terminal::functionUnit(), TTAProgram::InstructionReference::instruction(), TTAProgram::Terminal::instructionReference(), TTAProgram::Move::isCall(), TTAProgram::Terminal::isCodeSymbolReference(), TTAProgram::Terminal::isInstructionAddress(), TTAProgram::Move::isJump(), TTAProgram::Procedure::name(), TTAMachine::Component::name(), TTAProgram::Instruction::parent(), TTAProgram::Move::source(), DisassemblyMove::toString(), and TTAProgram::Terminal::toString().
Referenced by TTAProgram::CodeSnippet::add(), TTAProgram::Instruction::address(), SimpleBrokerDirector::assign(), SimProgramBuilder::build(), SimulatorFrontend::compareState(), TTAProgram::ProgramWriter::createCodeSection(), ControlFlowGraph::createControlFlowEdge(), ControlFlowGraph::directJump(), ProgramDependenceGraph::disassemble(), disassemble(), disassembleInstruction(), TTAProgram::CodeSnippet::disassembly(), llvm::LLVMTCEBuilder::doFinalization(), ControlFlowGraph::findNextIndex(), main(), CriticalPathBBMoveNodeSelector::mightBeReady(), DataDependenceGraph::nodeOfMove(), SimProgramBuilder::processInstruction(), DataDependenceGraphBuilder::processTriggerPO(), BFUnscheduleFromBody::returnOriginal(), BFUnscheduleMove::returnOriginal(), BFShareOperandLate::revert(), BFOptimization::rmLC(), TTAProgram::Move::toString(), TTAProgram::Instruction::toString(), MoveNode::toString(), and TTAProgram::Program::toString().
|
static |
Static helper function to create a disassembly string from a procedure.
proc | Procedure to disassemble. |
printAddresses | Print the instruction addresses as comment. |
Exception | Can leak exceptions if the traversed program is malformed, etc. |
Definition at line 1011 of file POMDisassembler.cc.
References disassembleProcedure().
|
static |
Static helper function to create a disassembly string from a program.
program | Program to disassemble. |
printAddresses | Print the instruction addresses as comment. |
Exception | Can leak exceptions if the traversed program is malformed, etc. |
Definition at line 826 of file POMDisassembler.cc.
References disassembleProcedures(), and program.
|
static |
Static helper function to create a disassembly string from a whole program including section markers and data memory initializations.
program | Program to disassemble. |
printAddresses | If the instruction addresses should be printed. |
Exception | Can leak exceptions if the traversed program is malformed, etc. |
Definition at line 910 of file POMDisassembler.cc.
References disassembleProgram(), and program.
|
virtual |
"Template methods" that can be overridden in the derived assemblers.
Definition at line 675 of file POMDisassembler.cc.
References disassemble(), and printAddresses_.
Referenced by SimulatorFrontend::disassembleInstruction(), disassembleProcedure(), and SimulatorFrontend::programLocationDescription().
|
virtual |
Definition at line 861 of file POMDisassembler.cc.
References destinationLabels(), disassembleInstruction(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Address::location(), procedureDescription(), TTAProgram::Instruction::size(), and TTAProgram::CodeSnippet::startAddress().
Referenced by disassemble(), and disassembleProcedures().
|
virtual |
Definition at line 886 of file POMDisassembler.cc.
References disassembleProcedure(), TTAProgram::Program::procedureAtIndex(), TTAProgram::Program::procedureCount(), and program_.
Referenced by disassemble(), and disassembleProgram().
|
virtual |
Create a disassembly string from the whole program including module headers, section markers and data memory initializations.
Exception | Can leak exceptions if the traversed program is malformed, etc. |
Definition at line 956 of file POMDisassembler.cc.
References TTAProgram::DataMemory::addressSpace(), codeSectionDescription(), dataDefDescription(), TTAProgram::DataMemory::dataDefinition(), TTAProgram::DataMemory::dataDefinitionCount(), TTAProgram::Program::dataMemory(), TTAProgram::Program::dataMemoryCount(), dataSectionDescription(), disassembleProcedures(), TTAProgram::Address::location(), program_, TTAProgram::DataDefinition::startAddress(), and startAddress().
Referenced by disassembleFully().
|
static |
A factor for building a correct type of disassembler for the target.
Definition at line 1022 of file POMDisassembler.cc.
References POMDisassembler(), and program.
Referenced by TTAProgram::Program::finalize(), and SimulatorFrontend::initializeDisassembler().
|
virtual |
Returns number of instructions in the program.
Definition at line 495 of file POMDisassembler.cc.
References TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Program::procedure(), TTAProgram::Program::procedureCount(), and program_.
|
inlinevirtual |
Returns the size of the instruction in memory addresses, if known. Falls back to address per instruction.
Definition at line 119 of file POMDisassembler.hh.
Referenced by TTAProgram::Program::finalize().
|
staticprivate |
Checks if the terminal is a control unit jump or call operand.
terminal | Terminal to check. |
Definition at line 595 of file POMDisassembler.cc.
References TTAProgram::Terminal::functionUnit(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isOpcodeSetting(), Operation::name(), TTAProgram::Terminal::operation(), and StringTools::stringToLower().
Referenced by createMove().
|
staticprivate |
Returns instruction label with the given index.
address | Instruction address. |
program | Program to search label for. |
OutOfRange | The address or index is out of range. |
Definition at line 563 of file POMDisassembler.cc.
References __func__, label(), labelCount(), program, and Conversion::toString().
std::string POMDisassembler::label | ( | Word | address, |
int | index | ||
) | const |
Returns instruction label with the given index.
address | Instruction address. |
OutOfRange | The address or index is out of range. |
Definition at line 550 of file POMDisassembler.cc.
References program_.
Referenced by createMove(), destinationLabels(), and label().
|
staticprivate |
Returns number of labels at the given address.
address | Instruction address. |
Definition at line 523 of file POMDisassembler.cc.
References TTAProgram::GlobalScope::globalCodeLabelCount(), labelCount(), and program.
int POMDisassembler::labelCount | ( | Word | address | ) | const |
Returns number of labels at the given address.
address | Instruction address. |
Definition at line 512 of file POMDisassembler.cc.
References program_.
Referenced by createMove(), destinationLabels(), label(), and labelCount().
Definition at line 856 of file POMDisassembler.cc.
Referenced by destinationLabels().
|
virtual |
Definition at line 1030 of file POMDisassembler.cc.
References TTAProgram::Instruction::address(), and TTAProgram::Address::location().
|
virtual |
Definition at line 833 of file POMDisassembler.cc.
References TTAProgram::Procedure::name().
Referenced by disassembleProcedure().
|
inlinevirtual |
|
virtual |
Returns start address of the program.
Definition at line 483 of file POMDisassembler.cc.
References TTAProgram::Address::location(), program_, and TTAProgram::Program::startAddress().
Referenced by codeSectionDescription(), disassembleProgram(), and main().
|
protected |
True if instruction indices (addresses) should be printed at the end of lines.
Definition at line 134 of file POMDisassembler.hh.
Referenced by disassembleInstruction(), and setPrintAddresses().
|
protected |
Program object model to disassemble.
Definition at line 132 of file POMDisassembler.hh.
Referenced by createInstruction(), disassembleProcedures(), disassembleProgram(), instructionCount(), label(), labelCount(), and startAddress().