OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ITemplateBroker Class Reference

#include <ITemplateBroker.hh>

Inheritance diagram for ITemplateBroker:
Inheritance graph
Collaboration diagram for ITemplateBroker:
Collaboration graph

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::Instructioninstruction (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 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
 
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 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::ComparatoroldParentInstruction_
 MoveNode/ original parent instruction. More...
 
std::map< const MoveNode *, int, GraphNode::ComparatorimmediateCycles_
 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::ComparatorimmediateValues_
 
std::map< int, bool > instructionsNotOwned_
 
SimpleResourceManagerrm_
 
BusBrokerbusBroker_
 

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

ITemplate broker.

Definition at line 65 of file ITemplateBroker.hh.

Member Typedef Documentation

◆ Immediates

typedef std::vector<std::shared_ptr<const TTAProgram::Immediate> > ITemplateBroker::Immediates
private

Definition at line 124 of file ITemplateBroker.hh.

◆ Moves

typedef std::vector<std::shared_ptr<const TTAProgram::Move> > ITemplateBroker::Moves
private

Definition at line 123 of file ITemplateBroker.hh.

Constructor & Destructor Documentation

◆ ITemplateBroker() [1/2]

ITemplateBroker::ITemplateBroker ( std::string  name,
BusBroker busBroker,
unsigned int  initiationInterval = 0 
)

Constructor.

Definition at line 68 of file ITemplateBroker.cc.

69  :
70  ResourceBroker(name, initiationInterval),
71  rm_(NULL), busBroker_(busBroker) {
72 }

◆ ITemplateBroker() [2/2]

ITemplateBroker::ITemplateBroker ( std::string  name,
BusBroker busBroker,
SimpleResourceManager rm,
unsigned int  initiationInterval = 0 
)

Constructor.

Definition at line 77 of file ITemplateBroker.cc.

81  :
82  ResourceBroker(name, initiationInterval),
83  rm_(rm), busBroker_(busBroker) {
84 }

◆ ~ITemplateBroker()

ITemplateBroker::~ITemplateBroker ( )
virtual

Destructor.

Definition at line 89 of file ITemplateBroker.cc.

89  {
90  for (std::map<int, TTAProgram::Instruction*>::iterator i =
91  instructions_.begin(); i != instructions_.end(); i++) {
92  std::map<int, bool>::iterator j = instructionsNotOwned_.find(i->first);
93  // not found = >owns, deletes.
94  if (j == instructionsNotOwned_.end() || j->second == false) {
95  delete i->second;
96  }
97  }
98 
99 }

References instructions_, and instructionsNotOwned_.

Member Function Documentation

◆ allAvailableResources()

SchedulingResourceSet ITemplateBroker::allAvailableResources ( 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
overridevirtual

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

Parameters
cycleCycle.
nodeNode.
Returns
All resources managed by this broker that can be assigned to the given node in the given cycle.
Note
This method is called twice, first it check available resources for immediate write, second call checks resources for MoveNode

Reimplemented from ResourceBroker.

Definition at line 144 of file ITemplateBroker.cc.

151  {
152  cycle = instructionIndex(cycle);
153  Moves moves;
154  Immediates immediates;
155  MoveNode& testedNode = const_cast<MoveNode&>(node);
156  if (node.isMove()) {
157  moves.push_back(testedNode.movePtr());
158  } else if (node.isImmediate()) {
159  immediates.push_back(testedNode.immediatePtr());
160  }
161  return findITemplates(cycle, moves, immediates);
162 }

References findITemplates(), MoveNode::immediatePtr(), ResourceBroker::instructionIndex(), MoveNode::isImmediate(), MoveNode::isMove(), and MoveNode::movePtr().

Referenced by isAnyResourceAvailable().

Here is the call graph for this function:

◆ assign()

void ITemplateBroker::assign ( int  cycle,
MoveNode node,
SchedulingResource res,
int  immWriteCycle,
int  immRegIndex 
)
overridevirtual

Assigns instruction template resource to the parent instruction of the given node.

Parameters
cycleCycle of node.
nodeNode.
resInstruction template resource to assign.
Exceptions
WrongSubclassIf this broker does not recognise the given type of resource.
InvalidDataIf he given resource cannot be assigned to given node or no corresponding machine part is found.
Note
Ownership of a Move in MoveNode will be passed to Instruction inside the broker.

Implements ResourceBroker.

Definition at line 180 of file ITemplateBroker.cc.

181  {
182 
183  cycle = instructionIndex(cycle);
184 
185  ITemplateResource& templateRes =
186  static_cast<ITemplateResource&>(res);
187  const InstructionTemplate& iTemplate =
188  static_cast<const InstructionTemplate&>(machinePartOf(res));
189  TTAProgram::Instruction* ins = NULL;
190  if (MapTools::containsKey(instructions_, cycle)) {
191  ins = MapTools::valueForKey<TTAProgram::Instruction*>(
192  instructions_, cycle);
193 
194  // In case template was already assigned and it changes
195  if (ins->instructionTemplate().name() != iTemplate.name()) {
196  SchedulingResource& oldRes =
198  ITemplateResource& oldTemplateRes =
199  dynamic_cast<ITemplateResource&>(oldRes);
200  oldTemplateRes.unassign(cycle);
201 
202  // In case the amount of transportable immediate bits decreases
203  // due to ITemplate change, update each immediate bit width to
204  // the new width. If this is not done, negative immediates ends up
205  // to take more bits than they really need in TPEF and later
206  // loading the TPEF fails in TPEFProgramFactory.
207  for (int i = 0; i < ins->immediateCount(); i++) {
208  // Can not change bit width of these.
209  if (ins->immediate(i).value().isInstructionAddress() ||
210  ins->immediate(i).value().isBasicBlockReference() ||
211  ins->immediate(i).value().isCodeSymbolReference()) {
212  continue;
213  }
214  int currentWidth = ins->immediate(i).value().value().width();
215  const ImmediateUnit& destIU =
216  ins->immediate(i).destination().immediateUnit();
217  int newSupportedWidth = iTemplate.supportedWidth(destIU);
218  if (currentWidth > newSupportedWidth) {
219  SimValue sim(
220  (destIU.signExtends() ?
221  ins->immediate(i).value().value().intValue() :
222  ins->immediate(i).value().value().unsignedValue()),
223  newSupportedWidth);
224  TerminalImmediate* ti = new TerminalImmediate(sim);
225  ins->immediate(i).setValue(ti);
226  }
227  }
228 
229  ins->setInstructionTemplate(iTemplate);
230  templateRes.assign(cycle);
231  }
232  } else {
233  ins = new TTAProgram::Instruction(iTemplate);
234  instructions_[cycle] = ins;
235  templateRes.assign(cycle);
236  }
237 
238  Instruction* oldIn = NULL;
239  if (node.isImmediate()) {
240  oldIn = node.immediate().parent();
241  if (oldIn != NULL) {
242  oldIn->removeImmediate(node.immediate());
243  }
244  ins->addImmediate(node.immediatePtr());
245  } else {
246  if (node.move().isInInstruction()) {
247  oldIn = &node.move().parent();
248  oldIn->removeMove(node.move());
249  }
250  ins->addMove(node.movePtr());
251  }
252  oldParentInstruction_.insert(
253  std::pair<const MoveNode*, TTAProgram::Instruction*>
254  (&node, oldIn));
255 
256  // TODO: refactor this away.
257  if (node.isSourceImmediateRegister()) {
258  // Gets data from Immediate Unit broker, indirectly
259 
260  auto immValue = rm_->immediateValue(node);
261  if (immValue) {
262  TerminalImmediate* tempImm =
263  dynamic_cast<TerminalImmediate*>(
264  immValue->copy());
265  int defCycle = instructionIndex(rm_->immediateWriteCycle(node));
266  if (defCycle >= 0) {
267  TerminalRegister* tmpReg =
268  dynamic_cast<TerminalRegister*>(
269  node.move().source().copy());
270  auto imm = std::make_shared<Immediate>(tempImm, tmpReg);
271  if (!isImmediateInTemplate(defCycle,imm)) {
272  assignImmediate(defCycle, imm);
273  immediateCycles_.insert(
274  std::pair<const MoveNode*, int>(&node,defCycle));
275  immediateValues_.insert(
276  std::pair<const MoveNode*,
277  std::shared_ptr<TTAProgram::Immediate> >(
278  &node,imm));
279  } else {
280  abortWithError("Failed to assign immediate write");
281  }
282  }
283  }
284  }
285 }

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().

Here is the call graph for this function:

◆ assignImmediate()

void ITemplateBroker::assignImmediate ( int  cycle,
std::shared_ptr< TTAProgram::Immediate immediate 
)
private

Assigns instruction template resource to the given instruction located in given cycle.

Parameters
cycleCycle where to store immediate write.
immediateImmediate to be written in cycle
Exceptions
WrongSubclassIf this broker does not recognise the given type of resource.
InvalidDataIf he given resource cannot be assigned to given node or no corresponding machine part is found.

Definition at line 300 of file ITemplateBroker.cc.

301  {
302  cycle = instructionIndex(cycle);
303 
304  try {
305  // Find a template for definition cycle
306  Moves moves;
307  Immediates immediates;
308  immediates.push_back(immediate);
309 
311  findITemplates(cycle, moves, immediates);
312  assert(resources.count());
313  ITemplateResource& templateRes =
314  static_cast<ITemplateResource&>(resources.resource(0));
315  const InstructionTemplate& iTemplate =
316  static_cast<const InstructionTemplate&>(
317  machinePartOf(templateRes));
318 
319  // Find instruction, if there is none, create new.
320  TTAProgram::Instruction* ins = NULL;
321  if (MapTools::containsKey(instructions_, cycle)) {
322  ins = MapTools::valueForKey<TTAProgram::Instruction*>(
323  instructions_, cycle);
324  // Remove old template assignment
325  SchedulingResource& oldRes =
327  ITemplateResource& oldTemplateRes =
328  static_cast<ITemplateResource&>(oldRes);
329  oldTemplateRes.unassign(cycle);
330  } else {
331  ins = new TTAProgram::Instruction(iTemplate);
332  instructions_[cycle] = ins;
333  }
334 
335  // Define new immediate, depending on supported bit width of
336  // template for given immediate unit
337  const ImmediateUnit& iu = immediate->destination().immediateUnit();
338  int neededBitWidth = iTemplate.supportedWidth(iu);
339  if (neededBitWidth <= INT_WORD_SIZE &&
340  (!immediate->value().isInstructionAddress() &&
341  !immediate->value().isBasicBlockReference() &&
342  !immediate->value().isCodeSymbolReference())) {
343  // If it is not floating point or instruction address
344  // we recreate SimValue with proper bit width based on destination
345  if (iu.extensionMode() == Machine::ZERO) {
346  SimValue sim(
347  immediate->value().value().unsignedValue(), neededBitWidth);
348  TerminalImmediate* ti = new TerminalImmediate(sim);
349  immediate->setValue(ti);
350  }
351  if (iu.extensionMode() == Machine::SIGN) {
352  SimValue sim(
353  immediate->value().value().intValue(), neededBitWidth);
354  TerminalImmediate* ti = new TerminalImmediate(sim);
355  immediate->setValue(ti);
356  }
357  }
358 
359  templateRes.assign(cycle);
360  ins->setInstructionTemplate(iTemplate);
361  ins->addImmediate(immediate);
362 
363  } catch (const std::bad_cast& e) {
364  string msg = "Resource is not of an instruction template resource.";
365  throw WrongSubclass(__FILE__, __LINE__, __func__, msg);
366  } catch (const KeyNotFound& e) {
367  string msg = "Broker does not contain given resource.";
368  throw InvalidData(__FILE__, __LINE__, __func__, msg);
369  }
370 }

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().

Here is the call graph for this function:

◆ buildResources()

void ITemplateBroker::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 596 of file ITemplateBroker.cc.

596  {
597 
600 
601  for (int i = 0; i < templateNavi.count(); i++) {
602  InstructionTemplate* itemplate = templateNavi.item(i);
603  ITemplateResource* itemplateResource =
604  new ITemplateResource(*itemplate, initiationInterval_);
605  ResourceBroker::addResource(*itemplate, itemplateResource);
606  }
607 
608  Machine::BusNavigator busNavi = target.busNavigator();
609 
610  for (int i = 0; i < busNavi.count(); i++) {
611  slots_.push_back(busNavi.item(i));
612  }
613 }

References ResourceBroker::addResource(), TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), ResourceBroker::initiationInterval_, TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and slots_.

Here is the call graph for this function:

◆ clear()

void ITemplateBroker::clear ( )
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.

976  {
979 
980  for (std::map<int, TTAProgram::Instruction*>::iterator i =
981  instructions_.begin(); i != instructions_.end(); i++) {
982  std::map<int, bool>::iterator j = instructionsNotOwned_.find(i->first);
983  // does not find => owns, delete.
984  if (j == instructionsNotOwned_.end() || j->second == false) {
985  delete i->second;
986  }
987  }
988  instructions_.clear();
989  instructionsNotOwned_.clear();
990  immediateCycles_.clear();
991  immediateValues_.clear();
992 }

References ResourceBroker::clear(), clearOldResources(), immediateCycles_, immediateValues_, instructions_, and instructionsNotOwned_.

Here is the call graph for this function:

◆ clearOldResources()

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.

966  {
967  oldParentInstruction_.clear();
968 }

References oldParentInstruction_.

Referenced by clear(), and SimpleBrokerDirector::clearOldResources().

◆ earliestCycle()

int ITemplateBroker::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
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 500 of file ITemplateBroker.cc.

504  {
505  abortWithError("Not implemented.");
506  return -1;
507 }

References abortWithError.

◆ findITemplates()

SchedulingResourceSet ITemplateBroker::findITemplates ( int  cycle,
Moves moves,
Immediates immediates 
) const
private

Helper function, finds all templates that are applicable for current status of instruction and new node that needs to be added

Parameters
movesA set of moves which has to fit into template
immediatesA set of immediates which has to fit into template
Returns
A set of instruction templates that supports current instruction plus new instruction
Note
The test for Moves is done by checking if a bus Move uses is not allocated by template for immediate move. Immediate slots are not relevant here.

Definition at line 738 of file ITemplateBroker.cc.

741  {
742 
743  cycle = instructionIndex(cycle);
744  SchedulingResourceSet result;
745  Instruction* ins = NULL;
746  // Read in content of instruction if there is something already
747  // stored in given cycle
748  if (MapTools::containsKey(instructions_, cycle)) {
749  ins = MapTools::valueForKey<TTAProgram::Instruction*>(
750  instructions_, cycle);
751  for (int i = 0; i < ins->moveCount(); i++) {
752  moves.push_back(ins->movePtr(i));
753  }
754  for (int i = 0; i < ins->immediateCount(); i++) {
755  immediates.push_back(ins->immediatePtr(i));
756  }
757  }
758 
759  for (ResourceMap::const_iterator resIter = resMap_.begin();
760  resIter != resMap_.end(); resIter++) {
761  bool addResult = true;
762  // bus resources (slots) are in dependent group 0
763  // immediate resources are in group 1
764  // trying to find template that has exactly same number or
765  // higher number of immediate writes as instruction
766  if ((*resIter).second->dependentResourceGroupCount() > 1 &&
767  immediates.size() > static_cast<unsigned int>(
768  (*resIter).second->dependentResourceCount(1))) {
769  continue;
770  }
771 
772  const InstructionTemplate& iTemplate =
773  dynamic_cast<const InstructionTemplate&>(*(*resIter).first);
774 
775  // For each of already assigned immediate writes, template
776  // has to have destination unit
777  std::vector<const TTAMachine::ImmediateUnit*> unitWriten;
778  for (unsigned int i = 0; i < immediates.size(); i++) {
779  const ImmediateUnit& unit =
780  immediates[i]->destination().immediateUnit();
781  if (ContainerTools::containsValue(unitWriten, &unit)) {
782  addResult = false;
783  break;
784  }
785  // immediate and immediate units has correct width, this checks
786  // if template can transport such a number of bits into the unit
787  // it is possible to have template which transport less bits
788  if (!iTemplate.isOneOfDestinations(unit)) {
789  addResult = false;
790  break;
791  }
792  // FIXME: hack to check if terminal is floating point value
793  if (immediates[i]->value().value().width() > INT_WORD_SIZE &&
794  (immediates[i]->value().value().width() >
795  iTemplate.supportedWidth(unit))) {
796  addResult = false;
797  break;
798  }
799  // FIXME: instruction addresses hold reference to instruction
800  // reference which computes the SimValue depending on target
801  // instruction's address. So it is not possible to modify the
802  // bit width of such SimValue
803  if (immediates[i]->value().isInstructionAddress() &&
804  !immediates[i]->value().isBasicBlockReference() &&
805  !immediates[i]->value().isCodeSymbolReference()) {
806 
807  const AddressSpace& as =
809  int requiredBitWidth = unit.extensionMode() == Machine::SIGN ?
811  MathTools::requiredBits(as.end());
812  if (requiredBitWidth > iTemplate.supportedWidth(unit)) {
813  addResult = false;
814  break;
815  }
816  }
817  // Ignore instruction addresses, based on destination mode
818  // tests required bits of correct representation of SimValue
819  if (!immediates[i]->value().isInstructionAddress() &&
820  !immediates[i]->value().isBasicBlockReference() &&
821  !immediates[i]->value().isCodeSymbolReference() &&
822  unit.extensionMode() == Machine::ZERO &&
824  immediates[i]->value().value().unsignedValue()) >
825  iTemplate.supportedWidth(unit)) {
826  addResult = false;
827  break;
828  }
829  if (!immediates[i]->value().isInstructionAddress() &&
830  !immediates[i]->value().isBasicBlockReference() &&
831  !immediates[i]->value().isCodeSymbolReference() &&
832  unit.extensionMode() == Machine::SIGN &&
834  immediates[i]->value().value().intValue()) >
835  iTemplate.supportedWidth(unit)) {
836  addResult = false;
837  break;
838  }
839 
840  if (immediates[i]->value().isCodeSymbolReference() &&
841  immediates[i]->value().toString() == "_end") {
842 
843  AddressSpace* dataAS;
844  try {
845  dataAS =
847  } catch (Exception&) {
848  assert(false && "No default data address space");
849  }
850 
851  int requiredBitWidth = unit.extensionMode() == Machine::SIGN ?
853  MathTools::requiredBits(dataAS->end());
854 
855  if (requiredBitWidth > iTemplate.supportedWidth(unit)) {
856  addResult = false;
857  break;
858  }
859 
860  } else if (immediates[i]->value().isBasicBlockReference() ||
861  immediates[i]->value().isCodeSymbolReference()) {
862 
863  const AddressSpace& as
864  = *rm_->machine().controlUnit()->addressSpace();
865  int requiredBitWidth = unit.extensionMode() == Machine::SIGN ?
867  MathTools::requiredBits(as.end());
868 
869  if (requiredBitWidth > iTemplate.supportedWidth(unit)) {
870  addResult = false;
871  break;
872  }
873 
874  }
875 
876  unitWriten.push_back(&unit);
877  }
878  // For each of moves already assigned template
879  // should not use the bus for immediate transport or as
880  // a fixed NOP slot
881  for (unsigned int i = 0; i < moves.size(); i++) {
882 
883  const bool isNOPSlot = false;
884 
885  SchedulingResource* bus =
886  busBroker_.resourceOf(moves[i]->bus());
887  if ((*resIter).second->hasDependentResource(*bus) ||
888  isNOPSlot) {
889  addResult = false;
890  break;
891  }
892  }
893  if (addResult) {
894  result.insert(*(*resIter).second);
895  }
896  }
897  result.sort();
898  return result;
899 }

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().

Here is the call graph for this function:

◆ instruction()

TTAProgram::Instruction * ITemplateBroker::instruction ( int  cycle)
virtual

Returns an instruction at a given cycle.

Parameters
cycleCycle for which to return instruction
Returns
an instruction object for given cycle, empty instruction if there is no record.

Definition at line 693 of file ITemplateBroker.cc.

693  {
694  cycle = instructionIndex(cycle);
695  if (!MapTools::containsKey(instructions_, cycle)) {
696  Moves moves;
697  Immediates immediates;
698  SchedulingResourceSet defaultTemplates = findITemplates(
699  cycle, moves, immediates);
700  if (defaultTemplates.count() == 0) {
701  throw InvalidData(
702  __FILE__, __LINE__, __func__,
703  "No Instruction Template available!");
704  }
705  SchedulingResource& iTemp = defaultTemplates.resource(0);
706  const MachinePart& mp = machinePartOf(iTemp);
707  const InstructionTemplate& iTemplate =
708  dynamic_cast<const InstructionTemplate&>(mp);
709  ITemplateResource& templateRes =
710  dynamic_cast<ITemplateResource&>(iTemp);
711  templateRes.assign(cycle);
712  TTAProgram::Instruction* ins = NULL;
713  ins = new TTAProgram::Instruction(iTemplate);
714  instructions_[cycle] = ins;
715  ins->setInstructionTemplate(iTemplate);
716  return ins;
717  }
718  Instruction* ins =
719  MapTools::valueForKey<TTAProgram::Instruction*>(
720  instructions_, cycle);
721  return ins;
722 }

References __func__, ITemplateResource::assign(), MapTools::containsKey(), SchedulingResourceSet::count(), findITemplates(), ResourceBroker::instructionIndex(), instructions_, ResourceBroker::machinePartOf(), SchedulingResourceSet::resource(), and TTAProgram::Instruction::setInstructionTemplate().

Referenced by SimpleBrokerDirector::instruction().

Here is the call graph for this function:

◆ isAlreadyAssigned()

bool ITemplateBroker::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 544 of file ITemplateBroker.cc.

545  {
546  if (node.isImmediate()) {
547  return node.immediate().parent() != NULL;
548  }
549  Move& move = const_cast<MoveNode&>(node).move();
550 
551  cycle = instructionIndex(cycle);
552  if (!move.isInInstruction()) {
553  return false;
554  }
555  const InstructionTemplate& iTemplate =
556  move.parent().instructionTemplate();
557 
558  // Cannot be already assigned if template is null.
559  if (&iTemplate != &NullInstructionTemplate::instance()) {
560  // When node is assigned, it's old parent is stored, thus if the
561  // old parent is stored, node was assigned
563  SchedulingResource* res = resourceOf(iTemplate);
564  if ( res != NULL && res->isInUse(cycle)) {
565  return true;
566  }
567  }
568  }
569  return false;
570 }

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().

Here is the call graph for this function:

◆ isAnyResourceAvailable()

bool ITemplateBroker::isAnyResourceAvailable ( 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 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.

Parameters
cycleCycle where instruction template is used.
nodeNode which contains long immediate register read.
Returns
True if there's an instruction template available to be used on the given cycle, and the template is able to encode bits for long immediate that is read in given node.

Reimplemented from ResourceBroker.

Definition at line 115 of file ITemplateBroker.cc.

123  {
124  cycle = instructionIndex(cycle);
125  int resultCount = allAvailableResources(
126  cycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex).
127  count();
128  return resultCount > 0;
129 }

References allAvailableResources(), and ResourceBroker::instructionIndex().

Here is the call graph for this function:

◆ isApplicable()

bool ITemplateBroker::isApplicable ( const MoveNode node,
const TTAMachine::Bus  
) 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 needs a resource of the type managed by this broker, false otherwise.
Todo:
reconsider, should be applicable for all the MoveNodes

Implements ResourceBroker.

Definition at line 582 of file ITemplateBroker.cc.

582  {
583  return true;
584 }

◆ isImmediateInTemplate()

bool ITemplateBroker::isImmediateInTemplate ( int  defCycle,
std::shared_ptr< TTAProgram::Immediate imm 
) const
private

Definition at line 920 of file ITemplateBroker.cc.

922  {
923 
924  if (!MapTools::containsKey(instructions_, defCycle)) {
925  return false;
926  }
927  Instruction* ins = MapTools::valueForKey<TTAProgram::Instruction*>(
928  instructions_, defCycle);
929  for (int i = 0; i < ins->immediateCount(); i++){
930  if (ins->immediate(i).value().value() == imm->value().value() &&
931  ins->immediate(i).destination().equals(imm->destination())){
932  return true;
933  }
934  }
935  return false;
936 }

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().

Here is the call graph for this function:

◆ isITemplateBroker()

bool ITemplateBroker::isITemplateBroker ( ) const
overridevirtual

Return true always.

Returns
True always.

Reimplemented from ResourceBroker.

Definition at line 681 of file ITemplateBroker.cc.

681  {
682  return true;
683 }

◆ isTemplateAvailable()

bool ITemplateBroker::isTemplateAvailable ( int  defCycle,
std::shared_ptr< TTAProgram::Immediate immediate 
) const
virtual

Tests if there is any instruction template available for immediate in given cycle

Parameters
defCyclecycle to test
immediateImmediate to test
Returns
True if there is instruction template for given cycle which can write given immediate

Definition at line 948 of file ITemplateBroker.cc.

950  {
951 
952  Immediates immediates;
953  Moves moves;
954  immediates.push_back(immediate);
955  int availableCount =
956  findITemplates(defCycle, moves, immediates).count();
957  return availableCount > 0;
958 }

References SchedulingResourceSet::count(), and findITemplates().

Referenced by SimpleBrokerDirector::isTemplateAvailable().

Here is the call graph for this function:

◆ latestCycle()

int ITemplateBroker::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
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 521 of file ITemplateBroker.cc.

525  {
526  abortWithError("Not implemented.");
527  return -1;
528 }

References abortWithError.

◆ loseInstructionOwnership()

void ITemplateBroker::loseInstructionOwnership ( int  cycle)
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.

908  {
909  instructionsNotOwned_[cycle] = true;
910 }

References instructionsNotOwned_.

Referenced by SimpleBrokerDirector::loseInstructionOwnership().

◆ reselectTemplate()

void ITemplateBroker::reselectTemplate ( TTAProgram::Instruction ins,
int  cycle 
)
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.

470  {
471  // set new template that does not use immediate slot just unassigned
472  // moves and immediate will be filled from instruction in given cycle
473  // inside findITTemplates method
474  Moves moves;
475  Immediates immediates;
477  findITemplates(cycle, moves, immediates);
478  assert(resources.count() >0);
479  ITemplateResource& newTemplateRes = static_cast<ITemplateResource&>(
480  resources.resource(0));
481  const InstructionTemplate& newTemplate =
482  dynamic_cast<const InstructionTemplate&>(
483  machinePartOf(newTemplateRes));
484  ins.setInstructionTemplate(newTemplate);
485  newTemplateRes.assign(cycle);
486 }

References assert, ITemplateResource::assign(), findITemplates(), ResourceBroker::machinePartOf(), ResourceBroker::resources(), and TTAProgram::Instruction::setInstructionTemplate().

Referenced by unassign(), and unassignImmediate().

Here is the call graph for this function:

◆ setupResourceLinks()

void ITemplateBroker::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 625 of file ITemplateBroker.cc.

625  {
626 
627  setResourceMapper(mapper);
628 
629  for (ResourceMap::iterator resIter = resMap_.begin();
630  resIter != resMap_.end(); resIter++) {
631 
632  const InstructionTemplate* itemplate =
633  dynamic_cast<const InstructionTemplate*>((*resIter).first);
634  if (itemplate == NULL){
635  throw InvalidData(
636  __FILE__, __LINE__, __func__,
637  "Broker does not have necessary Template registered!");
638  }
639 
640  SchedulingResource* templateResource = (*resIter).second;
641 
642  for (unsigned int i = 0; i < slots_.size(); i++) {
643  if (itemplate->usesSlot(slots_[i]->name())) {
644  try {
645  SchedulingResource& depSlot =
646  mapper.resourceOf(*slots_[i]);
647  templateResource->addToDependentGroup(0, depSlot);
648  } catch (const KeyNotFound& e) {
649  std::string msg = "ITemplateBroker: finding ";
650  msg += " resource for Slot ";
651  msg += " failed with error: ";
652  msg += e.errorMessageStack();
653  throw KeyNotFound(
654  __FILE__, __LINE__, __func__, msg);
655  }
656 
657  ImmediateUnit* iu =
658  itemplate->destinationOfSlot(slots_[i]->name());
659  try {
660  SchedulingResource& depIU = mapper.resourceOf(*iu);
661  templateResource->addToDependentGroup(1, depIU);
662  } catch (const KeyNotFound& e) {
663  std::string msg = "ITemplateBroker: finding ";
664  msg += " resource for IU ";
665  msg += " failed with error: ";
666  msg += e.errorMessageStack();
667  throw KeyNotFound(
668  __FILE__, __LINE__, __func__, msg);
669  }
670  }
671  }
672  }
673 }

References __func__, SchedulingResource::addToDependentGroup(), TTAMachine::InstructionTemplate::destinationOfSlot(), Exception::errorMessageStack(), ResourceBroker::resMap_, ResourceMapper::resourceOf(), ResourceBroker::setResourceMapper(), slots_, and TTAMachine::InstructionTemplate::usesSlot().

Here is the call graph for this function:

◆ unassign()

void ITemplateBroker::unassign ( MoveNode node)
overridevirtual

Free the instruction template resource used in the parent instruction of the given node.

Parameters
nodeNode.
Note
Returns ownership of Move in MoveNode to the original parent instruction

Implements ResourceBroker.

Definition at line 381 of file ITemplateBroker.cc.

381  {
382  // Template not to be unassgined, it is just that there will be space
383  // left in this template for move
384 
385  TTAProgram::Instruction& ins = node.isMove() ? node.move().parent() :
386  *node.immediate().parent();
388  if (node.isMove()) {
389  ins.removeMove(node.move());
390  TTAProgram::Instruction* oldParent =
391  MapTools::valueForKey<TTAProgram::Instruction*>(
392  oldParentInstruction_, &node);
393  if (oldParent != NULL) {
394  oldParent->addMove(node.movePtr());
395  }
396  oldParentInstruction_.erase(&node);
397  } else if (node.isImmediate()) {
398  ins.removeImmediate(node.immediate());
399  TTAProgram::Instruction* oldParent =
400  MapTools::valueForKey<TTAProgram::Instruction*>(
401  oldParentInstruction_, &node);
402  if (oldParent != NULL) {
403  oldParent->addImmediate(node.immediatePtr());
404  }
405  oldParentInstruction_.erase(&node);
406  reselectTemplate(ins, node.cycle());
407  return;
408  }
409  }
410  if (node.isSourceConstant() &&
412  int defCycle = MapTools::valueForKey<int>(immediateCycles_, &node);
413  auto imm =
414  MapTools::valueForKey<std::shared_ptr<TTAProgram::Immediate> >(
415  immediateValues_, &node);
416 
417  if (isImmediateInTemplate(defCycle, imm)) {
418  unassignImmediate(defCycle, imm->destination().immediateUnit());
419  } else {
420  abortWithError("Failed to remove Immediate from instruction");
421  }
422  immediateCycles_.erase(&node);
423  immediateValues_.erase(&node);
424  }
425  reselectTemplate(ins, node.cycle());
426 }

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().

Here is the call graph for this function:

◆ unassignImmediate()

void ITemplateBroker::unassignImmediate ( int  cycle,
const TTAMachine::ImmediateUnit immediateUnit 
)
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.

Parameters
cycleCycle from where to unassign immediate
immediateImmediate to remove from cycle

Definition at line 440 of file ITemplateBroker.cc.

442  {
443  cycle = instructionIndex(cycle);
444 
445  if (!MapTools::containsKey(instructions_, cycle)) {
446  return;
447  }
448  Instruction* ins =
449  MapTools::valueForKey<Instruction*>(instructions_, cycle);
450  const InstructionTemplate& iTemplate = ins->instructionTemplate();
451  SchedulingResource& res = *resourceOf(iTemplate);
452  ITemplateResource& templateRes = dynamic_cast<ITemplateResource&>(res);
453 
454  templateRes.unassign(cycle);
455  for (int i = 0; i < ins->immediateCount(); i++) {
456  if (ins->immediate(i).destination().immediateUnit().name() ==
457  immediateUnit.name()) {
458  ins->removeImmediate(ins->immediate(i));
459  break;
460  }
461  }
462  reselectTemplate(*ins, cycle);
463 }

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().

Here is the call graph for this function:

Member Data Documentation

◆ busBroker_

BusBroker& ITemplateBroker::busBroker_
private

Definition at line 153 of file ITemplateBroker.hh.

Referenced by findITemplates().

◆ immediateCycles_

std::map<const MoveNode*, int, GraphNode::Comparator> ITemplateBroker::immediateCycles_
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().

◆ immediateValues_

std::map<const MoveNode*, std::shared_ptr<TTAProgram::Immediate>, GraphNode::Comparator> ITemplateBroker::immediateValues_
private

Definition at line 146 of file ITemplateBroker.hh.

Referenced by assign(), clear(), and unassign().

◆ instructions_

std::map<int, TTAProgram::Instruction*> ITemplateBroker::instructions_
private

◆ instructionsNotOwned_

std::map<int, bool> ITemplateBroker::instructionsNotOwned_
private

Definition at line 148 of file ITemplateBroker.hh.

Referenced by clear(), loseInstructionOwnership(), and ~ITemplateBroker().

◆ oldParentInstruction_

std::map<const MoveNode*, TTAProgram::Instruction*, MoveNode::Comparator> ITemplateBroker::oldParentInstruction_
private

MoveNode/ original parent instruction.

Definition at line 138 of file ITemplateBroker.hh.

Referenced by assign(), clearOldResources(), isAlreadyAssigned(), and unassign().

◆ rm_

SimpleResourceManager* ITemplateBroker::rm_
private

Definition at line 152 of file ITemplateBroker.hh.

Referenced by assign(), and findITemplates().

◆ slots_

std::vector<TTAMachine::Bus*> ITemplateBroker::slots_
private

Move/immediate slots.

Definition at line 133 of file ITemplateBroker.hh.

Referenced by buildResources(), and setupResourceLinks().


The documentation for this class was generated from the following files:
ITemplateBroker::instructions_
std::map< int, TTAProgram::Instruction * > instructions_
cycle/instruction
Definition: ITemplateBroker.hh:135
SchedulingResource::addToDependentGroup
virtual void addToDependentGroup(const int group, SchedulingResource &resource)
Definition: SchedulingResource.cc:101
ITemplateBroker::assignImmediate
void assignImmediate(int, std::shared_ptr< TTAProgram::Immediate >)
Definition: ITemplateBroker.cc:300
SimValue::intValue
int intValue() const
Definition: SimValue.cc:895
SimpleResourceManager::immediateWriteCycle
virtual int immediateWriteCycle(const MoveNode &) const
Definition: SimpleResourceManager.cc:520
TTAProgram::Immediate::value
TerminalImmediate & value() const
Definition: Immediate.cc:103
TTAProgram::Instruction::removeMove
void removeMove(Move &move)
Definition: Instruction.cc:536
TTAProgram::Instruction::addMove
void addMove(std::shared_ptr< Move > move)
Definition: Instruction.cc:147
ITemplateBroker::busBroker_
BusBroker & busBroker_
Definition: ITemplateBroker.hh:153
ResourceBroker::initiationInterval_
unsigned int initiationInterval_
Definition: ResourceBroker.hh:158
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAProgram::Terminal::isInstructionAddress
virtual bool isInstructionAddress() const
Definition: Terminal.cc:87
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
ResourceBroker::resMap_
ResourceMap resMap_
Definition: ResourceBroker.hh:165
MoveNode::movePtr
std::shared_ptr< TTAProgram::Move > movePtr()
MathTools
Definition: MathTools.hh:42
TTAProgram::Instruction
Definition: Instruction.hh:57
SimpleResourceManager::immediateValue
virtual std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue(const MoveNode &)
Definition: SimpleResourceManager.cc:509
ITemplateBroker::oldParentInstruction_
std::map< const MoveNode *, TTAProgram::Instruction *, MoveNode::Comparator > oldParentInstruction_
MoveNode/ original parent instruction.
Definition: ITemplateBroker.hh:138
ITemplateResource::unassign
virtual void unassign(const int cycle, MoveNode &node) override
Definition: ITemplateResource.cc:112
TTAMachine::ImmediateUnit::signExtends
bool signExtends() const
Definition: ImmediateUnit.hh:62
TTAProgram::Instruction::removeImmediate
void removeImmediate(Immediate &imm)
Definition: Instruction.cc:560
ITemplateBroker::allAvailableResources
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
Definition: ITemplateBroker.cc:144
TTAProgram::Terminal::isBasicBlockReference
virtual bool isBasicBlockReference() const
Definition: Terminal.cc:139
MoveNode
Definition: MoveNode.hh:65
MoveNode::isSourceConstant
bool isSourceConstant() const
Definition: MoveNode.cc:238
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
ResourceMapper::resourceOf
SchedulingResource & resourceOf(const TTAMachine::MachinePart &mp, int index=0) const
Definition: ResourceMapper.cc:96
TTAMachine::Machine::Navigator::count
int count() const
ResourceBroker::addResource
void addResource(const TTAMachine::MachinePart &mp, SchedulingResource *res)
Definition: ResourceBroker.cc:265
SimValue
Definition: SimValue.hh:96
MoveNode::isSourceImmediateRegister
bool isSourceImmediateRegister() const
Definition: MoveNode.cc:223
MachineInfo::defaultDataAddressSpace
static TTAMachine::AddressSpace * defaultDataAddressSpace(const TTAMachine::Machine &mach)
Definition: MachineInfo.cc:176
TTAMachine::InstructionTemplate
Definition: InstructionTemplate.hh:49
SchedulingResourceSet
Definition: SchedulingResource.hh:161
TTAProgram::Immediate::destination
const Terminal & destination() const
Definition: Immediate.cc:92
assert
#define assert(condition)
Definition: Application.hh:86
ITemplateBroker::findITemplates
SchedulingResourceSet findITemplates(int, Moves &, Immediates &) const
Definition: ITemplateBroker.cc:738
TTAProgram::TerminalImmediate::value
virtual SimValue value() const
Definition: TerminalImmediate.cc:75
ResourceBroker::resources
void resources(ResourceSet &contents)
Definition: ResourceBroker.cc:279
MoveNode::isImmediate
bool isImmediate() const
Definition: MoveNode.hh:143
MoveNode::isMove
bool isMove() const
ResourceBroker::setResourceMapper
void setResourceMapper(const ResourceMapper &mapper)
Definition: ResourceBroker.cc:224
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
MoveNode::cycle
int cycle() const
Definition: MoveNode.cc:421
InvalidData
Definition: Exception.hh:149
ITemplateResource::assign
virtual void assign(const int cycle, MoveNode &node) override
Definition: ITemplateResource.cc:87
WrongSubclass
Definition: Exception.hh:336
SchedulingResource
Definition: SchedulingResource.hh:52
TTAProgram::Immediate::parent
Instruction * parent() const
Definition: Immediate.hh:67
__func__
#define __func__
Definition: Application.hh:67
ResourceBroker::clear
virtual void clear()
Definition: ResourceBroker.cc:365
TTAMachine::MachinePart
Definition: MachinePart.hh:57
Exception::errorMessageStack
std::string errorMessageStack(bool messagesOnly=false) const
Definition: Exception.cc:138
ResourceBroker::resourceOf
SchedulingResource * resourceOf(const TTAMachine::MachinePart &mp) const
TTAProgram::Terminal::immediateUnit
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
Definition: Terminal.cc:240
ITemplateBroker::Moves
std::vector< std::shared_ptr< const TTAProgram::Move > > Moves
Definition: ITemplateBroker.hh:123
MathTools::requiredBits
static int requiredBits(unsigned long int number)
TTAMachine::InstructionTemplate::supportedWidth
virtual int supportedWidth() const
Definition: InstructionTemplate.cc:427
ITemplateBroker::reselectTemplate
void reselectTemplate(TTAProgram::Instruction &ins, int cycle)
Definition: ITemplateBroker.cc:470
INT_WORD_SIZE
const Byte INT_WORD_SIZE
Definition: BaseType.hh:154
TTAProgram::Move
Definition: Move.hh:55
SchedulingResource::isInUse
virtual bool isInUse(const int cycle) const =0
Exception
Definition: Exception.hh:54
TTAProgram::Move::isInInstruction
bool isInInstruction() const
Definition: Move.cc:144
TTAMachine::InstructionTemplate::isOneOfDestinations
virtual bool isOneOfDestinations(const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:323
TTAProgram::Instruction::immediatePtr
std::shared_ptr< Immediate > immediatePtr(int i) const
Definition: Instruction.cc:309
TTAProgram::Instruction::immediate
Immediate & immediate(int i) const
Definition: Instruction.cc:285
TTAProgram::Immediate::setValue
void setValue(TerminalImmediate *value)
Definition: Immediate.cc:114
MoveNode::immediatePtr
std::shared_ptr< TTAProgram::Immediate > immediatePtr()
Definition: MoveNode.cc:846
TTAProgram::Instruction::instructionTemplate
const TTAMachine::InstructionTemplate & instructionTemplate() const
Definition: Instruction.cc:523
SimValue::unsignedValue
unsigned int unsignedValue() const
Definition: SimValue.cc:919
TTAProgram::TerminalImmediate
Definition: TerminalImmediate.hh:44
ITemplateBroker::rm_
SimpleResourceManager * rm_
Definition: ITemplateBroker.hh:152
MoveNode::move
TTAProgram::Move & move()
SimValue::width
int width() const
Definition: SimValue.cc:103
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
TTAProgram::Move::parent
Instruction & parent() const
Definition: Move.cc:115
SchedulingResourceSet::count
int count() const
Definition: SchedulingResource.cc:251
ITemplateBroker::instructionsNotOwned_
std::map< int, bool > instructionsNotOwned_
Definition: ITemplateBroker.hh:148
ResourceManager::machine
const TTAMachine::Machine & machine() const
Definition: ResourceManager.cc:56
TTAProgram::Instruction::immediateCount
int immediateCount() const
Definition: Instruction.cc:267
TTAProgram::Instruction::setInstructionTemplate
void setInstructionTemplate(const TTAMachine::InstructionTemplate &insTemp)
Definition: Instruction.cc:488
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
ResourceBroker::instructionIndex
unsigned int instructionIndex(unsigned int) const
Definition: ResourceBroker.cc:249
TTAProgram::Terminal::copy
virtual Terminal * copy() const =0
ResourceBroker::ResourceBroker
ResourceBroker(std::string, unsigned int initiationInterval=0)
Definition: ResourceBroker.cc:49
TTAProgram::Terminal::equals
virtual bool equals(const Terminal &other) const =0
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
ResourceBroker::machinePartOf
virtual const TTAMachine::MachinePart & machinePartOf(const SchedulingResource &r) const
Definition: ResourceBroker.cc:181
ContainerTools::containsValue
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
KeyNotFound
Definition: Exception.hh:285
TTAProgram::Terminal::isCodeSymbolReference
virtual bool isCodeSymbolReference() const
Definition: Terminal.cc:154
ITemplateResource
Definition: ITemplateResource.hh:51
SchedulingResourceSet::resource
SchedulingResource & resource(int index) const
Definition: SchedulingResource.cc:263
ITemplateBroker::clearOldResources
void clearOldResources()
Definition: ITemplateBroker.cc:966
ITemplateBroker::unassignImmediate
void unassignImmediate(int, const TTAMachine::ImmediateUnit &)
Definition: ITemplateBroker.cc:440
TTAMachine::ImmediateUnit::extensionMode
virtual Machine::Extension extensionMode() const
Definition: ImmediateUnit.cc:143
TTAProgram::Instruction::movePtr
std::shared_ptr< Move > movePtr(int i) const
Definition: Instruction.cc:216
MoveNode::immediate
TTAProgram::Immediate & immediate()
Definition: MoveNode.cc:838
ITemplateBroker::immediateCycles_
std::map< const MoveNode *, int, GraphNode::Comparator > immediateCycles_
Record cycle for MoveNodes that needed immediate writes, IU broker restores immediates before the tem...
Definition: ITemplateBroker.hh:144
TTAMachine::Machine::instructionTemplateNavigator
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition: Machine.cc:428
ITemplateBroker::Immediates
std::vector< std::shared_ptr< const TTAProgram::Immediate > > Immediates
Definition: ITemplateBroker.hh:124
SchedulingResourceSet::insert
void insert(SchedulingResource &resource)
Definition: SchedulingResource.cc:236
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::AddressSpace::end
virtual ULongWord end() const
Definition: AddressSpace.cc:177
SLongWord
long SLongWord
Definition: BaseType.hh:52
MathTools::requiredBitsSigned
static int requiredBitsSigned(SLongWord number)
ITemplateBroker::immediateValues_
std::map< const MoveNode *, std::shared_ptr< TTAProgram::Immediate >, GraphNode::Comparator > immediateValues_
Definition: ITemplateBroker.hh:146
TTAProgram::Instruction::moveCount
int moveCount() const
Definition: Instruction.cc:176
ITemplateBroker::slots_
std::vector< TTAMachine::Bus * > slots_
Move/immediate slots.
Definition: ITemplateBroker.hh:133
TTAMachine::InstructionTemplate::usesSlot
virtual bool usesSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:265
TTAProgram::TerminalRegister
Definition: TerminalRegister.hh:53
TTAProgram::Instruction::addImmediate
void addImmediate(std::shared_ptr< Immediate > imm)
Definition: Instruction.cc:234
TTAMachine::InstructionTemplate::destinationOfSlot
virtual ImmediateUnit * destinationOfSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:346
SchedulingResourceSet::sort
void sort()
Definition: SchedulingResource.cc:328
ITemplateBroker::isImmediateInTemplate
bool isImmediateInTemplate(int, std::shared_ptr< TTAProgram::Immediate >) const
Definition: ITemplateBroker.cc:920
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50