OpenASIP
2.0
|
#include <InstructionTemplate.hh>
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 TemplateSlot * | slot (int index) const |
TemplateSlot * | templateSlot (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 ImmediateUnit * | destinationOfSlot (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 ObjectState * | saveState () const |
virtual void | loadState (const ObjectState *state) |
Public Member Functions inherited from TTAMachine::Component | |
virtual | ~Component () |
virtual TCEString | name () const |
virtual Machine * | machine () 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 () |
Definition at line 49 of file InstructionTemplate.hh.
|
private |
Container for TemplateSlots.
Definition at line 94 of file InstructionTemplate.hh.
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.
name | Name of the instruction template. |
owner | The machine to which the instruction template is going to be registered. |
ComponentAlreadyExists | If the given machine already contains another instruction template by the same name. |
InvalidName | If the given name is not a valid component name. |
Definition at line 69 of file InstructionTemplate.cc.
References setMachine().
TTAMachine::InstructionTemplate::InstructionTemplate | ( | const ObjectState * | state, |
Machine & | owner | ||
) |
Constructor.
Loads the state of the instruction template completely from the given ObjectState tree.
state | The ObjectState instance. |
owner | The machine to which the instruction template is going to be registered. |
ObjectStateLoadingException | If 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.
References loadState(), TTAMachine::Component::name(), setMachine(), Texts::TextGenerator::text(), MOMTextGenerator::TXT_IT_EXISTS_BY_NAME, and unsetMachine().
|
virtual |
Destructor.
Deletes all the slots of this instruction template too.
Definition at line 119 of file InstructionTemplate.cc.
References unsetMachine().
|
virtual |
Adds a template slot.
The given bit width must be greater than 0.
slotName | Transport bus in which (part of) part of the long immediate is stored. |
width | The number of long immediate bits that are encoded on the slot. |
dstUnit | Destination immediate unit. |
InstanceNotFound | If the machine does not have a bus or immediate slot with the given name. |
IllegalRegistration | If the given destination unit is not registered to the same machine. |
ComponentAlreadyExists | If the given slot is already in use. |
OutOfRange | If the given bit width is out of range. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 169 of file InstructionTemplate.cc.
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().
|
private |
Deletes all the template slots.
Definition at line 616 of file InstructionTemplate.cc.
References SequenceTools::deleteAllItems(), and slots_.
Referenced by loadState(), and unsetMachine().
|
virtual |
Returns the destination unit of the given slot.
slotName | Name of the slot. |
InstanceNotFound | If 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.
References TTAMachine::TemplateSlot::destination(), slot(), TTAMachine::TemplateSlot::slot(), and slots_.
Referenced by CodeCompressorPlugin::encodeLongImmediate(), ITemplateBroker::setupResourceLinks(), and TemplateListDialog::updateSlotList().
|
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.
slotName | Name of the slot. |
dstUnit | The destination immediate unit. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 280 of file InstructionTemplate.cc.
References TTAMachine::TemplateSlot::destination(), slot(), and templateSlot().
|
virtual |
Checks whether the instruction template is an empty instruction template which cannot have any slots.
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 494 of file InstructionTemplate.cc.
References slots_.
Referenced by CodeCompressorPlugin::instructionTemplate(), and ImmediateGenerator::printImmediateTemplates().
|
virtual |
Checks whether the given immediate unit is one of the immediate destinations in this instruction template.
dstUnit | The immediate unit to check. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 323 of file InstructionTemplate.cc.
References TTAMachine::TemplateSlot::destination(), slot(), and slots_.
Referenced by BEMGenerator::addLongImmDstRegisterFields(), BEMValidator::checkLImmDstRegisterFields(), TTAProgram::TPEFProgramFactory::findInstrTemplate(), ITemplateBroker::findITemplates(), IUBroker::setupResourceLinks(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().
|
virtual |
Loads its state from the given ObjectState tree.
state | The ObjectState tree. |
ObjectStateLoadingException | If the given ObjectState tree is invalid. |
Reimplemented from TTAMachine::Component.
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 558 of file InstructionTemplate.cc.
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().
|
virtual |
Returns how many immediate units are written in parallel by this instruction template.
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 300 of file InstructionTemplate.cc.
References TTAMachine::TemplateSlot::destination(), slot(), and slots_.
Referenced by TTAProgram::TPEFProgramFactory::findInstrTemplate(), and ImmediateGenerator::printImmediateTemplates().
|
virtual |
Tells the number of slots that are used to encode the long immediate which is written to the given destination unit.
dstUnit | The destination unit. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 367 of file InstructionTemplate.cc.
References TTAMachine::TemplateSlot::destination(), slot(), and slots_.
Referenced by CodeCompressorPlugin::encodeLongImmediate(), slotOfDestination(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().
|
virtual |
Removes the template slot which uses the given slot.
slotName | Name of the slot. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 201 of file InstructionTemplate.cc.
References assert, ContainerTools::deleteValueIfExists(), slot(), slots_, and templateSlot().
Referenced by TTAMachine::ImmediateSlot::unsetMachine(), and TTAMachine::Bus::unsetMachine().
|
virtual |
Removes the template slots that has the given immediate unit as destination unit.
dstUnit | The destination immediate unit. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 217 of file InstructionTemplate.cc.
References TTAMachine::TemplateSlot::destination(), slot(), and slots_.
Referenced by TTAMachine::ImmediateUnit::unsetMachine().
|
virtual |
Saves its state to an ObjectState tree.
Reimplemented from TTAMachine::Component.
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 536 of file InstructionTemplate.cc.
References ObjectState::addChild(), OSNAME_INSTRUCTION_TEMPLATE, TTAMachine::TemplateSlot::saveState(), TTAMachine::Component::saveState(), ObjectState::setName(), slots_, and templateSlot().
|
virtual |
Adds the instruction template to the given machine.
machine | Machine to which the instruction template is added. |
ComponentAlreadyExists | If 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.
References TTAMachine::Machine::addInstructionTemplate(), TTAMachine::Component::internalSetMachine(), and TTAMachine::Component::machine().
Referenced by InstructionTemplate().
|
virtual |
Sets the name of the instruction template.
name | Name of the instruction template. |
ComponentAlreadyExists | If an instruction template with the given name is already in the same machine. |
InvalidName | If 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.
References TTAMachine::Component::machine(), TTAMachine::Component::name(), and TTAMachine::Component::setName().
|
virtual |
Return the slot in the given index.
index | Index of slot. |
OutOfRange | If 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.
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().
|
virtual |
Return the total number of slots in the template.
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 236 of file InstructionTemplate.cc.
References slots_.
Referenced by BusBroker::buildResources(), BEMGenerator::maxLongImmSlotWidth(), ImmediateGenerator::printImmediateTemplates(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().
|
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.
dstUnit | The destination unit. |
index | The index. |
OutOfRange | If 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.
References assert, TTAMachine::TemplateSlot::destination(), numberOfSlots(), slot(), TTAMachine::TemplateSlot::slot(), and slots_.
Referenced by CodeCompressorPlugin::encodeLongImmediate(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().
|
virtual |
Returns the bit width of the widest long immediate that can be encoded by this instruction template.
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 427 of file InstructionTemplate.cc.
References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and TTAMachine::Component::machine().
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(), TemplateListDialog::updateSlotList(), TTAMachine::ImmediateSlot::width(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().
|
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.
dstUnit | The immediate unit. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 453 of file InstructionTemplate.cc.
References TTAMachine::TemplateSlot::destination(), slot(), slots_, and TTAMachine::TemplateSlot::width().
|
virtual |
Returns the bit width of the long immediate that can be encoded in the given slot by this instruction template.
slotName | Name of the slot. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 477 of file InstructionTemplate.cc.
References slot(), templateSlot(), and TTAMachine::TemplateSlot::width().
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.
slotName | Name of the slot. |
Definition at line 630 of file InstructionTemplate.cc.
References slot(), TTAMachine::TemplateSlot::slot(), and slots_.
Referenced by addSlot(), destinationUsesSlot(), removeSlot(), saveState(), supportedWidth(), and usesSlot().
|
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.
References assert, deleteAllSlots(), TTAMachine::Machine::deleteInstructionTemplate(), TTAMachine::Component::internalUnsetMachine(), and TTAMachine::Component::machine().
Referenced by InstructionTemplate(), and ~InstructionTemplate().
|
virtual |
Returns true if the instruction template uses the given slot.
slotName | Name of the slot. |
Reimplemented in TTAMachine::NullInstructionTemplate.
Definition at line 265 of file InstructionTemplate.cc.
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().
|
static |
ObjectState name for instruction template.
Definition at line 90 of file InstructionTemplate.hh.
Referenced by loadState(), TTAMachine::Machine::loadState(), and saveState().
|
private |
Contains all the slots of the instruction template.
Definition at line 98 of file InstructionTemplate.hh.
Referenced by addSlot(), deleteAllSlots(), destinationOfSlot(), isEmpty(), isOneOfDestinations(), numberOfDestinations(), numberOfSlots(), removeSlot(), removeSlots(), saveState(), slot(), slotCount(), slotOfDestination(), supportedWidth(), and templateSlot().