OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
TTAMachine::InstructionTemplate Class Reference

#include <InstructionTemplate.hh>

Inheritance diagram for TTAMachine::InstructionTemplate:
Inheritance graph
Collaboration diagram for TTAMachine::InstructionTemplate:
Collaboration graph

Public Member Functions

 InstructionTemplate (const std::string &name, Machine &owner)
 
 InstructionTemplate (const ObjectState *state, Machine &owner)
 
virtual ~InstructionTemplate ()
 
virtual void setName (const std::string &name)
 
virtual void addSlot (const std::string &slotName, int width, ImmediateUnit &dstUnit)
 
virtual void removeSlot (const std::string &slotName)
 
virtual void removeSlots (const ImmediateUnit &dstUnit)
 
virtual int slotCount () const
 
virtual TemplateSlotslot (int index) const
 
TemplateSlottemplateSlot (const std::string &slotName) const
 
virtual bool usesSlot (const std::string &slotName) const
 
virtual bool destinationUsesSlot (const std::string &slotName, const ImmediateUnit &dstUnit) const
 
virtual int numberOfDestinations () const
 
virtual bool isOneOfDestinations (const ImmediateUnit &dstUnit) const
 
virtual ImmediateUnitdestinationOfSlot (const std::string &slotName) const
 
virtual int numberOfSlots (const ImmediateUnit &dstUnit) const
 
virtual std::string slotOfDestination (const ImmediateUnit &dstUnit, int index) const
 
virtual int supportedWidth () const
 
virtual int supportedWidth (const ImmediateUnit &dstUnit) const
 
virtual int supportedWidth (const std::string &slotName) const
 
virtual bool isEmpty () const
 
virtual void setMachine (Machine &machine)
 
virtual void unsetMachine ()
 
virtual ObjectStatesaveState () const
 
virtual void loadState (const ObjectState *state)
 
- Public Member Functions inherited from TTAMachine::Component
virtual ~Component ()
 
virtual TCEString name () const
 
virtual Machinemachine () const
 
virtual void ensureRegistration (const Component &component) const
 
virtual bool isRegistered () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_INSTRUCTION_TEMPLATE = "i_template"
 ObjectState name for instruction template. More...
 
- Static Public Attributes inherited from TTAMachine::Component
static const std::string OSNAME_COMPONENT = "component"
 ObjectState name for component. More...
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for the name of the component. More...
 

Private Types

typedef std::vector< TemplateSlot * > SlotTable
 Container for TemplateSlots. More...
 

Private Member Functions

void deleteAllSlots ()
 

Private Attributes

SlotTable slots_
 Contains all the slots of the instruction template. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TTAMachine::Component
 Component (const std::string &name)
 
 Component (const ObjectState *state)
 
void internalSetMachine (Machine &machine)
 
void internalUnsetMachine ()
 
- Protected Member Functions inherited from TTAMachine::MachinePart
 MachinePart ()
 
virtual ~MachinePart ()
 

Detailed Description

Definition at line 49 of file InstructionTemplate.hh.

Member Typedef Documentation

◆ SlotTable

Container for TemplateSlots.

Definition at line 94 of file InstructionTemplate.hh.

Constructor & Destructor Documentation

◆ InstructionTemplate() [1/2]

TTAMachine::InstructionTemplate::InstructionTemplate ( const std::string &  name,
Machine owner 
)

Constructor.

Creates an empty instruction template. Add slots to make the instruction template non-empty. An empty instruction template represents the encoding format of instructions that don't specify any bits of a long immediate or any immediate register-write action.

Parameters
nameName of the instruction template.
ownerThe machine to which the instruction template is going to be registered.
Exceptions
ComponentAlreadyExistsIf the given machine already contains another instruction template by the same name.
InvalidNameIf the given name is not a valid component name.

Definition at line 69 of file InstructionTemplate.cc.

70  : Component(name) {
71  setMachine(owner);
72 }

References setMachine().

Here is the call graph for this function:

◆ InstructionTemplate() [2/2]

TTAMachine::InstructionTemplate::InstructionTemplate ( const ObjectState state,
Machine owner 
)

Constructor.

Loads the state of the instruction template completely from the given ObjectState tree.

Parameters
stateThe ObjectState instance.
ownerThe machine to which the instruction template is going to be registered.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid or if there exists an instruction template by the same as the upcoming name in the machine or if references to other components cannot be resolved.

Definition at line 90 of file InstructionTemplate.cc.

92  : Component(state) {
93  const string procName = "InstructionTemplate::InstructionTemplate";
94 
95  try {
96  setMachine(owner);
97  } catch (const ComponentAlreadyExists&) {
98  MOMTextGenerator textGenerator;
99  format errorMsg = textGenerator.text(
101  errorMsg % name();
103  __FILE__, __LINE__, procName, errorMsg.str());
104  }
105 
106  try {
107  loadState(state);
108  } catch (const ObjectStateLoadingException&) {
109  unsetMachine();
110  throw;
111  }
112 }

References loadState(), TTAMachine::Component::name(), setMachine(), Texts::TextGenerator::text(), MOMTextGenerator::TXT_IT_EXISTS_BY_NAME, and unsetMachine().

Here is the call graph for this function:

◆ ~InstructionTemplate()

TTAMachine::InstructionTemplate::~InstructionTemplate ( )
virtual

Destructor.

Deletes all the slots of this instruction template too.

Definition at line 119 of file InstructionTemplate.cc.

119  {
120  unsetMachine();
121 }

References unsetMachine().

Here is the call graph for this function:

Member Function Documentation

◆ addSlot()

void TTAMachine::InstructionTemplate::addSlot ( const std::string &  slotName,
int  width,
ImmediateUnit dstUnit 
)
virtual

Adds a template slot.

The given bit width must be greater than 0.

Parameters
slotNameTransport bus in which (part of) part of the long immediate is stored.
widthThe number of long immediate bits that are encoded on the slot.
dstUnitDestination immediate unit.
Exceptions
InstanceNotFoundIf the machine does not have a bus or immediate slot with the given name.
IllegalRegistrationIf the given destination unit is not registered to the same machine.
ComponentAlreadyExistsIf the given slot is already in use.
OutOfRangeIf the given bit width is out of range.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 169 of file InstructionTemplate.cc.

170  {
171  const string procName = "InstructionTemplate::addSlot";
172 
173  ensureRegistration(dstUnit);
174 
175  if (width <= 0) {
176  throw OutOfRange(__FILE__, __LINE__, procName);
177  }
178 
179  if (templateSlot(slotName) != NULL) {
180  throw ComponentAlreadyExists(__FILE__, __LINE__, procName);
181  }
182 
183  if (machine()->busNavigator().hasItem(slotName)) {
184  Bus* bus = machine()->busNavigator().item(slotName);
185  slots_.push_back(new TemplateSlot(*bus, width, dstUnit));
186  } else if (machine()->immediateSlotNavigator().hasItem(slotName)) {
187  ImmediateSlot* slot = machine()->immediateSlotNavigator().item(
188  slotName);
189  slots_.push_back(new TemplateSlot(*slot, width, dstUnit));
190  } else {
191  throw InstanceNotFound(__FILE__, __LINE__, procName);
192  }
193 }

References TTAMachine::Machine::busNavigator(), TTAMachine::Component::ensureRegistration(), TTAMachine::Machine::immediateSlotNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), slot(), slots_, and templateSlot().

Referenced by ImmediateGenerator::addSplitInsTemplate(), BlocksTranslator::BuildTTAModel(), VLIWConnectIC::explore(), BlocksConnectIC::explore(), and loadState().

Here is the call graph for this function:

◆ deleteAllSlots()

void TTAMachine::InstructionTemplate::deleteAllSlots ( )
private

Deletes all the template slots.

Definition at line 616 of file InstructionTemplate.cc.

616  {
618 }

References SequenceTools::deleteAllItems(), and slots_.

Referenced by loadState(), and unsetMachine().

Here is the call graph for this function:

◆ destinationOfSlot()

ImmediateUnit * TTAMachine::InstructionTemplate::destinationOfSlot ( const std::string &  slotName) const
virtual

Returns the destination unit of the given slot.

Parameters
slotNameName of the slot.
Returns
The destination unit.
Exceptions
InstanceNotFoundIf the instruction template does not use the given slot to encode long immediate.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 346 of file InstructionTemplate.cc.

346  {
347  for (SlotTable::const_iterator iter = slots_.begin();
348  iter != slots_.end(); iter++) {
349  TemplateSlot* slot = *iter;
350  if (slot->slot() == slotName) {
351  return slot->destination();
352  }
353  }
354 
355  const string procName = "InstructionTemplate::destinationOfSlot";
356  throw InstanceNotFound(__FILE__, __LINE__, procName);
357 }

References TTAMachine::TemplateSlot::destination(), slot(), TTAMachine::TemplateSlot::slot(), and slots_.

Referenced by CodeCompressorPlugin::encodeLongImmediate(), ITemplateBroker::setupResourceLinks(), and TemplateListDialog::updateSlotList().

Here is the call graph for this function:

◆ destinationUsesSlot()

bool TTAMachine::InstructionTemplate::destinationUsesSlot ( const std::string &  slotName,
const ImmediateUnit dstUnit 
) const
virtual

Returns true if the instruction template reserves the template slot given by the slotName input argument for long immediate bits that are written into a register of the given immediate unit.

Parameters
slotNameName of the slot.
dstUnitThe destination immediate unit.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 280 of file InstructionTemplate.cc.

282  {
283 
284  TemplateSlot* slot = templateSlot(slotName);
285  if (slot == NULL) {
286  return false;
287  }
288 
289  return (slot->destination() == &dstUnit);
290 }

References TTAMachine::TemplateSlot::destination(), slot(), and templateSlot().

Here is the call graph for this function:

◆ isEmpty()

bool TTAMachine::InstructionTemplate::isEmpty ( ) const
virtual

Checks whether the instruction template is an empty instruction template which cannot have any slots.

Returns
True if the instruction template is empty, otherwise false.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 494 of file InstructionTemplate.cc.

494  {
495  return (slots_.size() == 0);
496 }

References slots_.

Referenced by CodeCompressorPlugin::instructionTemplate(), and ImmediateGenerator::printImmediateTemplates().

◆ isOneOfDestinations()

bool TTAMachine::InstructionTemplate::isOneOfDestinations ( const ImmediateUnit dstUnit) const
virtual

Checks whether the given immediate unit is one of the immediate destinations in this instruction template.

Parameters
dstUnitThe immediate unit to check.
Returns
True if the given immediate unit is a destination, otherwise false.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 323 of file InstructionTemplate.cc.

324  {
325 
326  for (SlotTable::const_iterator iter = slots_.begin();
327  iter != slots_.end(); iter++) {
328  TemplateSlot* slot = *iter;
329  if (slot->destination() == &dstUnit) {
330  return true;
331  }
332  }
333  return false;
334 }

References TTAMachine::TemplateSlot::destination(), slot(), and slots_.

Referenced by BEMGenerator::addLongImmDstRegisterFields(), BEMValidator::checkLImmDstRegisterFields(), TTAProgram::TPEFProgramFactory::findInstrTemplate(), ITemplateBroker::findITemplates(), IUBroker::setupResourceLinks(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().

Here is the call graph for this function:

◆ loadState()

void TTAMachine::InstructionTemplate::loadState ( const ObjectState state)
virtual

Loads its state from the given ObjectState tree.

Parameters
stateThe ObjectState tree.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState tree is invalid.

Reimplemented from TTAMachine::Component.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 558 of file InstructionTemplate.cc.

558  {
559  const string procName = "InstructionTemplate::loadState";
560 
561  if (state->name() != OSNAME_INSTRUCTION_TEMPLATE) {
562  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
563  }
564 
565  deleteAllSlots();
566  Component::loadState(state);
567 
568  // add template slots
569  try {
570  for (int i = 0; i < state->childCount(); i++) {
571  MOMTextGenerator textGenerator;
572  ObjectState* child = state->child(i);
573 
574  string slotName = child->stringAttribute(
576  if (!machine()->busNavigator().hasItem(slotName) &&
577  !machine()->immediateSlotNavigator().hasItem(slotName)) {
578  format errorMsg = textGenerator.text(
580  errorMsg % slotName % name();
582  __FILE__, __LINE__, procName, errorMsg.str());
583  }
584 
585  if (child->name() == TemplateSlot::OSNAME_TEMPLATE_SLOT) {
586  int width = child->intAttribute(TemplateSlot::OSKEY_WIDTH);
587  string destination =
591  ImmediateUnit* iu = NULL;
592 
593  try {
594  iu = iuNav.item(destination);
595  } catch (const InstanceNotFound&) {
596  format errorMsg = textGenerator.text(
598  errorMsg % destination % name();
600  __FILE__, __LINE__, procName, errorMsg.str());
601  }
602 
603  addSlot(slotName, width, *iu);
604  }
605  }
606  } catch (const Exception& exception) {
608  __FILE__, __LINE__, procName, exception.errorMessage());
609  }
610 }

References addSlot(), ObjectState::child(), ObjectState::childCount(), deleteAllSlots(), Exception::errorMessage(), TTAMachine::Machine::immediateUnitNavigator(), ObjectState::intAttribute(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::loadState(), TTAMachine::Component::machine(), ObjectState::name(), TTAMachine::Component::name(), TTAMachine::TemplateSlot::OSKEY_DESTINATION, TTAMachine::TemplateSlot::OSKEY_SLOT, TTAMachine::TemplateSlot::OSKEY_WIDTH, OSNAME_INSTRUCTION_TEMPLATE, TTAMachine::TemplateSlot::OSNAME_TEMPLATE_SLOT, ObjectState::stringAttribute(), Texts::TextGenerator::text(), MOMTextGenerator::TXT_IT_REF_LOAD_ERR_IU, and MOMTextGenerator::TXT_IT_REF_LOAD_ERR_SLOT.

Referenced by InstructionTemplate().

Here is the call graph for this function:

◆ numberOfDestinations()

int TTAMachine::InstructionTemplate::numberOfDestinations ( ) const
virtual

Returns how many immediate units are written in parallel by this instruction template.

Returns
The number of immediate units.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 300 of file InstructionTemplate.cc.

300  {
301 
302  std::set<ImmediateUnit*> destinations;
303 
304  for (SlotTable::const_iterator iter = slots_.begin();
305  iter != slots_.end(); iter++) {
306  TemplateSlot* slot = *iter;
307  destinations.insert(slot->destination());
308  }
309 
310  return destinations.size();
311 }

References TTAMachine::TemplateSlot::destination(), slot(), and slots_.

Referenced by TTAProgram::TPEFProgramFactory::findInstrTemplate(), and ImmediateGenerator::printImmediateTemplates().

Here is the call graph for this function:

◆ numberOfSlots()

int TTAMachine::InstructionTemplate::numberOfSlots ( const ImmediateUnit dstUnit) const
virtual

Tells the number of slots that are used to encode the long immediate which is written to the given destination unit.

Parameters
dstUnitThe destination unit.
Returns
The number of slots.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 367 of file InstructionTemplate.cc.

367  {
368  int slots(0);
369  for (SlotTable::const_iterator iter = slots_.begin();
370  iter != slots_.end(); iter++) {
371  TemplateSlot* slot = *iter;
372  if (slot->destination() == &dstUnit) {
373  slots++;
374  }
375  }
376  return slots;
377 }

References TTAMachine::TemplateSlot::destination(), slot(), and slots_.

Referenced by CodeCompressorPlugin::encodeLongImmediate(), slotOfDestination(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().

Here is the call graph for this function:

◆ removeSlot()

void TTAMachine::InstructionTemplate::removeSlot ( const std::string &  slotName)
virtual

Removes the template slot which uses the given slot.

Parameters
slotNameName of the slot.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 201 of file InstructionTemplate.cc.

201  {
202  TemplateSlot* slot = templateSlot(slotName);
203  if (slot != NULL) {
205  assert(removed);
206  }
207 }

References assert, ContainerTools::deleteValueIfExists(), slot(), slots_, and templateSlot().

Referenced by TTAMachine::ImmediateSlot::unsetMachine(), and TTAMachine::Bus::unsetMachine().

Here is the call graph for this function:

◆ removeSlots()

void TTAMachine::InstructionTemplate::removeSlots ( const ImmediateUnit dstUnit)
virtual

Removes the template slots that has the given immediate unit as destination unit.

Parameters
dstUnitThe destination immediate unit.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 217 of file InstructionTemplate.cc.

217  {
218  for (SlotTable::iterator iter = slots_.begin(); iter != slots_.end();) {
219  TemplateSlot* slot = *iter;
220  if (slot->destination() == &dstUnit) {
221  delete slot;
222  SlotTable::iterator next = slots_.erase(iter);
223  iter = next;
224  } else {
225  iter++;
226  }
227  }
228 }

References TTAMachine::TemplateSlot::destination(), slot(), and slots_.

Referenced by TTAMachine::ImmediateUnit::unsetMachine().

Here is the call graph for this function:

◆ saveState()

ObjectState * TTAMachine::InstructionTemplate::saveState ( ) const
virtual

Saves its state to an ObjectState tree.

Returns
The newly created ObjectState tree.

Reimplemented from TTAMachine::Component.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 536 of file InstructionTemplate.cc.

536  {
539  SlotTable::const_iterator iter = slots_.begin();
540  while (iter != slots_.end()) {
541  TemplateSlot* templateSlot = *iter;
542  ObjectState* slotState = templateSlot->saveState();
543  state->addChild(slotState);
544  iter++;
545  }
546  return state;
547 }

References ObjectState::addChild(), OSNAME_INSTRUCTION_TEMPLATE, TTAMachine::TemplateSlot::saveState(), TTAMachine::Component::saveState(), ObjectState::setName(), slots_, and templateSlot().

Here is the call graph for this function:

◆ setMachine()

void TTAMachine::InstructionTemplate::setMachine ( Machine machine)
virtual

Adds the instruction template to the given machine.

Parameters
machineMachine to which the instruction template is added.
Exceptions
ComponentAlreadyExistsIf there already is another instruction template by the same name or another empty instruction template in the given machine.

Implements TTAMachine::Component.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 509 of file InstructionTemplate.cc.

509  {
512 }

References TTAMachine::Machine::addInstructionTemplate(), TTAMachine::Component::internalSetMachine(), and TTAMachine::Component::machine().

Referenced by InstructionTemplate().

Here is the call graph for this function:

◆ setName()

void TTAMachine::InstructionTemplate::setName ( const std::string &  name)
virtual

Sets the name of the instruction template.

Parameters
nameName of the instruction template.
Exceptions
ComponentAlreadyExistsIf an instruction template with the given name is already in the same machine.
InvalidNameIf the given name is not a valid component name.

Reimplemented from TTAMachine::Component.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 134 of file InstructionTemplate.cc.

134  {
135  if (name == this->name()) {
136  return;
137  }
138 
139  if (machine() != NULL) {
140  if (machine()->instructionTemplateNavigator().hasItem(name)) {
141  string procName = "InstructionTemplate::setName";
142  throw ComponentAlreadyExists(__FILE__, __LINE__, procName);
143  } else {
145  }
146  } else {
148  }
149 }

References TTAMachine::Component::machine(), TTAMachine::Component::name(), and TTAMachine::Component::setName().

Here is the call graph for this function:

◆ slot()

TemplateSlot * TTAMachine::InstructionTemplate::slot ( int  index) const
virtual

Return the slot in the given index.

Parameters
indexIndex of slot.
Returns
The slot in the given index.
Exceptions
OutOfRangeIf index is equal to or greater than the number of slots in the template.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 249 of file InstructionTemplate.cc.

249  {
250  if (index < 0 || index >= static_cast<int>(slots_.size())) {
251  string msg = "Slot index out of bounds.";
252  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
253  } else {
254  return slots_[index];
255  }
256 }

References __func__, and slots_.

Referenced by addSlot(), BusBroker::buildResources(), destinationOfSlot(), destinationUsesSlot(), isOneOfDestinations(), BEMGenerator::maxLongImmSlotWidth(), numberOfDestinations(), numberOfSlots(), ImmediateGenerator::printImmediateTemplates(), removeSlot(), removeSlots(), slotOfDestination(), supportedWidth(), templateSlot(), and usesSlot().

◆ slotCount()

int TTAMachine::InstructionTemplate::slotCount ( ) const
virtual

Return the total number of slots in the template.

Returns
The total number of slots in the template.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 236 of file InstructionTemplate.cc.

236  {
237  return slots_.size();
238 }

References slots_.

Referenced by BusBroker::buildResources(), BEMGenerator::maxLongImmSlotWidth(), ImmediateGenerator::printImmediateTemplates(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().

◆ slotOfDestination()

std::string TTAMachine::InstructionTemplate::slotOfDestination ( const ImmediateUnit dstUnit,
int  index 
) const
virtual

By the given index, returns the slot used to encode a part of the long immediate that is to be written to the given destination unit.

The slot are returned in the same order the parts of the long immediates are concatenated when they are written to the destination registers. The most significant end of the immediate is returned by index 0.

Parameters
dstUnitThe destination unit.
indexThe index.
Exceptions
OutOfRangeIf the given index is negative or not smaller than the number of slots that are written to the given destination unit.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 395 of file InstructionTemplate.cc.

396  {
397  if (index < 0 || index >= numberOfSlots(dstUnit)) {
398  const string procName = "InstructionTemplate::slotOfDestination";
399  throw OutOfRange(__FILE__, __LINE__, procName);
400  }
401 
402  int count(0);
403 
404  for (SlotTable::const_iterator iter = slots_.begin();
405  iter != slots_.end(); iter++) {
406  TemplateSlot* slot = *iter;
407  if (slot->destination() == &dstUnit) {
408  if (count == index) {
409  return slot->slot();
410  } else {
411  count++;
412  }
413  }
414  }
415 
416  assert(false);
417  return NULL;
418 }

References assert, TTAMachine::TemplateSlot::destination(), numberOfSlots(), slot(), TTAMachine::TemplateSlot::slot(), and slots_.

Referenced by CodeCompressorPlugin::encodeLongImmediate(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().

Here is the call graph for this function:

◆ supportedWidth() [1/3]

int TTAMachine::InstructionTemplate::supportedWidth ( ) const
virtual

◆ supportedWidth() [2/3]

int TTAMachine::InstructionTemplate::supportedWidth ( const ImmediateUnit dstUnit) const
virtual

Returns the bit width of the widest long immediate that can be encoded by this instruction template and that writes a register of the given immediate unit.

Parameters
dstUnitThe immediate unit.
Returns
The bit width.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 453 of file InstructionTemplate.cc.

453  {
454 
455  int totalWidth(0);
456 
457  for (SlotTable::const_iterator iter = slots_.begin();
458  iter != slots_.end(); iter++) {
459  TemplateSlot* slot = *iter;
460  if (slot->destination() == &dstUnit) {
461  totalWidth += slot->width();
462  }
463  }
464 
465  return totalWidth;
466 }

References TTAMachine::TemplateSlot::destination(), slot(), slots_, and TTAMachine::TemplateSlot::width().

Here is the call graph for this function:

◆ supportedWidth() [3/3]

int TTAMachine::InstructionTemplate::supportedWidth ( const std::string &  slotName) const
virtual

Returns the bit width of the long immediate that can be encoded in the given slot by this instruction template.

Parameters
slotNameName of the slot.
Returns
The bit width.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 477 of file InstructionTemplate.cc.

477  {
478  TemplateSlot* slot = templateSlot(slotName);
479  if (slot == NULL) {
480  return 0;
481  } else {
482  return slot->width();
483  }
484 }

References slot(), templateSlot(), and TTAMachine::TemplateSlot::width().

Here is the call graph for this function:

◆ templateSlot()

TemplateSlot * TTAMachine::InstructionTemplate::templateSlot ( const std::string &  slotName) const

Returns the template slot that uses slot with the given name.

Returns NULL if no template slot uses the given slot.

Parameters
slotNameName of the slot.
Returns
The template slot or NULL.

Definition at line 630 of file InstructionTemplate.cc.

630  {
631  for (SlotTable::const_iterator iter = slots_.begin();
632  iter != slots_.end(); iter++) {
633  TemplateSlot* slot = *iter;
634  if (slot->slot() == slotName) {
635  return slot;
636  }
637  }
638  return NULL;
639 }

References slot(), TTAMachine::TemplateSlot::slot(), and slots_.

Referenced by addSlot(), destinationUsesSlot(), removeSlot(), saveState(), supportedWidth(), and usesSlot().

Here is the call graph for this function:

◆ unsetMachine()

void TTAMachine::InstructionTemplate::unsetMachine ( )
virtual

Removes the instruction template from its machine.

The instruction template is also deleted because it cannot be alone. It must be registered to a machine.

Implements TTAMachine::Component.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 521 of file InstructionTemplate.cc.

521  {
522  deleteAllSlots();
523  Machine* mach = machine();
524  assert(mach != NULL);
526  mach->deleteInstructionTemplate(*this);
527 }

References assert, deleteAllSlots(), TTAMachine::Machine::deleteInstructionTemplate(), TTAMachine::Component::internalUnsetMachine(), and TTAMachine::Component::machine().

Referenced by InstructionTemplate(), and ~InstructionTemplate().

Here is the call graph for this function:

◆ usesSlot()

bool TTAMachine::InstructionTemplate::usesSlot ( const std::string &  slotName) const
virtual

Returns true if the instruction template uses the given slot.

Parameters
slotNameName of the slot.
Returns
True if the instruction template uses the given slot.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 265 of file InstructionTemplate.cc.

265  {
266  TemplateSlot* slot = templateSlot(slotName);
267  return (slot != NULL);
268 }

References slot(), and templateSlot().

Referenced by CodeCompressorPlugin::addBitsForImmediateSlot(), CodeCompressorPlugin::addBitsForMoveSlot(), TTAProgram::Instruction::addMove(), POMDisassembler::disassemble(), CodeCompressorPlugin::encodeLongImmediate(), TTAProgram::TPEFProgramFactory::findInstrTemplate(), TTAProgram::Instruction::setInstructionTemplate(), ITemplateBroker::setupResourceLinks(), MachineInfo::templatesUsesSlot(), MachineInfo::templatesUsingSlot(), and TemplateListDialog::updateSlotList().

Here is the call graph for this function:

Member Data Documentation

◆ OSNAME_INSTRUCTION_TEMPLATE

const string TTAMachine::InstructionTemplate::OSNAME_INSTRUCTION_TEMPLATE = "i_template"
static

ObjectState name for instruction template.

Definition at line 90 of file InstructionTemplate.hh.

Referenced by loadState(), TTAMachine::Machine::loadState(), and saveState().

◆ slots_

SlotTable TTAMachine::InstructionTemplate::slots_
private

The documentation for this class was generated from the following files:
TTAMachine::Component::internalUnsetMachine
void internalUnsetMachine()
TTAMachine::Component::setName
virtual void setName(const std::string &name)
Definition: MachinePart.cc:142
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
TTAMachine::TemplateSlot::OSKEY_SLOT
static const std::string OSKEY_SLOT
ObjectState attribute key for slot name.
Definition: TemplateSlot.hh:81
TTAMachine::TemplateSlot::saveState
ObjectState * saveState() const
Definition: TemplateSlot.cc:113
TTAMachine::InstructionTemplate::loadState
virtual void loadState(const ObjectState *state)
Definition: InstructionTemplate.cc:558
TTAMachine::TemplateSlot::OSNAME_TEMPLATE_SLOT
static const std::string OSNAME_TEMPLATE_SLOT
ObjectState name for template slot.
Definition: TemplateSlot.hh:79
ObjectStateLoadingException
Definition: Exception.hh:551
TTAMachine::InstructionTemplate::templateSlot
TemplateSlot * templateSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:630
TTAMachine::Component::ensureRegistration
virtual void ensureRegistration(const Component &component) const
Definition: MachinePart.cc:163
OutOfRange
Definition: Exception.hh:320
TTAMachine::Component::saveState
virtual ObjectState * saveState() const
Definition: MachinePart.cc:189
TTAMachine::InstructionTemplate::addSlot
virtual void addSlot(const std::string &slotName, int width, ImmediateUnit &dstUnit)
Definition: InstructionTemplate.cc:169
MOMTextGenerator::TXT_IT_REF_LOAD_ERR_SLOT
@ TXT_IT_REF_LOAD_ERR_SLOT
Definition: MOMTextGenerator.hh:70
ObjectState
Definition: ObjectState.hh:59
TTAMachine::TemplateSlot::OSKEY_WIDTH
static const std::string OSKEY_WIDTH
ObjectState attribute key for bit width.
Definition: TemplateSlot.hh:83
TTAMachine::InstructionTemplate::unsetMachine
virtual void unsetMachine()
Definition: InstructionTemplate.cc:521
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
ObjectState::setName
void setName(const std::string &name)
TTAMachine::Machine::addInstructionTemplate
virtual void addInstructionTemplate(InstructionTemplate &instrTempl)
Definition: Machine.cc:275
TTAMachine::InstructionTemplate::deleteAllSlots
void deleteAllSlots()
Definition: InstructionTemplate.cc:616
TTAMachine::Component::internalSetMachine
void internalSetMachine(Machine &machine)
TTAMachine::InstructionTemplate::setMachine
virtual void setMachine(Machine &machine)
Definition: InstructionTemplate.cc:509
MOMTextGenerator::TXT_IT_REF_LOAD_ERR_IU
@ TXT_IT_REF_LOAD_ERR_IU
Definition: MOMTextGenerator.hh:71
MOMTextGenerator::TXT_IT_EXISTS_BY_NAME
@ TXT_IT_EXISTS_BY_NAME
Definition: MOMTextGenerator.hh:69
assert
#define assert(condition)
Definition: Application.hh:86
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
TTAMachine::Component::Component
Component(const std::string &name)
Definition: MachinePart.cc:82
TTAMachine::InstructionTemplate::numberOfSlots
virtual int numberOfSlots(const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:367
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
TTAMachine::Component::loadState
virtual void loadState(const ObjectState *state)
Definition: MachinePart.cc:205
TTAMachine::TemplateSlot::destination
ImmediateUnit * destination() const
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::TemplateSlot::slot
std::string slot() const
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
TTAMachine::InstructionTemplate::supportedWidth
virtual int supportedWidth() const
Definition: InstructionTemplate.cc:427
Exception
Definition: Exception.hh:54
ObjectState::name
std::string name() const
TTAMachine::Machine::immediateSlotNavigator
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition: Machine.cc:462
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TTAMachine::Component::machine
virtual Machine * machine() const
MOMTextGenerator
Definition: MOMTextGenerator.hh:40
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
ComponentAlreadyExists
Definition: Exception.hh:510
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::TemplateSlot::width
int width() const
TTAMachine::InstructionTemplate::slot
virtual TemplateSlot * slot(int index) const
Definition: InstructionTemplate.cc:249
TTAMachine::InstructionTemplate::slots_
SlotTable slots_
Contains all the slots of the instruction template.
Definition: InstructionTemplate.hh:98
InstanceNotFound
Definition: Exception.hh:304
TTAMachine::InstructionTemplate::OSNAME_INSTRUCTION_TEMPLATE
static const std::string OSNAME_INSTRUCTION_TEMPLATE
ObjectState name for instruction template.
Definition: InstructionTemplate.hh:90
TTAMachine::Machine::ImmediateUnitNavigator
Navigator< ImmediateUnit > ImmediateUnitNavigator
Navigator type for ImmediateUnitNavigator.
Definition: Machine.hh:223
ContainerTools::deleteValueIfExists
static bool deleteValueIfExists(ContainerType &aContainer, const ElementType &aKey)
TTAMachine::TemplateSlot::OSKEY_DESTINATION
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination.
Definition: TemplateSlot.hh:85