OpenASIP  2.0
BUBasicBlockScheduler.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 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 BUBasicBlockScheduler.hh
26  *
27  * Declaration of BUBasicBlockScheduler class.
28  *
29  * @author Vladimir Guzma 2011 (vladimir.guzma-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_BU_BB_SCHEDULER_HH
34 #define TTA_BU_BB_SCHEDULER_HH
35 
36 #include "BUMoveNodeSelector.hh"
37 #include "DDGPass.hh"
38 #include "BasicBlockPass.hh"
39 #include "BasicBlockScheduler.hh"
40 #include "CodeGenerator.hh"
41 
42 class BasicBlockNode;
44 class SoftwareBypasser;
48 class RegisterRenamer;
49 class MoveNode;
50 class MoveNodeGroup;
52 
53 /**
54  * A class that implements the functionality of a bottom up basic block
55  * scheduler.
56  *
57  * Schedules the program one basic block at a time. Does not fill delay slots
58  * if they couldn't be filled with the basic block's contents itself (no
59  * instruction importing).
60  */
62  public BasicBlockScheduler {
63 public:
65  InterPassData& data, SoftwareBypasser* bypasser=NULL,
66  RegisterRenamer* registerRenamer = NULL);
67  virtual ~BUBasicBlockScheduler();
68 
69  virtual int handleDDG(
71  const TTAMachine::Machine& targetMachine, int minCycle = 0,
72  bool testOnly = false);
73  virtual int handleLoopDDG(
75  const TTAMachine::Machine& targetMachine, int tripCount,
76  SimpleResourceManager* prologRM = NULL, bool testOnly = false);
77 
78  virtual std::string shortDescription() const;
79  virtual std::string longDescription() const;
80 
81 /* virtual MoveNodeSelector* createSelector(
82  TTAProgram::BasicBlock& bb, const TTAMachine::Machine& machine) {
83  return new BUMoveNodeSelector(bb, machine);
84  }*/
85 
87 
88 protected:
89  struct ltstr
90  {
91  bool operator()(const MoveNode* m1, const MoveNode* m2) const
92  {
93  return m1->cycle() < m2->cycle();
94  }
95  };
96 
97  typedef std::set<MoveNode*, ltstr> OrderedSet;
98 
99  void scheduleRRMove(MoveNode& moveNode);
100 
101  void scheduleOperation(MoveNodeGroup& moves, BUMoveNodeSelector& selector);
102 
103  bool scheduleOperandWrites(MoveNodeGroup& moves, int cycle);
104 
106  MoveNodeGroup& moves, int cycle, bool bypass = false,
107  bool bypassLate = false);
108 
109  void scheduleMove(
110  MoveNode& move, int cycle, bool allowPredicationandRenaming);
111 
113  MoveNode& resultMove, MoveNode& resultRead, int lastUse);
114 
116  MoveNode& resultMove, MoveNode& resultRead);
117 
118  void scheduleRRTempMoves(
119  MoveNode& regToRegMove, MoveNode& firstMove, int lastUse);
120 
121  bool scheduleOperand(MoveNode&, int cycle);
122 
124 
125  bool tryToOptimizeWaw(const MoveNode& moveNode);
126 
128 
130 
131  void undoBypass(
132  MoveNode& node, MoveNode* single = NULL, int originalCycle = -1);
133 
134  bool bypassNode(MoveNode& node, int& maxResultCycle);
135 
136  void finalizeSchedule(MoveNode& node, BUMoveNodeSelector& selector);
137 
138  void unscheduleAllNodes();
139 
140  void clearRemovedNodes();
141 
143 
144  std::map<MoveNode*, std::vector<MoveNode*>, MoveNode::Comparator>
146  std::map<MoveNode*, std::vector<int>, MoveNode::Comparator >
148  std::map<MoveNode*,
149  std::vector<const TTAMachine::Bus*>,
152  std::set<MoveNode*> droppedNodes_;
153 
154  unsigned int endCycle_;
155  bool bypass_;
156  bool dre_;
158 };
159 
160 #endif
BUBasicBlockScheduler::longDescription
virtual std::string longDescription() const
Definition: BUBasicBlockScheduler.cc:1210
BUBasicBlockScheduler::BUBasicBlockScheduler
BUBasicBlockScheduler(InterPassData &data, SoftwareBypasser *bypasser=NULL, RegisterRenamer *registerRenamer=NULL)
Definition: BUBasicBlockScheduler.cc:86
BUBasicBlockScheduler::findBypassDestinations
OrderedSet findBypassDestinations(MoveNode &node)
Definition: BUBasicBlockScheduler.cc:1488
BUBasicBlockScheduler::scheduleResultReadTempMoves
void scheduleResultReadTempMoves(MoveNode &resultMove, MoveNode &resultRead, int lastUse)
Definition: BUBasicBlockScheduler.cc:1229
BUBasicBlockScheduler::undoBypass
void undoBypass(MoveNode &node, MoveNode *single=NULL, int originalCycle=-1)
Definition: BUBasicBlockScheduler.cc:1528
BUBasicBlockScheduler::scheduleMove
void scheduleMove(MoveNode &move, int cycle, bool allowPredicationandRenaming)
Definition: BUBasicBlockScheduler.cc:960
BUBasicBlockScheduler::bypass_
bool bypass_
Definition: BUBasicBlockScheduler.hh:155
BUBasicBlockScheduler::OrderedSet
std::set< MoveNode *, ltstr > OrderedSet
Definition: BUBasicBlockScheduler.hh:97
ProgramOperation
Definition: ProgramOperation.hh:70
MoveNode
Definition: MoveNode.hh:65
BUMoveNodeSelector.hh
BUMoveNodeSelector
Definition: BUMoveNodeSelector.hh:70
BasicBlockPass::ddgBuilder
virtual DataDependenceGraphBuilder & ddgBuilder()
Definition: BasicBlockPass.hh:86
BUBasicBlockScheduler
Definition: BUBasicBlockScheduler.hh:61
BasicBlockScheduler.hh
BUBasicBlockScheduler::tryToSwitchInputs
bool tryToSwitchInputs(ProgramOperation &op)
Definition: BUBasicBlockScheduler.cc:1910
BUBasicBlockScheduler::clearRemovedNodes
void clearRemovedNodes()
Definition: BUBasicBlockScheduler.cc:1874
BUBasicBlockScheduler::~BUBasicBlockScheduler
virtual ~BUBasicBlockScheduler()
Definition: BUBasicBlockScheduler.cc:101
BUBasicBlockScheduler::bypassNode
bool bypassNode(MoveNode &node, int &maxResultCycle)
Definition: BUBasicBlockScheduler.cc:1602
MoveNode::cycle
int cycle() const
Definition: MoveNode.cc:421
BUBasicBlockScheduler::unscheduleAllNodes
void unscheduleAllNodes()
Definition: BUBasicBlockScheduler.cc:1841
BUBasicBlockScheduler::scheduleRRTempMoves
void scheduleRRTempMoves(MoveNode &regToRegMove, MoveNode &firstMove, int lastUse)
Definition: BUBasicBlockScheduler.cc:1366
BUBasicBlockScheduler::dre_
bool dre_
Definition: BUBasicBlockScheduler.hh:156
BasicBlockPass.hh
BUBasicBlockScheduler::ltstr::operator()
bool operator()(const MoveNode *m1, const MoveNode *m2) const
Definition: BUBasicBlockScheduler.hh:91
BasicBlockScheduler
Definition: BasicBlockScheduler.hh:66
CopyingDelaySlotFiller
Definition: CopyingDelaySlotFiller.hh:71
BasicBlockNode
Definition: BasicBlockNode.hh:64
InterPassData
Definition: InterPassData.hh:48
GraphNode::Comparator
Definition: GraphNode.hh:56
BUBasicBlockScheduler::tryToOptimizeWaw
bool tryToOptimizeWaw(const MoveNode &moveNode)
Definition: BUBasicBlockScheduler.cc:1978
BUBasicBlockScheduler::handleDDG
virtual int handleDDG(DataDependenceGraph &ddg, SimpleResourceManager &rm, const TTAMachine::Machine &targetMachine, int minCycle=0, bool testOnly=false)
Definition: BUBasicBlockScheduler.cc:113
BUBasicBlockScheduler::finalizeSchedule
void finalizeSchedule(MoveNode &node, BUMoveNodeSelector &selector)
Definition: BUBasicBlockScheduler.cc:1744
BUBasicBlockScheduler::shortDescription
virtual std::string shortDescription() const
Definition: BUBasicBlockScheduler.cc:1197
BUBasicBlockScheduler::ltstr
Definition: BUBasicBlockScheduler.hh:89
LLVMTCECmdLineOptions
Definition: LLVMTCECmdLineOptions.hh:48
BUBasicBlockScheduler::bypassDestinationsBus_
std::map< MoveNode *, std::vector< const TTAMachine::Bus * >, MoveNode::Comparator > bypassDestinationsBus_
Definition: BUBasicBlockScheduler.hh:151
BUBasicBlockScheduler::handleLoopDDG
virtual int handleLoopDDG(DataDependenceGraph &ddg, SimpleResourceManager &rm, const TTAMachine::Machine &targetMachine, int tripCount, SimpleResourceManager *prologRM=NULL, bool testOnly=false)
Definition: BUBasicBlockScheduler.cc:260
BUBasicBlockScheduler::jumpMove_
MoveNode * jumpMove_
Definition: BUBasicBlockScheduler.hh:142
BUBasicBlockScheduler::scheduleOperand
bool scheduleOperand(MoveNode &, int cycle)
Definition: BUBasicBlockScheduler.cc:1449
BUBasicBlockScheduler::scheduleInputOperandTempMoves
void scheduleInputOperandTempMoves(MoveNode &resultMove, MoveNode &resultRead)
Definition: BUBasicBlockScheduler.cc:1290
BUBasicBlockScheduler::bypassDestinations_
std::map< MoveNode *, std::vector< MoveNode * >, MoveNode::Comparator > bypassDestinations_
Definition: BUBasicBlockScheduler.hh:145
BUBasicBlockScheduler::droppedNodes_
std::set< MoveNode * > droppedNodes_
Definition: BUBasicBlockScheduler.hh:152
CodeGenerator.hh
DataDependenceGraphBuilder
Definition: DataDependenceGraphBuilder.hh:70
BUBasicBlockScheduler::scheduleRRMove
void scheduleRRMove(MoveNode &moveNode)
Definition: BUBasicBlockScheduler.cc:912
BUBasicBlockScheduler::scheduleOperandWrites
bool scheduleOperandWrites(MoveNodeGroup &moves, int cycle)
Definition: BUBasicBlockScheduler.cc:664
DDGPass.hh
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
SoftwareBypasser
Definition: SoftwareBypasser.hh:52
BUBasicBlockScheduler::bypassDistance_
int bypassDistance_
Definition: BUBasicBlockScheduler.hh:157
BUBasicBlockScheduler::scheduleOperation
void scheduleOperation(MoveNodeGroup &moves, BUMoveNodeSelector &selector)
Definition: BUBasicBlockScheduler.cc:455
SimpleResourceManager
Definition: SimpleResourceManager.hh:58
BUBasicBlockScheduler::bypassDestinationsCycle_
std::map< MoveNode *, std::vector< int >, MoveNode::Comparator > bypassDestinationsCycle_
Definition: BUBasicBlockScheduler.hh:147
MoveNodeGroup
Definition: MoveNodeGroup.hh:48
BUBasicBlockScheduler::precedingTempMove
MoveNode * precedingTempMove(MoveNode &current)
Definition: BUBasicBlockScheduler.cc:1425
BUBasicBlockScheduler::scheduleResultReads
int scheduleResultReads(MoveNodeGroup &moves, int cycle, bool bypass=false, bool bypassLate=false)
Definition: BUBasicBlockScheduler.cc:805
RegisterRenamer
Definition: RegisterRenamer.hh:59
BUBasicBlockScheduler::endCycle_
unsigned int endCycle_
Definition: BUBasicBlockScheduler.hh:154
TTAMachine::Machine
Definition: Machine.hh:73