OpenASIP
2.0
|
#include <TPEFTools.hh>
Public Member Functions | |
TPEFTools (const Binary &aTpef) | |
void | clearCache () const |
Section & | sectionOfElement (const SectionElement &element) |
std::string | resourceName (ResourceElement::ResourceType type, HalfWord resourceId) const |
std::string | addressSpaceName (const ASpaceElement &aSpace) const |
bool | hasRelocation (const SectionElement &element) const |
const RelocElement & | relocation (const SectionElement &element) const |
Static Public Member Functions | |
static Section & | sectionOfElement (const Binary &bin, const SectionElement &element) |
static std::string | resourceName (const Binary &bin, ResourceElement::ResourceType type, HalfWord resourceId) |
static std::string | addressSpaceName (const Binary &bin, const ASpaceElement &aSpace) |
static bool | hasRelocation (const Binary &bin, const SectionElement &element) |
static const RelocElement & | relocation (const Binary &bin, const SectionElement &element) |
Private Member Functions | |
void | initRelocationCache () const |
Private Attributes | |
const Binary & | tpef_ |
TPEF whose resources are accessed. More... | |
std::map< const SectionElement *, const RelocElement * > | relocationCache_ |
Cache of Chunks and immediates, which are relocated. More... | |
Contains many helper functions that makes TPEF handling a bit easier.
These are kind of functions that doesn't fit to any Sections' or SectionElements' interfaces.
Class can be used stright through static interface, or client may create instance of TPEFTools, which enables caching functionality. Basically, if TPEFTools is highly utilized it should be used as a object.
Definition at line 62 of file TPEFTools.hh.
TPEF::TPEFTools::TPEFTools | ( | const Binary & | aTpef | ) |
Constructor.
aTpef | TPEF that is accessed with toolkit. |
Definition at line 54 of file TPEFTools.cc.
std::string TPEF::TPEFTools::addressSpaceName | ( | const ASpaceElement & | aSpace | ) | const |
Finds name string of an address space element.
aSpace | Element whose name is needed. |
Definition at line 96 of file TPEFTools.cc.
References tpef_.
Referenced by TTAProgram::TPEFProgramFactory::findAddressSpace().
|
static |
Finds name string of an address space element.
bin | TPEF which is checked. |
aSpace | Element whose name is needed. |
Definition at line 246 of file TPEFTools.cc.
References assert, TPEF::StringSection::chunk2String(), TPEF::Section::link(), TPEF::ASpaceElement::name(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), and TPEF::Section::ST_ADDRSP.
void TPEF::TPEFTools::clearCache | ( | ) | const |
|
static |
Checks if the requested immediate or chunk is relocated.
bin | TPEF which is checked. |
element | Element whose name is needed. |
Definition at line 268 of file TPEFTools.cc.
References assert, TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::RelocElement::location(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), and TPEF::Section::ST_RELOC.
bool TPEF::TPEFTools::hasRelocation | ( | const SectionElement & | element | ) | const |
Checks if the requested immediate or chunk is relocated.
element | Element whose name is needed. |
Definition at line 107 of file TPEFTools.cc.
References MapTools::containsKey(), initRelocationCache(), and relocationCache_.
Referenced by TTAProgram::TPEFProgramFactory::createInstruction(), and TTAProgram::TPEFProgramFactory::createTerminal().
|
private |
Inits cache for hasRelocation and relocation methods.
Definition at line 323 of file TPEFTools.cc.
References assert, TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::RelocElement::location(), relocationCache_, TPEF::Binary::section(), TPEF::Binary::sectionCount(), TPEF::Section::ST_RELOC, and tpef_.
Referenced by hasRelocation(), and relocation().
|
static |
Retrieves the relocation element requested immediate or chunk is relocated.
bin | TPEF which is checked. |
element | Element relocations are checked. |
Definition at line 296 of file TPEFTools.cc.
References __func__, assert, TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::RelocElement::location(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), and TPEF::Section::ST_RELOC.
const RelocElement & TPEF::TPEFTools::relocation | ( | const SectionElement & | element | ) | const |
Retrieves the relocation element requested immediate or chunk is relocated.
element | Element relocations are checked. |
Definition at line 119 of file TPEFTools.cc.
References initRelocationCache(), and relocationCache_.
Referenced by TTAProgram::TPEFProgramFactory::createInstruction(), and TTAProgram::TPEFProgramFactory::createTerminal().
|
static |
Finds name string of a resource.
bin | TPEF which is checked. |
type | Type of the resource. |
resourceId | Id of the resource. |
Definition at line 208 of file TPEFTools.cc.
References __func__, assert, TPEF::StringSection::chunk2String(), TPEF::ResourceSection::findResource(), TPEF::ResourceSection::hasResource(), TPEF::Section::link(), TPEF::ResourceElement::name(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), TPEF::Section::ST_MR, and Conversion::toString().
std::string TPEF::TPEFTools::resourceName | ( | ResourceElement::ResourceType | type, |
HalfWord | resourceId | ||
) | const |
Finds name string of a resource.
type | Type of the resource. |
resourceId | Id of the resource. |
Definition at line 84 of file TPEFTools.cc.
References tpef_.
|
static |
Return section of the requested element.
NOTE: method does not work for LineNumElements (line number section element desing is wrong).
bin | TPEF which is checked. |
element | Element whose section is needed. |
Definition at line 136 of file TPEFTools.cc.
References __func__, TPEF::RawSection::chunk(), TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::Section::isChunkable(), TPEF::Section::isCodeSection(), TPEF::CodeSection::isInSection(), TPEF::RawSection::length(), TPEF::Chunk::offset(), TPEF::Binary::section(), and TPEF::Binary::sectionCount().
Section & TPEF::TPEFTools::sectionOfElement | ( | const SectionElement & | element | ) |
Return section of the requested element.
element | Element whose section is needed. |
Definition at line 72 of file TPEFTools.cc.
References tpef_.
|
mutableprivate |
Cache of Chunks and immediates, which are relocated.
Definition at line 110 of file TPEFTools.hh.
Referenced by clearCache(), hasRelocation(), initRelocationCache(), and relocation().
|
private |
TPEF whose resources are accessed.
Definition at line 106 of file TPEFTools.hh.
Referenced by addressSpaceName(), initRelocationCache(), resourceName(), and sectionOfElement().