OpenASIP 2.2
Loading...
Searching...
No Matches
BFShareOperands.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 BFShareOperands.cc
27 *
28 * Definition of BFShareOperands class
29 *
30 * Searches for potential operations to share operand with, and
31 * then calls BFShareOperandWithScheduled to fo the actual operand sharing.
32 *
33 * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
34 * @note rating: red
35 */
36
37#include "BFShareOperands.hh"
39#include "FunctionUnit.hh"
40#include "Terminal.hh"
41#include "Move.hh"
42#include "Operation.hh"
43#include "BF2Scheduler.hh"
44#include "BF2ScheduleFront.hh"
46#include "HWOperation.hh"
47#include "FUPort.hh"
48
50 // TODO: alctually check the guards
51 if (!mn_.move().isUnconditional()) {
52 return false;
53 }
54
55#ifdef DEBUG_BUBBLEFISH_SCHEDULER
56 std::cerr << "\t\tShareOperands operator() called for:"
57 << mn_.toString() << std::endl;
58#endif
59
62#ifdef DEBUG_BUBBLEFISH_SCHEDULER
63 std::cerr << "\t\t\tIllegal operand share: " << mn_.toString()
64 << std::endl;
65#endif
66 return false;
67 }
68
69 bool didSomething = false;
71 const Operation& op = po.operation();
72 const TTAMachine::FunctionUnit* forcedFU = po.scheduledFU();
73
75 for (auto i : siblings) {
76 if (!i->isDestinationOperation()) {
77 continue;
78 }
79
80 if (i->isScheduled()) {
81 if (i->cycle() > maxCycle_) {
82 continue;
83 }
84 // limit operand sharing for reasonable distances
85 // TODO: use the cmd line parameter
86 int ddglc = ddg().latestCycle(mn_, ii(), false, false);
87 if (i->cycle() < ddglc - 5) {
88 continue;
89 }
90
91 // try share with already scheduled
92 const TTAProgram::Terminal& dt = i->move().destination();
93 if (dt.isFUPort()) {
95 if (!fu.hasOperation(op.name())) {
96 continue;
97 }
98 const TTAMachine::HWOperation* hwop = fu.operation(op.name());
99 const TTAMachine::FUPort *sharedPort =
101 if (sharedPort != &dt.port()) {
102 continue;
103 }
104 if (dt.isTriggering()) {
105 // TODO: is sibling commutative?
106 continue;
107 }
108 if (forcedFU != NULL) {
109 if (&fu == forcedFU) {
110 MoveNode* trigger =
112 mn_, targetMachine());
113 if (trigger == &mn_) {
114 continue;
115 }
116
119 if (runPreChild(sows)) {
120 didSomething = true;
121 }
122 }
123 } else {
124 if (fu.hasOperation(op.name())) {
125 if (sched_.isTrigger(fu, mn_)) {
126 // TODO: change commutative
127 continue;
128 }
129
132 if (runPreChild(sows)) {
133 didSomething = true;
134 }
135 }
136 }
137 }
138 }
139 }
140 return didSomething;
141}
142
144
145bool BFShareOperands::removedNode() { return false; }
DataDependenceGraph::NodeSet illegalOperandShares_
bool isTrigger(const TTAMachine::Unit &unit, MoveNode &mn)
BF2ScheduleFront * currentFront()
unsigned int ii() const
BF2Scheduler & sched_
static MoveNode * getSisterTrigger(const MoveNode &mn, const TTAMachine::Machine &mach)
DataDependenceGraph & ddg()
const TTAMachine::Machine & targetMachine() const
virtual bool removedNode()
virtual bool operator()()
virtual void undoOnlyMe()
NodeSet regDepSiblings(const MoveNode &mn) const
int latestCycle(const MoveNode &moveNode, unsigned int ii=UINT_MAX, bool ignoreRegAntideps=false, bool ignoreUnscheduledSuccessors=true, bool ignoreGuards=false, bool ignoreFUDeps=false, bool ignoreSameOperationEdges=false) const
std::set< GraphNode *, typename GraphNode::Comparator > NodeSet
Definition Graph.hh:53
std::string toString() const
Definition MoveNode.cc:576
TTAProgram::Move & move()
ProgramOperation & destinationOperation(unsigned int index=0) const
virtual TCEString name() const
Definition Operation.cc:93
const Operation & operation() const
const TTAMachine::FunctionUnit * scheduledFU() const
bool runPreChild(Reversible *preChild)
virtual HWOperation * operation(const std::string &name) const
virtual bool hasOperation(const std::string &name) const
virtual FUPort * port(int operand) const
bool isUnconditional() const
Definition Move.cc:154
Terminal & destination() const
Definition Move.cc:323
virtual bool isTriggering() const
Definition Terminal.cc:298
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition Terminal.cc:251
virtual int operationIndex() const
Definition Terminal.cc:364
virtual const TTAMachine::Port & port() const
Definition Terminal.cc:378
virtual bool isFUPort() const
Definition Terminal.cc:118