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

#include <BFDRELoop.hh>

Inheritance diagram for BFDRELoop:
Inheritance graph
Collaboration diagram for BFDRELoop:
Collaboration graph

Public Member Functions

 BFDRELoop (BF2Scheduler &sched, MoveNode &mn, int srcCycle)
 
bool operator() ()
 
void undoOnlyMe ()
 
bool dreAllowed ()
 
- Public Member Functions inherited from BFKillNode
 BFKillNode (BF2Scheduler &sched, MoveNode &mn)
 
bool operator() ()
 
void undoOnlyMe ()
 
- 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

unsigned int srcCycle_
 
MoveNodeprologMN_
 
bool createdPrologCopy_
 

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 BFKillNode
DataDependenceGraph::EdgeSet createdEdges_
 
MoveNodemn_
 
- 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 46 of file BFDRELoop.hh.

Constructor & Destructor Documentation

◆ BFDRELoop()

BFDRELoop::BFDRELoop ( BF2Scheduler sched,
MoveNode mn,
int  srcCycle 
)
inline

Definition at line 48 of file BFDRELoop.hh.

48  :
49  BFKillNode(sched, mn), srcCycle_(srcCycle), prologMN_(NULL),
50  createdPrologCopy_(false) {}

Member Function Documentation

◆ dreAllowed()

bool BFDRELoop::dreAllowed ( )

Definition at line 107 of file BFDRELoop.cc.

107  {
109  for (auto edge: edges) {
110  if (edge->edgeReason() == DataDependenceEdge::EDGE_OPERATION) {
111  return false;
112  }
113  if ((edge->edgeReason() == DataDependenceEdge::EDGE_REGISTER ||
114  edge->edgeReason() ==DataDependenceEdge::EDGE_RA) &&
115  edge->dependenceType() == DataDependenceEdge::DEP_RAW) {
116  return false;
117  }
118  }
119  return true;
120 }

References BFOptimization::ddg(), DataDependenceEdge::DEP_RAW, DataDependenceEdge::EDGE_OPERATION, DataDependenceEdge::EDGE_RA, DataDependenceEdge::EDGE_REGISTER, BFKillNode::mn_, and BoostGraph< GraphNode, GraphEdge >::outEdges().

Referenced by operator()().

Here is the call graph for this function:

◆ operator()()

bool BFDRELoop::operator() ( )
virtual

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

Implements Reversible.

Definition at line 46 of file BFDRELoop.cc.

46  {
47  if (!sched_.killDeadResults() || targetMachine().alwaysWriteResults()) {
48  return false;
49  }
50 
51  if (srcCycle_ < ii()) {
52 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
53  std::cerr << "\t\t\t\tCannot loop-dre due too early result cycle"
54  << std::endl;
55 #endif
56  return false;
57  }
58 
59  if (!dreAllowed()) {
60  return false;
61  }
62 
63  // Create a copy to prolog.
64  auto a = duplicator().duplicateMoveNode(mn_, true, true);
65  prologMN_ = a.first;
66  createdPrologCopy_ = a.second;
67 
68  int prologCycle = BF2Scheduler::PROLOG_CYCLE_BIAS + srcCycle_;
69  if (prologRM()->canAssign(prologCycle, *prologMN_)) {
70  prologRM()->assign(prologCycle, *prologMN_);
71 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
72  std::cerr << "\t\t\t\tAssigned loop-bypassed dead result to"
73  << " epilog, cycle:" << prologCycle << std::endl;
74 #endif
75  // TODO: where to add to the epilog DDG?
76  createdEdges_ = ddg().copyDepsOver(mn_, true, false);
77  ddg().dropNode(mn_);
79  return true;
80  } else {
81 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
82  std::cerr << "\t\t\t\tProlog cycle assign fail for loop-dre: "
83  << prologMN_->toString()
84  << " prolog cycle: " << prologCycle << std::endl;
85 #endif
86  if (createdPrologCopy_) {
88  }
89  return false;
90  }
91 }

References SimpleResourceManager::assign(), BFOptimization::canAssign(), DataDependenceGraph::copyDepsOver(), BFKillNode::createdEdges_, createdPrologCopy_, BFOptimization::ddg(), MoveNodeDuplicator::disposeMoveNode(), dreAllowed(), BoostGraph< GraphNode, GraphEdge >::dropNode(), MoveNodeDuplicator::duplicateMoveNode(), BFOptimization::duplicator(), BFOptimization::ii(), BF2Scheduler::killDeadResults(), BFKillNode::mn_, BF2Scheduler::nodeKilled(), BF2Scheduler::PROLOG_CYCLE_BIAS, prologMN_, BFOptimization::prologRM(), BFOptimization::sched_, srcCycle_, BFOptimization::targetMachine(), and MoveNode::toString().

Here is the call graph for this function:

◆ undoOnlyMe()

void BFDRELoop::undoOnlyMe ( )
virtual

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

Reimplemented from Reversible.

Definition at line 93 of file BFDRELoop.cc.

93  {
94  assert(prologRM()!=NULL);
95  assert(&mn_ != NULL);
98  prologMoves_.erase(&mn_);
99  if (createdPrologCopy_) {
101  }
102 
103 
105 }

References assert, createdPrologCopy_, MoveNodeDuplicator::disposeMoveNode(), BFOptimization::duplicator(), MoveNode::isScheduled(), BFKillNode::mn_, prologMN_, BFOptimization::prologMoves_, BFOptimization::prologRM(), SimpleResourceManager::unassign(), and BFKillNode::undoOnlyMe().

Here is the call graph for this function:

Member Data Documentation

◆ createdPrologCopy_

bool BFDRELoop::createdPrologCopy_
private

Definition at line 57 of file BFDRELoop.hh.

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

◆ prologMN_

MoveNode* BFDRELoop::prologMN_
private

Definition at line 56 of file BFDRELoop.hh.

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

◆ srcCycle_

unsigned int BFDRELoop::srcCycle_
private

Definition at line 55 of file BFDRELoop.hh.

Referenced by operator()().


The documentation for this class was generated from the following files:
BFKillNode::undoOnlyMe
void undoOnlyMe()
Definition: BFKillNode.cc:49
BFOptimization::duplicator
MoveNodeDuplicator & duplicator() const
Definition: BFOptimization.cc:87
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
BFDRELoop::prologMN_
MoveNode * prologMN_
Definition: BFDRELoop.hh:56
BFKillNode::createdEdges_
DataDependenceGraph::EdgeSet createdEdges_
Definition: BFKillNode.hh:51
BFOptimization::ii
unsigned int ii() const
Definition: BFOptimization.cc:85
BF2Scheduler::killDeadResults
bool killDeadResults() const
Definition: BF2Scheduler.hh:110
SimpleResourceManager::assign
virtual void assign(int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) override
Definition: SimpleResourceManager.cc:221
DataDependenceEdge::EDGE_REGISTER
@ EDGE_REGISTER
Definition: DataDependenceEdge.hh:53
SimpleResourceManager::unassign
virtual void unassign(MoveNode &node) override
Definition: SimpleResourceManager.cc:252
BoostGraph::dropNode
virtual void dropNode(Node &node)
BFOptimization::targetMachine
const TTAMachine::Machine & targetMachine() const
Definition: BFOptimization.cc:81
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
BFDRELoop::dreAllowed
bool dreAllowed()
Definition: BFDRELoop.cc:107
MoveNodeDuplicator::duplicateMoveNode
std::pair< MoveNode *, bool > duplicateMoveNode(MoveNode &mn, bool addToDDG, bool ignoreSameBBBackEdges)
Definition: MoveNodeDuplicator.cc:106
assert
#define assert(condition)
Definition: Application.hh:86
BFOptimization::prologRM
SimpleResourceManager * prologRM() const
Definition: BFOptimization.cc:77
BoostGraph< MoveNode, DataDependenceEdge >::EdgeSet
std::set< DataDependenceEdge *, typename DataDependenceEdge ::Comparator > EdgeSet
Definition: BoostGraph.hh:87
DataDependenceEdge::DEP_RAW
@ DEP_RAW
Definition: DataDependenceEdge.hh:47
MoveNodeDuplicator::disposeMoveNode
void disposeMoveNode(MoveNode *newMN)
Definition: MoveNodeDuplicator.cc:53
DataDependenceEdge::EDGE_OPERATION
@ EDGE_OPERATION
Definition: DataDependenceEdge.hh:56
BFKillNode::BFKillNode
BFKillNode(BF2Scheduler &sched, MoveNode &mn)
Definition: BFKillNode.hh:46
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
BFOptimization::prologMoves_
static std::map< MoveNode *, MoveNode *, MoveNode::Comparator > prologMoves_
Definition: BFOptimization.hh:146
BFDRELoop::createdPrologCopy_
bool createdPrologCopy_
Definition: BFDRELoop.hh:57
BF2Scheduler::PROLOG_CYCLE_BIAS
static const int PROLOG_CYCLE_BIAS
Definition: BF2Scheduler.hh:209
BoostGraph::outEdges
virtual EdgeSet outEdges(const Node &node) const
BFDRELoop::srcCycle_
unsigned int srcCycle_
Definition: BFDRELoop.hh:55
BFKillNode::mn_
MoveNode & mn_
Definition: BFKillNode.hh:52
MoveNode::isScheduled
bool isScheduled() const
Definition: MoveNode.cc:409
BF2Scheduler::nodeKilled
void nodeKilled(MoveNode &mn)
Definition: BF2Scheduler.cc:807
DataDependenceGraph::copyDepsOver
EdgeSet copyDepsOver(MoveNode &node, bool anti, bool raw)
Definition: DataDependenceGraph.cc:2422
DataDependenceEdge::EDGE_RA
@ EDGE_RA
Definition: DataDependenceEdge.hh:57
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