OpenASIP  2.0
Public Member Functions | Protected Member Functions | List of all members
BFRegCopyAfter Class Reference

#include <BFRegCopyAfter.hh>

Inheritance diagram for BFRegCopyAfter:
Inheritance graph
Collaboration diagram for BFRegCopyAfter:
Collaboration graph

Public Member Functions

 BFRegCopyAfter (BF2Scheduler &sched, MoveNode &mn, int lc)
 
virtual ~BFRegCopyAfter ()
 
- Public Member Functions inherited from BFRegCopy
 BFRegCopy (BF2Scheduler &sched, MoveNode &mn, int lc)
 
bool operator() ()
 
MoveNodegetRegCopy ()
 
void undoOnlyMe ()
 
void undoDDG ()
 
void createAntidepsForReg (MoveNode &firstMove, MoveNode &lastMove, const TTAMachine::RegisterFile &rf, int index, TCEString regName, BasicBlockNode &bbn, bool loopScheduling)
 
- 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 ()
 

Protected Member Functions

bool splitMove (BasicBlockNode &bbn)
 
void undoSplit ()
 
- Protected Member Functions inherited from BFRegCopy
MoveNodecreateRegCopy (bool after)
 
- 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)
 

Additional Inherited Members

- Static Public Member Functions inherited from BFOptimization
static void clearPrologMoves ()
 
static MoveNodegetSisterTrigger (const MoveNode &mn, const TTAMachine::Machine &mach)
 
- Protected Attributes inherited from BFRegCopy
MoveNodemn_
 
MoveNoderegCopy_
 
int lc_
 
- 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 44 of file BFRegCopyAfter.hh.

Constructor & Destructor Documentation

◆ BFRegCopyAfter()

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

Definition at line 46 of file BFRegCopyAfter.hh.

46  :
47  BFRegCopy(sched,mn,lc) {}

◆ ~BFRegCopyAfter()

virtual BFRegCopyAfter::~BFRegCopyAfter ( )
inlinevirtual

Definition at line 48 of file BFRegCopyAfter.hh.

48 {}

Member Function Documentation

◆ splitMove()

bool BFRegCopyAfter::splitMove ( BasicBlockNode bbn)
protectedvirtual

Implements BFRegCopy.

Definition at line 51 of file BFRegCopyAfter.cc.

51  {
52 
53 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
54  std::cerr << "\t\tBFRegCopyAfter splitting move: "
55  << mn_.toString() << std::endl;
56 #endif
57 
58  std::set<const TTAMachine::RegisterFile*,
60  rfs = sched_.possibleTempRegRFs(mn_, true);
61 
62  // cannot create reg copy if no temp regs available.
63  if (rfs.empty()) {
64  return false;
65  }
66 
67  const TTAMachine::RegisterFile& rf = **rfs.rbegin();
68 
69  int lastRegisterIndex = rf.size()-1;
70  TTAMachine::Port* dstRFPort = rf.firstWritePort();
71  TTAMachine::Port* srcRFPort = rf.firstReadPort();
72 
73  TTAProgram::TerminalRegister* tempWrite =
74  new TTAProgram::TerminalRegister(*dstRFPort, lastRegisterIndex);
75 
77  new TTAProgram::TerminalRegister(*srcRFPort, lastRegisterIndex);
78 
79  regCopy_->move().setSource(tempRead);
80  mn_.move().setDestination(tempWrite);
81 
82  auto iEdges = ddg().rootGraph()->inEdges(mn_);
83  for (auto iEdge : iEdges) {
84  if (!iEdge->isRegisterOrRA() || iEdge->headPseudo()) {
85  continue;
86  }
87 
88  //copy guard use edge to the regcopy.
89  if (iEdge->guardUse() &&
90  iEdge->dependenceType() == DataDependenceEdge::DEP_RAW) {
91  MoveNode& tail = ddg().rootGraph()->tailNode(*iEdge);
93  new BFConnectNodes(sched_, tail, *regCopy_, iEdge, true));
94  } else if (iEdge->isFalseDep()) {
95  MoveNode& tail = ddg().rootGraph()->tailNode(*iEdge);
96  runPostChild(new BFRemoveEdge(sched_, tail, mn_, *iEdge));
97  runPostChild(new BFConnectNodes(sched_, tail, *regCopy_, iEdge));
98  }
99  }
100 
101  auto oEdges = ddg().rootGraph()->outEdges(mn_);
102  for (auto oEdge : oEdges) {
103  if (!oEdge->isRegisterOrRA() || oEdge->tailPseudo()) {
104  continue;
105  }
106 
107  if (oEdge->dependenceType() == DataDependenceEdge::DEP_WAW ||
108  oEdge->dependenceType() == DataDependenceEdge::DEP_RAW) {
109 
110  MoveNode& head = ddg().rootGraph()->headNode(*oEdge);
111  runPostChild(new BFRemoveEdge(sched_, mn_, head, *oEdge));
112  runPostChild(new BFConnectNodes(sched_, *regCopy_, head, oEdge));
113  }
114 
115  if (oEdge->dependenceType() == DataDependenceEdge::DEP_WAR &&
116  oEdge->guardUse()) {
117  MoveNode& head = ddg().rootGraph()->headNode(*oEdge);
118  runPostChild(
119  new BFConnectNodes(sched_, *regCopy_, head, oEdge, true));
120  }
121  }
122 
123  TCEString tempRegName = rf.name() + '.' +
124  Conversion::toString(lastRegisterIndex);
125 
126  DataDependenceEdge* newEdge =
127  new DataDependenceEdge(
129  DataDependenceEdge::DEP_RAW, tempRegName);
130 
131  runPostChild(new BFConnectNodes(sched_, mn_, *regCopy_, newEdge));
132 
134  mn_, *regCopy_, rf, lastRegisterIndex,
135  tempRegName, bbn, ii()!= 0);
136 
137 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
138  std::cerr << " \t\t\tMoves after split: " << mn_.toString() << " and " <<
139  regCopy_->toString() << std::endl;
140 #endif
141 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
142 // writeDotWithNameAndNodeID(ddg(), "regcopy_created_after", mn_);
143 
144 // assert(ddg_->maxSourceDistance(mn) != -1);
145 // assert(ddg_->maxSourceDistance(*copyNode) != -1);
146 // std::cerr << "\t\tmn source distance: " << ddg_->maxSourceDistance(mn) << std::endl;
147 // std::cerr << "\t\tmn regcopy source distance: " << ddg_->maxSourceDistance(*copyNode) << std::endl;
148 #endif
149 
150  // TODO: bypass regcopies??
151  BFScheduleBU* regCopySched =
152  new BFScheduleBU(sched_,*regCopy_, lc_, true, true, false);
153  bool ok = runPostChild(regCopySched);
154  if (!ok) {
156  undoSplit();
157  return false;
158  }
159  return true;
160 }

References BFRegCopy::createAntidepsForReg(), BFOptimization::ddg(), DataDependenceEdge::DEP_RAW, DataDependenceEdge::DEP_WAR, DataDependenceEdge::DEP_WAW, DataDependenceEdge::EDGE_REGISTER, TTAMachine::RegisterFile::firstReadPort(), TTAMachine::RegisterFile::firstWritePort(), BoostGraph< GraphNode, GraphEdge >::headNode(), BFOptimization::ii(), BoostGraph< GraphNode, GraphEdge >::inEdges(), BFRegCopy::lc_, BFRegCopy::mn_, MoveNode::move(), TTAMachine::Component::name(), BoostGraph< GraphNode, GraphEdge >::outEdges(), BF2Scheduler::possibleTempRegRFs(), BFRegCopy::regCopy_, BoostGraph< GraphNode, GraphEdge >::rootGraph(), Reversible::runPostChild(), BFOptimization::sched_, TTAProgram::Move::setDestination(), TTAProgram::Move::setSource(), TTAMachine::BaseRegisterFile::size(), BoostGraph< GraphNode, GraphEdge >::tailNode(), Conversion::toString(), MoveNode::toString(), Reversible::undoAndRemovePostChildren(), and undoSplit().

Here is the call graph for this function:

◆ undoSplit()

void BFRegCopyAfter::undoSplit ( )
protectedvirtual

Implements BFRegCopy.

Definition at line 163 of file BFRegCopyAfter.cc.

163  {
164 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
165  std::cerr << "\t\tBFRegCopyAfter undoing split move: " << mn_.toString()
166  << " and " << regCopy_->toString() << std::endl;
167 #endif
169 }

References TTAProgram::Terminal::copy(), TTAProgram::Move::destination(), BFRegCopy::mn_, MoveNode::move(), BFRegCopy::regCopy_, TTAProgram::Move::setDestination(), and MoveNode::toString().

Referenced by splitMove().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
TTAMachine::RegisterFile::firstReadPort
Port * firstReadPort() const
Definition: RegisterFile.cc:607
BFRegCopy::createAntidepsForReg
void createAntidepsForReg(MoveNode &firstMove, MoveNode &lastMove, const TTAMachine::RegisterFile &rf, int index, TCEString regName, BasicBlockNode &bbn, bool loopScheduling)
Definition: BFRegCopy.cc:99
BoostGraph::tailNode
virtual Node & tailNode(const Edge &edge) const
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
BoostGraph::headNode
virtual Node & headNode(const Edge &edge) const
BF2Scheduler::possibleTempRegRFs
std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > possibleTempRegRFs(const MoveNode &mn, bool tempRegAfter, const TTAMachine::RegisterFile *forbiddenRF=nullptr)
Definition: BF2Scheduler.cc:899
BFOptimization::ii
unsigned int ii() const
Definition: BFOptimization.cc:85
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
MoveNode
Definition: MoveNode.hh:65
DataDependenceEdge::EDGE_REGISTER
@ EDGE_REGISTER
Definition: DataDependenceEdge.hh:53
Conversion::toString
static std::string toString(const T &source)
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
BFConnectNodes
Definition: BFConnectNodes.hh:38
TTAProgram::Move::setDestination
void setDestination(Terminal *dst)
Definition: Move.cc:333
BFRemoveEdge
Definition: BFRemoveEdge.hh:40
TTAMachine::RegisterFile::firstWritePort
Port * firstWritePort() const
Definition: RegisterFile.cc:618
BFScheduleBU
Definition: BFScheduleBU.hh:45
BoostGraph::rootGraph
BoostGraph * rootGraph()
DataDependenceEdge::DEP_RAW
@ DEP_RAW
Definition: DataDependenceEdge.hh:47
TTAMachine::Port
Definition: Port.hh:54
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
BFRegCopy::regCopy_
MoveNode * regCopy_
Definition: BFRegCopy.hh:70
DataDependenceEdge::DEP_WAW
@ DEP_WAW
Definition: DataDependenceEdge.hh:49
BoostGraph::inEdges
virtual EdgeSet inEdges(const Node &node) const
BoostGraph::outEdges
virtual EdgeSet outEdges(const Node &node) const
MoveNode::move
TTAProgram::Move & move()
BFRegCopy::mn_
MoveNode & mn_
Definition: BFRegCopy.hh:69
TCEString
Definition: TCEString.hh:53
Reversible::undoAndRemovePostChildren
void undoAndRemovePostChildren()
Definition: Reversible.cc:89
TTAProgram::Terminal::copy
virtual Terminal * copy() const =0
DataDependenceEdge
Definition: DataDependenceEdge.hh:43
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine::BaseRegisterFile::size
virtual int size() const
DataDependenceEdge::DEP_WAR
@ DEP_WAR
Definition: DataDependenceEdge.hh:48
TTAMachine::MachinePart::Comparator
Definition: MachinePart.hh:59
Reversible::runPostChild
bool runPostChild(Reversible *preChild)
Definition: Reversible.cc:139
BFRegCopyAfter::undoSplit
void undoSplit()
Definition: BFRegCopyAfter.cc:163
BFRegCopy::BFRegCopy
BFRegCopy(BF2Scheduler &sched, MoveNode &mn, int lc)
Definition: BFRegCopy.hh:49
TTAProgram::TerminalRegister
Definition: TerminalRegister.hh:53
TTAProgram::Move::setSource
void setSource(Terminal *src)
Definition: Move.cc:312
BFRegCopy::lc_
int lc_
Definition: BFRegCopy.hh:71