OpenASIP
2.0
|
#include <GuardField.hh>
Public Member Functions | |
GuardField (MoveSlot &parent) | |
GuardField (const ObjectState *state, MoveSlot &parent) | |
virtual | ~GuardField () |
MoveSlot * | parent () const |
void | addGuardEncoding (GPRGuardEncoding &encoding) |
void | removeGuardEncoding (GPRGuardEncoding &encoding) |
void | addGuardEncoding (FUGuardEncoding &encoding) |
void | removeGuardEncoding (FUGuardEncoding &encoding) |
void | addGuardEncoding (UnconditionalGuardEncoding &encoding) |
void | removeUnconditionalGuardEncoding (UnconditionalGuardEncoding &encoding) |
int | gprGuardEncodingCount () const |
GPRGuardEncoding & | gprGuardEncoding (int index) const |
bool | hasGPRGuardEncoding (const std::string ®File, int index, bool inverted) const |
GPRGuardEncoding & | gprGuardEncoding (const std::string ®File, int index, bool inverted) const |
int | fuGuardEncodingCount () const |
FUGuardEncoding & | fuGuardEncoding (int index) const |
bool | hasFUGuardEncoding (const std::string &fu, const std::string &port, bool inverted) const |
FUGuardEncoding & | fuGuardEncoding (const std::string &fu, const std::string &port, bool inverted) const |
bool | hasUnconditionalGuardEncoding (bool inverted) const |
UnconditionalGuardEncoding & | unconditionalGuardEncoding (bool inverted) const |
virtual int | childFieldCount () const |
virtual InstructionField & | childField (int) const |
virtual int | width () const |
virtual void | loadState (const ObjectState *state) |
virtual ObjectState * | saveState () const |
Public Member Functions inherited from InstructionField | |
virtual | ~InstructionField () |
InstructionField * | parent () const |
int | bitPosition () const |
int | relativePosition () const |
virtual void | setRelativePosition (int position) |
void | setExtraBits (int bits) |
int | extraBits () const |
Public Member Functions inherited from Serializable | |
virtual | ~Serializable () |
Static Public Attributes | |
static const std::string | OSNAME_GUARD_FIELD = "guard_field" |
ObjectState name for guard field. 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< GPRGuardEncoding * > | GPRGuardTable |
A container type for GPR guard encodings. More... | |
typedef std::vector< FUGuardEncoding * > | FUGuardTable |
A container type for FU guard encodings. More... | |
Private Member Functions | |
void | deleteGPRGuardEncodings () |
void | deleteFUGuardEncodings () |
void | deleteUnconditionalGuardEncodings () |
bool | isAssigned (unsigned int encoding) const |
Private Attributes | |
GPRGuardTable | gprGuards_ |
GPR guard encodings. More... | |
FUGuardTable | fuGuards_ |
FU guard encodings. More... | |
UnconditionalGuardEncoding * | alwaysTrue_ |
Unconditional guard encoding for always-true expression. More... | |
UnconditionalGuardEncoding * | alwaysFalse_ |
Unconditional guard encoding for always-false expression. More... | |
Additional Inherited Members | |
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) |
GuardField class represents the guard field of the move slot.
The guard field defines the guard expressions that control whether a data transport is completed or cancelled. A GuardField instance contains the control codes that identify the guard expressions supported by a given move slot. GuardField is an instruction field, hence it is derived from class InstructionField. GuardField instances cannot exist alone; they belong to a move slot and are registered to a MoveSlot object at construction time.
Definition at line 55 of file GuardField.hh.
|
private |
A container type for FU guard encodings.
Definition at line 105 of file GuardField.hh.
|
private |
A container type for GPR guard encodings.
Definition at line 103 of file GuardField.hh.
GuardField::GuardField | ( | MoveSlot & | parent | ) |
The constructor.
Registers the guard field to the parent move slot automatically.
parent | The parent move slot. |
ObjectAlreadyExists | If the parent move slot has a guard field already. |
Definition at line 60 of file GuardField.cc.
References MoveSlot::hasDestinationField(), MoveSlot::hasSourceField(), parent(), MoveSlot::setGuardField(), InstructionField::setParent(), and InstructionField::setRelativePosition().
GuardField::GuardField | ( | 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 parent move slot has a guard field already. |
Definition at line 89 of file GuardField.cc.
References loadState(), parent(), MoveSlot::setGuardField(), and InstructionField::setParent().
|
virtual |
The destructor.
Definition at line 100 of file GuardField.cc.
References assert, deleteFUGuardEncodings(), deleteGPRGuardEncodings(), deleteUnconditionalGuardEncodings(), parent(), InstructionField::setParent(), and MoveSlot::unsetGuardField().
void GuardField::addGuardEncoding | ( | FUGuardEncoding & | encoding | ) |
Adds a guard expression and its encoding to the set of expressions supported by this guard field.
This method is to be called from the constructor of FUGuardEncoding.
encoding | The encoding to be added. |
ObjectAlreadyExists | If the guard field already contains a guard encoding for the same guard expression or if the encoding is already assigned to another guard expression. |
Definition at line 183 of file GuardField.cc.
References assert, GuardEncoding::encoding(), fuGuards_, FUGuardEncoding::functionUnit(), hasFUGuardEncoding(), isAssigned(), GuardEncoding::isGuardInverted(), GuardEncoding::parent(), and FUGuardEncoding::port().
void GuardField::addGuardEncoding | ( | GPRGuardEncoding & | encoding | ) |
Adds a guard expression and its encoding to the set of expressions supported by this guard field.
This method is to be called from the constructor GPRGuardEncoding.
encoding | The encoding to be added. |
ObjectAlreadyExists | If the guard field already contains a guard encoding for the same guard expression or if the given encoding is already assigned. |
Definition at line 141 of file GuardField.cc.
References assert, GuardEncoding::encoding(), gprGuards_, hasGPRGuardEncoding(), isAssigned(), GuardEncoding::isGuardInverted(), GuardEncoding::parent(), GPRGuardEncoding::registerFile(), and GPRGuardEncoding::registerIndex().
Referenced by FUGuardEncoding::FUGuardEncoding(), GPRGuardEncoding::GPRGuardEncoding(), and UnconditionalGuardEncoding::UnconditionalGuardEncoding().
void GuardField::addGuardEncoding | ( | UnconditionalGuardEncoding & | encoding | ) |
Adds a guard expression and its encoding to the set of expressions supported by this guard field.
This method is to be called from the constructor of UnconditionalGuardEncoding.
encoding | The encoding to be added. |
ObjectAlreadyExists | If the guard field already contains an encoding for the same unconditional guard expression or if the encoding is already assigned to another guard expression. |
Definition at line 226 of file GuardField.cc.
References alwaysFalse_, alwaysTrue_, assert, GuardEncoding::encoding(), hasUnconditionalGuardEncoding(), isAssigned(), GuardEncoding::isGuardInverted(), and GuardEncoding::parent().
|
virtual |
Always throws OutOfRange exception since guard field does not have any child fields.
OutOfRange | Always thrown. |
Reimplemented from InstructionField.
Definition at line 522 of file GuardField.cc.
|
virtual |
Always returns 0 because guard field does not have any child fields.
Implements InstructionField.
Definition at line 509 of file GuardField.cc.
|
private |
Deletes all the function unit port guard encodings from the guard field.
Definition at line 664 of file GuardField.cc.
References SequenceTools::deleteAllItems(), and fuGuards_.
Referenced by loadState(), and ~GuardField().
|
private |
Deletes all the register guard encodings from the guard field.
Definition at line 655 of file GuardField.cc.
References SequenceTools::deleteAllItems(), and gprGuards_.
Referenced by loadState(), and ~GuardField().
|
private |
Deletes the unconditional guard encodings from the guard field.
Definition at line 673 of file GuardField.cc.
References alwaysFalse_, alwaysTrue_, and hasUnconditionalGuardEncoding().
Referenced by ~GuardField().
FUGuardEncoding & GuardField::fuGuardEncoding | ( | const std::string & | fu, |
const std::string & | port, | ||
bool | inverted | ||
) | const |
Returns the FUGuardEncoding for the given guard expression.
The expression is identified by a function unit output port (FU name and port name) and by the "invert" flag. Returns a NullFUGuardEncoding instance if there is no such guard.
fu | Name of the function unit. |
port | Name of the port. |
inverted | The "invert" flag. |
Definition at line 443 of file GuardField.cc.
References fuGuards_, FUGuardEncoding::functionUnit(), NullFUGuardEncoding::instance(), GuardEncoding::isGuardInverted(), and FUGuardEncoding::port().
FUGuardEncoding & GuardField::fuGuardEncoding | ( | int | index | ) | const |
Returns the FUGuardEncoding at the given position.
index | The position. |
OutOfRange | If the given index is negative or not smaller than the number of FU guard encodings. |
Definition at line 387 of file GuardField.cc.
References fuGuardEncodingCount(), and fuGuards_.
Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMTester::conflictsWithGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().
int GuardField::fuGuardEncodingCount | ( | ) | const |
Returns the number of guard expressions with function unit output term that are encoded in this field.
Definition at line 373 of file GuardField.cc.
References fuGuards_.
Referenced by BEMTester::conflictsWithGuardEncoding(), fuGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().
GPRGuardEncoding & GuardField::gprGuardEncoding | ( | const std::string & | regFile, |
int | index, | ||
bool | inverted | ||
) | const |
Returns the GPRGuardEncoding for the given guard expression.
The expression is identified by a general purpose register (register file name and register index) and by the "invert" flag. Returns a NullGPRGuardEncoding instance if there is no such guard.
regFile | Name of the register file. |
index | The register index. |
inverted | The "invert" flag. |
Definition at line 346 of file GuardField.cc.
References gprGuards_, NullGPRGuardEncoding::instance(), GuardEncoding::isGuardInverted(), GPRGuardEncoding::registerFile(), and GPRGuardEncoding::registerIndex().
GPRGuardEncoding & GuardField::gprGuardEncoding | ( | int | index | ) | const |
Returns the GPRGuardEncoding at the given position.
index | The position. |
OutOfRange | If the given index is negative or not smaller than the number of GPR guard encodings. |
Definition at line 290 of file GuardField.cc.
References gprGuardEncodingCount(), and gprGuards_.
Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMTester::conflictsWithGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().
int GuardField::gprGuardEncodingCount | ( | ) | const |
Returns the number of guard expressions with general purpose register term that are encoded in this field.
Definition at line 276 of file GuardField.cc.
References gprGuards_.
Referenced by BEMTester::conflictsWithGuardEncoding(), gprGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().
bool GuardField::hasFUGuardEncoding | ( | const std::string & | fu, |
const std::string & | port, | ||
bool | inverted | ||
) | const |
Tells whether the guard field has an encoding for the given guard expression.
The expression is identified by a function unit output port (FU name and port name) and by the "invert" flag.
fu | Name of the function unit. |
port | Name of the port. |
inverted | The "invert" flag. |
Definition at line 410 of file GuardField.cc.
References fuGuards_, FUGuardEncoding::functionUnit(), GuardEncoding::isGuardInverted(), and FUGuardEncoding::port().
Referenced by addGuardEncoding(), and BEMValidator::checkGuardField().
bool GuardField::hasGPRGuardEncoding | ( | const std::string & | regFile, |
int | index, | ||
bool | inverted | ||
) | const |
Tells whether the guard field has an encoding for the given guard expression.
The expression is identified by a general purpose register (register file name and register index) and by the "invert" flag.
regFile | Name of the register file. |
index | The register index. |
inverted | The "invert" flag. |
Definition at line 313 of file GuardField.cc.
References gprGuards_, GuardEncoding::isGuardInverted(), GPRGuardEncoding::registerFile(), and GPRGuardEncoding::registerIndex().
Referenced by addGuardEncoding(), and BEMValidator::checkGuardField().
bool GuardField::hasUnconditionalGuardEncoding | ( | bool | inverted | ) | const |
Tells whether the guard field has an encoding for unconditional guard.
inverted | The "invert" flag. |
Definition at line 471 of file GuardField.cc.
References alwaysFalse_, and alwaysTrue_.
Referenced by addGuardEncoding(), BEMValidator::checkGuardField(), BEMTester::conflictsWithGuardEncoding(), deleteUnconditionalGuardEncodings(), CodeCompressorPlugin::encodeNOP(), isAssigned(), printGuardFieldEncodings(), removeUnconditionalGuardEncoding(), saveState(), unconditionalGuardEncoding(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().
|
private |
Tells whether the given encoding is assigned to a guard expression.
encoding | The encoding. |
Definition at line 692 of file GuardField.cc.
References GuardEncoding::encoding(), fuGuardEncoding(), fuGuardEncodingCount(), gprGuardEncoding(), gprGuardEncodingCount(), hasUnconditionalGuardEncoding(), and unconditionalGuardEncoding().
Referenced by addGuardEncoding().
|
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 InstructionField.
Definition at line 585 of file GuardField.cc.
References ObjectState::child(), ObjectState::childCount(), deleteFUGuardEncodings(), deleteGPRGuardEncodings(), Exception::errorMessage(), InstructionField::loadState(), ObjectState::name(), FUGuardEncoding::OSNAME_FU_GUARD_ENCODING, GPRGuardEncoding::OSNAME_GPR_GUARD_ENCODING, and OSNAME_GUARD_FIELD.
Referenced by GuardField().
MoveSlot * GuardField::parent | ( | ) | const |
Returns the parent move slot.
Definition at line 117 of file GuardField.cc.
References assert, and InstructionField::parent().
Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMGenerator::addEncodings(), DefaultDecoderGenerator::findGuard(), GuardField(), MoveSlot::setGuardField(), and ~GuardField().
void GuardField::removeGuardEncoding | ( | FUGuardEncoding & | encoding | ) |
Removes the given guard encoding.
This method is to be called from the destructor of FUGuardField.
encoding | The encoding to be removed. |
Definition at line 205 of file GuardField.cc.
References assert, fuGuards_, GuardEncoding::parent(), and ContainerTools::removeValueIfExists().
void GuardField::removeGuardEncoding | ( | GPRGuardEncoding & | encoding | ) |
Removes the given guard encoding.
This method is to be called from the destructor of GPRGuardField.
encoding | The encoding to be removed. |
Definition at line 163 of file GuardField.cc.
References assert, gprGuards_, GuardEncoding::parent(), and ContainerTools::removeValueIfExists().
Referenced by FUGuardEncoding::~FUGuardEncoding(), and GPRGuardEncoding::~GPRGuardEncoding().
void GuardField::removeUnconditionalGuardEncoding | ( | UnconditionalGuardEncoding & | encoding | ) |
Removes the encoding for unconditional guard.
This method is to be called from the destructor of UnconditionalGuardEncoding class.
encoding | The encoding to be removed. |
Definition at line 252 of file GuardField.cc.
References alwaysFalse_, alwaysTrue_, assert, hasUnconditionalGuardEncoding(), GuardEncoding::isGuardInverted(), GuardEncoding::parent(), and unconditionalGuardEncoding().
Referenced by UnconditionalGuardEncoding::~UnconditionalGuardEncoding().
|
virtual |
Saves the state of the guard field to an ObjectState tree.
Reimplemented from InstructionField.
Definition at line 622 of file GuardField.cc.
References ObjectState::addChild(), fuGuardEncoding(), fuGuardEncodingCount(), gprGuardEncoding(), gprGuardEncodingCount(), hasUnconditionalGuardEncoding(), OSNAME_GUARD_FIELD, GPRGuardEncoding::saveState(), FUGuardEncoding::saveState(), InstructionField::saveState(), ObjectState::setName(), and unconditionalGuardEncoding().
UnconditionalGuardEncoding & GuardField::unconditionalGuardEncoding | ( | bool | inverted | ) | const |
Returns the unconditional guard encoding.
Returns NullUnconditionalGuardEncoding instance if there is no encoding for unconditional guard.
inverted | The "invert" flag. |
Definition at line 490 of file GuardField.cc.
References alwaysFalse_, alwaysTrue_, hasUnconditionalGuardEncoding(), and NullUnconditionalGuardEncoding::instance().
Referenced by BEMTester::conflictsWithGuardEncoding(), CodeCompressorPlugin::encodeNOP(), isAssigned(), printGuardFieldEncodings(), removeUnconditionalGuardEncoding(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().
|
virtual |
Returns the bit width of the guard field.
Implements InstructionField.
Definition at line 533 of file GuardField.cc.
References MathTools::bitLength(), GuardEncoding::encoding(), InstructionField::extraBits(), fuGuardEncoding(), fuGuardEncodingCount(), gprGuardEncoding(), gprGuardEncodingCount(), hasUnconditionalGuardEncoding(), and unconditionalGuardEncoding().
Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMTester::canAddComponentPriorityEncoding(), BEMTester::conflictsWithGuardEncoding(), CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), printGuardFieldEncodings(), printMoveSlotLayout(), MoveSlot::width(), DefaultDecoderGenerator::writeInstructionDismembering(), and DefaultDecoderGenerator::writeMoveFieldSignals().
|
private |
Unconditional guard encoding for always-false expression.
Definition at line 119 of file GuardField.hh.
Referenced by addGuardEncoding(), deleteUnconditionalGuardEncodings(), hasUnconditionalGuardEncoding(), removeUnconditionalGuardEncoding(), and unconditionalGuardEncoding().
|
private |
Unconditional guard encoding for always-true expression.
Definition at line 117 of file GuardField.hh.
Referenced by addGuardEncoding(), deleteUnconditionalGuardEncodings(), hasUnconditionalGuardEncoding(), removeUnconditionalGuardEncoding(), and unconditionalGuardEncoding().
|
private |
FU guard encodings.
Definition at line 115 of file GuardField.hh.
Referenced by addGuardEncoding(), deleteFUGuardEncodings(), fuGuardEncoding(), fuGuardEncodingCount(), hasFUGuardEncoding(), and removeGuardEncoding().
|
private |
GPR guard encodings.
Definition at line 113 of file GuardField.hh.
Referenced by addGuardEncoding(), deleteGPRGuardEncodings(), gprGuardEncoding(), gprGuardEncodingCount(), hasGPRGuardEncoding(), and removeGuardEncoding().
|
static |
ObjectState name for guard field.
Definition at line 99 of file GuardField.hh.
Referenced by BEMSerializer::guardFieldToOM(), MoveSlot::loadState(), loadState(), BEMSerializer::moveSlotToFile(), and saveState().