OpenASIP
2.0
|
#include <ITemplateBroker.hh>
Public Member Functions | |
ITemplateBroker (std::string, BusBroker &busBroker, unsigned int initiationInterval=0) | |
ITemplateBroker (std::string, BusBroker &busBroker, SimpleResourceManager *, unsigned int initiationInterval=0) | |
virtual | ~ITemplateBroker () |
virtual bool | isAnyResourceAvailable (int, const MoveNode &, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override |
virtual SchedulingResourceSet | allAvailableResources (int, const MoveNode &, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcUnit, const TTAMachine::FunctionUnit *dstUnit, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override |
virtual void | assign (int cycle, MoveNode &node, SchedulingResource &res, int immWriteCycle, int immRegIndex) override |
virtual void | unassign (MoveNode &node) override |
virtual int | earliestCycle (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcUnit, const TTAMachine::FunctionUnit *dstUnit, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override |
virtual int | latestCycle (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcUnit, const TTAMachine::FunctionUnit *dstUnit, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override |
virtual bool | isAlreadyAssigned (int cycle, const MoveNode &node, const TTAMachine::Bus *preassignedBus) const override |
virtual bool | isApplicable (const MoveNode &node, const TTAMachine::Bus *) const override |
virtual void | buildResources (const TTAMachine::Machine &target) override |
virtual void | setupResourceLinks (const ResourceMapper &mapper) override |
virtual bool | isITemplateBroker () const override |
virtual TTAProgram::Instruction * | instruction (int cycle) |
virtual void | loseInstructionOwnership (int cycle) |
virtual bool | isTemplateAvailable (int, std::shared_ptr< TTAProgram::Immediate >) const |
void | clearOldResources () |
void | clear () override |
Public Member Functions inherited from ResourceBroker | |
ResourceBroker (std::string, unsigned int initiationInterval=0) | |
virtual | ~ResourceBroker () |
virtual SchedulingResource & | availableResource (int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const |
virtual bool | isAvailable (SchedulingResource &des, const MoveNode &node, int cycle, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const |
SchedulingResource * | resourceOf (const TTAMachine::MachinePart &mp) const |
virtual const TTAMachine::MachinePart & | machinePartOf (const SchedulingResource &r) const |
bool | hasResourceOf (const TTAMachine::MachinePart &mp) const |
bool | hasResource (const SchedulingResource &r) const |
int | resourceCount () const |
virtual bool | isBusBroker () const |
virtual bool | isIUBroker () const |
virtual bool | isExecutionPipelineBroker () const |
void | validateResources () const |
virtual std::string | brokerName () const |
void | resources (ResourceSet &contents) |
virtual void | setInitiationInterval (unsigned int cycles) |
virtual void | setMaxCycle (unsigned int) |
Private Types | |
typedef std::vector< std::shared_ptr< const TTAProgram::Move > > | Moves |
typedef std::vector< std::shared_ptr< const TTAProgram::Immediate > > | Immediates |
Private Member Functions | |
SchedulingResourceSet | findITemplates (int, Moves &, Immediates &) const |
void | assignImmediate (int, std::shared_ptr< TTAProgram::Immediate >) |
void | unassignImmediate (int, const TTAMachine::ImmediateUnit &) |
bool | isImmediateInTemplate (int, std::shared_ptr< TTAProgram::Immediate >) const |
void | reselectTemplate (TTAProgram::Instruction &ins, int cycle) |
Private Attributes | |
std::vector< TTAMachine::Bus * > | slots_ |
Move/immediate slots. More... | |
std::map< int, TTAProgram::Instruction * > | instructions_ |
cycle/instruction More... | |
std::map< const MoveNode *, TTAProgram::Instruction *, MoveNode::Comparator > | oldParentInstruction_ |
MoveNode/ original parent instruction. More... | |
std::map< const MoveNode *, int, GraphNode::Comparator > | immediateCycles_ |
Record cycle for MoveNodes that needed immediate writes, IU broker restores immediates before the template broker is called so we need to explicitely find the Immediate to remove it from template. More... | |
std::map< const MoveNode *, std::shared_ptr< TTAProgram::Immediate >, GraphNode::Comparator > | immediateValues_ |
std::map< int, bool > | instructionsNotOwned_ |
SimpleResourceManager * | rm_ |
BusBroker & | busBroker_ |
Additional Inherited Members | |
Public Types inherited from ResourceBroker | |
typedef std::set< SchedulingResource * > | ResourceSet |
Protected Types inherited from ResourceBroker | |
typedef std::map< const TTAMachine::MachinePart *, SchedulingResource *, TTAMachine::MachinePart::Comparator > | ResourceMap |
typedef std::map< const MoveNode *, SchedulingResource *, MoveNode::Comparator > | MoveResMap |
Protected Member Functions inherited from ResourceBroker | |
void | setResourceMapper (const ResourceMapper &mapper) |
const ResourceMapper & | resourceMapper () const |
unsigned int | instructionIndex (unsigned int) const |
void | addResource (const TTAMachine::MachinePart &mp, SchedulingResource *res) |
Protected Attributes inherited from ResourceBroker | |
unsigned int | initiationInterval_ |
ResourceMap | resMap_ |
const ResourceMapper * | resourceMapper_ |
MoveResMap | assignedResources_ |
std::string | brokerName_ |
ITemplate broker.
Definition at line 65 of file ITemplateBroker.hh.
|
private |
Definition at line 124 of file ITemplateBroker.hh.
|
private |
Definition at line 123 of file ITemplateBroker.hh.
ITemplateBroker::ITemplateBroker | ( | std::string | name, |
BusBroker & | busBroker, | ||
unsigned int | initiationInterval = 0 |
||
) |
Constructor.
Definition at line 68 of file ITemplateBroker.cc.
ITemplateBroker::ITemplateBroker | ( | std::string | name, |
BusBroker & | busBroker, | ||
SimpleResourceManager * | rm, | ||
unsigned int | initiationInterval = 0 |
||
) |
Constructor.
Definition at line 77 of file ITemplateBroker.cc.
|
virtual |
Destructor.
Definition at line 89 of file ITemplateBroker.cc.
References instructions_, and instructionsNotOwned_.
|
overridevirtual |
Return all resources managed by this broker that can be assigned to the given node in the given cycle.
cycle | Cycle. |
node | Node. |
Reimplemented from ResourceBroker.
Definition at line 144 of file ITemplateBroker.cc.
References findITemplates(), MoveNode::immediatePtr(), ResourceBroker::instructionIndex(), MoveNode::isImmediate(), MoveNode::isMove(), and MoveNode::movePtr().
Referenced by isAnyResourceAvailable().
|
overridevirtual |
Assigns instruction template resource to the parent instruction of the given node.
cycle | Cycle of node. |
node | Node. |
res | Instruction template resource to assign. |
WrongSubclass | If this broker does not recognise the given type of resource. |
InvalidData | If he given resource cannot be assigned to given node or no corresponding machine part is found. |
Implements ResourceBroker.
Definition at line 180 of file ITemplateBroker.cc.
References abortWithError, TTAProgram::Instruction::addImmediate(), TTAProgram::Instruction::addMove(), ITemplateResource::assign(), assignImmediate(), MapTools::containsKey(), TTAProgram::Terminal::copy(), TTAProgram::Immediate::destination(), TTAProgram::Instruction::immediate(), MoveNode::immediate(), TTAProgram::Instruction::immediateCount(), immediateCycles_, MoveNode::immediatePtr(), TTAProgram::Terminal::immediateUnit(), SimpleResourceManager::immediateValue(), immediateValues_, SimpleResourceManager::immediateWriteCycle(), ResourceBroker::instructionIndex(), instructions_, TTAProgram::Instruction::instructionTemplate(), SimValue::intValue(), TTAProgram::Terminal::isBasicBlockReference(), TTAProgram::Terminal::isCodeSymbolReference(), MoveNode::isImmediate(), isImmediateInTemplate(), TTAProgram::Move::isInInstruction(), TTAProgram::Terminal::isInstructionAddress(), MoveNode::isSourceImmediateRegister(), ResourceBroker::machinePartOf(), MoveNode::move(), MoveNode::movePtr(), TTAMachine::Component::name(), oldParentInstruction_, TTAProgram::Move::parent(), TTAProgram::Immediate::parent(), TTAProgram::Instruction::removeImmediate(), TTAProgram::Instruction::removeMove(), ResourceBroker::resourceOf(), rm_, TTAProgram::Instruction::setInstructionTemplate(), TTAProgram::Immediate::setValue(), TTAMachine::ImmediateUnit::signExtends(), TTAProgram::Move::source(), TTAMachine::InstructionTemplate::supportedWidth(), ITemplateResource::unassign(), SimValue::unsignedValue(), TTAProgram::TerminalImmediate::value(), TTAProgram::Immediate::value(), and SimValue::width().
|
private |
Assigns instruction template resource to the given instruction located in given cycle.
cycle | Cycle where to store immediate write. |
immediate | Immediate to be written in cycle |
WrongSubclass | If this broker does not recognise the given type of resource. |
InvalidData | If he given resource cannot be assigned to given node or no corresponding machine part is found. |
Definition at line 300 of file ITemplateBroker.cc.
References __func__, TTAProgram::Instruction::addImmediate(), assert, ITemplateResource::assign(), MapTools::containsKey(), TTAProgram::Immediate::destination(), TTAMachine::ImmediateUnit::extensionMode(), findITemplates(), TTAProgram::Terminal::immediateUnit(), ResourceBroker::instructionIndex(), instructions_, TTAProgram::Instruction::instructionTemplate(), INT_WORD_SIZE, SimValue::intValue(), TTAProgram::Terminal::isBasicBlockReference(), TTAProgram::Terminal::isCodeSymbolReference(), TTAProgram::Terminal::isInstructionAddress(), ResourceBroker::machinePartOf(), ResourceBroker::resourceOf(), ResourceBroker::resources(), TTAProgram::Instruction::setInstructionTemplate(), TTAProgram::Immediate::setValue(), TTAMachine::InstructionTemplate::supportedWidth(), ITemplateResource::unassign(), SimValue::unsignedValue(), TTAProgram::TerminalImmediate::value(), and TTAProgram::Immediate::value().
Referenced by assign().
|
overridevirtual |
Build all resource objects of the controlled type required to model scheduling resources of the given target processor.
This method cannot set up the resource links (dependent and related resources) of the constructed resource objects.
target | Target machine. |
Implements ResourceBroker.
Definition at line 596 of file ITemplateBroker.cc.
References ResourceBroker::addResource(), TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), ResourceBroker::initiationInterval_, TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and slots_.
|
overridevirtual |
Clears all bookkeeping for the broker.
the RM can then be reused for another basic block.
Reimplemented from ResourceBroker.
Definition at line 976 of file ITemplateBroker.cc.
References ResourceBroker::clear(), clearOldResources(), immediateCycles_, immediateValues_, instructions_, and instructionsNotOwned_.
void ITemplateBroker::clearOldResources | ( | ) |
Clears bookkeeping which is needed for unassigning previously assigned moves. After this call these cannot be unassigned, but new moves which are assigned after this call can still be unassigned.
Definition at line 966 of file ITemplateBroker.cc.
References oldParentInstruction_.
Referenced by clear(), and SimpleBrokerDirector::clearOldResources().
|
overridevirtual |
Return the earliest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.
cycle | Cycle. |
node | Node. |
Implements ResourceBroker.
Definition at line 500 of file ITemplateBroker.cc.
References abortWithError.
|
private |
Helper function, finds all templates that are applicable for current status of instruction and new node that needs to be added
moves | A set of moves which has to fit into template |
immediates | A set of immediates which has to fit into template |
Definition at line 738 of file ITemplateBroker.cc.
References TTAMachine::FunctionUnit::addressSpace(), assert, busBroker_, MapTools::containsKey(), ContainerTools::containsValue(), TTAMachine::Machine::controlUnit(), MachineInfo::defaultDataAddressSpace(), TTAMachine::AddressSpace::end(), TTAMachine::ImmediateUnit::extensionMode(), TTAProgram::Instruction::immediateCount(), TTAProgram::Instruction::immediatePtr(), SchedulingResourceSet::insert(), ResourceBroker::instructionIndex(), instructions_, INT_WORD_SIZE, TTAMachine::InstructionTemplate::isOneOfDestinations(), ResourceManager::machine(), TTAProgram::Instruction::moveCount(), TTAProgram::Instruction::movePtr(), MathTools::requiredBits(), MathTools::requiredBitsSigned(), ResourceBroker::resMap_, ResourceBroker::resourceOf(), rm_, SchedulingResourceSet::sort(), and TTAMachine::InstructionTemplate::supportedWidth().
Referenced by allAvailableResources(), assignImmediate(), instruction(), isTemplateAvailable(), and reselectTemplate().
|
virtual |
Returns an instruction at a given cycle.
cycle | Cycle for which to return instruction |
Definition at line 693 of file ITemplateBroker.cc.
References __func__, ITemplateResource::assign(), MapTools::containsKey(), SchedulingResourceSet::count(), findITemplates(), ResourceBroker::instructionIndex(), instructions_, ResourceBroker::machinePartOf(), SchedulingResourceSet::resource(), and TTAProgram::Instruction::setInstructionTemplate().
Referenced by SimpleBrokerDirector::instruction().
|
overridevirtual |
Return true if the given node is already assigned a resource of the type managed by this broker, and the assignment appears valid (that is, the broker has marked that resource as in use in the given cycle).
cycle | Cycle. |
node | Node. |
Implements ResourceBroker.
Definition at line 544 of file ITemplateBroker.cc.
References MapTools::containsKey(), MoveNode::immediate(), ResourceBroker::instructionIndex(), TTAProgram::Instruction::instructionTemplate(), MoveNode::isImmediate(), TTAProgram::Move::isInInstruction(), SchedulingResource::isInUse(), oldParentInstruction_, TTAProgram::Move::parent(), TTAProgram::Immediate::parent(), and ResourceBroker::resourceOf().
|
overridevirtual |
Return true if there's an instruction template available to be used on the given cycle for the given move.
If the given node contains a long immediate register read, the instruction template must be able to encode required bits for it.
cycle | Cycle where instruction template is used. |
node | Node which contains long immediate register read. |
Reimplemented from ResourceBroker.
Definition at line 115 of file ITemplateBroker.cc.
References allAvailableResources(), and ResourceBroker::instructionIndex().
|
overridevirtual |
Return true if the given node needs a resource of the type managed by this broker, false otherwise.
node | Node. |
Implements ResourceBroker.
Definition at line 582 of file ITemplateBroker.cc.
|
private |
Definition at line 920 of file ITemplateBroker.cc.
References MapTools::containsKey(), TTAProgram::Immediate::destination(), TTAProgram::Terminal::equals(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), instructions_, TTAProgram::TerminalImmediate::value(), and TTAProgram::Immediate::value().
Referenced by assign(), and unassign().
|
overridevirtual |
Return true always.
Reimplemented from ResourceBroker.
Definition at line 681 of file ITemplateBroker.cc.
|
virtual |
Tests if there is any instruction template available for immediate in given cycle
defCycle | cycle to test |
immediate | Immediate to test |
Definition at line 948 of file ITemplateBroker.cc.
References SchedulingResourceSet::count(), and findITemplates().
Referenced by SimpleBrokerDirector::isTemplateAvailable().
|
overridevirtual |
Return the latest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.
cycle | Cycle. |
node | Node. |
Implements ResourceBroker.
Definition at line 521 of file ITemplateBroker.cc.
References abortWithError.
|
virtual |
Transfer the instruction ownership away from this object,
If this method is called, resource manager does not delete it's instructions when it it destroyed.
Definition at line 908 of file ITemplateBroker.cc.
References instructionsNotOwned_.
Referenced by SimpleBrokerDirector::loseInstructionOwnership().
|
private |
Reselect the template to be the most optimal (most nop slots etc) Called always on unassign.
Definition at line 470 of file ITemplateBroker.cc.
References assert, ITemplateResource::assign(), findITemplates(), ResourceBroker::machinePartOf(), ResourceBroker::resources(), and TTAProgram::Instruction::setInstructionTemplate().
Referenced by unassign(), and unassignImmediate().
|
overridevirtual |
Complete resource initialisation by creating the references to other resources due to a dependency or a relation.
Use the given resource mapper to lookup dependent and related resources using machine parts as keys.
mapper | Resource mapper. |
Implements ResourceBroker.
Definition at line 625 of file ITemplateBroker.cc.
References __func__, SchedulingResource::addToDependentGroup(), TTAMachine::InstructionTemplate::destinationOfSlot(), Exception::errorMessageStack(), ResourceBroker::resMap_, ResourceMapper::resourceOf(), ResourceBroker::setResourceMapper(), slots_, and TTAMachine::InstructionTemplate::usesSlot().
|
overridevirtual |
Free the instruction template resource used in the parent instruction of the given node.
node | Node. |
Implements ResourceBroker.
Definition at line 381 of file ITemplateBroker.cc.
References abortWithError, TTAProgram::Instruction::addImmediate(), TTAProgram::Instruction::addMove(), MapTools::containsKey(), MoveNode::cycle(), MoveNode::immediate(), immediateCycles_, MoveNode::immediatePtr(), immediateValues_, MoveNode::isImmediate(), isImmediateInTemplate(), MoveNode::isMove(), MoveNode::isSourceConstant(), MoveNode::move(), MoveNode::movePtr(), oldParentInstruction_, TTAProgram::Move::parent(), TTAProgram::Immediate::parent(), TTAProgram::Instruction::removeImmediate(), TTAProgram::Instruction::removeMove(), reselectTemplate(), and unassignImmediate().
|
private |
Free the Instruction template used at this cycle. Sets new instruction template that does not use freed immediate slot.
If this broker is not applicable to the given node, or the node is not assigned a resource of the managed type, this method does nothing.
cycle | Cycle from where to unassign immediate |
immediate | Immediate to remove from cycle |
Definition at line 440 of file ITemplateBroker.cc.
References MapTools::containsKey(), TTAProgram::Immediate::destination(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Terminal::immediateUnit(), ResourceBroker::instructionIndex(), instructions_, TTAProgram::Instruction::instructionTemplate(), TTAMachine::Component::name(), TTAProgram::Instruction::removeImmediate(), reselectTemplate(), ResourceBroker::resourceOf(), and ITemplateResource::unassign().
Referenced by unassign().
|
private |
Definition at line 153 of file ITemplateBroker.hh.
Referenced by findITemplates().
|
private |
Record cycle for MoveNodes that needed immediate writes, IU broker restores immediates before the template broker is called so we need to explicitely find the Immediate to remove it from template.
Definition at line 144 of file ITemplateBroker.hh.
Referenced by assign(), clear(), and unassign().
|
private |
Definition at line 146 of file ITemplateBroker.hh.
Referenced by assign(), clear(), and unassign().
|
private |
cycle/instruction
Definition at line 135 of file ITemplateBroker.hh.
Referenced by assign(), assignImmediate(), clear(), findITemplates(), instruction(), isImmediateInTemplate(), unassignImmediate(), and ~ITemplateBroker().
|
private |
Definition at line 148 of file ITemplateBroker.hh.
Referenced by clear(), loseInstructionOwnership(), and ~ITemplateBroker().
|
private |
MoveNode/ original parent instruction.
Definition at line 138 of file ITemplateBroker.hh.
Referenced by assign(), clearOldResources(), isAlreadyAssigned(), and unassign().
|
private |
Definition at line 152 of file ITemplateBroker.hh.
Referenced by assign(), and findITemplates().
|
private |
Move/immediate slots.
Definition at line 133 of file ITemplateBroker.hh.
Referenced by buildResources(), and setupResourceLinks().