OpenASIP 2.2
Loading...
Searching...
No Matches
BFLateBypassGuard.cc
Go to the documentation of this file.
2#include "BFScheduleBU.hh"
3#include "BFScheduleExact.hh"
4
7#include "MoveNode.hh"
8#include "Move.hh"
9
10#include "Bus.hh"
11#include "BUMoveNodeSelector.hh"
12#include "Terminal.hh"
13#include "FUPort.hh"
14#include "Guard.hh"
15#include "Operation.hh"
16#include "MoveGuard.hh"
17
18bool
20
21#ifdef DEBUG_BUBBLEFISH_SCHEDULER
22 std::cerr << "\t\tPerforming late bypass guard: " << dst_.toString() << std::endl;
23#endif
24
25 // Only allow guard bypass if it can save clock cycles on guard path.
26 if (dst_.cycle() > lc_ + dst_.guardLatency()-1) {
27#ifdef DEBUG_BUBBLEFISH_SCHEDULER
28 std::cerr << "\t\t\tAborting guard bypass due too long guard distance" << std::endl;
29#endif
30
31 return false;
32 }
33
34 if (!src_.isSourceOperation()) {
35#ifdef DEBUG_BUBBLEFISH_SCHEDULER
36 std::cerr << "\t\t\tsrc src not op: "<< src_.toString() << std::endl;
37#endif
38 return false;
39 }
40
41
42 if (dst_.isSourceOperation()) {
43#ifdef DEBUG_BUBBLEFISH_SCHEDULER
44 std::cerr << "\t\t\tsrc not constant: " << dst_.toString() << std::endl;
45#endif
46 return false;
47 }
48
49
51 const Operation& op = po.operation();
52
53 // TODO: might need set of these for annotations.
54 const TTAMachine::FunctionUnit* fu = NULL;
55 for (int i = 0; i < po.inputMoveCount(); i++) {
56 MoveNode& mn = po.inputMove(i);
57 if (mn.isScheduled()) {
58 fu = &mn.move().destination().functionUnit();
59 }
60 // TODO: fu annotations can forbid this?
61 }
62 for (int i = 0; i < po.outputMoveCount(); i++) {
63 MoveNode& mn = po.outputMove(i);
64 if (mn.isScheduled()) {
65 fu = &mn.move().source().functionUnit();
66 }
67 // TODO: fu annotations can forbid this?
68 }
69
70 if (dst_.move().isUnconditional()) {
71 ddg().writeToDotFile("guard_edge_dest_uncond.dot");
72 }
74 const TTAMachine::Bus& bus = dst_.move().bus();
75 for (int i = 0; i < bus.guardCount(); i++) {
76
77 TTAMachine::Guard* guard = bus.guard(i);
79 dynamic_cast<TTAMachine::PortGuard*>(guard);
80 if (pg == NULL) {
81 continue;
82 }
83 if (pg->isInverted() != dst_.move().guard().isInverted()) {
84 continue;
85 }
86 const TTAMachine::FUPort* port = pg->port();
88 if (gfu->hasOperation(op.name()) &&
89 po.outputIndexFromGuard(*pg) ==
91 (fu == NULL || fu == gfu)) {
92
93 if (!po.isLegalFU(*gfu)) {
94#ifdef DEBUG_BUBBLEFISH_SCHEDULER
95 std::cerr << "\t\t\tFU: " << gfu->name() << " not allowed for operation: " << po.toString() << std::endl;
96#endif
97 continue;
98 }
99
100#ifdef DEBUG_BUBBLEFISH_SCHEDULER
101 std::cerr << "\t\t\tFound suitable guard & FU" << std::endl;
102#endif
104 originalBus_ = &dst_.move().bus();
106
107 unassign(dst_, false);
108
109 // TODO: backup old guard.
111
113
115 if ((*sched)()) {
116 postChildren_.push(sched);
117#ifdef DEBUG_BUBBLEFISH_SCHEDULER
118 std::cerr << "\t\tGuard conversion ok: " << dst_.toString() << std::endl;
119#endif
120 return true;
121 } else {
122#ifdef DEBUG_BUBBLEFISH_SCHEDULER
123 std::cerr << "\t\tGuard conversion sched fail.: " << dst_.toString() << std::endl;
124#endif
125 delete sched;
126
128
131
134 }
135 }
136 }
137#ifdef DEBUG_BUBBLEFISH_SCHEDULER
138 std::cerr << "\t\t\tDid not find a bus with suitable guard?" << std::endl;
139#endif
140 return false;
141}
142
143
144
145
146void
148#ifdef DEBUG_BUBBLEFISH_SCHEDULER
149 std::cerr << "\t\t\tUndoing guard conversion: " << dst_.toString() << std::endl;
150#endif
151
153
155
157#ifdef DEBUG_BUBBLEFISH_SCHEDULER
158 std::cerr << "\t\t\tReassigning move: " << dst_.toString() << " to cycle: "
159 << originalCycle_ << " bus: " << originalBus_->name() << std::endl;
160#endif
163#ifdef DEBUG_BUBBLEFISH_SCHEDULER
164 std::cerr << "\t\tReassigned move:" << dst_.toString() << std::endl;
165#endif
166}
#define assert(condition)
const TTAMachine::Guard * originalGuard_
virtual void undoOnlyMe()
virtual bool operator()()
MoveNode & dst_
MoveNode & src_
const TTAMachine::Bus * originalBus_
BF2Scheduler & sched_
virtual bool canAssign(int cycle, MoveNode &mn, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1, bool ignoreGWN=false)
DataDependenceGraph & ddg()
virtual void unassign(MoveNode &mn, bool disposePrologCopy=true)
virtual bool assign(int cycle, MoveNode &, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU_=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1, bool ignoreGuardWriteCycle=false)
void guardConverted(MoveNode &guardSrc, MoveNode &dst)
void guardRestored(MoveNode &guardSrc, MoveNode &dst)
virtual void writeToDotFile(const TCEString &fileName) const
int cycle() const
Definition MoveNode.cc:421
int guardLatency() const
Definition MoveNode.cc:779
ProgramOperation & sourceOperation() const
Definition MoveNode.cc:453
std::string toString() const
Definition MoveNode.cc:576
TTAProgram::Move & move()
bool isSourceOperation() const
Definition MoveNode.cc:168
bool isScheduled() const
Definition MoveNode.cc:409
virtual TCEString name() const
Definition Operation.cc:93
int outputMoveCount() const
const Operation & operation() const
int outputIndexFromGuard(const TTAMachine::PortGuard &pg) const
int inputMoveCount() const
std::string toString() const
MoveNode & inputMove(int index) const
bool isLegalFU(const TTAMachine::FunctionUnit &fu) const
MoveNode & outputMove(int index) const
std::stack< Reversible * > postChildren_
Definition Reversible.hh:58
FunctionUnit * parentUnit() const
Definition BaseFUPort.cc:96
Guard * guard(int index) const
Definition Bus.cc:456
int guardCount() const
Definition Bus.cc:441
virtual TCEString name() const
virtual bool hasOperation(const std::string &name) const
virtual bool isInverted() const
FUPort * port() const
bool isInverted() const
Definition MoveGuard.cc:76
const TTAMachine::Guard & guard() const
Definition MoveGuard.cc:86
MoveGuard & guard() const
Definition Move.cc:345
bool isUnconditional() const
Definition Move.cc:154
Terminal & source() const
Definition Move.cc:302
void setGuard(MoveGuard *guard)
Definition Move.cc:360
void setBus(const TTAMachine::Bus &bus)
Definition Move.cc:383
Terminal & destination() const
Definition Move.cc:323
const TTAMachine::Bus & bus() const
Definition Move.cc:373
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition Terminal.cc:251
virtual int operationIndex() const
Definition Terminal.cc:364