OpenASIP
2.0
|
#include <CodeSection.hh>
Public Member Functions | |
virtual | ~CodeSection () |
virtual void | addElement (SectionElement *element) |
virtual void | setElement (Word index, SectionElement *element) |
virtual SectionType | type () const |
virtual InstructionElement * | element (Word index) const |
void | clearInstructionCache () const |
Word | instructionCount () const |
InstructionElement & | instruction (Word index) const |
Word | instructionToSectionIndex (Word index) const |
Word | indexOfElement (const InstructionElement &elem) const |
Word | indexOfInstruction (const InstructionElement &elem) const |
bool | isInSection (const InstructionElement &elem) const |
bool | isCodeSection () const override |
Public Member Functions inherited from TPEF::Section | |
virtual | ~Section () |
virtual bool | isChunkable () const |
virtual Chunk * | chunk (SectionOffset offset) const |
bool | isProgramSection () const |
bool | isAuxSection () const |
SectionElement * | element (Word index) const |
Word | elementCount () const |
void | setFlagNoBits () |
void | unsetFlagNoBits () |
bool | noBits () const |
bool | vLen () const |
Byte | flags () const |
void | setFlags (Byte flagByte) |
void | setStartingAddress (AddressImage address) |
AddressImage | startingAddress () const |
void | setLink (const ReferenceManager::SafePointer *aLink) |
void | setLink (Section *aLink) |
Section * | link () const |
void | setASpace (const ReferenceManager::SafePointer *addrSpace) |
void | setASpace (ASpaceElement *addrSpace) |
ASpaceElement * | aSpace () const |
void | setName (const ReferenceManager::SafePointer *sectionName) |
void | setName (Chunk *sectionName) |
Chunk * | name () const |
virtual bool | isDataSection () const |
Public Member Functions inherited from TPEF::SafePointable | |
virtual | ~SafePointable () |
Protected Member Functions | |
CodeSection (bool init) | |
virtual Section * | clone () const |
Protected Member Functions inherited from TPEF::Section | |
Section () | |
void | setFlagVLen () |
void | unsetFlagVLen () |
Protected Member Functions inherited from TPEF::SafePointable | |
SafePointable () | |
Private Member Functions | |
void | initInstructionCache () const |
Private Attributes | |
std::vector< Word > | instructionStartCache_ |
Cache vector of element indexes of those instruction elements, which begins a new instruction. More... | |
std::map< const InstructionElement *, Word > | elementIndexCache_ |
Cache of indexes of instruction elemenets. More... | |
Static Private Attributes | |
static CodeSection | proto_ |
Prototype instance of section. More... | |
Additional Inherited Members | |
Public Types inherited from TPEF::Section | |
enum | SectionType { ST_NULL = 0x00, ST_STRTAB = 0x01, ST_SYMTAB = 0x02, ST_DEBUG = 0x03, ST_RELOC = 0x04, ST_LINENO = 0x05, ST_NOTE = 0x06, ST_ADDRSP = 0x07, ST_MR = 0x0A, ST_CODE = 0x81, ST_DATA = 0x82, ST_UDATA = 0x83, ST_LEDATA = 0x84, ST_DUMMY = 0xff } |
enum | SectionFlag { SF_VLEN = 0x40, SF_NOBITS = 0x80 } |
Static Public Member Functions inherited from TPEF::Section | |
static Section * | createSection (SectionType type) |
static bool | isProgramSection (SectionType type) |
Static Protected Member Functions inherited from TPEF::Section | |
static void | registerSection (const Section *section) |
Code section.
Definition at line 44 of file CodeSection.hh.
|
virtual |
|
protected |
Constructor.
init | True if registeration is wanted. |
Definition at line 46 of file CodeSection.cc.
References TPEF::Section::registerSection(), TPEF::Section::setFlagVLen(), and TPEF::Section::unsetFlagNoBits().
Referenced by clone().
|
virtual |
Adds an element to section and clears internal caches.
element | Element that is added to section. |
Reimplemented from TPEF::Section.
Definition at line 267 of file CodeSection.cc.
References TPEF::Section::addElement(), clearInstructionCache(), and element().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), CodeSectionCreator::finalize(), and TPEF::TPEFCodeSectionReader::readData().
void TPEF::CodeSection::clearInstructionCache | ( | ) | const |
Clears instruction startpoint cache.
Definition at line 96 of file CodeSection.cc.
References elementIndexCache_, and instructionStartCache_.
Referenced by addElement(), and setElement().
|
protectedvirtual |
Creates an instance of CodeSection.
Implements TPEF::Section.
Definition at line 77 of file CodeSection.cc.
References CodeSection().
|
virtual |
Returns requested instruction element.
index | Index of requested element. |
Definition at line 88 of file CodeSection.cc.
References TPEF::Section::element().
Referenced by addElement(), TTAProgram::TPEFProgramFactory::addProcedures(), TPEFDisassembler::createInstruction(), TPEF::AOutSymbolSectionReader::finalize(), CodeCompressorPlugin::immediateTerminal(), TPEFDisassembler::initCache(), CodeCompressorPlugin::initializeRelocations(), initInstructionCache(), instruction(), and setElement().
Word TPEF::CodeSection::indexOfElement | ( | const InstructionElement & | elem | ) | const |
Returns index of instruction element.
If section elements are changed, cache must be cleared before calling this function.
elem | Element whose index is returned. |
Definition at line 198 of file CodeSection.cc.
References elementIndexCache_, and initInstructionCache().
Referenced by TPEFDumper::section().
Word TPEF::CodeSection::indexOfInstruction | ( | const InstructionElement & | elem | ) | const |
Returns index of instruction of requested element.
If requested element is in middle of instruction, then index of that instruction is returned.
If section elements are changed, cache must be cleared before calling this function.
elem | Element whose instruction index is returned. |
Definition at line 232 of file CodeSection.cc.
References elementIndexCache_, initInstructionCache(), instructionCount(), and instructionStartCache_.
Referenced by TPEFDumper::section(), and ProgramImageGenerator::writeDataSection().
|
private |
Initializes instruction cache.
Scans through section and marks element indexes of those instruction elements that starts a new instruction.
Also sets section element index for every element.
Definition at line 110 of file CodeSection.cc.
References assert, TPEF::InstructionElement::begin(), element(), TPEF::Section::elementCount(), elementIndexCache_, and instructionStartCache_.
Referenced by indexOfElement(), indexOfInstruction(), instructionCount(), instructionToSectionIndex(), and isInSection().
InstructionElement & TPEF::CodeSection::instruction | ( | Word | index | ) | const |
Returns starting element of requested instruction.
See. instructionCount() for more information.
If section elements are changed, cache must be cleared before calling this function.
index | Index of requested instruction. |
Definition at line 165 of file CodeSection.cc.
References element(), and instructionToSectionIndex().
Referenced by TTAProgram::ProgramWriter::createBinary(), TTAProgram::ProgramWriter::createRelocSections(), LabelManager::createSymbolWithReference(), TPEF::AOutSymbolSectionReader::finalize(), LabelManager::finalize(), and LabelManager::writeProcedureSymbols().
Word TPEF::CodeSection::instructionCount | ( | ) | const |
Returns number of instructions stored in section.
Each instruction elements that starts new instruction are marked with begin() flag.
If section elements are changed, cache must be cleared before calling this function.
Definition at line 148 of file CodeSection.cc.
References initInstructionCache(), and instructionStartCache_.
Referenced by TPEF::AOutSymbolSectionReader::finalize(), LabelManager::findRelocationDstSection(), TTAProgram::ProgramWriter::findSection(), LabelManager::findSectionByAddress(), indexOfInstruction(), and LabelManager::writeProcedureSymbols().
Word TPEF::CodeSection::instructionToSectionIndex | ( | Word | index | ) | const |
Returns element index of starting element of requested instruction.
I.e. converts instruction index to instruction element index.
See. instructionCount() for more information.
If section elements are changed, cache must be cleared before calling this function.
index | Index of instruction |
Definition at line 183 of file CodeSection.cc.
References initInstructionCache(), and instructionStartCache_.
Referenced by TPEF::AOutSymbolSectionReader::finalize(), and instruction().
|
inlineoverridevirtual |
bool TPEF::CodeSection::isInSection | ( | const InstructionElement & | elem | ) | const |
Returns true if element is found from section.
If section elements are changed, cache must be cleared before calling this function.
elem | Element to check. |
Definition at line 214 of file CodeSection.cc.
References MapTools::containsKey(), elementIndexCache_, and initInstructionCache().
Referenced by TPEF::TPEFTools::sectionOfElement().
|
virtual |
Sets replaces an element with another and clears internal caches.
index | Index of element that is replaced. |
element | Element that is set to given index. |
Reimplemented from TPEF::Section.
Definition at line 279 of file CodeSection.cc.
References clearInstructionCache(), element(), and TPEF::Section::setElement().
|
virtual |
Returns section's type.
Implements TPEF::Section.
Definition at line 67 of file CodeSection.cc.
References TPEF::Section::ST_CODE.
|
mutableprivate |
Cache of indexes of instruction elemenets.
Definition at line 81 of file CodeSection.hh.
Referenced by clearInstructionCache(), indexOfElement(), indexOfInstruction(), initInstructionCache(), and isInSection().
|
mutableprivate |
Cache vector of element indexes of those instruction elements, which begins a new instruction.
Definition at line 78 of file CodeSection.hh.
Referenced by clearInstructionCache(), indexOfInstruction(), initInstructionCache(), instructionCount(), and instructionToSectionIndex().
|
staticprivate |
Prototype instance of section.
Definition at line 74 of file CodeSection.hh.