Go to the documentation of this file.
36 #include <boost/format.hpp>
105 program_(
program), printAddresses_(printAddresses) {
116 program_(
NullProgram::instance()), printAddresses_(printAddresses) {
161 program.targetProcessor().busNavigator();
164 for (
int i = 0; i < navigator.
count(); i++) {
167 string busName = bus->
name();
171 for (
int i = 0; i < instruction.
moveCount(); i++) {
172 if (&instruction.
move(i).
bus() == bus) {
219 std::string codelabel =
label(
234 disassembly =
new DisassemblyMove(sourceDis, destinationDis, guardDis);
268 "Should handle immediate as a special case due to depending on "
275 if (terminal.
isGPR()) {
285 "Unknown terminal type.");
297 const Terminal& terminal,
bool signExtend) {
300 if (!tpo->isAddressKnown())
305 terminal.
value(), signExtend);
336 int operand = hwOperation->
io(*port);
349 "Osal operation for operation code name '%s' was not found.")
375 "Not register terminal.");
383 if (rf == &
machine->booleanRegisterFile()) {
394 if (universalRF == &
machine->integerRegisterFile()) {
399 if (universalRF == &
machine->doubleRegisterFile()) {
407 "Unknown universal machine register type.");
422 unsigned int index = terminal.
index();
442 if (portGuard != NULL) {
444 string portName = portGuard->
port()->
name();
451 if (registerGuard != NULL) {
498 for (
unsigned i = 0; i < procedureCount; i++) {
533 for (
int i = 0; i <
program.procedureCount(); i++) {
534 if (
program.procedure(i).startAddress().location() == address) {
566 for (
int i = 0; i <
program.procedureCount(); i++) {
567 if (
program.procedure(i).startAddress().location() == address) {
568 return program.procedure(i).name();
575 __FILE__, __LINE__,
__func__,
"No label in requested index: " +
582 program.globalScopeConst().globalCodeLabel(iaddr, index);
603 if (
dynamic_cast<const ControlUnit*
>(fu) == NULL) {
611 string operationName =
614 if (operationName ==
"call" || operationName ==
"jump") {
637 std::string disasm =
"";
648 std::string procName =
649 proc != NULL ? proc->
name() :
"unknown_proc";
650 return (boost::format(
"%s -> %s.call.1")
656 return (boost::format(
"%s -> %s.call.1")
662 return (boost::format(
"%s -> %s.jump.1")
668 std::string disasm =
"";
691 std::string disasm =
"";
700 for (
int i = 0; i < instruction.
moveCount(); i++) {
702 const Move& move = instruction.
move(i);
703 const Bus* bus = &move.
bus();
704 string busName = move.
bus().
name();
710 &NullInstructionTemplate::instance() &&
719 for (
int i = 0; i < instruction.
moveCount(); i++) {
720 if (&instruction.
move(i).
bus() == bus) {
737 disasm = dInstruction->
toString() +
" # 'free instruction'";
761 for (
int i = 0; i < instruction.
moveCount(); ++i) {
766 disasm +=
"\t# unscheduled: ";
774 if (printAddresses) {
785 for (
int i = 0; i < instruction.
moveCount(); ++i) {
793 if (fileNameStr !=
"")
794 disasm +=
"\t# file: " + fileNameStr;
798 for (
int i = 0; i < instruction.
moveCount(); ++i) {
801 if (lineNumberStr !=
"") {
802 lineNumberStr +=
", ";
809 if (lineNumberStr !=
"")
810 disasm +=
"\t# slines: " + lineNumberStr;
835 output <<
":procedure " << proc.
name() <<
";";
843 std::stringstream stringStream;
846 for (
int labelIndex = 0; labelIndex < lc; ++labelIndex) {
849 proc.
parent(), addr, labelIndex))
852 return stringStream.str();
857 return labelStr +
":";
863 std::stringstream stringStream;
869 instrIndex < iCount; ++instrIndex) {
877 if (currentInstruction->
size() > 0) {
878 stringStream <<
"\t" <<
882 return stringStream.str();
888 std::stringstream stringStream;
895 return stringStream.str();
927 output <<
"DATA " << aSpace.
name() <<
" "
936 std::ostringstream output;
937 output <<
"DA " << std::dec << def.
size();
939 for (
int mau = 0; mau < def.
size(); mau++) {
940 output << endl <<
"1:0x" << std::hex << def.
MAU(mau);
943 output <<
" ;" << endl;
958 std::stringstream output;
980 std::map<Word, const TTAProgram::DataDefinition*> definitions;
986 std::map<Word, const TTAProgram::DataDefinition*>::iterator iter =
989 for (; iter != definitions.end(); iter++) {
bool printAddresses_
True if instruction indices (addresses) should be printed at the end of lines.
std::string sourceFileName() const
std::string label(Word address, int index) const
virtual bool isFUPort() const
Instruction & instruction() const
virtual TCEString procedureDescription(const TTAProgram::Procedure &proc)
UInt32 InstructionAddress
virtual TCEString name() const
virtual int index() const
virtual bool isInstructionAddress() const
int procedureCount() const
virtual Address startAddress() const
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static DisassemblyGuard * createGuard(const TTAProgram::MoveGuard &guard)
virtual Word startAddress() const
Address startAddress() const
int registerIndex() const
FunctionUnit * parentUnit() const
virtual const TTAMachine::RegisterFile & registerFile() const
std::string toString() const
virtual bool isUniversalMachine() const
bool isUnconditional() const
virtual TCEString disassembleProcedures()
int sourceLineNumber() const
static TCEString disassembleFully(const TTAProgram::Program &program, bool indices=false)
virtual std::string toString() const
const TTAMachine::AddressSpace & addressSpace() const
Terminal & destination() const
virtual TCEString printAddress(const TTAProgram::Instruction &instr) const
static DisassemblyElement * createTerminal(const TTAProgram::Terminal &terminal)
virtual Word instructionCount() const
static SimValue & instance()
int dataDefinitionCount() const
static POMDisassembler * disassembler(const TTAMachine::Machine &mach, const TTAProgram::Program &program)
const TTAMachine::Bus & bus() const
virtual Operation & operation() const
virtual Address startAddress() const
virtual TCEString destinationLabels(const TTAProgram::Procedure &proc, int instrIndex) const
static DisassemblyImmediate * createInlineImmediate(const TTAProgram::Terminal &terminal, bool signExtend)
static bool isCallOrJump(const TTAProgram::Terminal &terminal)
virtual const InstructionReference & instructionReference() const
static NullOperation & instance()
int globalCodeLabelCount(Address address) const
static DisassemblyMove * createMove(const TTAProgram::Move &move)
virtual TCEString name() const
POMDisassembler(bool indices=false)
static std::string toString(const T &source)
virtual Operation & operation() const
const Procedure & procedureAtIndex(int index) const
#define assert(condition)
Instruction & instructionAt(InstructionAddress address) const
virtual TCEString labelPositionDescription(TCEString labelStr) const
virtual Operation & hintOperation() const
virtual bool isImmediateRegister() const
virtual TCEString dataSectionDescription(const TTAMachine::AddressSpace &aSpace, Word location)
int io(const FUPort &port) const
const std::string & name() const
virtual int instructionCount() const
virtual TCEString dataDefDescription(const TTAProgram::DataDefinition &def)
DataMemory & dataMemory(int index) const
virtual bool isInitialized() const
MoveGuard & guard() const
CodeSnippet & parent() const
virtual TCEString disassembleProcedure(const TTAProgram::Procedure &proc)
ULongWord uLongWordValue() const
virtual bool isGPR() const
virtual SimValue value() const
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
virtual const TTAMachine::Port & port() const
InstructionAddress location() const
static DisassemblyImmediateAssignment * createImmediateAssignment(const TTAProgram::Immediate &immediate)
bool isInInstruction() const
virtual bool isOpcodeSetting() const
Immediate & immediate(int i) const
virtual bool isOpcodeSetting() const
int dataMemoryCount() const
const TTAProgram::Program & program_
Program object model to disassemble.
void addMove(DisassemblyInstructionSlot *move)
const TTAMachine::InstructionTemplate & instructionTemplate() const
virtual const TTAMachine::FunctionUnit & functionUnit() const
static DisassemblyElement * createFUPort(const TTAProgram::Terminal &terminal)
bool isInProcedure() const
static std::string disassemble(const TTAProgram::Move &move)
bool hasSourceLineNumber() const
Instruction & parent() const
virtual TCEString disassembleProgram()
virtual TCEString toString() const =0
virtual TCEString codeSectionDescription(Word startAddress)
virtual Machine * machine() const
virtual std::string name() const
virtual Program & parent() const
int immediateCount() const
virtual const TTAMachine::HWOperation * hwOperation() const
DataDefinition & dataDefinition(Address address) const
virtual Instruction & instructionAtIndex(int index) const
Terminal & source() const
virtual const TTAMachine::Port & port() const
ComponentType * item(int index) const
virtual HWOperation * operation(const std::string &name) const
find Finds info of the inner loops in the program
virtual bool isCodeSymbolReference() const
const TTAMachine::Guard & guard() const
virtual FUPort * operationPort(const std::string &name) const
virtual TCEString disassembleInstruction(const TTAProgram::Instruction &instruction, int addr=-1)
"Template methods" that can be overridden in the derived assemblers.
int labelCount(Word address) const
void addLongImmediate(DisassemblyImmediateAssignment *longImm)
virtual bool isImmediate() const
bool isUnconditional() const
const RegisterFile * registerFile() const
static DisassemblyElement * createRegister(const TTAProgram::Terminal &terminal)
Procedure & procedure(int index) const
virtual ~POMDisassembler()
virtual bool usesSlot(const std::string &slotName) const
static DisassemblyImmediateRegister * createImmediateRegister(const TTAProgram::Terminal &terminal)
virtual bool isInProgram() const
bool hasSourceFileName() const
virtual DisassemblyInstruction * createInstruction(Word instructionIndex) const
virtual MinimumAddressableUnit MAU(int index) const