OpenASIP 2.2
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
IUBroker Class Reference

#include <IUBroker.hh>

Inheritance diagram for IUBroker:
Inheritance graph
Collaboration diagram for IUBroker:
Collaboration graph

Classes

struct  less_width
 Functor for sorting result of allAvailable by register width. More...
 

Public Member Functions

 IUBroker (std::string)
 
 IUBroker (std::string, SimpleResourceManager *, unsigned int initiationInterval=0)
 
virtual ~IUBroker ()
 
bool isAnyResourceAvailable (int useCycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const override
 
virtual SchedulingResourceavailableResource (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 override
 
virtual SchedulingResourceSet allAvailableResources (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 void assign (int, MoveNode &, SchedulingResource &, 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 *srcFU, const TTAMachine::FunctionUnit *dstFU, 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 *srcFU, const TTAMachine::FunctionUnit *dstFU, 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 *preassignedBus) const override
 
virtual void buildResources (const TTAMachine::Machine &target) override
 
virtual void setupResourceLinks (const ResourceMapper &mapper) override
 
virtual bool isIUBroker () const override
 
virtual std::shared_ptr< TTAProgram::TerminalImmediateimmediateValue (const MoveNode &node) const
 
virtual int immediateWriteCycle (const MoveNode &node) const
 
void clearOldResources ()
 
- Public Member Functions inherited from ResourceBroker
 ResourceBroker (std::string, unsigned int initiationInterval=0)
 
virtual ~ResourceBroker ()
 
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
 
SchedulingResourceresourceOf (const TTAMachine::MachinePart &mp) const
 
virtual const TTAMachine::MachinePartmachinePartOf (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 isITemplateBroker () 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 clear ()
 
virtual void setMaxCycle (unsigned int)
 

Private Attributes

const TTAMachine::Machinetarget_
 Target machine.
 
SimpleResourceManagerrm_
 

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::ComparatorResourceMap
 
typedef std::map< const MoveNode *, SchedulingResource *, MoveNode::ComparatorMoveResMap
 
- Protected Member Functions inherited from ResourceBroker
void setResourceMapper (const ResourceMapper &mapper)
 
const ResourceMapperresourceMapper () 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 ResourceMapperresourceMapper_
 
MoveResMap assignedResources_
 
std::string brokerName_
 

Detailed Description

Immediate unit broker.

Definition at line 57 of file IUBroker.hh.

Constructor & Destructor Documentation

◆ IUBroker() [1/2]

IUBroker::IUBroker ( std::string  name)

Constructor.

Definition at line 63 of file IUBroker.cc.

63 :
64 ResourceBroker(name),
65 target_(NULL),
66 rm_(NULL) {
67}
SimpleResourceManager * rm_
Definition IUBroker.hh:136
const TTAMachine::Machine * target_
Target machine.
Definition IUBroker.hh:127

◆ IUBroker() [2/2]

IUBroker::IUBroker ( std::string  name,
SimpleResourceManager rm,
unsigned int  initiationInterval = 0 
)

Constructor.

Definition at line 72 of file IUBroker.cc.

73 :
74 ResourceBroker(name, initiationInterval),
75 target_(NULL), rm_(rm) {
76}

◆ ~IUBroker()

IUBroker::~IUBroker ( )
virtual

Destructor.

Definition at line 81 of file IUBroker.cc.

81 {
82}

Member Function Documentation

◆ allAvailableResources()

SchedulingResourceSet IUBroker::allAvailableResources ( int  useCycle,
const MoveNode node,
const TTAMachine::Bus bus,
const TTAMachine::FunctionUnit srcFU,
const TTAMachine::FunctionUnit dstFU,
int  immWriteCycle,
const TTAMachine::ImmediateUnit immu,
int  immRegIndex 
) const
overridevirtual

Return all resources managed by this broker that can be assigned to the given node in the given cycle.

Parameters
useCycleRead from immediate register by Node
nodeNode.
Returns
All resources managed by this broker that can be assigned to the given node in the given cycle.

Reimplemented from ResourceBroker.

Definition at line 149 of file IUBroker.cc.

155 {
156
157 int defCycle = useCycle;
158 if (immWriteCycle != -1) {
159 defCycle = immWriteCycle;
160 }
161
162 SchedulingResourceSet results;
163
164 // pre-split LIMM
165 if (node.move().source().isImmediateRegister()) {
166 const ImmediateUnit& iu =
167 node.move().source().immediateUnit();
168 IUResource* iuRes = static_cast<IUResource*>(resourceOf(iu));
169 if (iuRes->canAssign(useCycle, node)) {
170 results.insert(*iuRes);
171 }
172 return results;
173 }
174
175 std::vector<IUResource*> tmpResult;
176
177 // RM breaks if LIMM write and use are in same instruction.
178 int maxLimmDistance = MAX_LIMM_DISTANCE;
180 maxLimmDistance = std::min(maxLimmDistance, (int)initiationInterval_);
181 }
182 while (defCycle >= 0 && (useCycle - defCycle) < maxLimmDistance &&
183 tmpResult.empty()) {
184 ResourceMap::const_iterator resIter = resMap_.begin();
185 while (resIter != resMap_.end()) {
186 // TODO: why is this dynamic, not static cast?
187 IUResource* iuRes = dynamic_cast<IUResource*>((*resIter).second);
188 if (immu == NULL || resourceOf(*immu) == (*resIter).second) {
189 if (iuRes->canAssign(defCycle, useCycle, node, immRegIndex)) {
190 TerminalImmediate* tempImm =
191 dynamic_cast<TerminalImmediate*>(
192 node.move().source().copy());
193 const ImmediateUnit& iu =
194 dynamic_cast<const ImmediateUnit&>(
195 machinePartOf(*iuRes));
196 RFPort* port = iu.port(0);
197 TerminalRegister* newSrc = new TerminalRegister(*port, 0);
198 auto imm = std::make_shared<Immediate>(tempImm, newSrc);
199 if (rm_->isTemplateAvailable(defCycle, imm)) {
200 tmpResult.push_back(iuRes);
201 }
202 }
203 }
204 resIter++;
205 }
206 sort(tmpResult.begin(), tmpResult.end(), less_width());
207 std::vector<IUResource*>::iterator tmpItr = tmpResult.begin();
208 while (tmpItr != tmpResult.end()) {
209 results.insert(*(*tmpItr));
210 tmpItr++;
211 }
212 if (immWriteCycle != -1) {
213 break;
214 }
215 defCycle--;
216 }
217 return results;
218}
static const int MAX_LIMM_DISTANCE
Definition IUBroker.cc:58
virtual bool canAssign(const int, const MoveNode &) const override
TTAProgram::Move & move()
SchedulingResource * resourceOf(const TTAMachine::MachinePart &mp) const
unsigned int initiationInterval_
virtual const TTAMachine::MachinePart & machinePartOf(const SchedulingResource &r) const
ResourceMap resMap_
void insert(SchedulingResource &resource)
virtual bool isTemplateAvailable(int, std::shared_ptr< TTAProgram::Immediate >) const
virtual RFPort * port(const std::string &name) const
Terminal & source() const
Definition Move.cc:302
virtual Terminal * copy() const =0
virtual bool isImmediateRegister() const
Definition Terminal.cc:97
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
Definition Terminal.cc:240

References IUResource::canAssign(), TTAProgram::Terminal::copy(), TTAProgram::Terminal::immediateUnit(), ResourceBroker::initiationInterval_, SchedulingResourceSet::insert(), TTAProgram::Terminal::isImmediateRegister(), SimpleResourceManager::isTemplateAvailable(), ResourceBroker::machinePartOf(), MAX_LIMM_DISTANCE, MoveNode::move(), TTAMachine::BaseRegisterFile::port(), ResourceBroker::resMap_, ResourceBroker::resourceOf(), rm_, and TTAProgram::Move::source().

Referenced by availableResource(), and isAnyResourceAvailable().

Here is the call graph for this function:

◆ assign()

void IUBroker::assign ( int  useCycle,
MoveNode node,
SchedulingResource res,
int  immWriteCycle,
int  immRegIndex 
)
overridevirtual

Mark given resource as in use for the given node, and assign the corresponding machine part (if applicable) to the node's move.

Parameters
useCycleCycle in which immediate register is read by Node
nodeMoveNode that reads a register
resLong immediate register file resource
immWriteCycleforced def cycle for the immediate. Not forced if -1
Exceptions
WrongSubclassIf this broker does not recognise the given type of resource.
InvalidParametersIf he given resource cannot be assigned to given node or no corresponding machine part is found.

Implements ResourceBroker.

Definition at line 233 of file IUBroker.cc.

235 {
236
237 int defCycle = useCycle;
238 if (immWriteCycle != -1) {
239 defCycle = immWriteCycle;
240 }
241
242 IUResource& iuRes = dynamic_cast<IUResource&>(res);
243 Move& move = const_cast<MoveNode&>(node).move();
244
245 if (hasResource(res)) {
246 ImmediateUnit& iu =
247 const_cast<ImmediateUnit&>(
248 dynamic_cast<const ImmediateUnit&>(machinePartOf(res)));
249
250 // pre-split LIMM
251 if (node.move().source().isImmediateRegister()) {
252 const ImmediateUnit& iuSrc =
253 node.move().source().immediateUnit();
254 assert(&iu == &iuSrc);
255 IUResource* iuRes = static_cast<IUResource*>(resourceOf(iu));
256 iuRes->assign(useCycle, node);
257 assignedResources_.insert(
258 std::pair<const MoveNode*, SchedulingResource*>(&node, iuRes));
259
260 } else {
261 int index = -1;
262 // IURes assign method will set index to the register
263 // in IU that was assigned for immediate read
264
265 while (defCycle >= 0 && (useCycle - defCycle) < MAX_LIMM_DISTANCE) {
266 if (iuRes.canAssign(defCycle, useCycle, node, immRegIndex)) {
267 TerminalImmediate* tempImm =
268 dynamic_cast<TerminalImmediate*>(
269 node.move().source().copy());
270 const ImmediateUnit& iu =
271 dynamic_cast<const ImmediateUnit&>(machinePartOf(iuRes));
272 RFPort* port = iu.port(0);
273 TerminalRegister* newSrc = new TerminalRegister(*port, 0);
274 auto imm = std::make_shared<Immediate>(tempImm, newSrc);
275 if (rm_->isTemplateAvailable(defCycle, imm)) {
276 break;
277 }
278 }
279 if (immWriteCycle != -1) {
280 std::cerr << "Use cycle: " << useCycle << " imm cycle: "
281 << immWriteCycle << " node: " << node.toString()
282 << std::endl;
283 assert(NULL && "Can't assign forced imm write at cycle");
284 }
285 defCycle--;
286 }
287 // is index forced?
288 if (immRegIndex != -1)
289 index = immRegIndex;
290 iuRes.assign(defCycle, useCycle, node, index);
291
292
293 // temporary, source() has to know some port of IU to
294 // be able to identify which IU Move uses.
295 // OutputPSocket broker will assign a free port later
296 RFPort* port = iu.port(0);
297 assignedResources_.insert(
298 std::pair<const MoveNode*, SchedulingResource*>(&node, &iuRes));
299 TerminalRegister* newSrc = new TerminalRegister(*port, index);
300 move.setSource(newSrc);
301 }
302 } else {
303 string msg = "Broker does not contain given resource.";
304 throw InvalidData(__FILE__, __LINE__, __func__, msg);
305 }
306}
#define __func__
#define assert(condition)
virtual void assign(const int cycle, MoveNode &node) override
std::string toString() const
Definition MoveNode.cc:576
MoveResMap assignedResources_
bool hasResource(const SchedulingResource &r) const
void setSource(Terminal *src)
Definition Move.cc:312

References __func__, assert, IUResource::assign(), ResourceBroker::assignedResources_, IUResource::canAssign(), TTAProgram::Terminal::copy(), ResourceBroker::hasResource(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::isImmediateRegister(), SimpleResourceManager::isTemplateAvailable(), ResourceBroker::machinePartOf(), MAX_LIMM_DISTANCE, MoveNode::move(), TTAMachine::BaseRegisterFile::port(), ResourceBroker::resourceOf(), rm_, TTAProgram::Move::setSource(), TTAProgram::Move::source(), and MoveNode::toString().

Here is the call graph for this function:

◆ availableResource()

SchedulingResource & IUBroker::availableResource ( int  useCycle,
const MoveNode node,
const TTAMachine::Bus bus,
const TTAMachine::FunctionUnit srcFU,
const TTAMachine::FunctionUnit dstFU,
int  immWriteCycle,
const TTAMachine::ImmediateUnit immu,
int  immRegIndex 
) const
overridevirtual

Return one (any) resource managed by this broker that has a register available for assignment between given definition and use cycles.

Parameters
useCycleUse cycle.
nodeNode.
Returns
One (any) resource managed by this broker that has a register available for assignment between given definition and use cycles.

Reimplemented from ResourceBroker.

Definition at line 122 of file IUBroker.cc.

129 {
130 try {
132 useCycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex).
133 resource(0);
134 } catch (const KeyNotFound& e) {
135 std::string message = "No immediate register resource available.";
136 throw InstanceNotFound(__FILE__, __LINE__, __func__, message);
137 }
138}
virtual SchedulingResourceSet allAvailableResources(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
Definition IUBroker.cc:149

References __func__, and allAvailableResources().

Here is the call graph for this function:

◆ buildResources()

void IUBroker::buildResources ( const TTAMachine::Machine target)
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.

Parameters
targetTarget machine.

Implements ResourceBroker.

Definition at line 453 of file IUBroker.cc.

453 {
454
455 target_ = &target;
457
458 for (int i = 0; i < navi.count(); i++) {
459 ImmediateUnit* iu = navi.item(i);
460 bool extension = false;
461 if (iu->extensionMode() == Machine::ZERO) {
462 extension = false;
463 } else {
464 extension = true;
465 }
466 IUResource* iuResource =
467 new IUResource(
468 target,
469 iu->name(), iu->numberOfRegisters(), iu->width(),
470 iu->latency(), extension, initiationInterval_);
471 ResourceBroker::addResource(*iu, iuResource);
472 }
473}
void addResource(const TTAMachine::MachinePart &mp, SchedulingResource *res)
virtual int numberOfRegisters() const
virtual int width() const
virtual TCEString name() const
virtual int latency() const
virtual Machine::Extension extensionMode() const
ComponentType * item(int index) const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
@ ZERO
Zero extension.
Definition Machine.hh:81

References ResourceBroker::addResource(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::ImmediateUnit::extensionMode(), TTAMachine::Machine::immediateUnitNavigator(), ResourceBroker::initiationInterval_, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::ImmediateUnit::latency(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), target_, TTAMachine::BaseRegisterFile::width(), and TTAMachine::Machine::ZERO.

Here is the call graph for this function:

◆ clearOldResources()

void IUBroker::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 598 of file IUBroker.cc.

598 {
599 for (ResourceMap::iterator i = resMap_.begin(); i != resMap_.end(); i++) {
600 IUResource* iuRes = static_cast<IUResource*>(i->second);
601 iuRes->clearOldResources();
602 }
603}
void clearOldResources()

References IUResource::clearOldResources(), and ResourceBroker::resMap_.

Referenced by SimpleBrokerDirector::clearOldResources().

Here is the call graph for this function:

◆ earliestCycle()

int IUBroker::earliestCycle ( 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
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.

Parameters
cycleCycle.
nodeNode.
Returns
The earliest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.

Implements ResourceBroker.

Definition at line 347 of file IUBroker.cc.

353 {
354 abortWithError("Not implemented.");
355 return -1;
356}
#define abortWithError(message)

References abortWithError.

◆ immediateValue()

std::shared_ptr< TTAProgram::TerminalImmediate > IUBroker::immediateValue ( const MoveNode node) const
virtual

Returns a original Immediate value for a node

Parameters
nodeNode that was changed to immediate register read
Returns
Terminal representing original source of Move

Definition at line 555 of file IUBroker.cc.

555 {
556 if (!node.isSourceImmediateRegister()) {
557 return NULL;
558 }
560 IUResource* iuRes = dynamic_cast<IUResource*>(
562 assignedResources_, &node));
563 return iuRes->immediateValue(node);
564 }
565 throw KeyNotFound(__FILE__, __LINE__, __func__,
566 "MoveNode was not assigned Immediate resource.");
567}
std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue(const MoveNode &node) const
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
static bool containsKey(const MapType &aMap, const KeyType &aKey)
bool isSourceImmediateRegister() const
Definition MoveNode.cc:223

References __func__, ResourceBroker::assignedResources_, MapTools::containsKey(), IUResource::immediateValue(), MoveNode::isSourceImmediateRegister(), and MapTools::keyForValue().

Referenced by SimpleBrokerDirector::immediateValue().

Here is the call graph for this function:

◆ immediateWriteCycle()

int IUBroker::immediateWriteCycle ( const MoveNode node) const
virtual

Returns a cycle in which the original Immediate value is written into immediate register.

Parameters
nodeNode that was changed to immediate register read
Returns
Cycle in which immediate was written into register.

Definition at line 578 of file IUBroker.cc.

578 {
579 if (!node.isSourceImmediateRegister()) {
580 return -1;
581 }
583 IUResource* iuRes = dynamic_cast<IUResource*>(
585 assignedResources_, &node));
586 return iuRes->immediateWriteCycle(node);
587 }
588 throw KeyNotFound(__FILE__, __LINE__, __func__,
589 "MoveNode was not assigned Immediate resource.");
590}
int immediateWriteCycle(const MoveNode &node) const

References __func__, ResourceBroker::assignedResources_, MapTools::containsKey(), IUResource::immediateWriteCycle(), MoveNode::isSourceImmediateRegister(), and MapTools::keyForValue().

Referenced by SimpleBrokerDirector::immediateWriteCycle().

Here is the call graph for this function:

◆ isAlreadyAssigned()

bool IUBroker::isAlreadyAssigned ( int  cycle,
const MoveNode node,
const TTAMachine::Bus preassignedBus 
) const
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).

Parameters
cycleCycle.
nodeNode.
Returns
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).

Implements ResourceBroker.

Definition at line 394 of file IUBroker.cc.

395 {
397 return false;
398 }
399 try {
400 // Somehow nasty solution, but in correct case should
401 // never be throwing exception
402 IUResource* iu = dynamic_cast<IUResource*>(
404 assignedResources_, &node));
405 iu->immediateValue(node);
406 } catch (const KeyNotFound&) {
407 return false;
408 }
409 return true;
410}

References ResourceBroker::assignedResources_, MapTools::containsKey(), IUResource::immediateValue(), and MapTools::keyForValue().

Here is the call graph for this function:

◆ isAnyResourceAvailable()

bool IUBroker::isAnyResourceAvailable ( int  useCycle,
const MoveNode node,
const TTAMachine::Bus bus,
const TTAMachine::FunctionUnit srcFU,
const TTAMachine::FunctionUnit dstFU,
int  immWriteCycle,
const TTAMachine::ImmediateUnit immu,
int  immRegIndex 
) const
overridevirtual

Return true if one of the resources managed by this broker is suitable for the request contained in the node and can be assigned to it in given cycle.

Parameters
defCycleCycle in which the write to long immediate register is
useCycleCycle in which the long immediate register is read by node
nodeNode.
Returns
True if one of the resources managed by this broker is suitable for the request contained in the node and can be assigned to it in given cycle.

Reimplemented from ResourceBroker.

Definition at line 97 of file IUBroker.cc.

103 {
104 int resultCount = allAvailableResources(
105 useCycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex).
106 count();
107 return (resultCount > 0);
108}

References allAvailableResources().

Here is the call graph for this function:

◆ isApplicable()

bool IUBroker::isApplicable ( const MoveNode node,
const TTAMachine::Bus preassignedBus 
) const
overridevirtual

Return true if the given node needs a resource of the type managed by this broker, false otherwise.

Parameters
nodeNode.
Returns
True if the given node is Immediate read.
Note
this method is called to determine if node needs IU resource as well as by resetAssignments to remove the IU assignment

Implements ResourceBroker.

Definition at line 422 of file IUBroker.cc.

423 {
424 if (!node.isMove()) {
425 return false;
426 }
427 if (node.isSourceImmediateRegister()) {
428 return true;
429 }
430 // If node is annotated, it needs to be converted to LIMM,
431 // detected in BB scheduler
432 if (node.isSourceConstant() && node.move().hasAnnotations(
434 return true;
435 }
436 if (node.isSourceConstant() &&
437 !rm_->canTransportImmediate(node, preassignedBus)) {
438 return true;
439 }
440 return false;
441}
bool isMove() const
bool isSourceConstant() const
Definition MoveNode.cc:238
virtual bool canTransportImmediate(const MoveNode &node, const TTAMachine::Bus *preAssignedBus=NULL) const
bool hasAnnotations(ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID) const

References TTAProgram::ProgramAnnotation::ANN_REQUIRES_LIMM, SimpleResourceManager::canTransportImmediate(), TTAProgram::AnnotatedInstructionElement::hasAnnotations(), MoveNode::isMove(), MoveNode::isSourceConstant(), MoveNode::isSourceImmediateRegister(), MoveNode::move(), and rm_.

Here is the call graph for this function:

◆ isIUBroker()

bool IUBroker::isIUBroker ( ) const
overridevirtual

Return true always.

Returns
True always.

Reimplemented from ResourceBroker.

Definition at line 543 of file IUBroker.cc.

543 {
544 return true;
545}

◆ latestCycle()

int IUBroker::latestCycle ( 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
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.

Parameters
cycleCycle.
nodeNode.
Returns
The latest cycle, starting from given cycle, where a resource of the type managed by this broker can be assigned to the given node.

Implements ResourceBroker.

Definition at line 370 of file IUBroker.cc.

375 {
376 abortWithError("Not implemented.");
377 return -1;
378}

References abortWithError.

◆ setupResourceLinks()

void IUBroker::setupResourceLinks ( const ResourceMapper mapper)
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.

Parameters
mapperResource mapper.

Implements ResourceBroker.

Definition at line 484 of file IUBroker.cc.

484 {
485
486 setResourceMapper(mapper);
487
488 for (ResourceMap::iterator resIter = resMap_.begin();
489 resIter != resMap_.end(); resIter++) {
490
491 const ImmediateUnit* iu =
492 dynamic_cast<const ImmediateUnit*>((*resIter).first);
493
494 SchedulingResource* iuResource = (*resIter).second;
495 for (int i = 0; i < iu->portCount(); i++) {
496 Port* port = iu->port(i);
497 if (port->outputSocket() != NULL) {
498 try {
499 SchedulingResource& relatedRes =
500 mapper.resourceOf(*port->outputSocket());
501 iuResource->addToRelatedGroup(0, relatedRes);
502 } catch (const KeyNotFound& e) {
503 std::string msg = "IUBroker: finding ";
504 msg += " resource for Socket ";
505 msg += " failed with error: ";
506 msg += e.errorMessageStack();
507 throw KeyNotFound(
508 __FILE__, __LINE__, __func__, msg);
509 }
510 }
511 }
512
515
516 for (int i = 0; i < navi.count(); i++) {
517 InstructionTemplate* itemplate = navi.item(i);
518 if (itemplate->isOneOfDestinations(*iu)) {
519 try {
520 SchedulingResource& relatedRes =
521 mapper.resourceOf(*itemplate);
522 iuResource->addToRelatedGroup(1, relatedRes);
523 } catch (const KeyNotFound& e) {
524 std::string msg = "IUBroker: finding ";
525 msg += " resource for Template ";
526 msg += " failed with error: ";
527 msg += e.errorMessageStack();
528 throw KeyNotFound(
529 __FILE__, __LINE__, __func__, msg);
530 }
531 }
532 }
533 }
534 // todo: dependent register resources?
535}
std::string errorMessageStack(bool messagesOnly=false) const
Definition Exception.cc:138
void setResourceMapper(const ResourceMapper &mapper)
SchedulingResource & resourceOf(const TTAMachine::MachinePart &mp, int index=0) const
virtual void addToRelatedGroup(const int group, SchedulingResource &resource)
virtual bool isOneOfDestinations(const ImmediateUnit &dstUnit) const
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition Machine.cc:428
virtual Socket * outputSocket() const
Definition Port.cc:281
virtual int portCount() const
Definition Unit.cc:135

References __func__, SchedulingResource::addToRelatedGroup(), TTAMachine::Machine::Navigator< ComponentType >::count(), Exception::errorMessageStack(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::InstructionTemplate::isOneOfDestinations(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Port::outputSocket(), TTAMachine::BaseRegisterFile::port(), TTAMachine::Unit::portCount(), ResourceBroker::resMap_, ResourceMapper::resourceOf(), ResourceBroker::setResourceMapper(), and target_.

Here is the call graph for this function:

◆ unassign()

void IUBroker::unassign ( MoveNode node)
overridevirtual

Free the Immediate register and set MoveNode source back to TerminalImmediate constant.

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.

Parameters
nodeNode.
Note
The ImmediateResource keeps a copy of original source terminal and will restore it during unassignment.

Implements ResourceBroker.

Definition at line 321 of file IUBroker.cc.

321 {
323 TCEString msg = "Trying to unassign Long Immediate register ";
324 msg += "that was not assigned previously: " + node.toString();
325 abortWithError(msg);
326 return;
327 }
328 IUResource* iuRes = dynamic_cast<IUResource*>(
330 assignedResources_, &node));
331 iuRes->unassign(node.cycle(), node);
332 assignedResources_.erase(&node);
333}
virtual void unassign(const int cycle, MoveNode &node) override
int cycle() const
Definition MoveNode.cc:421

References abortWithError, ResourceBroker::assignedResources_, MapTools::containsKey(), MoveNode::cycle(), MapTools::keyForValue(), MoveNode::toString(), and IUResource::unassign().

Here is the call graph for this function:

Member Data Documentation

◆ rm_

SimpleResourceManager* IUBroker::rm_
private

Definition at line 136 of file IUBroker.hh.

Referenced by allAvailableResources(), assign(), and isApplicable().

◆ target_

const TTAMachine::Machine* IUBroker::target_
private

Target machine.

Definition at line 127 of file IUBroker.hh.

Referenced by buildResources(), and setupResourceLinks().


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