OpenASIP  2.0
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();
87  TTAMachine::FunctionUnit* gfu = port->parentUnit();
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.
110  dst_.move().setGuard(new TTAProgram::MoveGuard(*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 }

References assert, BFOptimization::assign(), TTAProgram::Move::bus(), BFOptimization::canAssign(), MoveNode::cycle(), BFOptimization::ddg(), TTAProgram::Move::destination(), BFLateBypass::dst_, TTAProgram::Terminal::functionUnit(), TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), TTAMachine::Bus::guard(), DataDependenceGraph::guardConverted(), TTAMachine::Bus::guardCount(), MoveNode::guardLatency(), DataDependenceGraph::guardRestored(), TTAMachine::FunctionUnit::hasOperation(), ProgramOperation::inputMove(), ProgramOperation::inputMoveCount(), TTAProgram::MoveGuard::isInverted(), TTAMachine::Guard::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:
TTAMachine::Guard
Definition: Guard.hh:55
ProgramOperation::operation
const Operation & operation() const
Definition: ProgramOperation.cc:590
Reversible::postChildren_
std::stack< Reversible * > postChildren_
Definition: Reversible.hh:58
BFOptimization::unassign
virtual void unassign(MoveNode &mn, bool disposePrologCopy=true)
Definition: BFOptimization.cc:196
BFLateBypass::lc_
int lc_
Definition: BFLateBypass.hh:59
BFOptimization::assign
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)
Definition: BFOptimization.cc:103
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
TTAMachine::PortGuard::port
FUPort * port() const
BFLateBypass::BFLateBypass
BFLateBypass(BF2Scheduler &sched, MoveNode &src, MoveNode &dst, int lc)
Definition: BFLateBypass.hh:49
TTAMachine::BaseFUPort::parentUnit
FunctionUnit * parentUnit() const
Definition: BaseFUPort.cc:96
TTAProgram::MoveGuard::isInverted
bool isInverted() const
Definition: MoveGuard.cc:76
TTAProgram::Move::isUnconditional
bool isUnconditional() const
Definition: Move.cc:154
TTAMachine::Bus
Definition: Bus.hh:53
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
TTAProgram::Move::bus
const TTAMachine::Bus & bus() const
Definition: Move.cc:373
ProgramOperation
Definition: ProgramOperation.hh:70
TTAProgram::Move::setGuard
void setGuard(MoveGuard *guard)
Definition: Move.cc:360
MoveNode
Definition: MoveNode.hh:65
BFOptimization
Definition: BFOptimization.hh:73
BFLateBypass::dst_
MoveNode & dst_
Definition: BFLateBypass.hh:58
ProgramOperation::outputIndexFromGuard
int outputIndexFromGuard(const TTAMachine::PortGuard &pg) const
Definition: ProgramOperation.cc:266
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
ProgramOperation::isLegalFU
bool isLegalFU(const TTAMachine::FunctionUnit &fu) const
Definition: ProgramOperation.cc:915
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
MoveNode::sourceOperation
ProgramOperation & sourceOperation() const
Definition: MoveNode.cc:453
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::FUPort
Definition: FUPort.hh:46
TTAProgram::Terminal::operationIndex
virtual int operationIndex() const
Definition: Terminal.cc:364
MoveNode::cycle
int cycle() const
Definition: MoveNode.cc:421
MoveNode::guardLatency
int guardLatency() const
Definition: MoveNode.cc:779
TTAProgram::Move::guard
MoveGuard & guard() const
Definition: Move.cc:345
MoveNode::isSourceOperation
bool isSourceOperation() const
Definition: MoveNode.cc:168
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
TTAMachine::FunctionUnit::hasOperation
virtual bool hasOperation(const std::string &name) const
Definition: FunctionUnit.cc:330
ProgramOperation::inputMoveCount
int inputMoveCount() const
Definition: ProgramOperation.cc:600
TTAMachine::Bus::guardCount
int guardCount() const
Definition: Bus.cc:441
TTAMachine::Bus::guard
Guard * guard(int index) const
Definition: Bus.cc:456
Operation
Definition: Operation.hh:59
GraphBase::writeToDotFile
virtual void writeToDotFile(const TCEString &fileName) const
DataDependenceGraph::guardRestored
void guardRestored(MoveNode &guardSrc, MoveNode &dst)
Definition: DataDependenceGraph.cc:5849
ProgramOperation::outputMoveCount
int outputMoveCount() const
Definition: ProgramOperation.cc:610
TTAProgram::Terminal::functionUnit
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition: Terminal.cc:251
MoveNode::move
TTAProgram::Move & move()
BFLateBypassGuard::originalGuard_
const TTAMachine::Guard * originalGuard_
Definition: BFLateBypassGuard.hh:16
ProgramOperation::toString
std::string toString() const
Definition: ProgramOperation.cc:746
BFLateBypass::originalCycle_
int originalCycle_
Definition: BFLateBypass.hh:56
TTAMachine::Guard::isInverted
virtual bool isInverted() const
DataDependenceGraph::guardConverted
void guardConverted(MoveNode &guardSrc, MoveNode &dst)
Definition: DataDependenceGraph.cc:5795
BFScheduleExact
Definition: BFScheduleExact.hh:47
MoveNode::isScheduled
bool isScheduled() const
Definition: MoveNode.cc:409
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
BFLateBypass::src_
MoveNode & src_
Definition: BFLateBypass.hh:57
TTAMachine::PortGuard
Definition: Guard.hh:99
TTAProgram::MoveGuard::guard
const TTAMachine::Guard & guard() const
Definition: MoveGuard.cc:86
TTAProgram::MoveGuard
Definition: MoveGuard.hh:47
ProgramOperation::outputMove
MoveNode & outputMove(int index) const
Definition: ProgramOperation.cc:632
TTAProgram::Move::setBus
void setBus(const TTAMachine::Bus &bus)
Definition: Move.cc:383
BFOptimization::canAssign
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)
Definition: BFOptimization.cc:495
ProgramOperation::inputMove
MoveNode & inputMove(int index) const
Definition: ProgramOperation.cc:621
BFLateBypass::originalBus_
const TTAMachine::Bus * originalBus_
Definition: BFLateBypass.hh:60