OpenASIP  2.0
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. 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...
 
UnconditionalGuardEncodingalwaysTrue_
 Unconditional guard encoding for always-true expression. More...
 
UnconditionalGuardEncodingalwaysFalse_
 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)
 

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);
64  setParent(&parent);
65 
66  // update the relative position of the field
67  int position(0);
68  if (parent.hasSourceField()) {
69  position++;
70  }
72  position++;
73  }
75 }

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);
94  setParent(&parent);
95 }

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 }

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 
187  if (hasFUGuardEncoding(
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 }

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 }

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

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 }

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 }

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.

655  {
657 }

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  {
674  if (hasUnconditionalGuardEncoding(true)) {
675  delete alwaysFalse_;
676  alwaysFalse_ = NULL;
677  }
678  if (hasUnconditionalGuardEncoding(false)) {
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 }

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 }

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 }

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 }

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++) {
698  FUGuardEncoding& guard = fuGuardEncoding(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 
711  if (hasUnconditionalGuardEncoding(false)) {
712  if (unconditionalGuardEncoding(false).encoding() == encoding) {
713  return true;
714  }
715  }
716 
717  if (hasUnconditionalGuardEncoding(true)) {
718  if (unconditionalGuardEncoding(true).encoding() == encoding) {
719  return true;
720  }
721  }
722 
723  return false;
724 }

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

Referenced by 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 }

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 }

References assert, and InstructionField::parent().

Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMGenerator::addEncodings(), DefaultDecoderGenerator::findGuard(), GuardField(), 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 }

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 
625  state->setName(OSNAME_GUARD_FIELD);
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
640  if (hasUnconditionalGuardEncoding(true)) {
642  }
643  if (hasUnconditionalGuardEncoding(false)) {
645  }
646 
647  return state;
648 }

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

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 }

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 
555  if (hasUnconditionalGuardEncoding(true)) {
557  true);
558  int requiredBits = MathTools::bitLength(encoding.encoding());
559  if (requiredBits > width) {
560  width = requiredBits;
561  }
562  }
563 
564  if (hasUnconditionalGuardEncoding(false)) {
566  false);
567  int requiredBits = MathTools::bitLength(encoding.encoding());
568  if (requiredBits > width) {
569  width = requiredBits;
570  }
571  }
572 
573  return width + extraBits();
574 }

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

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:
NullUnconditionalGuardEncoding::instance
static NullUnconditionalGuardEncoding & instance()
Definition: NullUnconditionalGuardEncoding.cc:64
GuardField::saveState
virtual ObjectState * saveState() const
Definition: GuardField.cc:622
GuardField::deleteFUGuardEncodings
void deleteFUGuardEncodings()
Definition: GuardField.cc:664
GuardField::hasFUGuardEncoding
bool hasFUGuardEncoding(const std::string &fu, const std::string &port, bool inverted) const
Definition: GuardField.cc:410
MoveSlot
Definition: MoveSlot.hh:60
FUGuardEncoding::saveState
virtual ObjectState * saveState() const
Definition: FUGuardEncoding.cc:143
ObjectStateLoadingException
Definition: Exception.hh:551
GuardField::fuGuardEncoding
FUGuardEncoding & fuGuardEncoding(int index) const
Definition: GuardField.cc:387
GPRGuardEncoding::registerFile
std::string registerFile() const
Definition: GPRGuardEncoding.cc:122
OutOfRange
Definition: Exception.hh:320
GuardEncoding::isGuardInverted
bool isGuardInverted() const
Definition: GuardEncoding.cc:101
GuardField::gprGuards_
GPRGuardTable gprGuards_
GPR guard encodings.
Definition: GuardField.hh:113
ObjectState
Definition: ObjectState.hh:59
GuardField::unconditionalGuardEncoding
UnconditionalGuardEncoding & unconditionalGuardEncoding(bool inverted) const
Definition: GuardField.cc:490
ObjectState::setName
void setName(const std::string &name)
FUGuardEncoding
Definition: FUGuardEncoding.hh:47
InstructionField
Definition: InstructionField.hh:43
InstructionField::saveState
virtual ObjectState * saveState() const
Definition: InstructionField.cc:268
assert
#define assert(condition)
Definition: Application.hh:86
GuardField::loadState
virtual void loadState(const ObjectState *state)
Definition: GuardField.cc:585
GuardField::gprGuardEncoding
GPRGuardEncoding & gprGuardEncoding(int index) const
Definition: GuardField.cc:290
MoveSlot::hasSourceField
bool hasSourceField() const
Definition: MoveSlot.cc:264
GPRGuardEncoding::saveState
virtual ObjectState * saveState() const
Definition: GPRGuardEncoding.cc:144
FUGuardEncoding::functionUnit
std::string functionUnit() const
Definition: FUGuardEncoding.cc:121
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
FUGuardEncoding::OSNAME_FU_GUARD_ENCODING
static const std::string OSNAME_FU_GUARD_ENCODING
ObjectState name for FU guard encoding.
Definition: FUGuardEncoding.hh:61
GuardField::isAssigned
bool isAssigned(unsigned int encoding) const
Definition: GuardField.cc:692
ContainerTools::removeValueIfExists
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)
NullGPRGuardEncoding::instance
static NullGPRGuardEncoding & instance()
Definition: NullGPRGuardEncoding.cc:64
MoveSlot::hasDestinationField
bool hasDestinationField() const
Definition: MoveSlot.cc:327
GuardField::parent
MoveSlot * parent() const
Definition: GuardField.cc:117
GuardField::hasGPRGuardEncoding
bool hasGPRGuardEncoding(const std::string &regFile, int index, bool inverted) const
Definition: GuardField.cc:313
InstructionField::setParent
void setParent(InstructionField *parent)
Definition: InstructionField.cc:282
InstructionField::parent
InstructionField * parent() const
Definition: InstructionField.cc:100
GuardField::fuGuards_
FUGuardTable fuGuards_
FU guard encodings.
Definition: GuardField.hh:115
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
ObjectState::addChild
void addChild(ObjectState *child)
Definition: ObjectState.cc:376
ObjectState::childCount
int childCount() const
GuardField::hasUnconditionalGuardEncoding
bool hasUnconditionalGuardEncoding(bool inverted) const
Definition: GuardField.cc:471
Exception
Definition: Exception.hh:54
GuardEncoding::encoding
unsigned int encoding() const
Definition: GuardEncoding.cc:112
ObjectState::name
std::string name() const
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
GuardField::OSNAME_GUARD_FIELD
static const std::string OSNAME_GUARD_FIELD
ObjectState name for guard field.
Definition: GuardField.hh:99
GuardField::deleteUnconditionalGuardEncodings
void deleteUnconditionalGuardEncodings()
Definition: GuardField.cc:673
GuardField::gprGuardEncodingCount
int gprGuardEncodingCount() const
Definition: GuardField.cc:276
NullFUGuardEncoding::instance
static NullFUGuardEncoding & instance()
Definition: NullFUGuardEncoding.cc:64
InstructionField::extraBits
int extraBits() const
Definition: InstructionField.cc:229
GPRGuardEncoding::OSNAME_GPR_GUARD_ENCODING
static const std::string OSNAME_GPR_GUARD_ENCODING
ObjectState name for GPR guard encoding.
Definition: GPRGuardEncoding.hh:61
GuardField::fuGuardEncodingCount
int fuGuardEncodingCount() const
Definition: GuardField.cc:373
ObjectAlreadyExists
Definition: Exception.hh:1002
InstructionField::loadState
virtual void loadState(const ObjectState *state)
Definition: InstructionField.cc:242
MathTools::bitLength
static unsigned int bitLength(long unsigned int number)
FUGuardEncoding::port
std::string port() const
Definition: FUGuardEncoding.cc:132
MoveSlot::unsetGuardField
void unsetGuardField()
Definition: MoveSlot.cc:189
GuardField::alwaysTrue_
UnconditionalGuardEncoding * alwaysTrue_
Unconditional guard encoding for always-true expression.
Definition: GuardField.hh:117
GuardField::alwaysFalse_
UnconditionalGuardEncoding * alwaysFalse_
Unconditional guard encoding for always-false expression.
Definition: GuardField.hh:119
GPRGuardEncoding::registerIndex
int registerIndex() const
Definition: GPRGuardEncoding.cc:133
MoveSlot::setGuardField
void setGuardField(GuardField &field)
Definition: MoveSlot.cc:171
GPRGuardEncoding
Definition: GPRGuardEncoding.hh:47
UnconditionalGuardEncoding
Definition: UnconditionalGuardEncoding.hh:47
InstructionField::InstructionField
InstructionField(InstructionField *parent)
Definition: InstructionField.cc:56
GuardField::width
virtual int width() const
Definition: GuardField.cc:533
InstructionField::setRelativePosition
virtual void setRelativePosition(int position)
Definition: InstructionField.cc:172
GuardField::deleteGPRGuardEncodings
void deleteGPRGuardEncodings()
Definition: GuardField.cc:655
GuardEncoding::parent
GuardField * parent() const
Definition: GuardEncoding.cc:90