OpenASIP  2.0
BasicBlockScheduler.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file BasicBlockScheduler.hh
26  *
27  * Declaration of BasicBlockScheduler class.
28  *
29  * @author Pekka J��skel�inen 2006,2010 (pjaaskel-no.spam-cs.tut.fi)
30  * @author Fabio Garzia 2010 (fabio.garzia-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_BB_SCHEDULER_HH
35 #define TTA_BB_SCHEDULER_HH
36 
37 #include <boost/timer.hpp>
38 #include <boost/progress.hpp>
39 
40 #include "MoveNodeSelector.hh"
41 #include "DDGPass.hh"
42 #include "BasicBlockPass.hh"
43 #include "DataDependenceGraph.hh"
44 
46 class SoftwareBypasser;
48 class RegisterRenamer;
49 class MoveNode;
50 class MoveNodeGroup;
52 
53 namespace TTAMachine {
54  class Unit;
55  class Port;
56  class RegisterFile;
57 }
58 
59 /**
60  * A class that implements the functionality of a basic block scheduler.
61  *
62  * Schedules the program one basic block at a time. Does not fill delay slots
63  * if they couldn't be filled with the basic block's contents itself (no
64  * instruction importing).
65  */
67  public DDGPass, public BasicBlockPass {
68 public:
70  InterPassData& data, SoftwareBypasser* bypasser=NULL,
71  RegisterRenamer* renamer=NULL);
72 
73  virtual ~BasicBlockScheduler();
74 
75  virtual int handleDDG(
77  const TTAMachine::Machine& targetMachine, int minCycle = 0,
78  bool testOnly = false) override;
79 
80  virtual int handleLoopDDG(
82  const TTAMachine::Machine& targetMachine, int tripCount,
83  SimpleResourceManager* prologRM, bool testOnly = false) override;
84 
85  virtual std::string shortDescription() const;
86  virtual std::string longDescription() const;
87 
88  virtual void printStats() const;
89 
91 
92  static MoveNode* findTrigger(
93  const ProgramOperation& po,
94  const TTAMachine::Machine& mach);
95 
96 protected:
97  void scheduleRRMove(MoveNode& moveNode);
98 
99  void scheduleOperation(MoveNodeGroup& moves);
100 
101  int scheduleOperandWrites(int& cycle, MoveNodeGroup& moves);
102 
103  bool scheduleResultReads(MoveNodeGroup& moves);
104 
105  void scheduleMove(
106  MoveNode& move, int earliestCycle, bool allowPredicationAndRenaming);
107 
108  void scheduleRRTempMoves(
109  MoveNode& regToRegMove, MoveNode& firstMove, int lastUse);
110 
112  MoveNode& operandMove, MoveNode& operandWrite);
113 
114  void unschedule(MoveNode& moveNode);
115 
116  void unscheduleAllNodes();
117 
118  void unscheduleInputOperandTempMoves(MoveNode& operandMove);
119 
121  MoveNode& resultMove, MoveNode& resultRead, int lastUse);
122 
123  void unscheduleResultReadTempMoves(MoveNode& resultMove);
124 
125  void notifyScheduled(MoveNodeGroup& moves, MoveNodeSelector& selector);
126 
127  void ddgSnapshot(
128  DataDependenceGraph& ddg, const std::string& name,
129  DataDependenceGraph::DumpFileFormat format, bool final,
130  bool resetCounter = false) const;
131 
133 
135  const ProgramOperation& po, const TTAMachine::Unit& unit);
136 
137  int getTriggerOperand(
138  const Operation& operation, const TTAMachine::Machine& machine);
139 
141 
143  std::set<std::pair<TTAProgram::Move*, int> > removedMoves);
144 
145  bool tryToOptimizeWaw(const MoveNode& moveNode);
146 
147  void tryToDelayOperands(MoveNodeGroup& moves);
148 
149  /// The target machine we are scheduling the program against.
151  /// DDG of the currently scheduled BB.
153  /// Resource Manager of the currently scheduled BB.
155  /// Stores the MoveNodes that were scheduled as temp moves during
156  /// scheduling of the operand move.
157  std::map<const MoveNode*, DataDependenceGraph::NodeSet> scheduledTempMoves_;
158  /// The software bypasser to use to bypass registers when possible.
160 
162 
163  /// The earliest cycle to schedule moves in. Used to leave room for
164  /// sched_yield() by the sched_yield() emitter.
166 
168  /// Time for getting the scheduling time for current basic block.
169  boost::timer schedulingTime_;
172 
174 
176 
178 };
179 
180 #endif
BasicBlockScheduler::ddg_
DataDependenceGraph * ddg_
DDG of the currently scheduled BB.
Definition: BasicBlockScheduler.hh:152
BasicBlockScheduler::unschedule
void unschedule(MoveNode &moveNode)
Definition: BasicBlockScheduler.cc:1488
BasicBlockScheduler::deadResults_
int deadResults_
Definition: BasicBlockScheduler.hh:171
BasicBlockScheduler::~BasicBlockScheduler
virtual ~BasicBlockScheduler()
Definition: BasicBlockScheduler.cc:95
BasicBlockScheduler::succeedingTempMove
MoveNode * succeedingTempMove(MoveNode &current)
Definition: BasicBlockScheduler.cc:1410
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
BasicBlockScheduler::selector_
MoveNodeSelector * selector_
Definition: BasicBlockScheduler.hh:167
BasicBlockScheduler::scheduleResultReadTempMoves
void scheduleResultReadTempMoves(MoveNode &resultMove, MoveNode &resultRead, int lastUse)
Definition: BasicBlockScheduler.cc:1442
DataDependenceGraph.hh
ProgramOperation
Definition: ProgramOperation.hh:70
MoveNode
Definition: MoveNode.hh:65
BasicBlockScheduler::unscheduleResultReadTempMoves
void unscheduleResultReadTempMoves(MoveNode &resultMove)
Definition: BasicBlockScheduler.cc:1553
BasicBlockScheduler::BasicBlockScheduler
BasicBlockScheduler(InterPassData &data, SoftwareBypasser *bypasser=NULL, RegisterRenamer *renamer=NULL)
Definition: BasicBlockScheduler.cc:85
BasicBlockScheduler::longDescription
virtual std::string longDescription() const
Definition: BasicBlockScheduler.cc:1587
BasicBlockPass::ddgBuilder
virtual DataDependenceGraphBuilder & ddgBuilder()
Definition: BasicBlockPass.hh:86
BasicBlockScheduler::options_
LLVMTCECmdLineOptions * options_
Definition: BasicBlockScheduler.hh:173
BasicBlockScheduler::bypassedCount_
int bypassedCount_
Definition: BasicBlockScheduler.hh:170
BasicBlockScheduler::findTriggerFromUnit
static MoveNode * findTriggerFromUnit(const ProgramOperation &po, const TTAMachine::Unit &unit)
Definition: BasicBlockScheduler.cc:2130
BasicBlockScheduler::handleLoopDDG
virtual int handleLoopDDG(DataDependenceGraph &ddg, SimpleResourceManager &rm, const TTAMachine::Machine &targetMachine, int tripCount, SimpleResourceManager *prologRM, bool testOnly=false) override
Definition: BasicBlockScheduler.cc:254
BasicBlockScheduler::scheduleMove
void scheduleMove(MoveNode &move, int earliestCycle, bool allowPredicationAndRenaming)
Definition: BasicBlockScheduler.cc:950
BasicBlockScheduler::minCycle_
int minCycle_
The earliest cycle to schedule moves in. Used to leave room for sched_yield() by the sched_yield() em...
Definition: BasicBlockScheduler.hh:165
BasicBlockScheduler::tripCount_
int tripCount_
Definition: BasicBlockScheduler.hh:177
BasicBlockScheduler::scheduleOperandWrites
int scheduleOperandWrites(int &cycle, MoveNodeGroup &moves)
Definition: BasicBlockScheduler.cc:633
MoveNodeSelector.hh
BasicBlockScheduler::findTrigger
static MoveNode * findTrigger(const ProgramOperation &po, const TTAMachine::Machine &mach)
Definition: BasicBlockScheduler.cc:2094
BasicBlockScheduler::scheduleRRMove
void scheduleRRMove(MoveNode &moveNode)
Definition: BasicBlockScheduler.cc:902
BasicBlockScheduler::targetMachine_
const TTAMachine::Machine * targetMachine_
The target machine we are scheduling the program against.
Definition: BasicBlockScheduler.hh:150
BasicBlockPass
Definition: BasicBlockPass.hh:60
BasicBlockScheduler::shortDescription
virtual std::string shortDescription() const
Definition: BasicBlockScheduler.cc:1574
BasicBlockScheduler::ddgSnapshot
void ddgSnapshot(DataDependenceGraph &ddg, const std::string &name, DataDependenceGraph::DumpFileFormat format, bool final, bool resetCounter=false) const
Definition: BasicBlockScheduler.cc:1633
TTAMachine::Unit
Definition: Unit.hh:51
BasicBlockScheduler::printStats
virtual void printStats() const
Definition: BasicBlockScheduler.cc:1908
BasicBlockScheduler::handleRemovedResultMoves
void handleRemovedResultMoves(std::set< std::pair< TTAProgram::Move *, int > > removedMoves)
Definition: BasicBlockScheduler.cc:1807
BasicBlockPass.hh
BasicBlockScheduler
Definition: BasicBlockScheduler.hh:66
InterPassData
Definition: InterPassData.hh:48
BasicBlockScheduler::unscheduleInputOperandTempMoves
void unscheduleInputOperandTempMoves(MoveNode &operandMove)
Definition: BasicBlockScheduler.cc:1532
BasicBlockScheduler::scheduleRRTempMoves
void scheduleRRTempMoves(MoveNode &regToRegMove, MoveNode &firstMove, int lastUse)
Definition: BasicBlockScheduler.cc:1297
BasicBlockScheduler::unscheduleAllNodes
void unscheduleAllNodes()
Definition: BasicBlockScheduler.cc:1511
MoveNodeSelector
Definition: MoveNodeSelector.hh:45
BasicBlockScheduler::handleDDG
virtual int handleDDG(DataDependenceGraph &ddg, SimpleResourceManager &rm, const TTAMachine::Machine &targetMachine, int minCycle=0, bool testOnly=false) override
Definition: BasicBlockScheduler.cc:109
BasicBlockScheduler::scheduleInputOperandTempMoves
void scheduleInputOperandTempMoves(MoveNode &operandMove, MoveNode &operandWrite)
Definition: BasicBlockScheduler.cc:1344
LLVMTCECmdLineOptions
Definition: LLVMTCECmdLineOptions.hh:48
Operation
Definition: Operation.hh:59
BasicBlockScheduler::renamer_
RegisterRenamer * renamer_
Definition: BasicBlockScheduler.hh:161
BasicBlockScheduler::rm_
SimpleResourceManager * rm_
Resource Manager of the currently scheduled BB.
Definition: BasicBlockScheduler.hh:154
DDGPass
Definition: DDGPass.hh:51
BasicBlockScheduler::getTriggerOperand
int getTriggerOperand(const Operation &operation, const TTAMachine::Machine &machine)
Definition: BasicBlockScheduler.cc:1684
DDGPass.hh
BasicBlockScheduler::softwareBypasser_
SoftwareBypasser * softwareBypasser_
The software bypasser to use to bypass registers when possible.
Definition: BasicBlockScheduler.hh:159
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
SoftwareBypasser
Definition: SoftwareBypasser.hh:52
BasicBlockScheduler::scheduledTempMoves_
std::map< const MoveNode *, DataDependenceGraph::NodeSet > scheduledTempMoves_
Stores the MoveNodes that were scheduled as temp moves during scheduling of the operand move.
Definition: BasicBlockScheduler.hh:157
BasicBlockScheduler::scheduleResultReads
bool scheduleResultReads(MoveNodeGroup &moves)
Definition: BasicBlockScheduler.cc:847
SimpleResourceManager
Definition: SimpleResourceManager.hh:58
BasicBlockScheduler::tryToSwitchInputs
bool tryToSwitchInputs(ProgramOperation &op)
Definition: BasicBlockScheduler.cc:1734
BasicBlockScheduler::tryToOptimizeWaw
bool tryToOptimizeWaw(const MoveNode &moveNode)
Definition: BasicBlockScheduler.cc:1920
MoveNodeGroup
Definition: MoveNodeGroup.hh:48
DataDependenceGraph::DumpFileFormat
DumpFileFormat
Definition: DataDependenceGraph.hh:85
TTAMachine
Definition: Assembler.hh:48
BasicBlockScheduler::tryToDelayOperands
void tryToDelayOperands(MoveNodeGroup &moves)
Definition: BasicBlockScheduler.cc:2021
RegisterRenamer
Definition: RegisterRenamer.hh:59
BasicBlockScheduler::notifyScheduled
void notifyScheduled(MoveNodeGroup &moves, MoveNodeSelector &selector)
Definition: BasicBlockScheduler.cc:1602
TTAMachine::Machine
Definition: Machine.hh:73
BasicBlockScheduler::scheduleOperation
void scheduleOperation(MoveNodeGroup &moves)
Definition: BasicBlockScheduler.cc:401
BasicBlockScheduler::schedulingTime_
boost::timer schedulingTime_
Time for getting the scheduling time for current basic block.
Definition: BasicBlockScheduler.hh:169
BasicBlockScheduler::jumpNode_
MoveNode * jumpNode_
Definition: BasicBlockScheduler.hh:175