OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
- Static Public Attributes inherited from TTAMachine::Component
static const std::string OSNAME_COMPONENT = "component"
 ObjectState name for component.
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for the name of the component.
 

Private Types

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

Private Member Functions

void deleteAllSlots ()
 

Private Attributes

SlotTable slots_
 Contains all the slots of the instruction template.
 

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}
Component(const std::string &name)
virtual TCEString name() const
virtual void setMachine(Machine &machine)

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}
virtual void loadState(const ObjectState *state)
virtual boost::format text(int textId)

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}
virtual Machine * machine() const
virtual void ensureRegistration(const Component &component) const
SlotTable slots_
Contains all the slots of the instruction template.
virtual TemplateSlot * slot(int index) const
TemplateSlot * templateSlot(const std::string &slotName) const
ComponentType * item(int index) const
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition Machine.cc:462
virtual BusNavigator busNavigator() const
Definition Machine.cc:356

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(), BlocksConnectIC::explore(), VLIWConnectIC::explore(), loadState(), and TemplateSlotDialog::onOK().

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}
static void deleteAllItems(SequenceType &aSequence)

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}
std::string slot() const
ImmediateUnit * destination() const

References TTAMachine::TemplateSlot::destination(), TTAMachine::TemplateSlot::slot(), 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
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
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}
std::string errorMessage() const
Definition Exception.cc:123
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
int intAttribute(const std::string &name) const
std::string name() const
int childCount() const
virtual void loadState(const ObjectState *state)
virtual void addSlot(const std::string &slotName, int width, ImmediateUnit &dstUnit)
static const std::string OSNAME_INSTRUCTION_TEMPLATE
ObjectState name for instruction template.
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
Navigator< ImmediateUnit > ImmediateUnitNavigator
Navigator type for ImmediateUnitNavigator.
Definition Machine.hh:223
static const std::string OSNAME_TEMPLATE_SLOT
ObjectState name for template slot.
static const std::string OSKEY_SLOT
ObjectState attribute key for slot name.
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination.
static const std::string OSKEY_WIDTH
ObjectState attribute key for bit width.

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(), TTAMachine::Component::name(), ObjectState::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}
#define assert(condition)
static bool deleteValueIfExists(ContainerType &aContainer, const ElementType &aKey)

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

Referenced by TemplateListDialog::onDeleteSlot(), TemplateSlotDialog::onOK(), TTAMachine::Bus::unsetMachine(), and TTAMachine::ImmediateSlot::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}
void setName(const std::string &name)
void addChild(ObjectState *child)
virtual ObjectState * saveState() const
ObjectState * saveState() const

References ObjectState::addChild(), OSNAME_INSTRUCTION_TEMPLATE, TTAMachine::Component::saveState(), TTAMachine::TemplateSlot::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}
void internalSetMachine(Machine &machine)
virtual void addInstructionTemplate(InstructionTemplate &instrTempl)
Definition Machine.cc:275

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

Referenced by InstructionTemplate(), and 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}
virtual void setName(const std::string &name)

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}
#define __func__

References __func__, and slots_.

Referenced by addSlot(), BusBroker::buildResources(), destinationOfSlot(), destinationUsesSlot(), isOneOfDestinations(), BEMGenerator::maxLongImmSlotWidth(), numberOfDestinations(), numberOfSlots(), ImmediateGenerator::printImmediateTemplates(), removeSlot(), removeSlots(), slotOfDestination(), supportedWidth(), 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}
virtual int numberOfSlots(const ImmediateUnit &dstUnit) const

References assert, TTAMachine::TemplateSlot::destination(), numberOfSlots(), TTAMachine::TemplateSlot::slot(), 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

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

Returns
The bit width.

Reimplemented in TTAMachine::NullInstructionTemplate.

Definition at line 427 of file InstructionTemplate.cc.

427 {
428
429 int maxWidth(0);
430
433 for (int i = 0; i < iuNav.count(); i++) {
434 ImmediateUnit* iu = iuNav.item(i);
435 if (supportedWidth(*iu) > maxWidth) {
436 maxWidth = supportedWidth(*iu);
437 }
438 }
439
440 return maxWidth;
441}

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), and supportedWidth().

Referenced by TTAProgram::Instruction::addImmediate(), ITemplateBroker::assign(), ITemplateBroker::assignImmediate(), MachineInfo::canEncodeImmediateInteger(), POMValidator::checkLongImmediates(), TTAProgram::TPEFProgramFactory::createInstruction(), CodeCompressorPlugin::encodeLongImmediate(), TTAProgram::TPEFProgramFactory::findInstrTemplate(), ITemplateBroker::findITemplates(), ImmediateGenerator::printImmediateTemplates(), TTAProgram::Instruction::setInstructionTemplate(), supportedWidth(), TemplateListDialog::updateSlotList(), TTAMachine::ImmediateSlot::width(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().

Here is the call graph for this function:

◆ 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 TTAMachine::TemplateSlot::slot(), 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 {
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

Member Data Documentation

◆ OSNAME_INSTRUCTION_TEMPLATE

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

◆ slots_

SlotTable TTAMachine::InstructionTemplate::slots_
private

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