Go to the documentation of this file.
36 #include <boost/lexical_cast.hpp>
69 std::string name,
BusBroker& busBroker,
unsigned int initiationInterval) :
71 rm_(NULL), busBroker_(busBroker) {
81 unsigned int initiationInterval) :
83 rm_(rm), busBroker_(busBroker) {
90 for (std::map<int, TTAProgram::Instruction*>::iterator i =
123 int immRegIndex)
const {
126 cycle, node, bus, srcFU, dstFU, immWriteCycle, immu, immRegIndex).
128 return resultCount > 0;
157 moves.push_back(testedNode.
movePtr());
191 ins = MapTools::valueForKey<TTAProgram::Instruction*>(
218 if (currentWidth > newSupportedWidth) {
230 templateRes.
assign(cycle);
235 templateRes.
assign(cycle);
253 std::pair<const MoveNode*, TTAProgram::Instruction*>
270 auto imm = std::make_shared<Immediate>(tempImm, tmpReg);
274 std::pair<const MoveNode*, int>(&node,defCycle));
277 std::shared_ptr<TTAProgram::Immediate> >(
301 int cycle, std::shared_ptr<Immediate> immediate) {
308 immediates.push_back(immediate);
322 ins = MapTools::valueForKey<TTAProgram::Instruction*>(
359 templateRes.
assign(cycle);
363 }
catch (
const std::bad_cast& e) {
364 string msg =
"Resource is not of an instruction template resource.";
367 string msg =
"Broker does not contain given resource.";
391 MapTools::valueForKey<TTAProgram::Instruction*>(
393 if (oldParent != NULL) {
400 MapTools::valueForKey<TTAProgram::Instruction*>(
402 if (oldParent != NULL) {
414 MapTools::valueForKey<std::shared_ptr<TTAProgram::Immediate> >(
457 immediateUnit.
name()) {
485 newTemplateRes.
assign(cycle);
559 if (&iTemplate != &NullInstructionTemplate::instance()) {
564 if ( res != NULL && res->
isInUse(cycle)) {
601 for (
int i = 0; i < templateNavi.
count(); i++) {
610 for (
int i = 0; i < busNavi.
count(); i++) {
629 for (ResourceMap::iterator resIter =
resMap_.begin();
630 resIter !=
resMap_.end(); resIter++) {
634 if (itemplate == NULL){
637 "Broker does not have necessary Template registered!");
642 for (
unsigned int i = 0; i <
slots_.size(); i++) {
649 std::string msg =
"ITemplateBroker: finding ";
650 msg +=
" resource for Slot ";
651 msg +=
" failed with error: ";
663 std::string msg =
"ITemplateBroker: finding ";
664 msg +=
" resource for IU ";
665 msg +=
" failed with error: ";
699 cycle, moves, immediates);
700 if (defaultTemplates.
count() == 0) {
703 "No Instruction Template available!");
711 templateRes.
assign(cycle);
719 MapTools::valueForKey<TTAProgram::Instruction*>(
749 ins = MapTools::valueForKey<TTAProgram::Instruction*>(
751 for (
int i = 0; i < ins->
moveCount(); i++) {
752 moves.push_back(ins->
movePtr(i));
759 for (ResourceMap::const_iterator resIter =
resMap_.begin();
760 resIter !=
resMap_.end(); resIter++) {
761 bool addResult =
true;
766 if ((*resIter).second->dependentResourceGroupCount() > 1 &&
767 immediates.size() >
static_cast<unsigned int>(
768 (*resIter).second->dependentResourceCount(1))) {
777 std::vector<const TTAMachine::ImmediateUnit*> unitWriten;
778 for (
unsigned int i = 0; i < immediates.size(); i++) {
780 immediates[i]->destination().immediateUnit();
793 if (immediates[i]->value().value().width() >
INT_WORD_SIZE &&
794 (immediates[i]->value().value().width() >
803 if (immediates[i]->value().isInstructionAddress() &&
804 !immediates[i]->value().isBasicBlockReference() &&
805 !immediates[i]->value().isCodeSymbolReference()) {
809 int requiredBitWidth = unit.
extensionMode() == Machine::SIGN ?
819 if (!immediates[i]->value().isInstructionAddress() &&
820 !immediates[i]->value().isBasicBlockReference() &&
821 !immediates[i]->value().isCodeSymbolReference() &&
824 immediates[i]->value().value().unsignedValue()) >
829 if (!immediates[i]->value().isInstructionAddress() &&
830 !immediates[i]->value().isBasicBlockReference() &&
831 !immediates[i]->value().isCodeSymbolReference() &&
834 immediates[i]->value().value().intValue()) >
840 if (immediates[i]->value().isCodeSymbolReference() &&
841 immediates[i]->value().toString() ==
"_end") {
848 assert(
false &&
"No default data address space");
851 int requiredBitWidth = unit.
extensionMode() == Machine::SIGN ?
860 }
else if (immediates[i]->value().isBasicBlockReference() ||
861 immediates[i]->value().isCodeSymbolReference()) {
865 int requiredBitWidth = unit.
extensionMode() == Machine::SIGN ?
876 unitWriten.push_back(&unit);
881 for (
unsigned int i = 0; i < moves.size(); i++) {
883 const bool isNOPSlot =
false;
887 if ((*resIter).second->hasDependentResource(*bus) ||
894 result.
insert(*(*resIter).second);
922 std::shared_ptr<Immediate> imm)
const {
927 Instruction* ins = MapTools::valueForKey<TTAProgram::Instruction*>(
950 std::shared_ptr<Immediate> immediate)
const {
954 immediates.push_back(immediate);
957 return availableCount > 0;
980 for (std::map<int, TTAProgram::Instruction*>::iterator i =
std::map< int, TTAProgram::Instruction * > instructions_
cycle/instruction
virtual void addToDependentGroup(const int group, SchedulingResource &resource)
void assignImmediate(int, std::shared_ptr< TTAProgram::Immediate >)
virtual bool isTemplateAvailable(int, std::shared_ptr< TTAProgram::Immediate >) const
virtual void setupResourceLinks(const ResourceMapper &mapper) override
virtual int immediateWriteCycle(const MoveNode &) const
void removeMove(Move &move)
void addMove(std::shared_ptr< Move > move)
unsigned int initiationInterval_
virtual TCEString name() const
virtual bool isInstructionAddress() const
std::shared_ptr< TTAProgram::Move > movePtr()
virtual bool isITemplateBroker() const override
#define IGNORE_CLANG_WARNING(X)
virtual std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue(const MoveNode &)
std::map< const MoveNode *, TTAProgram::Instruction *, MoveNode::Comparator > oldParentInstruction_
MoveNode/ original parent instruction.
virtual void unassign(const int cycle, MoveNode &node) override
void removeImmediate(Immediate &imm)
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 bool isBasicBlockReference() const
ITemplateBroker(std::string, BusBroker &busBroker, unsigned int initiationInterval=0)
bool isSourceConstant() const
virtual AddressSpace * addressSpace() const
SchedulingResource & resourceOf(const TTAMachine::MachinePart &mp, int index=0) const
virtual void assign(int cycle, MoveNode &node, SchedulingResource &res, int immWriteCycle, int immRegIndex) override
void addResource(const TTAMachine::MachinePart &mp, SchedulingResource *res)
bool isSourceImmediateRegister() const
static TTAMachine::AddressSpace * defaultDataAddressSpace(const TTAMachine::Machine &mach)
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
#define assert(condition)
SchedulingResourceSet findITemplates(int, Moves &, Immediates &) const
virtual void loseInstructionOwnership(int cycle)
void resources(ResourceSet &contents)
void setResourceMapper(const ResourceMapper &mapper)
virtual ControlUnit * controlUnit() const
#define abortWithError(message)
virtual void assign(const int cycle, MoveNode &node) override
virtual bool isApplicable(const MoveNode &node, const TTAMachine::Bus *) const override
std::string errorMessageStack(bool messagesOnly=false) const
SchedulingResource * resourceOf(const TTAMachine::MachinePart &mp) const
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
std::vector< std::shared_ptr< const TTAProgram::Move > > Moves
virtual void buildResources(const TTAMachine::Machine &target) override
virtual int supportedWidth() const
void reselectTemplate(TTAProgram::Instruction &ins, int cycle)
virtual bool isInUse(const int cycle) const =0
virtual bool isAlreadyAssigned(int cycle, const MoveNode &node, const TTAMachine::Bus *preassignedBus) const override
bool isInInstruction() const
virtual bool isOneOfDestinations(const ImmediateUnit &dstUnit) const
std::shared_ptr< Immediate > immediatePtr(int i) const
Immediate & immediate(int i) const
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
std::shared_ptr< TTAProgram::Immediate > immediatePtr()
const TTAMachine::InstructionTemplate & instructionTemplate() const
unsigned int unsignedValue() const
SimpleResourceManager * rm_
TTAProgram::Move & move()
Instruction & parent() const
std::map< int, bool > instructionsNotOwned_
const TTAMachine::Machine & machine() const
virtual TTAProgram::Instruction * instruction(int cycle)
int immediateCount() const
void setInstructionTemplate(const TTAMachine::InstructionTemplate &insTemp)
virtual BusNavigator busNavigator() const
unsigned int instructionIndex(unsigned int) const
virtual Terminal * copy() const =0
virtual bool equals(const Terminal &other) const =0
Terminal & source() const
virtual const TTAMachine::MachinePart & machinePartOf(const SchedulingResource &r) const
virtual ~ITemplateBroker()
ComponentType * item(int index) const
virtual bool isCodeSymbolReference() const
SchedulingResource & resource(int index) const
void unassignImmediate(int, const TTAMachine::ImmediateUnit &)
std::shared_ptr< Move > movePtr(int i) const
TTAProgram::Immediate & immediate()
virtual void unassign(MoveNode &node) override
std::map< const MoveNode *, int, GraphNode::Comparator > immediateCycles_
Record cycle for MoveNodes that needed immediate writes, IU broker restores immediates before the tem...
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
std::vector< std::shared_ptr< const TTAProgram::Immediate > > Immediates
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
void insert(SchedulingResource &resource)
virtual ULongWord end() const
std::map< const MoveNode *, std::shared_ptr< TTAProgram::Immediate >, GraphNode::Comparator > immediateValues_
std::vector< TTAMachine::Bus * > slots_
Move/immediate slots.
virtual bool usesSlot(const std::string &slotName) const
void addImmediate(std::shared_ptr< Immediate > imm)
virtual ImmediateUnit * destinationOfSlot(const std::string &slotName) const
bool isImmediateInTemplate(int, std::shared_ptr< TTAProgram::Immediate >) const