Go to the documentation of this file.
38 #include <boost/config.hpp>
39 #include <boost/format.hpp>
71 class SequentialSelector;
131 std::string message =
" Move(s) did not get scheduled: ";
132 for (
int i = 0; i < moves.
nodeCount(); i++) {
138 for (
int moveIndex = 0; moveIndex < moves.
nodeCount(); ++moveIndex) {
148 #ifdef DEBUG_REG_COPY_ADDER
149 static int graphCount = 0;
178 #ifdef DEBUG_REG_COPY_ADDER
179 const int tempsAdded = addedCopies.
count_;
183 for (
int i = 0; i < moves.
nodeCount(); i++) {
190 earliestCycle, moves, addedCopies);
191 if (triggerCycle == -1) {
194 "Scheduling operands failed for: " +moves.
toString());
199 if (lastCycle == -1) {
202 "Scheduling results failed for: " +moves.
toString());
227 int scheduledMoves = 0;
232 for (
int i = 0; i < moves.
nodeCount(); i++) {
257 cycle = node.
cycle() + 1;
281 for (
int moveIndex = 0; moveIndex < moves.
nodeCount(); ++moveIndex) {
288 (boost::format(
"Move to schedule '%s' is not "
289 "result move!") % node.
toString()).str());
299 (boost::format(
"Move '%s' did not get scheduled!")
346 (boost::format(
"Move '%s' is already scheduled!")
362 earliestCycle += std::max(0, guardLatency - 1);
407 if (earliestCycle == -1 || earliestCycle == INT_MAX) {
415 std::string msg =
"Assignment of MoveNode " + moveNode.
toString();
416 msg +=
" failed! Most likely missing Long Immediate Unit";
417 msg +=
" or Instruction Template!";
421 std::string msg =
"Assignment of MoveNode " + moveNode.
toString();
430 (boost::format(
"Assignment of MoveNode '%s' failed!")
433 return earliestCycle;
453 if (regCopies.
count_ > 0) {
460 DataDependenceGraph::NodeSet::iterator i = tempMoves.end();
461 while(i != tempMoves.begin()){
482 if (regCopies.
count_ > 0) {
488 DataDependenceGraph::NodeSet::iterator i = tempMoves.begin();
494 while(i != tempMoves.begin()){
514 if (regCopies.
count_ > 0) {
518 for (DataDependenceGraph::NodeSet::iterator i = tempMoves.begin();
519 i != tempMoves.end(); ++i) {
540 if (regCopies.
count_ > 0) {
547 DataDependenceGraph::NodeSet::iterator i = tempMoves.end();
548 while (i != tempMoves.begin()) {
570 (boost::format(
"Trying to unschedule move '%s' which "
571 "is not scheduled!") % moveNode.
toString()).str());
583 (boost::format(
"Unscheduling of move '%s' failed!")
602 std::vector<TTAProgram::BasicBlock*> basicBlocks;
603 std::vector<int> bbAddresses;
606 for (
unsigned int i = 0; i < basicBlocks.size();i++) {
608 *basicBlocks[i], targetMachine,
615 for (
unsigned int i = 0; i < basicBlocks.size();i++) {
616 delete basicBlocks[i];
628 return "Sequential Instruction scheduler";
641 return "Sequential Instruction scheduler";
650 std::vector<TTAProgram::BasicBlock*> &basicBlocks,
651 std::vector<int>& bbAddresses) {
655 int lastStartAddress = 0;
663 if (currentBB != NULL) {
666 basicBlocks.push_back(currentBB);
667 bbAddresses.push_back(lastStartAddress);
677 assert(currentBB != NULL);
678 currentBB->
add(insCopy);
682 basicBlocks.push_back(currentBB);
683 bbAddresses.push_back(lastStartAddress);
689 if (currentBB !=
nullptr) {
692 basicBlocks.push_back(currentBB);
693 bbAddresses.push_back(lastStartAddress);
703 std::vector<TTAProgram::BasicBlock*>& basicBlocks,
704 std::vector<int>& bbAddresses) {
708 for (
unsigned int i = 0; i < basicBlocks.size(); i++) {
714 irm.
replace(oldProcIns, bbIns);
719 for (
unsigned int i = 0; i < basicBlocks.size(); i++) {
726 proc.CodeSnippet::add(insCopy);
735 proc.CodeSnippet::add(insCopy);
virtual bool isFUPort() const
void unscheduleInputOperandTempMoves(MoveNode &operandMove, RegisterCopyAdder::AddedRegisterCopies ®Copies)
virtual bool isTriggering() const
int scheduleOperandWrites(int cycle, MoveNodeGroup &moves, RegisterCopyAdder::AddedRegisterCopies ®Copies)
SequentialScheduler(InterPassData &data)
virtual Instruction & firstInstruction() const
virtual int largestCycle() const override
std::string toString() const
MoveNode & node(int index) const
virtual std::string longDescription() const
bool isDestinationOperation() const
std::set< MoveNode *, typename MoveNode ::Comparator > NodeSet
bool isUnconditional() const
void setAnnotation(const ProgramAnnotation &annotation)
SimpleResourceManager * rm_
Resource Manager of the currently scheduled BB.
Terminal & destination() const
virtual MoveNodeGroup candidates()
AddedRegisterCopyMap operandCopies_
bool isSourceConstant() const
virtual void assign(int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) override
const TTAMachine::Machine * targetMachine_
The target machine we are scheduling the program against.
int scheduleMove(int earliestCycle, MoveNode &move)
virtual void unassign(MoveNode &node) override
ProgramOperation & sourceOperation() const
#define assert(condition)
int scheduleInputOperandTempMoves(int cycle, MoveNode &operandMove, RegisterCopyAdder::AddedRegisterCopies ®Copies)
Procedure & nextProcedure(const Procedure &proc) const
int earliestResultReadCycle() const
virtual ControlUnit * controlUnit() const
AddedRegisterCopies addRegisterCopiesToRRMove(MoveNode &moveNode, DataDependenceGraph *ddg)
void moveProcedure(Procedure &proc, int howMuch)
virtual int instructionCount() const
virtual void add(Instruction *ins)
int scheduleResultTempMoves(int cycle, MoveNode &resultMove, RegisterCopyAdder::AddedRegisterCopies ®Copies)
virtual void notifyScheduled(MoveNode &node)
Instruction * copy() const
bool hasReference(Instruction &ins) const
void replace(Instruction &insA, Instruction &insB)
MoveGuard & guard() const
virtual int earliestCycle(MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override
virtual ~SequentialScheduler()
bool isSourceOperation() const
static void disposeRM(SimpleResourceManager *rm, bool allowReuse=true)
InstructionAddress location() const
virtual std::string shortDescription() const
int inputMoveCount() const
static void copyRMToBB(SimpleResourceManager &rm, TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, int lastCycle=-1)
bool hasAnnotations(ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID) const
std::string toString() const
static SimpleResourceManager * createRM(const TTAMachine::Machine &machine, unsigned int ii=0)
virtual void handleBasicBlock(TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, BasicBlockNode *bbn=NULL)
void copyBasicBlocksToProcedure(TTAProgram::Procedure &cs, std::vector< TTAProgram::BasicBlock * > &basicBlocks, std::vector< int > &bbAddresses)
int scheduleRRTempMoves(int cycle, MoveNode ®ToRegMove, RegisterCopyAdder::AddedRegisterCopies ®Copies)
ProgramOperation & destinationOperation(unsigned int index=0) const
TTAProgram::Move & move()
InterPassData & interPassData()
int scheduleResultReads(int triggerCycle, MoveNodeGroup &moves, RegisterCopyAdder::AddedRegisterCopies ®Copies)
InstructionReferenceManager & instructionReferenceManager() const
AddedRegisterCopyMap resultCopies_
@ ANN_STACKFRAME_PROCEDURE_RETURN
precedure return jmp
void addMoveNode(MoveNode &)
virtual bool canTransportImmediate(const MoveNode &node, const TTAMachine::Bus *preAssignedBus=NULL) const
virtual Program & parent() const
void handleProcedure(TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetMachine)
bool isOperationMove() const
virtual Instruction & instructionAtIndex(int index) const
MoveNodeSelector * selector_
void createBasicBlocks(TTAProgram::Procedure &cs, std::vector< TTAProgram::BasicBlock * > &basicBlocks, std::vector< int > &bbAddresses)
bool hasControlFlowMove() const
virtual int guardLatency() const
const TTAMachine::Guard & guard() const
Procedure & lastProcedure() const
void removeAnnotations(ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID)
virtual Instruction & instructionAt(UIntWord address) const
int globalGuardLatency() const
virtual bool isRA() const
void unschedule(MoveNode &moveNode)
const RegisterFile * registerFile() const
virtual bool isInProgram() const
int scheduleOperation(MoveNodeGroup &moves, int earliestCycle)
AddedRegisterCopies addMinimumRegisterCopies(ProgramOperation &programOperation, const TTAMachine::Machine &targetMachine, DataDependenceGraph *ddg)
int scheduleRRMove(int cycle, MoveNode &moveNode)