OpenASIP  2.0
BFPostpassBypasser.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2014 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 /**
26  * @file BFPostpassBypasser.cc
27  *
28  * Definition of BFPostpassBypasser class
29  *
30  * After scheduling all moves, searches for a bypasses which can be bypassed
31  * after scheduling everything. Calls BFPostpassBypass to bypass these.
32  *
33  * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
34  * @note rating: red
35  */
36 
37 #include "BFPostpassBypasser.hh"
38 #include "DataDependenceGraph.hh"
39 #include "BF2Scheduler.hh"
40 #include "BFPostpassBypass.hh"
41 
43 
44  for (int i = 0; i < ddg().nodeCount(); i++) {
45  MoveNode& n = ddg().node(i);
46  bool dred = tryBypassNode(n);
47  // make sure do not skip over one if dre removes something
48  if (dred) {
49  i--;
50  }
51  }
52  return !postChildren_.empty();
53 }
54 
56 
57  DataDependenceEdge* bypassEdge = sched_.findBypassEdge(n);
58  if (bypassEdge == NULL) {
59  return false;
60  }
61  MoveNode& src = ddg().tailNode(*bypassEdge);
62 
63  if (!ddg().guardsAllowBypass(src, n)) {
64  return false;
65  }
66 
67  auto bypass = new BFPostpassBypass(sched_, src, n, bypassEdge->isBackEdge());
68  if (!(runPostChild(bypass))) {
69  return false;
70  }
71  return bypass->dred();
72 }
Reversible::postChildren_
std::stack< Reversible * > postChildren_
Definition: Reversible.hh:58
BoostGraph::tailNode
virtual Node & tailNode(const Edge &edge) const
BoostGraph::node
Node & node(const int index) const
DataDependenceEdge::isBackEdge
bool isBackEdge() const
Definition: DataDependenceEdge.hh:118
BFPostpassBypasser::operator()
bool operator()() override
Definition: BFPostpassBypasser.cc:42
DataDependenceGraph.hh
MoveNode
Definition: MoveNode.hh:65
BFPostpassBypasser.hh
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
BF2Scheduler::findBypassEdge
DataDependenceEdge * findBypassEdge(const MoveNode &mn)
Definition: BF2Scheduler.cc:838
BFPostpassBypass.hh
BF2Scheduler.hh
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
DataDependenceEdge
Definition: DataDependenceEdge.hh:43
Reversible::runPostChild
bool runPostChild(Reversible *preChild)
Definition: Reversible.cc:139
BFPostpassBypass
Definition: BFPostpassBypass.hh:42
BoostGraph::nodeCount
int nodeCount() const
BFPostpassBypasser::tryBypassNode
bool tryBypassNode(MoveNode &n)
Definition: BFPostpassBypasser.cc:55