OpenASIP
2.0
|
#include <AOutTextSectionReader.hh>
Public Member Functions | |
virtual | ~AOutTextSectionReader () |
Public Member Functions inherited from TPEF::AOutSectionReader | |
virtual | ~AOutSectionReader () |
Public Member Functions inherited from TPEF::SectionReader | |
virtual | ~SectionReader () |
Static Public Attributes | |
static const int | OFFSET_TO_IMMEDIATE_VALUE = 4 |
Protected Member Functions | |
AOutTextSectionReader () | |
virtual Section::SectionType | type () const |
virtual void | readData (BinaryStream &stream, Section *section) const |
Protected Member Functions inherited from TPEF::AOutSectionReader | |
AOutSectionReader () | |
virtual BinaryReader * | parent () const |
Protected Member Functions inherited from TPEF::SectionReader | |
SectionReader () | |
virtual void | finalize (Section *section) const |
Private Member Functions | |
void | initializeImmediateMove (BinaryStream &stream, MoveElement *move, ImmediateElement *immediate) const |
void | initializeMove (BinaryStream &stream, MoveElement *move) const |
void | updateMoveDestination (MoveElement *move, const HalfWord dest) const |
void | updateMoveSource (MoveElement *move, const Word src) const |
Word | convertAOutIndexToTPEF (const Word reg) const |
void | setReference (InstructionElement *elem, SectionOffset sectionOffset, SectionId sectionID) const |
AOutTextSectionReader (const AOutTextSectionReader &) | |
Copying not allowed. More... | |
AOutTextSectionReader & | operator= (const AOutTextSectionReader &) |
Assignment not allowed. More... | |
Static Private Attributes | |
static AOutTextSectionReader | proto_ |
Prototype to be registered to SectionReader. More... | |
Additional Inherited Members | |
Public Types inherited from TPEF::SectionReader | |
typedef BinaryReader::Length | Length |
Static Public Member Functions inherited from TPEF::SectionReader | |
static void | readSection (BinaryStream &stream, Section *section, BinaryReader *reader) |
static void | finalizeBinary (Binary *binaryToFinalize, BinaryReader *reader) |
Static Protected Member Functions inherited from TPEF::SectionReader | |
static const SectionReader * | findSectionReader (const Section::SectionType type, const BinaryReader *bReader) |
static void | registerSectionReader (const SectionReader *sReader) |
Reads text sections of a.out format.
Definition at line 49 of file AOutTextSectionReader.hh.
|
virtual |
|
protected |
Constructor.
Registers itself to SectionReader.
Definition at line 64 of file AOutTextSectionReader.cc.
References TPEF::SectionReader::registerSectionReader().
|
private |
Copying not allowed.
|
private |
Convert an a.out register index into a TPEF register index.
Service helper method. The callers are responsible for ensuring that the given register index is within the allowed range.
reg | A.out index of the register. |
Definition at line 209 of file AOutTextSectionReader.cc.
References TPEF::AOutReader::FIRST_BOOL_REGISTER, TPEF::AOutReader::FIRST_FP_REGISTER, TPEF::AOutReader::FIRST_FU_REGISTER, and TPEF::AOutReader::FIRST_INT_REGISTER.
Referenced by updateMoveDestination(), and updateMoveSource().
|
private |
The attributes of move that has immediate in its source field are initialized.
Immediate value of a move is modeled as a separate object.
stream | Stream to be read from. |
move | Move to be initialized |
immediate | Immediate to be initialized. |
OutOfRange | If destination register index is too large. |
UnreachableStream | If there occurs problems with stream. |
Definition at line 162 of file AOutTextSectionReader.cc.
References TPEF::ResourceElement::INLINE_IMM, TPEF::MoveElement::MF_IMM, TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readWord(), TPEF::ImmediateElement::setDestinationIndex(), TPEF::ImmediateElement::setDestinationUnit(), TPEF::MoveElement::setSourceIndex(), TPEF::MoveElement::setSourceType(), TPEF::MoveElement::setSourceUnit(), TPEF::ImmediateElement::setWord(), and updateMoveDestination().
Referenced by readData().
|
private |
Initializes an 'ordinary' Move.
stream | Stream to be read from. |
move | Move to be initialized. |
OutOfRange | If destination or source register index is too big. |
UnreachableStream | If there occurs problems with stream. |
Definition at line 190 of file AOutTextSectionReader.cc.
References TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readWord(), updateMoveDestination(), and updateMoveSource().
Referenced by readData().
|
private |
Assignment not allowed.
|
protectedvirtual |
Reads all Moves from stream and stores them in to Section.
One move consists of 4 fields: guard (Byte), immediate (Byte), destination index (HalfWord), and source index (Word). If immediate is 1 then the source field of the move contains an immediate value.
stream | Stream to be read from. |
section | Pointer to section in which information is stored. |
UnreachableStream | If reading of section fails. |
KeyAlreadyExists | Key was in use when trying to register object. |
EndOfFile | If end of file were reached while it shouldn't. |
OutOfRange | Some of read values were out of range. |
WrongSubclass | Some class couldn't do what it was asked for. |
UnexpectedValue | If there was unexpected value when reading. |
Implements TPEF::SectionReader.
Definition at line 101 of file AOutTextSectionReader.cc.
References TPEF::Section::addElement(), assert, TPEF::ResourceElement::BOOL_RF, TPEF::AOutReader::header(), initializeImmediateMove(), initializeMove(), TPEF::MoveElement::MF_RF, TPEF::AOutSectionReader::parent(), TPEF::BinaryStream::readByte(), TPEF::BinaryStream::readPosition(), TPEF::AOutReader::Header::sectionSizeText(), TPEF::InstructionElement::setBegin(), TPEF::MoveElement::setBus(), TPEF::MoveElement::setGuarded(), TPEF::MoveElement::setGuardIndex(), TPEF::MoveElement::setGuardInverted(), TPEF::MoveElement::setGuardType(), TPEF::MoveElement::setGuardUnit(), setReference(), TPEF::AOutReader::ST_TEXT, and TPEF::ResourceElement::UNIVERSAL_BUS.
|
private |
Sets references to ReferenceManager to enable referencing if it's needed later.
elem | Element to be registered to ReferenceManager. |
sectionOffset | The offset of the element in the section. |
sectionID | Identification code of the referenced section. |
KeyAlreadyExists | If registration fails because of existing key. |
Definition at line 319 of file AOutTextSectionReader.cc.
References TPEF::ReferenceManager::SafePointer::addObjectReference().
Referenced by readData().
|
protectedvirtual |
Returns section type which reader can read.
Implements TPEF::SectionReader.
Definition at line 80 of file AOutTextSectionReader.cc.
References TPEF::Section::ST_CODE.
|
private |
Convert an a.out register index to a TPEF register index and update the destination of the given move to reflect the given register index.
Possible values of move destination field are indices of: integer registers, floating point registers, Boolean registers, or function unit registers. The type of the move destination is also set.
move | The Move to be updated. |
dest | Index of the destination register. |
OutOfRange | If destination index is too large. |
Definition at line 250 of file AOutTextSectionReader.cc.
References TPEF::ResourceElement::BOOL_RF, convertAOutIndexToTPEF(), TPEF::AOutReader::FIRST_BOOL_REGISTER, TPEF::AOutReader::FIRST_FP_REGISTER, TPEF::AOutReader::FIRST_FU_REGISTER, TPEF::ResourceElement::FP_RF, TPEF::ResourceElement::INT_RF, TPEF::MoveElement::MF_RF, TPEF::MoveElement::MF_UNIT, TPEF::MoveElement::setDestinationIndex(), TPEF::MoveElement::setDestinationType(), TPEF::MoveElement::setDestinationUnit(), and TPEF::ResourceElement::UNIVERSAL_FU.
Referenced by initializeImmediateMove(), and initializeMove().
|
private |
Convert an a.out register index to a TPEF register index and update the source of the given move to reflect the given register index.
Possible values of move source field are indices of: integer registers, floating point registers, Boolean registers, or function unit registers. The type of the move source is also set.
move | The Move to be updated. |
src | Index of the source register. |
OutOfRange | If source index is too large. |
Definition at line 286 of file AOutTextSectionReader.cc.
References TPEF::ResourceElement::BOOL_RF, convertAOutIndexToTPEF(), TPEF::AOutReader::FIRST_BOOL_REGISTER, TPEF::AOutReader::FIRST_FP_REGISTER, TPEF::AOutReader::FIRST_FU_REGISTER, TPEF::ResourceElement::FP_RF, TPEF::ResourceElement::INT_RF, TPEF::MoveElement::MF_RF, TPEF::MoveElement::MF_UNIT, TPEF::MoveElement::setSourceIndex(), TPEF::MoveElement::setSourceType(), TPEF::MoveElement::setSourceUnit(), and TPEF::ResourceElement::UNIVERSAL_FU.
Referenced by initializeMove().
|
static |
Definition at line 51 of file AOutTextSectionReader.hh.
Referenced by TPEF::AOutRelocationSectionReader::initializeRelocElement().
|
staticprivate |
Prototype to be registered to SectionReader.
Definition at line 84 of file AOutTextSectionReader.hh.