OpenASIP  2.0
CycleLookBackSoftwareBypasser.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 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 CycleLookBackSoftwareBypasser.hh
26  *
27  * Declaration of CycleLookBackSoftwareBypasser interface.
28  *
29  * @author Pekka Jääskeläinen 2007 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_CYCLE_LOOK_BACK_SOFTWARE_BYPASSER_HH
34 #define TTA_CYCLE_LOOK_BACK_SOFTWARE_BYPASSER_HH
35 
36 #include <map>
37 #include <set>
38 
39 #include "SoftwareBypasser.hh"
40 #include "DataDependenceGraph.hh"
41 
42 namespace TTAMachine {
43  class Bus;
44 }
45 class MoveNodeSelector;
46 class MoveNode;
47 /**
48  * A simple implementation of software bypassing that reschedules operand
49  * writes as bypassed moves in case the result has been produced in n
50  * previous cycles.
51  */
53 public:
56 
57  virtual int bypass(
58  MoveNodeGroup& candidates,
60  ResourceManager& rm, bool bypassTrigger);
61 
62  virtual void removeBypass(
63  MoveNodeGroup& candidates,
65  ResourceManager& rm);
66 
67  virtual void removeBypass(
68  MoveNode& moveNode,
70  ResourceManager& rm, bool restoreSource=true);
71 
72  virtual int removeDeadResults(
73  MoveNodeGroup& candidates,
75  ResourceManager& rm,
76  std::set<std::pair<TTAProgram::Move*, int> >& removedMoves);
77 
78  void setSelector(MoveNodeSelector* selector);
79 
80  virtual void clearCaches(DataDependenceGraph& ddg, bool removeDeadResults);
81 
82  static void printStats();
83 private:
84  /// count of cycles before the operand write to look for the producer
85  /// of the read value
87 
88  /// count of cycles before the operand write to look for the producer
89  /// of the read value when cannot kill result
91 
92  // whether dead results should be killed.
94 
95  // whether to bypass from register-to-register moves
97 
98  // whether to bypass to register-to-register moves
100 
101  int bypassNode(
102  MoveNode& nodeToBypass,
103  int& lastOperandCycle,
104  DataDependenceGraph& ddg,
105  ResourceManager& rm);
106 
107  /// Stores sources and bypassed moves in case they
108  /// have to be unassigned (case when operands are scheduled
109  /// and bypassed but result can not be scheduled with such operands
110  // First is bypassed node, second is original source
111  std::map<MoveNode*, MoveNode*, MoveNode::Comparator> storedSources_;
112 
113  // cycles and buses of source nodes so that they can be reassigned.
114  std::map<MoveNode*, int> sourceCycles_;
115  std::map<MoveNode*, const TTAMachine::Bus*> sourceBuses_;
116 
117  std::map<MoveNode*, MoveNode*, MoveNode::Comparator> removedStoredSources_;
118 
119  // these are alreayd removed from the dubgraph. remove also from the
120  // big ddg.
122 
124 
125  static int bypassCount_;
126  static int deadResultCount_;
127  static int triggerAbortCount_;
128 };
129 
130 #endif
CycleLookBackSoftwareBypasser::deadResultCount_
static int deadResultCount_
Definition: CycleLookBackSoftwareBypasser.hh:126
CycleLookBackSoftwareBypasser::clearCaches
virtual void clearCaches(DataDependenceGraph &ddg, bool removeDeadResults)
Definition: CycleLookBackSoftwareBypasser.cc:769
CycleLookBackSoftwareBypasser::triggerAbortCount_
static int triggerAbortCount_
Definition: CycleLookBackSoftwareBypasser.hh:127
CycleLookBackSoftwareBypasser
Definition: CycleLookBackSoftwareBypasser.hh:52
BoostGraph< MoveNode, DataDependenceEdge >::NodeSet
std::set< MoveNode *, typename MoveNode ::Comparator > NodeSet
Definition: BoostGraph.hh:86
CycleLookBackSoftwareBypasser::sourceBuses_
std::map< MoveNode *, const TTAMachine::Bus * > sourceBuses_
Definition: CycleLookBackSoftwareBypasser.hh:115
CycleLookBackSoftwareBypasser::sourceCycles_
std::map< MoveNode *, int > sourceCycles_
Definition: CycleLookBackSoftwareBypasser.hh:114
CycleLookBackSoftwareBypasser::killDeadResults_
bool killDeadResults_
Definition: CycleLookBackSoftwareBypasser.hh:93
CycleLookBackSoftwareBypasser::storedSources_
std::map< MoveNode *, MoveNode *, MoveNode::Comparator > storedSources_
Stores sources and bypassed moves in case they have to be unassigned (case when operands are schedule...
Definition: CycleLookBackSoftwareBypasser.hh:111
DataDependenceGraph.hh
MoveNode
Definition: MoveNode.hh:65
CycleLookBackSoftwareBypasser::bypassNode
int bypassNode(MoveNode &nodeToBypass, int &lastOperandCycle, DataDependenceGraph &ddg, ResourceManager &rm)
Definition: CycleLookBackSoftwareBypasser.cc:98
CycleLookBackSoftwareBypasser::removeBypass
virtual void removeBypass(MoveNodeGroup &candidates, DataDependenceGraph &ddg, ResourceManager &rm)
Definition: CycleLookBackSoftwareBypasser.cc:515
CycleLookBackSoftwareBypasser::cyclesToLookBackNoDRE_
int cyclesToLookBackNoDRE_
count of cycles before the operand write to look for the producer of the read value when cannot kill ...
Definition: CycleLookBackSoftwareBypasser.hh:90
CycleLookBackSoftwareBypasser::printStats
static void printStats()
Definition: CycleLookBackSoftwareBypasser.cc:788
CycleLookBackSoftwareBypasser::selector_
MoveNodeSelector * selector_
Definition: CycleLookBackSoftwareBypasser.hh:123
CycleLookBackSoftwareBypasser::removedNodes_
DataDependenceGraph::NodeSet removedNodes_
Definition: CycleLookBackSoftwareBypasser.hh:121
ResourceManager
Definition: ResourceManager.hh:53
CycleLookBackSoftwareBypasser::setSelector
void setSelector(MoveNodeSelector *selector)
Definition: CycleLookBackSoftwareBypasser.cc:756
CycleLookBackSoftwareBypasser::~CycleLookBackSoftwareBypasser
virtual ~CycleLookBackSoftwareBypasser()
Definition: CycleLookBackSoftwareBypasser.cc:83
CycleLookBackSoftwareBypasser::bypassCount_
static int bypassCount_
Definition: CycleLookBackSoftwareBypasser.hh:125
MoveNodeSelector
Definition: MoveNodeSelector.hh:45
CycleLookBackSoftwareBypasser::bypassToRegs_
bool bypassToRegs_
Definition: CycleLookBackSoftwareBypasser.hh:99
CycleLookBackSoftwareBypasser::CycleLookBackSoftwareBypasser
CycleLookBackSoftwareBypasser()
Definition: CycleLookBackSoftwareBypasser.cc:62
CycleLookBackSoftwareBypasser::bypassFromRegs_
bool bypassFromRegs_
Definition: CycleLookBackSoftwareBypasser.hh:96
CycleLookBackSoftwareBypasser::removeDeadResults
virtual int removeDeadResults(MoveNodeGroup &candidates, DataDependenceGraph &ddg, ResourceManager &rm, std::set< std::pair< TTAProgram::Move *, int > > &removedMoves)
Definition: CycleLookBackSoftwareBypasser.cc:600
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
SoftwareBypasser
Definition: SoftwareBypasser.hh:52
CycleLookBackSoftwareBypasser::removedStoredSources_
std::map< MoveNode *, MoveNode *, MoveNode::Comparator > removedStoredSources_
Definition: CycleLookBackSoftwareBypasser.hh:117
MoveNodeGroup
Definition: MoveNodeGroup.hh:48
TTAMachine
Definition: Assembler.hh:48
CycleLookBackSoftwareBypasser::cyclesToLookBack_
int cyclesToLookBack_
count of cycles before the operand write to look for the producer of the read value
Definition: CycleLookBackSoftwareBypasser.hh:86
SoftwareBypasser.hh
CycleLookBackSoftwareBypasser::bypass
virtual int bypass(MoveNodeGroup &candidates, DataDependenceGraph &ddg, ResourceManager &rm, bool bypassTrigger)
Definition: CycleLookBackSoftwareBypasser.cc:353