OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
GuardField Class Reference

#include <GuardField.hh>

Inheritance diagram for GuardField:
Inheritance graph
Collaboration diagram for GuardField:
Collaboration graph

Public Member Functions

 GuardField (MoveSlot &parent)
 
 GuardField (const ObjectState *state, MoveSlot &parent)
 
virtual ~GuardField ()
 
MoveSlotparent () 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
 
GPRGuardEncodinggprGuardEncoding (int index) const
 
bool hasGPRGuardEncoding (const std::string &regFile, int index, bool inverted) const
 
GPRGuardEncodinggprGuardEncoding (const std::string &regFile, int index, bool inverted) const
 
int fuGuardEncodingCount () const
 
FUGuardEncodingfuGuardEncoding (int index) const
 
bool hasFUGuardEncoding (const std::string &fu, const std::string &port, bool inverted) const
 
FUGuardEncodingfuGuardEncoding (const std::string &fu, const std::string &port, bool inverted) const
 
bool hasUnconditionalGuardEncoding (bool inverted) const
 
UnconditionalGuardEncodingunconditionalGuardEncoding (bool inverted) const
 
virtual int childFieldCount () const
 
virtual InstructionFieldchildField (int) const
 
virtual int width () const
 
virtual void loadState (const ObjectState *state)
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from InstructionField
virtual ~InstructionField ()
 
InstructionFieldparent () 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.
 
- Static Public Attributes inherited from InstructionField
static const std::string OSNAME_INSTRUCTION_FIELD = "instr_field"
 ObjectState name for instruction field.
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits.
 
static const std::string OSKEY_POSITION = "position"
 ObjectState attribute key for the relative position of the field.
 

Private Types

typedef std::vector< GPRGuardEncoding * > GPRGuardTable
 A container type for GPR guard encodings.
 
typedef std::vector< FUGuardEncoding * > FUGuardTable
 A container type for FU guard encodings.
 

Private Member Functions

void deleteGPRGuardEncodings ()
 
void deleteFUGuardEncodings ()
 
void deleteUnconditionalGuardEncodings ()
 
bool isAssigned (unsigned int encoding) const
 

Private Attributes

GPRGuardTable gprGuards_
 GPR guard encodings.
 
FUGuardTable fuGuards_
 FU guard encodings.
 
UnconditionalGuardEncodingalwaysTrue_
 Unconditional guard encoding for always-true expression.
 
UnconditionalGuardEncodingalwaysFalse_
 Unconditional guard encoding for always-false expression.
 

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)
 

Detailed Description

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.

Member Typedef Documentation

◆ FUGuardTable

typedef std::vector<FUGuardEncoding*> GuardField::FUGuardTable
private

A container type for FU guard encodings.

Definition at line 105 of file GuardField.hh.

◆ GPRGuardTable

typedef std::vector<GPRGuardEncoding*> GuardField::GPRGuardTable
private

A container type for GPR guard encodings.

Definition at line 103 of file GuardField.hh.

Constructor & Destructor Documentation

◆ GuardField() [1/2]

GuardField::GuardField ( MoveSlot parent)

The constructor.

Registers the guard field to the parent move slot automatically.

Parameters
parentThe parent move slot.
Exceptions
ObjectAlreadyExistsIf the parent move slot has a guard field already.

Definition at line 60 of file GuardField.cc.

62 setParent(NULL);
63 parent.setGuardField(*this);
65
66 // update the relative position of the field
67 int position(0);
68 if (parent.hasSourceField()) {
69 position++;
70 }
72 position++;
73 }
75}
UnconditionalGuardEncoding * alwaysFalse_
Unconditional guard encoding for always-false expression.
UnconditionalGuardEncoding * alwaysTrue_
Unconditional guard encoding for always-true expression.
MoveSlot * parent() const
void setParent(InstructionField *parent)
virtual void setRelativePosition(int position)
void setGuardField(GuardField &field)
Definition MoveSlot.cc:171
bool hasSourceField() const
Definition MoveSlot.cc:264
bool hasDestinationField() const
Definition MoveSlot.cc:327

References MoveSlot::hasDestinationField(), MoveSlot::hasSourceField(), parent(), MoveSlot::setGuardField(), InstructionField::setParent(), and InstructionField::setRelativePosition().

Here is the call graph for this function:

◆ GuardField() [2/2]

GuardField::GuardField ( const ObjectState state,
MoveSlot parent 
)

The constructor.

Loads the state of the object from the given ObjectState tree.

Parameters
stateThe ObjectState tree.
parentThe parent move slot.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.
ObjectAlreadyExistsIf the parent move slot has a guard field already.

Definition at line 89 of file GuardField.cc.

90 : InstructionField(state, &parent), alwaysTrue_(NULL), alwaysFalse_(NULL) {
91 loadState(state);
92 setParent(NULL);
93 parent.setGuardField(*this);
95}
virtual void loadState(const ObjectState *state)

References loadState(), parent(), MoveSlot::setGuardField(), and InstructionField::setParent().

Here is the call graph for this function:

◆ ~GuardField()

GuardField::~GuardField ( )
virtual

The destructor.

Definition at line 100 of file GuardField.cc.

100 {
104 MoveSlot* oldParent = parent();
105 setParent(NULL);
106 assert(oldParent != NULL);
107 oldParent->unsetGuardField();
108}
#define assert(condition)
void deleteFUGuardEncodings()
void deleteGPRGuardEncodings()
void deleteUnconditionalGuardEncodings()
void unsetGuardField()
Definition MoveSlot.cc:189

References assert, deleteFUGuardEncodings(), deleteGPRGuardEncodings(), deleteUnconditionalGuardEncodings(), parent(), InstructionField::setParent(), and MoveSlot::unsetGuardField().

Here is the call graph for this function:

Member Function Documentation

◆ addGuardEncoding() [1/3]

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.

Parameters
encodingThe encoding to be added.
Exceptions
ObjectAlreadyExistsIf 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.

183 {
184 // verify that this is called from GPRGuardEncoding constructor
185 assert(encoding.parent() == NULL);
186
188 encoding.functionUnit(), encoding.port(),
189 encoding.isGuardInverted()) || isAssigned(encoding.encoding())) {
190 const string procName = "GuardField::addGuardEncoding";
191 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
192 }
193
194 fuGuards_.push_back(&encoding);
195}
std::string port() const
std::string functionUnit() const
GuardField * parent() const
unsigned int encoding() const
bool isGuardInverted() const
bool isAssigned(unsigned int encoding) const
FUGuardTable fuGuards_
FU guard encodings.
bool hasFUGuardEncoding(const std::string &fu, const std::string &port, bool inverted) const

References assert, GuardEncoding::encoding(), fuGuards_, FUGuardEncoding::functionUnit(), hasFUGuardEncoding(), isAssigned(), GuardEncoding::isGuardInverted(), GuardEncoding::parent(), and FUGuardEncoding::port().

Here is the call graph for this function:

◆ addGuardEncoding() [2/3]

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.

Parameters
encodingThe encoding to be added.
Exceptions
ObjectAlreadyExistsIf 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.

141 {
142 // verify that this is called from GPRGuardEncoding constructor
143 assert(encoding.parent() == NULL);
144
146 encoding.registerFile(), encoding.registerIndex(),
147 encoding.isGuardInverted()) || isAssigned(encoding.encoding())) {
148 const string procName = "GuardField::addGuardEncoding";
149 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
150 }
151
152 gprGuards_.push_back(&encoding);
153}
int registerIndex() const
std::string registerFile() const
bool hasGPRGuardEncoding(const std::string &regFile, int index, bool inverted) const
GPRGuardTable gprGuards_
GPR guard encodings.

References assert, GuardEncoding::encoding(), gprGuards_, hasGPRGuardEncoding(), isAssigned(), GuardEncoding::isGuardInverted(), GuardEncoding::parent(), GPRGuardEncoding::registerFile(), and GPRGuardEncoding::registerIndex().

Referenced by FUGuardEncoding::FUGuardEncoding(), FUGuardEncoding::FUGuardEncoding(), GPRGuardEncoding::GPRGuardEncoding(), GPRGuardEncoding::GPRGuardEncoding(), UnconditionalGuardEncoding::UnconditionalGuardEncoding(), and UnconditionalGuardEncoding::UnconditionalGuardEncoding().

Here is the call graph for this function:

◆ addGuardEncoding() [3/3]

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.

Parameters
encodingThe encoding to be added.
Exceptions
ObjectAlreadyExistsIf 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.

226 {
227 // verify that this is called from UnconditionalGuardEncoding constructor
228 assert(encoding.parent() == NULL);
229
231 isAssigned(encoding.encoding())) {
232 const string procName = "GuardField::addGuardEncoding";
233 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
234 }
235
236 if (encoding.isGuardInverted()) {
237 alwaysFalse_ = &encoding;
238 } else {
239 alwaysTrue_ = &encoding;
240 }
241}
bool hasUnconditionalGuardEncoding(bool inverted) const

References alwaysFalse_, alwaysTrue_, assert, GuardEncoding::encoding(), hasUnconditionalGuardEncoding(), isAssigned(), GuardEncoding::isGuardInverted(), and GuardEncoding::parent().

Here is the call graph for this function:

◆ childField()

InstructionField & GuardField::childField ( int  ) const
virtual

Always throws OutOfRange exception since guard field does not have any child fields.

Returns
Never returns.
Exceptions
OutOfRangeAlways thrown.

Reimplemented from InstructionField.

Definition at line 522 of file GuardField.cc.

522 {
523 const string procName = "GuardField::childField";
524 throw OutOfRange(__FILE__, __LINE__, procName);
525}

◆ childFieldCount()

int GuardField::childFieldCount ( ) const
virtual

Always returns 0 because guard field does not have any child fields.

Returns
0.

Implements InstructionField.

Definition at line 509 of file GuardField.cc.

509 {
510 return 0;
511}

◆ deleteFUGuardEncodings()

void GuardField::deleteFUGuardEncodings ( )
private

Deletes all the function unit port guard encodings from the guard field.

Definition at line 664 of file GuardField.cc.

664 {
666}
static void deleteAllItems(SequenceType &aSequence)

References SequenceTools::deleteAllItems(), and fuGuards_.

Referenced by loadState(), and ~GuardField().

Here is the call graph for this function:

◆ deleteGPRGuardEncodings()

void GuardField::deleteGPRGuardEncodings ( )
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().

Here is the call graph for this function:

◆ deleteUnconditionalGuardEncodings()

void GuardField::deleteUnconditionalGuardEncodings ( )
private

Deletes the unconditional guard encodings from the guard field.

Definition at line 673 of file GuardField.cc.

673 {
675 delete alwaysFalse_;
676 alwaysFalse_ = NULL;
677 }
679 delete alwaysTrue_;
680 alwaysTrue_ = NULL;
681 }
682}

References alwaysFalse_, alwaysTrue_, and hasUnconditionalGuardEncoding().

Referenced by ~GuardField().

Here is the call graph for this function:

◆ fuGuardEncoding() [1/2]

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.

Parameters
fuName of the function unit.
portName of the port.
invertedThe "invert" flag.
Returns
FUGuardEncoding of the given guard expression.

Definition at line 443 of file GuardField.cc.

446 {
447
448 for (FUGuardTable::const_iterator iter = fuGuards_.begin();
449 iter != fuGuards_.end(); iter++) {
450
451 FUGuardEncoding* encoding = *iter;
452 if (encoding->functionUnit() == fu &&
453 encoding->port() == port &&
454 encoding->isGuardInverted() == inverted) {
455 return *encoding;
456 }
457 }
458
460}
static NullFUGuardEncoding & instance()

References fuGuards_, FUGuardEncoding::functionUnit(), NullFUGuardEncoding::instance(), GuardEncoding::isGuardInverted(), and FUGuardEncoding::port().

Here is the call graph for this function:

◆ fuGuardEncoding() [2/2]

FUGuardEncoding & GuardField::fuGuardEncoding ( int  index) const

Returns the FUGuardEncoding at the given position.

Parameters
indexThe position.
Returns
The FU guard encoding.
Exceptions
OutOfRangeIf the given index is negative or not smaller than the number of FU guard encodings.

Definition at line 387 of file GuardField.cc.

387 {
388 if (index < 0 || index >= fuGuardEncodingCount()) {
389 const string procName = "GuardField::fuGuardEncoding";
390 throw OutOfRange(__FILE__, __LINE__, procName);
391 }
392
393 return *fuGuards_[index];
394}
int fuGuardEncodingCount() const

References fuGuardEncodingCount(), and fuGuards_.

Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMTester::conflictsWithGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

Here is the call graph for this function:

◆ fuGuardEncodingCount()

int GuardField::fuGuardEncodingCount ( ) const

Returns the number of guard expressions with function unit output term that are encoded in this field.

Returns
The number of guard expressions.

Definition at line 373 of file GuardField.cc.

373 {
374 return fuGuards_.size();
375}

References fuGuards_.

Referenced by BEMTester::conflictsWithGuardEncoding(), fuGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

◆ gprGuardEncoding() [1/2]

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.

Parameters
regFileName of the register file.
indexThe register index.
invertedThe "invert" flag.
Returns
GPRGuardEncoding of the given guard expression.

Definition at line 346 of file GuardField.cc.

349 {
350
351 for (GPRGuardTable::const_iterator iter = gprGuards_.begin();
352 iter != gprGuards_.end(); iter++) {
353
354 GPRGuardEncoding* encoding = *iter;
355 if (encoding->registerFile() == regFile &&
356 encoding->registerIndex() == index &&
357 encoding->isGuardInverted() == inverted) {
358 return *encoding;
359 }
360 }
361
363}
static NullGPRGuardEncoding & instance()

References gprGuards_, NullGPRGuardEncoding::instance(), GuardEncoding::isGuardInverted(), GPRGuardEncoding::registerFile(), and GPRGuardEncoding::registerIndex().

Here is the call graph for this function:

◆ gprGuardEncoding() [2/2]

GPRGuardEncoding & GuardField::gprGuardEncoding ( int  index) const

Returns the GPRGuardEncoding at the given position.

Parameters
indexThe position.
Returns
The GPR guard encoding.
Exceptions
OutOfRangeIf the given index is negative or not smaller than the number of GPR guard encodings.

Definition at line 290 of file GuardField.cc.

290 {
291 if (index < 0 || index >= gprGuardEncodingCount()) {
292 const string procName = "GuardField::gprGuardEncoding";
293 throw OutOfRange(__FILE__, __LINE__, procName);
294 }
295
296 return *gprGuards_[index];
297}
int gprGuardEncodingCount() const

References gprGuardEncodingCount(), and gprGuards_.

Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMTester::conflictsWithGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

Here is the call graph for this function:

◆ gprGuardEncodingCount()

int GuardField::gprGuardEncodingCount ( ) const

Returns the number of guard expressions with general purpose register term that are encoded in this field.

Returns
The number of guard expressions.

Definition at line 276 of file GuardField.cc.

276 {
277 return gprGuards_.size();
278}

References gprGuards_.

Referenced by BEMTester::conflictsWithGuardEncoding(), gprGuardEncoding(), isAssigned(), printGuardFieldEncodings(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

◆ hasFUGuardEncoding()

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.

Parameters
fuName of the function unit.
portName of the port.
invertedThe "invert" flag.
Returns
True if the guard field has an encoding for the given guard expression, otherwise false.

Definition at line 410 of file GuardField.cc.

413 {
414
415 for (FUGuardTable::const_iterator iter = fuGuards_.begin();
416 iter != fuGuards_.end(); iter++) {
417
418 FUGuardEncoding* encoding = *iter;
419 if (encoding->functionUnit() == fu &&
420 encoding->port() == port &&
421 encoding->isGuardInverted() == inverted) {
422 return true;
423 }
424 }
425
426 return false;
427}

References fuGuards_, FUGuardEncoding::functionUnit(), GuardEncoding::isGuardInverted(), and FUGuardEncoding::port().

Referenced by addGuardEncoding(), and BEMValidator::checkGuardField().

Here is the call graph for this function:

◆ hasGPRGuardEncoding()

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.

Parameters
regFileName of the register file.
indexThe register index.
invertedThe "invert" flag.
Returns
True if the guard field has an encoding for the given guard expression, otherwise false.

Definition at line 313 of file GuardField.cc.

316 {
317
318 for (GPRGuardTable::const_iterator iter = gprGuards_.begin();
319 iter != gprGuards_.end(); iter++) {
320
321 GPRGuardEncoding* encoding = *iter;
322 if (encoding->registerFile() == regFile &&
323 encoding->registerIndex() == index &&
324 encoding->isGuardInverted() == inverted) {
325 return true;
326 }
327 }
328
329 return false;
330}

References gprGuards_, GuardEncoding::isGuardInverted(), GPRGuardEncoding::registerFile(), and GPRGuardEncoding::registerIndex().

Referenced by addGuardEncoding(), and BEMValidator::checkGuardField().

Here is the call graph for this function:

◆ hasUnconditionalGuardEncoding()

bool GuardField::hasUnconditionalGuardEncoding ( bool  inverted) const

Tells whether the guard field has an encoding for unconditional guard.

Parameters
invertedThe "invert" flag.
Returns
True if there is an encoding for unconditional guard, otherwise false.

Definition at line 471 of file GuardField.cc.

471 {
472 if (inverted) {
473 return alwaysFalse_ != NULL;
474 } else {
475 return alwaysTrue_ != NULL;
476 }
477}

References alwaysFalse_, and alwaysTrue_.

Referenced by addGuardEncoding(), BEMValidator::checkGuardField(), BEMTester::conflictsWithGuardEncoding(), deleteUnconditionalGuardEncodings(), CodeCompressorPlugin::encodeNOP(), isAssigned(), printGuardFieldEncodings(), removeUnconditionalGuardEncoding(), saveState(), unconditionalGuardEncoding(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

◆ isAssigned()

bool GuardField::isAssigned ( unsigned int  encoding) const
private

Tells whether the given encoding is assigned to a guard expression.

Parameters
encodingThe encoding.
Returns
True if the encoding is assigned, otherwise false.

Definition at line 692 of file GuardField.cc.

692 {
693
694 int fuGuards = fuGuardEncodingCount();
695 int rfGuards = gprGuardEncodingCount();
696
697 for (int i = 0; i < fuGuards; i++) {
699 if (guard.encoding() == encoding) {
700 return true;
701 }
702 }
703
704 for (int i = 0; i < rfGuards; i++) {
706 if (guard.encoding() == encoding) {
707 return true;
708 }
709 }
710
712 if (unconditionalGuardEncoding(false).encoding() == encoding) {
713 return true;
714 }
715 }
716
718 if (unconditionalGuardEncoding(true).encoding() == encoding) {
719 return true;
720 }
721 }
722
723 return false;
724}
FUGuardEncoding & fuGuardEncoding(int index) const
UnconditionalGuardEncoding & unconditionalGuardEncoding(bool inverted) const
GPRGuardEncoding & gprGuardEncoding(int index) const

References GuardEncoding::encoding(), fuGuardEncoding(), fuGuardEncodingCount(), gprGuardEncoding(), gprGuardEncodingCount(), hasUnconditionalGuardEncoding(), and unconditionalGuardEncoding().

Referenced by addGuardEncoding(), addGuardEncoding(), and addGuardEncoding().

Here is the call graph for this function:

◆ loadState()

void GuardField::loadState ( const ObjectState state)
virtual

Loads the state of the object from the given ObjectState tree.

Parameters
stateThe ObjectState tree.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Reimplemented from InstructionField.

Definition at line 585 of file GuardField.cc.

585 {
586 const string procName = "GuardField::loadState";
587
588 if (state->name() != OSNAME_GUARD_FIELD) {
589 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
590 }
591
595
596 try {
597 for (int i = 0; i < state->childCount(); i++) {
598 ObjectState* child = state->child(i);
600 new FUGuardEncoding(child, *this);
601 } else if (child->name() ==
603 new GPRGuardEncoding(child, *this);
604 } else if (child->name() ==
606 OSNAME_UNCONDITIONAL_GUARD_ENCODING) {
607 new UnconditionalGuardEncoding(child, *this);
608 }
609 }
610 } catch (const Exception& exception) {
612 __FILE__, __LINE__, procName, exception.errorMessage());
613 }
614}
std::string errorMessage() const
Definition Exception.cc:123
static const std::string OSNAME_FU_GUARD_ENCODING
ObjectState name for FU guard encoding.
static const std::string OSNAME_GPR_GUARD_ENCODING
ObjectState name for GPR guard encoding.
static const std::string OSNAME_GUARD_FIELD
ObjectState name for guard field.
Definition GuardField.hh:99
virtual void loadState(const ObjectState *state)
ObjectState * child(int index) const
std::string name() const
int childCount() const

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().

Here is the call graph for this function:

◆ parent()

MoveSlot * GuardField::parent ( ) const

Returns the parent move slot.

Returns
The parent move slot.

Definition at line 117 of file GuardField.cc.

117 {
119 if (parent == NULL) {
120 return NULL;
121 } else {
122 MoveSlot* slot = dynamic_cast<MoveSlot*>(parent);
123 assert(slot != NULL);
124 return slot;
125 }
126}
InstructionField * parent() const

References assert, parent(), and InstructionField::parent().

Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMGenerator::addEncodings(), DefaultDecoderGenerator::findGuard(), DefaultDecoderGenerator::findGuard(), GuardField(), GuardField(), parent(), MoveSlot::setGuardField(), and ~GuardField().

Here is the call graph for this function:

◆ removeGuardEncoding() [1/2]

void GuardField::removeGuardEncoding ( FUGuardEncoding encoding)

Removes the given guard encoding.

This method is to be called from the destructor of FUGuardField.

Parameters
encodingThe encoding to be removed.

Definition at line 205 of file GuardField.cc.

205 {
206 // verify that this is called from GPRGuardEncoding destructor
207 assert(encoding.parent() == NULL);
209}
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)

References assert, fuGuards_, GuardEncoding::parent(), and ContainerTools::removeValueIfExists().

Here is the call graph for this function:

◆ removeGuardEncoding() [2/2]

void GuardField::removeGuardEncoding ( GPRGuardEncoding encoding)

Removes the given guard encoding.

This method is to be called from the destructor of GPRGuardField.

Parameters
encodingThe encoding to be removed.

Definition at line 163 of file GuardField.cc.

163 {
164 // verify that this is called from GPRGuardEncoding destructor
165 assert(encoding.parent() == NULL);
167}

References assert, gprGuards_, GuardEncoding::parent(), and ContainerTools::removeValueIfExists().

Referenced by FUGuardEncoding::~FUGuardEncoding(), and GPRGuardEncoding::~GPRGuardEncoding().

Here is the call graph for this function:

◆ removeUnconditionalGuardEncoding()

void GuardField::removeUnconditionalGuardEncoding ( UnconditionalGuardEncoding encoding)

Removes the encoding for unconditional guard.

This method is to be called from the destructor of UnconditionalGuardEncoding class.

Parameters
encodingThe encoding to be removed.

Definition at line 252 of file GuardField.cc.

253 {
254
256 assert(
258 &encoding);
259 assert(encoding.parent() == NULL);
260
261 if (encoding.isGuardInverted()) {
262 alwaysFalse_ = NULL;
263 } else {
264 alwaysTrue_ = NULL;
265 }
266}

References alwaysFalse_, alwaysTrue_, assert, hasUnconditionalGuardEncoding(), GuardEncoding::isGuardInverted(), GuardEncoding::parent(), and unconditionalGuardEncoding().

Referenced by UnconditionalGuardEncoding::~UnconditionalGuardEncoding().

Here is the call graph for this function:

◆ saveState()

ObjectState * GuardField::saveState ( ) const
virtual

Saves the state of the guard field to an ObjectState tree.

Returns
The newly created ObjectState tree.

Reimplemented from InstructionField.

Definition at line 622 of file GuardField.cc.

622 {
623
626
627 // add GPR guard encodings
628 for (int i = 0; i < gprGuardEncodingCount(); i++) {
630 state->addChild(enc.saveState());
631 }
632
633 // add FU guard encodings
634 for (int i = 0; i < fuGuardEncodingCount(); i++) {
636 state->addChild(enc.saveState());
637 }
638
639 // add unconditional guard encodings
642 }
645 }
646
647 return state;
648}
virtual ObjectState * saveState() const
virtual ObjectState * saveState() const
virtual ObjectState * saveState() const
virtual ObjectState * saveState() const
void setName(const std::string &name)
void addChild(ObjectState *child)

References ObjectState::addChild(), fuGuardEncoding(), fuGuardEncodingCount(), gprGuardEncoding(), gprGuardEncodingCount(), hasUnconditionalGuardEncoding(), OSNAME_GUARD_FIELD, FUGuardEncoding::saveState(), GPRGuardEncoding::saveState(), saveState(), InstructionField::saveState(), ObjectState::setName(), and unconditionalGuardEncoding().

Referenced by saveState().

Here is the call graph for this function:

◆ unconditionalGuardEncoding()

UnconditionalGuardEncoding & GuardField::unconditionalGuardEncoding ( bool  inverted) const

Returns the unconditional guard encoding.

Returns NullUnconditionalGuardEncoding instance if there is no encoding for unconditional guard.

Parameters
invertedThe "invert" flag.
Returns
The unconditional guard encoding.

Definition at line 490 of file GuardField.cc.

490 {
491 if (hasUnconditionalGuardEncoding(inverted)) {
492 if (inverted) {
493 return *alwaysFalse_;
494 } else {
495 return *alwaysTrue_;
496 }
497 } else {
499 }
500}
static NullUnconditionalGuardEncoding & instance()

References alwaysFalse_, alwaysTrue_, hasUnconditionalGuardEncoding(), and NullUnconditionalGuardEncoding::instance().

Referenced by BEMTester::conflictsWithGuardEncoding(), CodeCompressorPlugin::encodeNOP(), isAssigned(), printGuardFieldEncodings(), removeUnconditionalGuardEncoding(), saveState(), width(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

Here is the call graph for this function:

◆ width()

int GuardField::width ( ) const
virtual

Returns the bit width of the guard field.

Returns
Bit width of the field.

Implements InstructionField.

Definition at line 533 of file GuardField.cc.

533 {
534
535 int gprGuards = gprGuardEncodingCount();
536 int fuGuards = fuGuardEncodingCount();
537 int width(0);
538
539 for (int i = 0; i < gprGuards; i++) {
540 GPRGuardEncoding& encoding = gprGuardEncoding(i);
541 int requiredBits = MathTools::bitLength(encoding.encoding());
542 if (requiredBits > width) {
543 width = requiredBits;
544 }
545 }
546
547 for (int i = 0; i < fuGuards; i++) {
548 FUGuardEncoding& encoding = fuGuardEncoding(i);
549 int requiredBits = MathTools::bitLength(encoding.encoding());
550 if (requiredBits > width) {
551 width = requiredBits;
552 }
553 }
554
557 true);
558 int requiredBits = MathTools::bitLength(encoding.encoding());
559 if (requiredBits > width) {
560 width = requiredBits;
561 }
562 }
563
566 false);
567 int requiredBits = MathTools::bitLength(encoding.encoding());
568 if (requiredBits > width) {
569 width = requiredBits;
570 }
571 }
572
573 return width + extraBits();
574}
virtual int width() const
static unsigned int bitLength(long unsigned int number)

References MathTools::bitLength(), GuardEncoding::encoding(), InstructionField::extraBits(), fuGuardEncoding(), fuGuardEncodingCount(), gprGuardEncoding(), gprGuardEncodingCount(), hasUnconditionalGuardEncoding(), unconditionalGuardEncoding(), and width().

Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMTester::canAddComponentPriorityEncoding(), BEMTester::conflictsWithGuardEncoding(), CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), printGuardFieldEncodings(), printMoveSlotLayout(), width(), MoveSlot::width(), DefaultDecoderGenerator::writeInstructionDismembering(), and DefaultDecoderGenerator::writeMoveFieldSignals().

Here is the call graph for this function:

Member Data Documentation

◆ alwaysFalse_

UnconditionalGuardEncoding* GuardField::alwaysFalse_
private

Unconditional guard encoding for always-false expression.

Definition at line 119 of file GuardField.hh.

Referenced by addGuardEncoding(), deleteUnconditionalGuardEncodings(), hasUnconditionalGuardEncoding(), removeUnconditionalGuardEncoding(), and unconditionalGuardEncoding().

◆ alwaysTrue_

UnconditionalGuardEncoding* GuardField::alwaysTrue_
private

Unconditional guard encoding for always-true expression.

Definition at line 117 of file GuardField.hh.

Referenced by addGuardEncoding(), deleteUnconditionalGuardEncodings(), hasUnconditionalGuardEncoding(), removeUnconditionalGuardEncoding(), and unconditionalGuardEncoding().

◆ fuGuards_

FUGuardTable GuardField::fuGuards_
private

◆ gprGuards_

GPRGuardTable GuardField::gprGuards_
private

◆ OSNAME_GUARD_FIELD

const std::string GuardField::OSNAME_GUARD_FIELD = "guard_field"
static

The documentation for this class was generated from the following files: