OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
BFLateBypassGuard Class Reference

#include <BFLateBypassGuard.hh>

Inheritance diagram for BFLateBypassGuard:
Inheritance graph
Collaboration diagram for BFLateBypassGuard:
Collaboration graph

Public Member Functions

 BFLateBypassGuard (BF2Scheduler &sched, MoveNode &src, MoveNode &dst, int lc)
 
virtual bool operator() ()
 
virtual void undoOnlyMe ()
 
- Public Member Functions inherited from BFLateBypass
 BFLateBypass (BF2Scheduler &sched, MoveNode &src, MoveNode &dst, int lc)
 
- Public Member Functions inherited from BFOptimization
 BFOptimization (BF2Scheduler &sched)
 
virtual bool isFinishFront ()
 
virtual void mightBeReady (MoveNode &mn)
 
- Public Member Functions inherited from Reversible
virtual void undo ()
 
virtual ~Reversible ()
 
void deleteChildren (std::stack< Reversible * > &children)
 
int id ()
 
 Reversible ()
 

Private Attributes

const TTAMachine::GuardoriginalGuard_
 

Additional Inherited Members

- Static Public Member Functions inherited from BFOptimization
static void clearPrologMoves ()
 
static MoveNodegetSisterTrigger (const MoveNode &mn, const TTAMachine::Machine &mach)
 
- Protected Member Functions inherited from BFOptimization
DataDependenceGraphddg ()
 
DataDependenceGraphrootDDG ()
 
const DataDependenceGraphddg () const
 
DataDependenceGraphprologDDG ()
 
SimpleResourceManagerrm () const
 
SimpleResourceManagerprologRM () const
 
BUMoveNodeSelectorselector ()
 
const TTAMachine::MachinetargetMachine () const
 
unsigned int ii () const
 
MoveNodeDuplicatorduplicator () const
 
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)
 
virtual void unassign (MoveNode &mn, bool disposePrologCopy=true)
 
virtual int rmEC (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)
 
virtual int rmLC (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)
 
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)
 
bool putAlsoToPrologEpilog (int cycle, MoveNode &mn)
 
void setPrologSrcFUAnno (MoveNode &prologMN, MoveNode &loopMN)
 
void setPrologDstFUAnno (MoveNode &prologMN, MoveNode &loopMN)
 
void setJumpGuard (MoveNode &mn)
 
void unsetJumpGuard (MoveNode &mn)
 
bool needJumpGuard (const MoveNode &mn, int cycle)
 
int jumpGuardAvailableCycle (const MoveNode &mn)
 
bool canBeSpeculated (const Operation &op)
 
bool canBeSpeculated (const MoveNode &mn)
 
bool usePrologMove (const MoveNode &mn)
 
bool canBeScheduled (const MoveNode &mn)
 
const TTAMachine::RegisterFileRFReadPortCountPreventsScheduling (const MoveNode &mn)
 
bool immCountPreventsScheduling (const MoveNode &mn)
 
- Protected Member Functions inherited from Reversible
bool runPreChild (Reversible *preChild)
 
bool runPostChild (Reversible *preChild)
 
bool runChild (std::stack< Reversible * > &children, Reversible *child)
 
bool runChild (Reversible *child, bool pre)
 
void undoAndRemovePreChildren ()
 
void undoAndRemovePostChildren ()
 
void undoAndRemoveChildren (std::stack< Reversible * > &children)
 
- Protected Attributes inherited from BFLateBypass
int originalCycle_
 
MoveNodesrc_
 
MoveNodedst_
 
int lc_
 
const TTAMachine::BusoriginalBus_
 
const TTAMachine::BusprologBus_
 
- Protected Attributes inherited from BFOptimization
BF2Schedulersched_
 
- Protected Attributes inherited from Reversible
std::stack< Reversible * > preChildren_
 
std::stack< Reversible * > postChildren_
 
- Static Protected Attributes inherited from BFOptimization
static std::map< MoveNode *, MoveNode *, MoveNode::ComparatorprologMoves_
 

Detailed Description

Definition at line 8 of file BFLateBypassGuard.hh.

Constructor & Destructor Documentation

◆ BFLateBypassGuard()

BFLateBypassGuard::BFLateBypassGuard ( BF2Scheduler sched,
MoveNode src,
MoveNode dst,
int  lc 
)
inline

Definition at line 10 of file BFLateBypassGuard.hh.

10 :
11 BFLateBypass(sched, src, dst, lc) {}

Member Function Documentation

◆ operator()()

bool BFLateBypassGuard::operator() ( )
virtual

This performs the operation. Returns true if success, false if fail.

Reimplemented from BFLateBypass.

Definition at line 19 of file BFLateBypassGuard.cc.

19 {
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}
#define assert(condition)
const TTAMachine::Guard * originalGuard_
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

References assert, BFOptimization::assign(), TTAProgram::Move::bus(), BFOptimization::canAssign(), MoveNode::cycle(), BFOptimization::ddg(), TTAProgram::Move::destination(), BFLateBypass::dst_, TTAProgram::Terminal::functionUnit(), TTAProgram::Move::guard(), TTAProgram::MoveGuard::guard(), TTAMachine::Bus::guard(), DataDependenceGraph::guardConverted(), TTAMachine::Bus::guardCount(), MoveNode::guardLatency(), DataDependenceGraph::guardRestored(), TTAMachine::FunctionUnit::hasOperation(), ProgramOperation::inputMove(), ProgramOperation::inputMoveCount(), TTAMachine::Guard::isInverted(), TTAProgram::MoveGuard::isInverted(), ProgramOperation::isLegalFU(), MoveNode::isScheduled(), MoveNode::isSourceOperation(), TTAProgram::Move::isUnconditional(), BFLateBypass::lc_, MoveNode::move(), TTAMachine::Component::name(), Operation::name(), ProgramOperation::operation(), TTAProgram::Terminal::operationIndex(), BFLateBypass::originalBus_, BFLateBypass::originalCycle_, originalGuard_, ProgramOperation::outputIndexFromGuard(), ProgramOperation::outputMove(), ProgramOperation::outputMoveCount(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::PortGuard::port(), Reversible::postChildren_, BFOptimization::sched_, TTAProgram::Move::setBus(), TTAProgram::Move::setGuard(), TTAProgram::Move::source(), MoveNode::sourceOperation(), BFLateBypass::src_, MoveNode::toString(), ProgramOperation::toString(), BFOptimization::unassign(), and GraphBase< GraphNode, GraphEdge >::writeToDotFile().

Here is the call graph for this function:

◆ undoOnlyMe()

void BFLateBypassGuard::undoOnlyMe ( )
virtual

Undoes the operations done by this class but not children. This method should be overloaded by most derived classes.

Reimplemented from BFLateBypass.

Definition at line 147 of file BFLateBypassGuard.cc.

147 {
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}

References assert, BFOptimization::assign(), BFOptimization::canAssign(), BFOptimization::ddg(), BFLateBypass::dst_, DataDependenceGraph::guardRestored(), MoveNode::move(), TTAMachine::Component::name(), BFLateBypass::originalBus_, BFLateBypass::originalCycle_, originalGuard_, TTAProgram::Move::setBus(), TTAProgram::Move::setGuard(), BFLateBypass::src_, and MoveNode::toString().

Here is the call graph for this function:

Member Data Documentation

◆ originalGuard_

const TTAMachine::Guard* BFLateBypassGuard::originalGuard_
private

Definition at line 16 of file BFLateBypassGuard.hh.

Referenced by operator()(), and undoOnlyMe().


The documentation for this class was generated from the following files: