OpenASIP
2.0
|
#include <SourceField.hh>
Static Public Attributes | |
static const std::string | OSNAME_SOURCE_FIELD = "source_field" |
ObjectState name for source field. More... | |
Static Public Attributes inherited from SlotField | |
static const std::string | OSNAME_SLOT_FIELD = "slot_field" |
ObjectState name for slot field. More... | |
static const std::string | OSKEY_COMPONENT_ID_POSITION = "comp_id_pos" |
ObjectState attribute key for component ID position. More... | |
Static Public Attributes inherited from InstructionField | |
static const std::string | OSNAME_INSTRUCTION_FIELD = "instr_field" |
ObjectState name for instruction field. More... | |
static const std::string | OSKEY_EXTRA_BITS = "extra_bits" |
ObjectState attribute key for the number of extra bits. More... | |
static const std::string | OSKEY_POSITION = "position" |
ObjectState attribute key for the relative position of the field. More... | |
Private Types | |
typedef std::vector< BridgeEncoding * > | BridgeEncodingTable |
Container type for bridge encodings. More... | |
Private Member Functions | |
void | clearBridgeEncodings () |
void | clearImmediateEncoding () |
Private Attributes | |
BridgeEncodingTable | bridgeEncodings_ |
Container for bridge encodings. More... | |
ImmediateEncoding * | immEncoding_ |
The immediate encoding. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from SlotField | |
SlotField (BinaryEncoding::Position componentIDPos, MoveSlot &parent) | |
SlotField (const ObjectState *state, MoveSlot &parent) | |
Protected Member Functions inherited from InstructionField | |
InstructionField (InstructionField *parent) | |
InstructionField (const ObjectState *state, InstructionField *parent) | |
void | setParent (InstructionField *parent) |
Static Protected Member Functions inherited from InstructionField | |
static void | reorderSubfields (ObjectState *state) |
SourceField class represents the source field of a move slot.
It is a specialisation of InstructionField class. In addition to socket encodings, a source field may encode an inline immediate or up to two bridge sources.
Definition at line 48 of file SourceField.hh.
|
private |
Container type for bridge encodings.
Definition at line 78 of file SourceField.hh.
SourceField::SourceField | ( | BinaryEncoding::Position | componentIDPos, |
MoveSlot & | parent | ||
) |
The constructor.
Creates a source field and registers it into the given move slot.
componentIDPos | Position of the socket or bridge ID within the source field. |
parent | The parent move slot. |
ObjectAlreadyExists | If the given move slot already has a source field. |
IllegalParameters | If the given component ID position is not the same with other source fields in the binary encoding map. |
Definition at line 65 of file SourceField.cc.
References SlotField::componentIDPosition(), MoveSlot::hasSourceField(), BinaryEncoding::moveSlot(), BinaryEncoding::moveSlotCount(), SlotField::parent(), MoveSlot::parent(), InstructionField::setParent(), MoveSlot::setSourceField(), and MoveSlot::sourceField().
SourceField::SourceField | ( | const ObjectState * | state, |
MoveSlot & | parent | ||
) |
The constructor.
Loads the state of the object from the given ObjectState tree.
state | The ObjectState tree. |
parent | The parent move slot. |
ObjectStateLoadingException | If an error occurs while loading the state. |
ObjectAlreadyExists | If the given move slot already has a source field. |
Definition at line 97 of file SourceField.cc.
References loadState(), SlotField::parent(), InstructionField::setParent(), and MoveSlot::setSourceField().
|
virtual |
The destructor.
Definition at line 108 of file SourceField.cc.
References clearBridgeEncodings(), clearImmediateEncoding(), SlotField::parent(), InstructionField::setParent(), and MoveSlot::unsetSourceField().
void SourceField::addBridgeEncoding | ( | BridgeEncoding & | encoding | ) |
Adds the given encoding for a bridge to the source field.
This method is to be called from the constructor of BridgeEncoding class.
encoding | The encoding to be added. |
ObjectAlreadyExists | If the field already has an encoding for the given bridge or if the encoding is ambiguous with another encoding or if the source field has encodings for two bridges already. |
Definition at line 130 of file SourceField.cc.
References assert, bridgeEncodingCount(), bridgeEncodings_, BridgeEncoding::bridgeName(), BEMTester::canAddComponentEncoding(), Encoding::encoding(), Encoding::extraBits(), hasBridgeEncoding(), and BridgeEncoding::parent().
Referenced by BridgeEncoding::BridgeEncoding().
BridgeEncoding & SourceField::bridgeEncoding | ( | const std::string & | bridge | ) | const |
Returns the encoding for the given bridge.
bridge | Name of the bridge. |
Definition at line 191 of file SourceField.cc.
References bridgeEncodingCount(), BridgeEncoding::bridgeName(), and NullBridgeEncoding::instance().
Referenced by BEMTester::canAddComponentEncoding(), hasBridgeEncoding(), printSourceFieldEncodings(), saveState(), and width().
BridgeEncoding & SourceField::bridgeEncoding | ( | int | index | ) | const |
Returns the bridge encoding stored at the given position.
index | The position. |
OutOfRange | If the given index is negative or not smaller than the number of bridge encodings. |
Definition at line 222 of file SourceField.cc.
References bridgeEncodingCount(), and bridgeEncodings_.
int SourceField::bridgeEncodingCount | ( | ) | const |
Returns the number of bridge encodings defined for this source field.
Definition at line 209 of file SourceField.cc.
References bridgeEncodings_.
Referenced by addBridgeEncoding(), bridgeEncoding(), BEMTester::canAddComponentEncoding(), hasBridgeEncoding(), printSourceFieldEncodings(), saveState(), and width().
|
private |
Clears all the bridge encodings from the source field.
Definition at line 396 of file SourceField.cc.
References bridgeEncodings_, and SequenceTools::deleteAllItems().
Referenced by loadState(), and ~SourceField().
|
private |
Deletes the immediate encoding if one exists.
Definition at line 405 of file SourceField.cc.
References hasImmediateEncoding(), and immEncoding_.
Referenced by loadState(), and ~SourceField().
bool SourceField::hasBridgeEncoding | ( | const std::string & | bridge | ) | const |
Tells whether the source field has an encoding defined for the given bridge.
bridge | Name of the bridge. |
Definition at line 169 of file SourceField.cc.
References bridgeEncoding(), bridgeEncodingCount(), and BridgeEncoding::bridgeName().
Referenced by addBridgeEncoding(), and BEMValidator::checkSourceField().
bool SourceField::hasImmediateEncoding | ( | ) | const |
Tells whether the source field has an immediate encoding.
Definition at line 279 of file SourceField.cc.
References immEncoding_.
Referenced by BEMTester::canAddComponentEncoding(), BEMValidator::checkSourceField(), clearImmediateEncoding(), BEMTester::conflictsWithSourceEncodings(), immediateEncoding(), printSourceFieldEncodings(), saveState(), setImmediateEncoding(), unsetImmediateEncoding(), width(), and DefaultDecoderGenerator::writeBusControlRulesOfSImmSocketOfBus().
ImmediateEncoding & SourceField::immediateEncoding | ( | ) | const |
Returns the immediate encoding.
Returns NullImmediateEncoding instance if the source field does not have an immediate encoding.
Definition at line 293 of file SourceField.cc.
References hasImmediateEncoding(), immEncoding_, and NullImmediateEncoding::instance().
Referenced by BEMTester::canAddComponentEncoding(), BEMTester::conflictsWithSourceEncodings(), CodeCompressorPlugin::encodeImmediateTerminal(), printSourceFieldEncodings(), saveState(), unsetImmediateEncoding(), width(), DefaultDecoderGenerator::writeBusControlRulesOfSImmSocketOfBus(), and DefaultDecoderGenerator::writeSimmDataSignal().
|
virtual |
Loads the state of the object from the given ObjectState tree.
state | The ObjectState tree. |
ObjectStateLoadingException | If an error occurs while loading the state. |
Reimplemented from SlotField.
Definition at line 336 of file SourceField.cc.
References ObjectState::child(), ObjectState::childCount(), clearBridgeEncodings(), clearImmediateEncoding(), Exception::errorMessage(), SlotField::loadState(), ObjectState::name(), BridgeEncoding::OSNAME_BRIDGE_ENCODING, ImmediateEncoding::OSNAME_IMM_ENCODING, and OSNAME_SOURCE_FIELD.
Referenced by SourceField().
void SourceField::removeBridgeEncoding | ( | BridgeEncoding & | encoding | ) |
Removes the given bridge encoding from the source field.
This method is to be called from the destructor of BridgeEncoding class.
encoding | The encoding to be removed. |
Definition at line 154 of file SourceField.cc.
References assert, bridgeEncodings_, BridgeEncoding::parent(), and ContainerTools::removeValueIfExists().
Referenced by BridgeEncoding::~BridgeEncoding().
|
virtual |
Saves the state of the object to an ObjectState tree.
Reimplemented from SlotField.
Definition at line 372 of file SourceField.cc.
References ObjectState::addChild(), bridgeEncoding(), bridgeEncodingCount(), hasImmediateEncoding(), immediateEncoding(), OSNAME_SOURCE_FIELD, BridgeEncoding::saveState(), SlotField::saveState(), and ObjectState::setName().
void SourceField::setImmediateEncoding | ( | ImmediateEncoding & | encoding | ) |
Sets the given encoding for inline immediates.
This method is to be called from the constructor of ImmediateEncoding.
encoding | The encoding to be set. |
ObjectAlreadyExists | If the source field has an immediate encoding already or if the given encoding is ambiguous with some socket or bridge encoding. |
Definition at line 243 of file SourceField.cc.
References assert, BEMTester::canAddComponentEncoding(), Encoding::encoding(), Encoding::extraBits(), hasImmediateEncoding(), immEncoding_, MoveSlot::name(), ImmediateEncoding::parent(), SlotField::parent(), Texts::TextGenerator::text(), and BEMTextGenerator::TXT_ILLEGAL_IMM_ENC.
Referenced by ImmediateEncoding::ImmediateEncoding().
void SourceField::unsetImmediateEncoding | ( | ) |
Unsets the immediate encoding.
This method is to be called from the destructor of ImmediateEncoding.
Definition at line 265 of file SourceField.cc.
References assert, hasImmediateEncoding(), immediateEncoding(), immEncoding_, and SlotField::parent().
Referenced by ImmediateEncoding::~ImmediateEncoding().
|
virtual |
Returns the bit width of the source field.
Reimplemented from SlotField.
Definition at line 308 of file SourceField.cc.
References bridgeEncoding(), bridgeEncodingCount(), InstructionField::extraBits(), hasImmediateEncoding(), immediateEncoding(), Encoding::width(), ImmediateEncoding::width(), and SlotField::width().
Referenced by CodeCompressorPlugin::addBitsForSourceField(), BridgeEncoding::bitPosition(), BEMTester::canAddComponentPriorityEncoding(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), ImmediateEncoding::encodingPosition(), ImmediateEncoding::immediatePosition(), printMoveSlotLayout(), printSourceFieldEncodings(), MoveSlot::width(), DefaultDecoderGenerator::writeInstructionDismembering(), and DefaultDecoderGenerator::writeMoveFieldSignals().
|
private |
Container for bridge encodings.
Definition at line 84 of file SourceField.hh.
Referenced by addBridgeEncoding(), bridgeEncoding(), bridgeEncodingCount(), clearBridgeEncodings(), and removeBridgeEncoding().
|
private |
The immediate encoding.
Definition at line 86 of file SourceField.hh.
Referenced by clearImmediateEncoding(), hasImmediateEncoding(), immediateEncoding(), setImmediateEncoding(), and unsetImmediateEncoding().
|
static |
ObjectState name for source field.
Definition at line 74 of file SourceField.hh.
Referenced by loadState(), MoveSlot::loadState(), BEMSerializer::moveSlotToFile(), saveState(), and BEMSerializer::sourceFieldToOM().