OpenASIP
2.0
|
#include <TPEFDisassembler.hh>
Public Member Functions | |
TPEFDisassembler (const TPEF::Binary &aTpef) | |
virtual | ~TPEFDisassembler () |
virtual DisassemblyInstruction * | createInstruction (Word instructionIndex) const |
virtual Word | startAddress () const |
virtual Word | instructionCount () const |
void | clearCache () const |
Protected Types | |
typedef std::pair< Word, Word > | ImmediateKey |
typedef std::map< ImmediateKey, TPEF::ImmediateElement * > | ImmediateMap |
Protected Member Functions | |
void | initCache () const |
DisassemblyElement * | createDisassemblyElement (TPEF::MoveElement::FieldType type, Word unit, Word index, ImmediateMap &immediateMap) const |
Private Attributes | |
const TPEF::Binary * | tpef_ |
Binary where data for disassembler is retrieved. More... | |
std::vector< Word > | instructionStartCache_ |
Cache of starting elements of instructions. More... | |
Retrievs data from TPEF and builds Disassembler instructions out of TPEF hierarchy.
Contains internal cache to speedup instruction fetching, so if instruction ordering of TPEF is changed cache will not be valid anymore and must be cleared.
NOTE: Class disassembles only the first of code sections in binary.
Definition at line 58 of file TPEFDisassembler.hh.
|
protected |
Definition at line 72 of file TPEFDisassembler.hh.
|
protected |
Definition at line 73 of file TPEFDisassembler.hh.
TPEFDisassembler::TPEFDisassembler | ( | const TPEF::Binary & | aTpef | ) |
Constructor.
aTpef | TPEF hierarchy whose code sections are disassembled. |
Definition at line 70 of file TPEFDisassembler.cc.
|
virtual |
void TPEFDisassembler::clearCache | ( | ) | const |
Clears internal cache of instruction start indexes in TPEF code section.
If you modify order or begin flags of instruction elements in TPEF, chache should be cleared, because instruction start indexes might be changed.
Definition at line 296 of file TPEFDisassembler.cc.
References instructionStartCache_.
|
protected |
Creates DisassemblyElement out of given paramters.
Finds needed strings and stuff from TPEF hierarchy.
type | Type of elemet to create. |
unit | Unit id of referred resource. |
index | Index part of referred resource. |
immediateMap | All immediate values found in instruction. |
Definition at line 334 of file TPEFDisassembler.cc.
References abortWithError, assert, TPEF::StringSection::chunk2String(), MapTools::containsKey(), TPEF::ResourceSection::findResource(), TPEF::ResourceSection::hasResource(), TPEF::ImmediateElement::isInline(), TPEF::Section::link(), TPEF::ResourceElement::name(), TPEF::Binary::section(), TPEF::ImmediateElement::sLongWord(), Conversion::toInt(), Conversion::toString(), Conversion::toUnsignedInt(), and tpef_.
Referenced by createInstruction().
|
virtual |
Creates dynamically allocated disassembler instruction.
instructionIndex | Number of instruction to return. |
Definition at line 87 of file TPEFDisassembler.cc.
References DisassemblyInstructionSlot::addAnnotation(), DisassemblyInstruction::addAnnotation(), DisassemblyInstruction::addLongImmediate(), DisassemblyInstruction::addMove(), TPEF::InstructionElement::annotation(), TPEF::InstructionElement::annotationCount(), assert, TPEF::InstructionElement::begin(), TPEF::MoveElement::bus(), createDisassemblyElement(), TPEF::ImmediateElement::destinationIndex(), TPEF::MoveElement::destinationIndex(), TPEF::MoveElement::destinationType(), TPEF::ImmediateElement::destinationUnit(), TPEF::MoveElement::destinationUnit(), TPEF::CodeSection::element(), TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::MoveElement::guardIndex(), TPEF::MoveElement::guardType(), TPEF::MoveElement::guardUnit(), TPEF::InstructionAnnotation::id(), TPEF::ResourceElement::id(), initCache(), instructionStartCache_, TPEF::MoveElement::isEmpty(), TPEF::MoveElement::isGuarded(), TPEF::MoveElement::isGuardInverted(), TPEF::InstructionElement::isImmediate(), TPEF::ImmediateElement::isInline(), TPEF::InstructionElement::isMove(), TPEF::ImmediateElement::longWord(), TPEF::InstructionAnnotation::payload(), TPEF::Binary::section(), TPEF::MoveElement::sourceIndex(), TPEF::MoveElement::sourceType(), TPEF::MoveElement::sourceUnit(), tpef_, and TPEF::ResourceElement::type().
Referenced by TPEFDumper::section().
|
protected |
Initilises instruction start indexes in code section to vector.
After cache init we have vector of all instruction start indexes of the section.
Definition at line 307 of file TPEFDisassembler.cc.
References assert, TPEF::InstructionElement::begin(), TPEF::CodeSection::element(), TPEF::Section::elementCount(), instructionStartCache_, TPEF::Binary::section(), and tpef_.
Referenced by createInstruction(), and instructionCount().
|
virtual |
Number of instructions available in first code section of TPEF.
Definition at line 280 of file TPEFDisassembler.cc.
References initCache(), and instructionStartCache_.
Referenced by TPEFDumper::section().
|
virtual |
Address of first instruction.
Definition at line 266 of file TPEFDisassembler.cc.
References assert, TPEF::Binary::section(), TPEF::Section::startingAddress(), and tpef_.
Referenced by TPEFDumper::section().
|
mutableprivate |
Cache of starting elements of instructions.
Definition at line 86 of file TPEFDisassembler.hh.
Referenced by clearCache(), createInstruction(), initCache(), and instructionCount().
|
private |
Binary where data for disassembler is retrieved.
Definition at line 83 of file TPEFDisassembler.hh.
Referenced by createDisassemblyElement(), createInstruction(), initCache(), and startAddress().