OpenASIP 2.2
Loading...
Searching...
No Matches
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"
40#include "CodeGenerator.hh"
41
42class BasicBlockNode;
48class RegisterRenamer;
49class MoveNode;
50class 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 {
63public:
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
88protected:
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
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_;
156 bool dre_;
158};
159
160#endif
void scheduleRRMove(MoveNode &moveNode)
std::map< MoveNode *, std::vector< int >, MoveNode::Comparator > bypassDestinationsCycle_
void scheduleOperation(MoveNodeGroup &moves, BUMoveNodeSelector &selector)
bool scheduleOperandWrites(MoveNodeGroup &moves, int cycle)
bool tryToSwitchInputs(ProgramOperation &op)
bool scheduleOperand(MoveNode &, int cycle)
bool tryToOptimizeWaw(const MoveNode &moveNode)
virtual int handleLoopDDG(DataDependenceGraph &ddg, SimpleResourceManager &rm, const TTAMachine::Machine &targetMachine, int tripCount, SimpleResourceManager *prologRM=NULL, bool testOnly=false)
bool bypassNode(MoveNode &node, int &maxResultCycle)
virtual std::string longDescription() const
void undoBypass(MoveNode &node, MoveNode *single=NULL, int originalCycle=-1)
MoveNode * precedingTempMove(MoveNode &current)
void scheduleMove(MoveNode &move, int cycle, bool allowPredicationandRenaming)
void finalizeSchedule(MoveNode &node, BUMoveNodeSelector &selector)
std::set< MoveNode *, ltstr > OrderedSet
std::set< MoveNode * > droppedNodes_
OrderedSet findBypassDestinations(MoveNode &node)
std::map< MoveNode *, std::vector< const TTAMachine::Bus * >, MoveNode::Comparator > bypassDestinationsBus_
virtual int handleDDG(DataDependenceGraph &ddg, SimpleResourceManager &rm, const TTAMachine::Machine &targetMachine, int minCycle=0, bool testOnly=false)
virtual std::string shortDescription() const
void scheduleResultReadTempMoves(MoveNode &resultMove, MoveNode &resultRead, int lastUse)
void scheduleInputOperandTempMoves(MoveNode &resultMove, MoveNode &resultRead)
std::map< MoveNode *, std::vector< MoveNode * >, MoveNode::Comparator > bypassDestinations_
int scheduleResultReads(MoveNodeGroup &moves, int cycle, bool bypass=false, bool bypassLate=false)
void scheduleRRTempMoves(MoveNode &regToRegMove, MoveNode &firstMove, int lastUse)
virtual DataDependenceGraphBuilder & ddgBuilder()
int cycle() const
Definition MoveNode.cc:421
bool operator()(const MoveNode *m1, const MoveNode *m2) const