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

#include <MoveNodeDuplicator.hh>

Collaboration diagram for MoveNodeDuplicator:
Collaboration graph

Public Member Functions

 MoveNodeDuplicator (DataDependenceGraph &oldDDG, DataDependenceGraph &newDDG)
 
std::pair< MoveNode *, bool > duplicateMoveNode (MoveNode &mn, bool addToDDG, bool ignoreSameBBBackEdges)
 
std::shared_ptr< TTAProgram::MoveduplicateMove (TTAProgram::Move &old)
 
ProgramOperationPtr duplicateProgramOperationPtr (ProgramOperationPtr old)
 
void disposeMoveNode (MoveNode *newMN)
 
void setBBN (BasicBlockNode &bbn)
 
MoveNodegetMoveNode (MoveNode &mn)
 
ProgramOperationPtr getProgramOperation (ProgramOperationPtr old)
 
void dumpDDG ()
 

Private Attributes

std::map< ProgramOperation *, ProgramOperationPtr, ProgramOperation::ComparatorprogramOperations_
 
std::map< ProgramOperation *, ProgramOperationPtr, ProgramOperation::ComparatoroldProgramOperations_
 
std::map< MoveNode *, MoveNode *, MoveNode::ComparatormoveNodes_
 
std::map< MoveNode *, MoveNode *, MoveNode::ComparatoroldMoveNodes_
 
std::map< TTAProgram::Move *, std::shared_ptr< TTAProgram::Move > > moves_
 
BasicBlockNodebbn_
 
DataDependenceGrapholdDDG_
 
DataDependenceGraphnewDDG_
 
DataDependenceGraphbigDDG_
 

Detailed Description

Definition at line 38 of file MoveNodeDuplicator.hh.

Constructor & Destructor Documentation

◆ MoveNodeDuplicator()

MoveNodeDuplicator::MoveNodeDuplicator ( DataDependenceGraph oldDDG,
DataDependenceGraph newDDG 
)

This class is used for copying moves from a basic block to another corresponding basic block, copying also the programoperation structure.

Definition at line 48 of file MoveNodeDuplicator.cc.

49  :
50  oldDDG_(&oldDDG), newDDG_(&newDDG),
51  bigDDG_(static_cast<DataDependenceGraph*>(oldDDG.rootGraph())) { }

Member Function Documentation

◆ disposeMoveNode()

void MoveNodeDuplicator::disposeMoveNode ( MoveNode newMN)

Definition at line 53 of file MoveNodeDuplicator.cc.

53  {
54  if (newMN == NULL) {
55  return;
56  }
57  if (newMN->isScheduled()) {
58  std::cerr << "\t\t\t\t\tCannot dispose scheduled mn: "
59  << newMN->toString() << std::endl;
60  assert(false);
61  }
62  assert(!newMN->isScheduled());
63  std::map<MoveNode*,MoveNode*,MoveNode::Comparator>::iterator i =
64  oldMoveNodes_.find(newMN);
65  // already disposed?
66  if (i == oldMoveNodes_.end()) {
67  return;
68  }
69  MoveNode* old = i->second;
70  moveNodes_.erase(old);
71  oldMoveNodes_.erase(newMN);
72  TTAProgram::Move* oldMove = &old->move();
73  moves_.erase(oldMove);
74  if (newDDG_->hasNode(*newMN)) {
75  newDDG_->removeNode(*newMN);
76  }
77  delete newMN;
78 }

References assert, BoostGraph< GraphNode, GraphEdge >::hasNode(), MoveNode::isScheduled(), MoveNode::move(), moveNodes_, moves_, newDDG_, oldMoveNodes_, DataDependenceGraph::removeNode(), and MoveNode::toString().

Referenced by BFOptimization::canAssign(), BFSchedulePreLoopShared::operator()(), BFDRELoop::operator()(), BFOptimization::rmEC(), BFOptimization::rmLC(), BFOptimization::unassignCopyFromPrologEpilog(), BFSchedulePreLoopShared::undoOnlyMe(), BFDRELoop::undoOnlyMe(), and BFMergeAndKeepUser::undoOnlyMe().

Here is the call graph for this function:

◆ dumpDDG()

void MoveNodeDuplicator::dumpDDG ( )

Definition at line 273 of file MoveNodeDuplicator.cc.

273  {
274  newDDG_->writeToDotFile("prolog_ddg.dot");
275 }

References newDDG_, and GraphBase< GraphNode, GraphEdge >::writeToDotFile().

Here is the call graph for this function:

◆ duplicateMove()

std::shared_ptr< TTAProgram::Move > MoveNodeDuplicator::duplicateMove ( TTAProgram::Move old)

Definition at line 199 of file MoveNodeDuplicator.cc.

199  {
200  if (AssocTools::containsKey(moves_,&old)) {
201  return moves_[&old];
202  } else {
203  MoveNode& oldMN = oldDDG_->nodeOfMove(old);
204  std::shared_ptr<TTAProgram::Move> newMove(old.copy());
205  newMove->setBus(UniversalMachine::instance().universalBus());
206 
207  TTAProgram::Terminal& source = newMove->source();
208  if (oldMN.isSourceOperation()) {
209  if (oldMN.isScheduled()) {
210  assert(source.isFUPort());
211  std::string fuName = source.functionUnit().name();
212  //TODO: which is the correct annotation here?
215  fuName);
216  newMove->setAnnotation(srcUnit);
217  const Operation &srcOp = oldMN.sourceOperation().operation();
218  const TTAMachine::HWOperation& hwop =
220  operation(srcOp.name());
221  newMove->setSource(new TTAProgram::TerminalFUPort(
222  hwop, old.source().operationIndex()));
223  }
224  } else {
225  if (source.isRA()) {
226  newMove->setSource(
228  *UniversalMachine::instance().controlUnit()->
229  returnAddressPort()));
230  }
231  }
232 
233  TTAProgram::Terminal& dest = newMove->destination();
234  if (oldMN.isDestinationOperation()) {
235  assert(dest.isFUPort());
236 
237  if (oldMN.isScheduled()) {
238  std::string fuName = dest.functionUnit().name();
239  //TODO: which is the correct annotation here?
242  fuName);
243  newMove->setAnnotation(dstUnit);
244  const Operation &dstOp =
248  operation(dstOp.name());
249  newMove->setDestination(new TTAProgram::TerminalFUPort(
250  hwop, old.destination().
251  operationIndex()));
252  } else {
253  if (dest.isRA()) {
254  newMove->setDestination(
256  *UniversalMachine::instance().controlUnit()->
257  returnAddressPort()));
258  }
259  }
260  }
261 
262  moves_[&old] = newMove;
263 
264  // set guard of new move to be same as old move.
265  if (!old.isUnconditional()) {
266  TTAProgram::MoveGuard* g = old.guard().copy();
267  newMove->setGuard(g);
268  }
269  return newMove;
270  }
271 }

References TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_DST, TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_SRC, assert, AssocTools::containsKey(), TTAProgram::MoveGuard::copy(), TTAProgram::Move::copy(), TTAProgram::Move::destination(), MoveNode::destinationOperation(), TTAProgram::Terminal::functionUnit(), TTAProgram::Move::guard(), UniversalMachine::instance(), MoveNode::isDestinationOperation(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isRA(), MoveNode::isScheduled(), MoveNode::isSourceOperation(), TTAProgram::Move::isUnconditional(), moves_, TTAMachine::Component::name(), Operation::name(), DataDependenceGraph::nodeOfMove(), oldDDG_, ProgramOperation::operation(), TTAProgram::Terminal::operationIndex(), TTAProgram::AnnotatedInstructionElement::setAnnotation(), TTAProgram::Move::setBus(), TTAProgram::Move::setDestination(), TTAProgram::Move::setGuard(), TTAProgram::Move::setSource(), TTAProgram::Move::source(), MoveNode::sourceOperation(), and UniversalMachine::universalFunctionUnit().

Referenced by duplicateMoveNode().

Here is the call graph for this function:

◆ duplicateMoveNode()

std::pair< MoveNode *, bool > MoveNodeDuplicator::duplicateMoveNode ( MoveNode old,
bool  addToDDG,
bool  ignoreSameBBBackEdges 
)

Duplicates a corresponding MoveNode a given move in the next BB.

If no corresponding MoveNode created, creates one

Parameters
oldProgramOperation in jump target BB.
Returns
new MoveNode for this BB.

Definition at line 106 of file MoveNodeDuplicator.cc.

107  {
108  std::map<MoveNode*,MoveNode*,MoveNode::Comparator>::iterator iter =
109  moveNodes_.find(&old);
110 
111  if (iter != moveNodes_.end()) {
112  MoveNode* node = iter->second;
113  if (addToDDG) {
114  if (!newDDG_->hasNode(*node)) {
115  newDDG_->addNode(*node, *bbn_);
116  bigDDG_->copyDependencies(old,*node, ignoreSameBBBackEdges, false);
117  }
118  }
119  }
121 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
122  std::cerr << "\t\t\t\t\told mn found: "
123  << moveNodes_[&old]->toString() << std::endl;
124 #endif
125  return std::make_pair(moveNodes_[&old], false);
126  } else {
127  auto movePtr = duplicateMove(old.move());
128  MoveNode *newMN = new MoveNode(movePtr);
129 
130  // TODO: only add to ddg if really scheduling, not for testing?
131  if (addToDDG) {
132  newDDG_->addNode(*newMN, *bbn_);
133  bigDDG_->copyDependencies(old,*newMN, ignoreSameBBBackEdges, false);
134  }
135 
136  moveNodes_[&old] = newMN;
137  oldMoveNodes_[newMN] = &old;
138  if (old.isSourceOperation()) {
139  newMN->setSourceOperationPtr(
141  newMN->sourceOperation().addOutputNode(*newMN);
142  assert(newMN->isSourceOperation());
143  }
144  if (old.isDestinationOperation()) {
145  for (unsigned int i = 0;
146  i < old.destinationOperationCount(); i++) {
149  old.destinationOperationPtr(i)));
150  newMN->destinationOperation(i).addInputNode(*newMN);
151  }
152  assert(newMN->isDestinationOperation());
153  }
154  if (old.isGuardOperation()) {
155  newMN->setGuardOperationPtr(
157  newMN->guardOperation().addGuardOutputNode(*newMN);
158  assert(newMN->isGuardOperation());
159  }
160  return std::make_pair(newMN, true);
161  }
162 }

References MoveNode::addDestinationOperationPtr(), ProgramOperation::addGuardOutputNode(), ProgramOperation::addInputNode(), DataDependenceGraph::addNode(), ProgramOperation::addOutputNode(), assert, bbn_, bigDDG_, AssocTools::containsKey(), DataDependenceGraph::copyDependencies(), MoveNode::destinationOperation(), MoveNode::destinationOperationCount(), MoveNode::destinationOperationPtr(), duplicateMove(), duplicateProgramOperationPtr(), MoveNode::guardOperation(), MoveNode::guardOperationPtr(), BoostGraph< GraphNode, GraphEdge >::hasNode(), MoveNode::isDestinationOperation(), MoveNode::isGuardOperation(), MoveNode::isSourceOperation(), MoveNode::move(), moveNodes_, newDDG_, oldMoveNodes_, MoveNode::setGuardOperationPtr(), MoveNode::setSourceOperationPtr(), MoveNode::sourceOperation(), and MoveNode::sourceOperationPtr().

Referenced by BFOptimization::canAssign(), BFOptimization::createCopyForPrologEpilog(), BFSchedulePreLoopShared::operator()(), BFDRELoop::operator()(), BFMergeAndKeepUser::operator()(), BFOptimization::rmEC(), and BFOptimization::rmLC().

Here is the call graph for this function:

◆ duplicateProgramOperationPtr()

ProgramOperationPtr MoveNodeDuplicator::duplicateProgramOperationPtr ( ProgramOperationPtr  old)

Gets a corresponding ProgramOperation to a given move in the next BB.

If no corresponding ProgramOperation created, creates one

Parameters
oldProgramOperation in jump target BB.
Returns
new ProgramOperation for this BB.

Definition at line 173 of file MoveNodeDuplicator.cc.

174  { // , BasicBlockNode& bbn) {
176  return programOperations_[old.get()];
177  } else {
180  new ProgramOperation(old->operation()));
181  programOperations_[old.get()] = po;
182  oldProgramOperations_[po.get()] = old;
183  return po;
184  }
185 }

References AssocTools::containsKey(), oldProgramOperations_, and programOperations_.

Referenced by duplicateMoveNode(), and BFShareOperand::operator()().

Here is the call graph for this function:

◆ getMoveNode()

MoveNode * MoveNodeDuplicator::getMoveNode ( MoveNode mn)

◆ getProgramOperation()

ProgramOperationPtr MoveNodeDuplicator::getProgramOperation ( ProgramOperationPtr  old)

Definition at line 188 of file MoveNodeDuplicator.cc.

188  {
189  auto i = programOperations_.find(old.get());
190  if (i != programOperations_.end()) {
191  return i->second;
192  } else {
193  return ProgramOperationPtr(nullptr);
194  }
195 }

References programOperations_.

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

◆ setBBN()

void MoveNodeDuplicator::setBBN ( BasicBlockNode bbn)
inline

Definition at line 52 of file MoveNodeDuplicator.hh.

52  {
53  bbn_ = &bbn;
54  }

References bbn_.

Referenced by BF2Scheduler::handleLoopDDG().

Member Data Documentation

◆ bbn_

BasicBlockNode* MoveNodeDuplicator::bbn_
private

Definition at line 77 of file MoveNodeDuplicator.hh.

Referenced by duplicateMoveNode(), and setBBN().

◆ bigDDG_

DataDependenceGraph* MoveNodeDuplicator::bigDDG_
private

Definition at line 80 of file MoveNodeDuplicator.hh.

Referenced by duplicateMoveNode().

◆ moveNodes_

std::map<MoveNode*,MoveNode*,MoveNode::Comparator> MoveNodeDuplicator::moveNodes_
private

Definition at line 72 of file MoveNodeDuplicator.hh.

Referenced by disposeMoveNode(), duplicateMoveNode(), and getMoveNode().

◆ moves_

std::map<TTAProgram::Move*,std::shared_ptr<TTAProgram::Move> > MoveNodeDuplicator::moves_
private

Definition at line 75 of file MoveNodeDuplicator.hh.

Referenced by disposeMoveNode(), and duplicateMove().

◆ newDDG_

DataDependenceGraph* MoveNodeDuplicator::newDDG_
private

Definition at line 79 of file MoveNodeDuplicator.hh.

Referenced by disposeMoveNode(), dumpDDG(), and duplicateMoveNode().

◆ oldDDG_

DataDependenceGraph* MoveNodeDuplicator::oldDDG_
private

Definition at line 78 of file MoveNodeDuplicator.hh.

Referenced by duplicateMove().

◆ oldMoveNodes_

std::map<MoveNode*,MoveNode*,MoveNode::Comparator> MoveNodeDuplicator::oldMoveNodes_
private

Definition at line 74 of file MoveNodeDuplicator.hh.

Referenced by disposeMoveNode(), and duplicateMoveNode().

◆ oldProgramOperations_

std::map<ProgramOperation*, ProgramOperationPtr, ProgramOperation::Comparator> MoveNodeDuplicator::oldProgramOperations_
private

Definition at line 70 of file MoveNodeDuplicator.hh.

Referenced by duplicateProgramOperationPtr().

◆ programOperations_

std::map<ProgramOperation*, ProgramOperationPtr, ProgramOperation::Comparator> MoveNodeDuplicator::programOperations_
private

Definition at line 65 of file MoveNodeDuplicator.hh.

Referenced by duplicateProgramOperationPtr(), and getProgramOperation().


The documentation for this class was generated from the following files:
TTAProgram::Move::copy
std::shared_ptr< Move > copy() const
Definition: Move.cc:413
ProgramOperation::operation
const Operation & operation() const
Definition: ProgramOperation.cc:590
TTAProgram::Terminal::isFUPort
virtual bool isFUPort() const
Definition: Terminal.cc:118
MoveNodeDuplicator::newDDG_
DataDependenceGraph * newDDG_
Definition: MoveNodeDuplicator.hh:79
ProgramOperation::addGuardOutputNode
void addGuardOutputNode(MoveNode &node)
Definition: ProgramOperation.cc:201
MoveNodeDuplicator::bigDDG_
DataDependenceGraph * bigDDG_
Definition: MoveNodeDuplicator.hh:80
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
MoveNodeDuplicator::programOperations_
std::map< ProgramOperation *, ProgramOperationPtr, ProgramOperation::Comparator > programOperations_
Definition: MoveNodeDuplicator.hh:65
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
MoveNode::guardOperationPtr
ProgramOperationPtr guardOperationPtr() const
Definition: MoveNode.cc:484
TTAMachine::HWOperation
Definition: HWOperation.hh:52
MoveNode::isDestinationOperation
bool isDestinationOperation() const
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
TTAProgram::Move::isUnconditional
bool isUnconditional() const
Definition: Move.cc:154
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
MoveNodeDuplicator::moves_
std::map< TTAProgram::Move *, std::shared_ptr< TTAProgram::Move > > moves_
Definition: MoveNodeDuplicator.hh:75
UniversalMachine::instance
static UniversalMachine & instance()
Definition: UniversalMachine.cc:73
ProgramOperation
Definition: ProgramOperation.hh:70
MoveNode
Definition: MoveNode.hh:65
MoveNodeDuplicator::duplicateProgramOperationPtr
ProgramOperationPtr duplicateProgramOperationPtr(ProgramOperationPtr old)
Definition: MoveNodeDuplicator.cc:173
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
MoveNodeDuplicator::bbn_
BasicBlockNode * bbn_
Definition: MoveNodeDuplicator.hh:77
ProgramOperationPtr
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition: MoveNode.hh:52
ProgramOperation::addOutputNode
void addOutputNode(MoveNode &node, int outputIndex)
Definition: ProgramOperation.cc:167
MoveNode::setSourceOperationPtr
void setSourceOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:541
MoveNode::sourceOperation
ProgramOperation & sourceOperation() const
Definition: MoveNode.cc:453
assert
#define assert(condition)
Definition: Application.hh:86
MoveNode::isGuardOperation
bool isGuardOperation() const
Definition: MoveNode.cc:181
TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_SRC
@ ANN_CONN_CANDIDATE_UNIT_SRC
Src. unit candidate.
Definition: ProgramAnnotation.hh:115
TTAProgram::Terminal::operationIndex
virtual int operationIndex() const
Definition: Terminal.cc:364
BoostGraph::rootGraph
BoostGraph * rootGraph()
MoveNode::addDestinationOperationPtr
void addDestinationOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:533
TTAProgram::Move::guard
MoveGuard & guard() const
Definition: Move.cc:345
DataDependenceGraph::nodeOfMove
MoveNode & nodeOfMove(const TTAProgram::Move &move)
Definition: DataDependenceGraph.cc:3600
MoveNodeDuplicator::oldDDG_
DataDependenceGraph * oldDDG_
Definition: MoveNodeDuplicator.hh:78
DataDependenceGraph::removeNode
void removeNode(MoveNode &node)
Definition: DataDependenceGraph.cc:2843
MoveNode::isSourceOperation
bool isSourceOperation() const
Definition: MoveNode.cc:168
TTAProgram::Move
Definition: Move.hh:55
MoveNode::destinationOperationCount
unsigned int destinationOperationCount() const
BoostGraph::hasNode
bool hasNode(const Node &) const
Operation
Definition: Operation.hh:59
GraphBase::writeToDotFile
virtual void writeToDotFile(const TCEString &fileName) const
TTAProgram::TerminalFUPort
Definition: TerminalFUPort.hh:56
TTAProgram::Terminal::functionUnit
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition: Terminal.cc:251
MoveNodeDuplicator::moveNodes_
std::map< MoveNode *, MoveNode *, MoveNode::Comparator > moveNodes_
Definition: MoveNodeDuplicator.hh:72
UniversalMachine::universalFunctionUnit
UniversalFunctionUnit & universalFunctionUnit() const
Definition: UniversalMachine.cc:205
MoveNode::destinationOperation
ProgramOperation & destinationOperation(unsigned int index=0) const
DataDependenceGraph::addNode
void addNode(MoveNode &moveNode)
Definition: DataDependenceGraph.cc:144
ProgramOperation::addInputNode
void addInputNode(MoveNode &node)
Definition: ProgramOperation.cc:144
MoveNode::destinationOperationPtr
ProgramOperationPtr destinationOperationPtr(unsigned int index=0) const
MoveNode::move
TTAProgram::Move & move()
MoveNodeDuplicator::oldProgramOperations_
std::map< ProgramOperation *, ProgramOperationPtr, ProgramOperation::Comparator > oldProgramOperations_
Definition: MoveNodeDuplicator.hh:70
MoveNodeDuplicator::oldMoveNodes_
std::map< MoveNode *, MoveNode *, MoveNode::Comparator > oldMoveNodes_
Definition: MoveNodeDuplicator.hh:74
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
MoveNode::setGuardOperationPtr
void setGuardOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:550
MoveNode::sourceOperationPtr
ProgramOperationPtr sourceOperationPtr() const
Definition: MoveNode.cc:458
TTAProgram::Terminal
Definition: Terminal.hh:60
MoveNode::isScheduled
bool isScheduled() const
Definition: MoveNode.cc:409
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
TTAProgram::MoveGuard::copy
MoveGuard * copy() const
Definition: MoveGuard.cc:96
TTAProgram::ProgramAnnotation
Definition: ProgramAnnotation.hh:49
TTAProgram::Terminal::isRA
virtual bool isRA() const
Definition: Terminal.cc:129
TTAProgram::MoveGuard
Definition: MoveGuard.hh:47
DataDependenceGraph::copyDependencies
void copyDependencies(const MoveNode &src, MoveNode &dst, bool ignoreSameBBBackedges, bool moveOverLoopEdge=true)
Definition: DataDependenceGraph.cc:3816
MoveNodeDuplicator::duplicateMove
std::shared_ptr< TTAProgram::Move > duplicateMove(TTAProgram::Move &old)
Definition: MoveNodeDuplicator.cc:199
TTAProgram::ProgramAnnotation::ANN_CONN_CANDIDATE_UNIT_DST
@ ANN_CONN_CANDIDATE_UNIT_DST
Dst. unit candidate.
Definition: ProgramAnnotation.hh:116
MoveNode::guardOperation
ProgramOperation & guardOperation() const
Definition: MoveNode.cc:479