OpenASIP 2.2
Loading...
Searching...
No Matches
BFEarlyBypasser.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 BFEarlyBypasser.cc
27 *
28 * Definition of BFEarlyBypassed class.
29 *
30 * Before scheduling an operand move, searches for a move which might be a
31 * bypass source and then tries class BFEarlyBypass or BFLoopBypass class
32 * to perform the actual bypass.
33 *
34 * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
35 * @note rating: red
36 */
37
38#include "BFEarlyBypasser.hh"
39#include "BFDREEarly.hh"
42#include "BF2Scheduler.hh"
43#include "BF2ScheduleFront.hh"
44#include "BFEarlyBypass.hh"
46
47bool
49
50 if (bypassDistance_ == 0) return false;
51
53 if (bypassEdge == NULL) {
54 return false;
55 }
56 MoveNode& src = ddg().tailNode(*bypassEdge);
57
58 if (sched_.currentFront()->illegalBypassSources_.count(&src)) {
59#ifdef DEBUG_BUBBLEFISH_SCHEDULER
60 std::cerr << "Bypass source illegal: " << src.toString() << std::endl;
61#endif
62 return 0;
63 }
64
65 if (!ddg().guardsAllowBypass(src, dst_, bypassEdge->isBackEdge())) {
66 return false;
67 }
68
70 src, dst_, sched_.targetMachine())) {
71 return false;
72 }
73
74 int bypassSourceLC = bypassSourceLatestCycle(src, dst_);
75 if (bypassSourceLC == -1) {
76 return false;
77 }
78
79 if (bypassEdge->isBackEdge()) {
80 if (!src.isScheduled() || src.cycle() < (int)ii()) {
81 return false;
82 }
83 } else {
84 return runPreChild(new BFEarlyBypass(sched_, src, dst_));
85 }
86 return false;
87}
88
89/**
90 * Checks that bypass source does not WHAT??? */
92 MoveNode& bypassSrc, MoveNode& bypassDst) {
94
95 int lc = INT_MAX;
96
97 if (bypassSrc.isSourceOperation()) {
98 ProgramOperation& po = bypassSrc.sourceOperation();
99 for (int j = 0; j < po.inputMoveCount(); j++) {
100 MoveNode& inputMove = po.inputMove(j);
101 // may also be a shared operand
102 if (!sched_.isPreLoopSharedOperand(inputMove)) {
103 nodes.insert(&inputMove);
104 }
105 }
106
107 for (int j = 0; j < po.outputMoveCount(); j++) {
108 MoveNode& outputMove = po.outputMove(j);
109 if (!sched_.isDeadResult(outputMove)) {
110 nodes.insert(&outputMove);
111 }
112 }
113 } else {
114 nodes.insert(&bypassSrc);
115 }
116
117 for (auto mn : nodes) {
119 for (auto e : edges) {
120 MoveNode& head = ddg().headNode(*e);
121 if (head.isScheduled()) {
122 lc = std::min(lc, head.cycle());
123 continue;
124 }
125 if (&head == &bypassDst || head.isInFrontier() ||
126 e->isBackEdge() || nodes.count(&head)) {
127 continue;
128 }
129#ifdef DEBUG_BUBBLEFISH_SCHEDULER
130 std::cerr << "\t\t\t\tEdge almost preventing bypass from: "
131 << bypassSrc.toString() << "to: " <<bypassDst.toString()
132 << ": " << e->toString() << " dst: "
133 << head.toString() << std::endl;
134#endif
135 return -1;
136 }
137 }
138 return lc;
139}
140
142 BFOptimization(sched), dst_(mn) {
145 if (opts != NULL && opts->bypassDistance() > -1) {
147 }
148}
static CmdLineOptions * cmdLineOptions()
DataDependenceGraph::NodeSet illegalBypassSources_
bool isDeadResult(MoveNode &mn) const
TTAMachine::FUPort * isPreLoopSharedOperand(MoveNode &mn) const
const TTAMachine::Machine & targetMachine() const
DataDependenceEdge * findBypassEdge(const MoveNode &mn)
BF2ScheduleFront * currentFront()
BFEarlyBypasser(BF2Scheduler &sched, MoveNode &mn)
int bypassSourceLatestCycle(MoveNode &bypassSrc, MoveNode &bypassDst)
unsigned int ii() const
BF2Scheduler & sched_
DataDependenceGraph & ddg()
virtual Node & headNode(const Edge &edge) const
virtual EdgeSet outEdges(const Node &node) const
virtual Node & tailNode(const Edge &edge) const
std::set< GraphNode *, typename GraphNode::Comparator > NodeSet
Definition Graph.hh:53
std::set< GraphEdge *, typename GraphEdge::Comparator > EdgeSet
Definition Graph.hh:54
static bool canBypass(const MoveNode &src, const MoveNode &user, const TTAMachine::Machine &targetMachine)
int cycle() const
Definition MoveNode.cc:421
bool isInFrontier() const
ProgramOperation & sourceOperation() const
Definition MoveNode.cc:453
std::string toString() const
Definition MoveNode.cc:576
bool isSourceOperation() const
Definition MoveNode.cc:168
bool isScheduled() const
Definition MoveNode.cc:409
int outputMoveCount() const
int inputMoveCount() const
MoveNode & inputMove(int index) const
MoveNode & outputMove(int index) const
bool runPreChild(Reversible *preChild)