OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BFPushMoveUp2 Class Reference

#include <BFPushMoveUp2.hh>

Inheritance diagram for BFPushMoveUp2:
Inheritance graph
Collaboration diagram for BFPushMoveUp2:
Collaboration graph

Public Member Functions

 BFPushMoveUp2 (BF2Scheduler &sched, MoveNode &mn, int lc)
 
bool operator() ()
 
- Public Member Functions inherited from BFUnscheduleMove
 BFUnscheduleMove (BF2Scheduler &sched, MoveNode &mn)
 
void unscheduleOriginal ()
 
void undoOnlyMe ()
 
bool operator() ()
 
- 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 Member Functions

bool isLoopBypass (MoveNode &mn)
 

Private Attributes

int lc_
 

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 BFUnscheduleMove
void returnOriginal ()
 
- 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 BFUnscheduleMove
MoveNodemn_
 
int oldCycle_
 
const TTAMachine::BusoldBus_
 
const TTAMachine::BusprologBus_
 
int oldImmWriteCycle_
 
int prologImmWriteCycle_
 
const TTAMachine::FunctionUnitdstFU_
 
const TTAMachine::FunctionUnitsrcFU_
 
const TTAMachine::ImmediateUnitimmu_
 
int immRegIndex_
 
- Protected Attributes inherited from BFOptimization
BF2Schedulersched_
 
- Protected Attributes inherited from Reversible
std::stack< Reversible * > preChildren_
 
std::stack< Reversible * > postChildren_
 
- Static Protected Attributes inherited from BFUnscheduleMove
static int recurseCounter_ = 0
 
- Static Protected Attributes inherited from BFOptimization
static std::map< MoveNode *, MoveNode *, MoveNode::ComparatorprologMoves_
 

Detailed Description

Definition at line 51 of file BFPushMoveUp2.hh.

Constructor & Destructor Documentation

◆ BFPushMoveUp2()

BFPushMoveUp2::BFPushMoveUp2 ( BF2Scheduler sched,
MoveNode mn,
int  lc 
)
inline

Definition at line 54 of file BFPushMoveUp2.hh.

55  :
56  BFUnscheduleMove(sched, mn), lc_(lc) {}

Member Function Documentation

◆ isLoopBypass()

bool BFPushMoveUp2::isLoopBypass ( MoveNode mn)
private

Definition at line 181 of file BFPushMoveUp2.cc.

181  {
182  auto inEdges = ddg().operationInEdges(mn);
183  for (auto e: inEdges) {
184  if (e->isBackEdge()) {
185  return true;
186  }
187  }
188 
189  return false;
190 }

References BFOptimization::ddg(), and DataDependenceGraph::operationInEdges().

Referenced by operator()().

Here is the call graph for this function:

◆ operator()()

bool BFPushMoveUp2::operator() ( )
virtual

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

Implements Reversible.

Definition at line 48 of file BFPushMoveUp2.cc.

48  {
49 
50  if (lc_ == -1) {
51  std::cerr << "incoming lc -1 on pushmoveup!" << std::endl;
52  assert(false);
53  }
54  if (mn_.move().isControlFlowMove()) {
55 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
56  std::cerr << "\t\t|TCannot reschedule control flow move!" << std::endl;
57 #endif
58  return false;
59  }
60 
61  if (&mn_ == sched_.guardWriteNode()) {
62 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
63  std::cerr << "\t\t|TCannot reschedule guard write move!" << std::endl;
64 #endif
65  return false;
66  }
67 
68  if (!mn_.isSourceOperation()) {
69  return false;
70  }
71 
72  // unschedule this (result) move
74  MoveNode* trigger = po.triggeringMove();
76 
77  int ddgLC = ddg().latestCycle(mn_,ii());
78  int ddgEC = ddg().earliestCycle(mn_,ii());
79 
80  if (ddgLC == -1) {
81 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
82  std::cerr << "ddg latest cycle -1 in pushmoveup2 of:"
83  << mn_.toString() << std::endl;
84 #endif
86  return false;
87  }
88 
89  int lc = std::min(lc_, ddgLC);
90 
91  if (ddgEC > lc) {
92  DataDependenceGraph::NodeSet unschedOperands;
93  DataDependenceGraph::NodeSet unschedResults;
94  // undo the inputs
95  for (int i = 0; i < po.inputMoveCount(); i++) {
96  MoveNode& operand = po.inputMove(i);
97  if (operand.isScheduled()) {
98  if (!runPostChild(new BFUnscheduleMove(sched_, operand))) {
99  undo();
100  return false;
101  } else {
102  unschedOperands.insert(&operand);
103  }
104  }
105  }
106 
107  for (int i = 0; i < po.outputMoveCount(); i++) {
108  MoveNode& res = po.outputMove(i);
109  if (res.isScheduled() &&
110  (res.cycle() > lc ||
111  (isLoopBypass(res) && res.cycle()+((signed)ii()) > lc))) {
112  if (!runPostChild(new BFUnscheduleMove(sched_, res))) {
113  undo();
114  return false;
115  } else {
116  unschedResults.insert(&res);
117  }
118 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
119  } else {
120  std::cerr << "res which is not scheduled:" << res.toString()
121  << std::endl;
122 #endif
123  }
124  }
125 
126  // now whole op is not scheduled?
127 
128  // reschedule other results
129  for (int i = po.outputMoveCount()-1; i >= 0; i--) {
130  MoveNode& res = po.outputMove(i);
131  if (AssocTools::containsKey(unschedResults, &res)) {
132  int myLC = lc - isLoopBypass(res) * ii();
133  if (!runPostChild(
134  new BFScheduleBU(
135  sched_, res, myLC, false, false, false))) {
136  undo();
137  return false;
138  }
139  }
140  }
141 
142  // reschedule me.
143  if (!runPostChild(
144  new BFScheduleBU(sched_, mn_, lc, false, false, false))) {
145  undo();
146  return false;
147  }
148 
149  // reschdule trigger
150  if (AssocTools::containsKey(unschedOperands, trigger)) {
151  if (!runPostChild(
152  new BFScheduleBU(
153  sched_, *trigger, lc, false, false, false))) {
154  undo();
155  return false;
156  }
157  }
158 
159  // reschedule other operands
160  for (int i = 0; i < po.inputMoveCount(); i++) {
161  MoveNode& operand = po.inputMove(i);
162  if (&operand != trigger) {
163  if (AssocTools::containsKey(unschedOperands, &operand)) {
164  if (!runPostChild(
165  new BFScheduleBU(
166  sched_, operand, lc, false, false, false))) {
167  undo();
168  return false;
169  }
170  }
171  }
172  }
173  } else {
174  undo();
175  return false;
176  }
178  return true;
179 }

References assert, BFUnscheduleMove::BFUnscheduleMove(), AssocTools::containsKey(), MoveNode::cycle(), BFOptimization::ddg(), DataDependenceGraph::earliestCycle(), BF2Scheduler::guardWriteNode(), BFOptimization::ii(), ProgramOperation::inputMove(), ProgramOperation::inputMoveCount(), TTAProgram::Move::isControlFlowMove(), isLoopBypass(), MoveNode::isScheduled(), MoveNode::isSourceOperation(), DataDependenceGraph::latestCycle(), lc_, BFUnscheduleMove::mn_, MoveNode::move(), ProgramOperation::outputMove(), ProgramOperation::outputMoveCount(), BFUnscheduleMove::returnOriginal(), Reversible::runPostChild(), BFOptimization::sched_, MoveNode::sourceOperation(), MoveNode::toString(), ProgramOperation::triggeringMove(), Reversible::undo(), and BFUnscheduleMove::unscheduleOriginal().

Here is the call graph for this function:

Member Data Documentation

◆ lc_

int BFPushMoveUp2::lc_
private

Definition at line 62 of file BFPushMoveUp2.hh.

Referenced by operator()().


The documentation for this class was generated from the following files:
BFPushMoveUp2::lc_
int lc_
Definition: BFPushMoveUp2.hh:62
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
BFOptimization::ii
unsigned int ii() const
Definition: BFOptimization.cc:85
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
BoostGraph< MoveNode, DataDependenceEdge >::NodeSet
std::set< MoveNode *, typename MoveNode ::Comparator > NodeSet
Definition: BoostGraph.hh:86
BFUnscheduleMove::returnOriginal
void returnOriginal()
Definition: BFUnscheduleMove.cc:107
ProgramOperation
Definition: ProgramOperation.hh:70
MoveNode
Definition: MoveNode.hh:65
ProgramOperation::triggeringMove
MoveNode * triggeringMove() const
Definition: ProgramOperation.cc:643
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
BFUnscheduleMove::mn_
MoveNode & mn_
Definition: BFUnscheduleMove.hh:61
MoveNode::sourceOperation
ProgramOperation & sourceOperation() const
Definition: MoveNode.cc:453
assert
#define assert(condition)
Definition: Application.hh:86
DataDependenceGraph::operationInEdges
EdgeSet operationInEdges(const MoveNode &node) const
Definition: DataDependenceGraph.cc:5913
MoveNode::cycle
int cycle() const
Definition: MoveNode.cc:421
BFScheduleBU
Definition: BFScheduleBU.hh:45
TTAProgram::Move::isControlFlowMove
bool isControlFlowMove() const
Definition: Move.cc:233
Reversible::undo
virtual void undo()
Definition: Reversible.cc:69
MoveNode::isSourceOperation
bool isSourceOperation() const
Definition: MoveNode.cc:168
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
ProgramOperation::inputMoveCount
int inputMoveCount() const
Definition: ProgramOperation.cc:600
BFUnscheduleMove::BFUnscheduleMove
BFUnscheduleMove(BF2Scheduler &sched, MoveNode &mn)
Definition: BFUnscheduleMove.hh:51
ProgramOperation::outputMoveCount
int outputMoveCount() const
Definition: ProgramOperation.cc:610
BFPushMoveUp2::isLoopBypass
bool isLoopBypass(MoveNode &mn)
Definition: BFPushMoveUp2.cc:181
DataDependenceGraph::earliestCycle
int earliestCycle(const MoveNode &moveNode, unsigned int ii=UINT_MAX, bool ignoreRegWaRs=false, bool ignoreRegWaWs=false, bool ignoreGuards=false, bool ignoreFUDeps=false, bool ignoreSameOperationEdges=false, bool assumeBypassing=false) const
Definition: DataDependenceGraph.cc:388
BFUnscheduleMove::unscheduleOriginal
void unscheduleOriginal()
Definition: BFUnscheduleMove.cc:47
MoveNode::move
TTAProgram::Move & move()
MoveNode::isScheduled
bool isScheduled() const
Definition: MoveNode.cc:409
BF2Scheduler::guardWriteNode
MoveNode * guardWriteNode()
Definition: BF2Scheduler.hh:191
Reversible::runPostChild
bool runPostChild(Reversible *preChild)
Definition: Reversible.cc:139
ProgramOperation::outputMove
MoveNode & outputMove(int index) const
Definition: ProgramOperation.cc:632
ProgramOperation::inputMove
MoveNode & inputMove(int index) const
Definition: ProgramOperation.cc:621
DataDependenceGraph::latestCycle
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
Definition: DataDependenceGraph.cc:543