OpenASIP  2.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BFRegCopy Class Referenceabstract

#include <BFRegCopy.hh>

Inheritance diagram for BFRegCopy:
Inheritance graph
Collaboration diagram for BFRegCopy:
Collaboration graph

Public Member Functions

 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

virtual bool splitMove (BasicBlockNode &bbn)=0
 
virtual void undoSplit ()=0
 
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)
 

Protected Attributes

MoveNodemn_
 
MoveNoderegCopy_
 
int lc_
 
- Protected Attributes inherited from BFOptimization
BF2Schedulersched_
 
- Protected Attributes inherited from Reversible
std::stack< Reversible * > preChildren_
 
std::stack< Reversible * > postChildren_
 

Additional Inherited Members

- Static Public Member Functions inherited from BFOptimization
static void clearPrologMoves ()
 
static MoveNodegetSisterTrigger (const MoveNode &mn, const TTAMachine::Machine &mach)
 
- Static Protected Attributes inherited from BFOptimization
static std::map< MoveNode *, MoveNode *, MoveNode::ComparatorprologMoves_
 

Detailed Description

Definition at line 47 of file BFRegCopy.hh.

Constructor & Destructor Documentation

◆ BFRegCopy()

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

Definition at line 49 of file BFRegCopy.hh.

49  :
50  BFOptimization(sched), mn_(mn), lc_(lc) {}

Member Function Documentation

◆ createAntidepsForReg()

void BFRegCopy::createAntidepsForReg ( MoveNode firstMove,
MoveNode lastMove,
const TTAMachine::RegisterFile rf,
int  index,
TCEString  regName,
BasicBlockNode bbn,
bool  loopScheduling 
)

Definition at line 99 of file BFRegCopy.cc.

106  {
107 
108  DataDependenceGraph::NodeSet firstScheduledDefs0 =
109  ddg().firstScheduledRegisterWrites(rf, index);
110 
111  MoveNode* lastScheduledKill0 =
112  ddg().lastScheduledRegisterKill(rf, index);
113 
114  for (auto i: firstScheduledDefs0) {
115  if (!ddg().exclusingGuards(*i, useMove)) {
116  DataDependenceEdge* war =
117  new DataDependenceEdge(
119  DataDependenceEdge::DEP_WAR, regName);
120  runPostChild(new BFConnectNodes(sched_, useMove, *i, war));
121  }
122  if (!ddg().exclusingGuards(*i, defMove)) {
123  DataDependenceEdge* waw =
124  new DataDependenceEdge(
126  DataDependenceEdge::DEP_WAW, regName);
127  runPostChild(new BFConnectNodes(sched_, defMove, *i, waw));
128  }
129  }
130 
131  if (loopScheduling) {
132  DataDependenceGraph::NodeSet lastScheduledReads0 =
133  ddg().lastScheduledRegisterReads(rf, index);
134 
135  for (auto i: lastScheduledReads0) {
136  if (!ddg().exclusingGuards(*i, defMove)) {
137  DataDependenceEdge* war =
138  new DataDependenceEdge(
141  false, false, false, false, 1);
142  runPostChild(new BFConnectNodes(sched_, *i, defMove, war));
143  }
144  }
145 
146  DataDependenceGraph::NodeSet lastScheduledDefs0 =
147  ddg().lastScheduledRegisterWrites(rf, index);
148  for (auto i: lastScheduledDefs0) {
149  if (!ddg().exclusingGuards(*i, defMove)) {
150  DataDependenceEdge* waw =
151  new DataDependenceEdge(
154  false, false, false, false, 1);
155  runPostChild(new BFConnectNodes(sched_, *i, defMove, waw));
156  }
157  }
158  }
159  if (bbn.basicBlock().liveRangeData_ != NULL) {
160  if (lastScheduledKill0 == NULL) {
161  LiveRangeData::MoveNodeUseSet& lastWrites0 =
162  bbn.basicBlock().liveRangeData_->regDefines_[regName];
164  sched_, lastWrites0, MoveNodeUse(defMove)));
165 
166  LiveRangeData::MoveNodeUseSet& lastReads0 =
167  bbn.basicBlock().liveRangeData_->regLastUses_[regName];
169  sched_, lastReads0, MoveNodeUse(useMove)));
170  }
171 
172  // last write, for WaW defs
173  LiveRangeData::MoveNodeUseSet& firstDefs =
175 
176  if (useMove.move().isUnconditional()) {
177  LiveRangeData::MoveNodeUseSet& firstReads =
178  bbn.basicBlock().liveRangeData_->regFirstUses_[regName];
179 
180  runPostChild(new BFClearLiveRangeUse(sched_, firstReads));
181  runPostChild(new BFClearLiveRangeUse(sched_, firstDefs));
182  // TODO: what about updating the kill bookkeeping?
183  }
184 
185  runPostChild(
187  sched_, firstDefs, MoveNodeUse(defMove)));
188  }
189 }

References BasicBlockNode::basicBlock(), BFOptimization::ddg(), DataDependenceEdge::DEP_WAR, DataDependenceEdge::DEP_WAW, DataDependenceEdge::EDGE_REGISTER, DataDependenceGraph::firstScheduledRegisterWrites(), TTAProgram::Move::isUnconditional(), DataDependenceGraph::lastScheduledRegisterKill(), DataDependenceGraph::lastScheduledRegisterReads(), DataDependenceGraph::lastScheduledRegisterWrites(), TTAProgram::BasicBlock::liveRangeData_, MoveNode::move(), LiveRangeData::regDefines_, LiveRangeData::regFirstDefines_, LiveRangeData::regFirstUses_, LiveRangeData::regLastUses_, Reversible::runPostChild(), and BFOptimization::sched_.

Referenced by BFRegCopyAfter::splitMove(), and BFRegCopyBefore::splitMove().

Here is the call graph for this function:

◆ createRegCopy()

MoveNode* BFRegCopy::createRegCopy ( bool  after)
protected

◆ getRegCopy()

MoveNode* BFRegCopy::getRegCopy ( )
inline

Definition at line 52 of file BFRegCopy.hh.

52 { return regCopy_; }

References regCopy_.

Referenced by BFScheduleBU::operator()(), and BFScheduleExact::operator()().

◆ operator()()

bool BFRegCopy::operator() ( )
virtual

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

Implements Reversible.

Definition at line 52 of file BFRegCopy.cc.

52  {
53 
54  if (mn_.move().isReturn()) {
57  mn_.move().setAnnotation(annotation);
58  }
59 
60  TTAProgram::ProgramAnnotation connMoveAnnotation(
62 
63  auto copyMove = mn_.move().copy();
64  regCopy_ = new MoveNode(copyMove);
66  ddg().addNode(*regCopy_,bbn);
67  copyMove->addAnnotation(connMoveAnnotation);
68 
69  if (splitMove(bbn)) {
70  return true;
71  }
72  else {
73 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
74  std::cerr << "Regcopy creation failing.." << std::endl;
75 #endif
76  undoDDG();
77  return false;
78  }
79 }

References DataDependenceGraph::addNode(), TTAProgram::ProgramAnnotation::ANN_CONNECTIVITY_MOVE, TTAProgram::ProgramAnnotation::ANN_STACKFRAME_PROCEDURE_RETURN, TTAProgram::Move::copy(), BFOptimization::ddg(), DataDependenceGraph::getBasicBlockNode(), TTAProgram::Move::isReturn(), mn_, MoveNode::move(), regCopy_, TTAProgram::AnnotatedInstructionElement::setAnnotation(), splitMove(), and undoDDG().

Here is the call graph for this function:

◆ splitMove()

virtual bool BFRegCopy::splitMove ( BasicBlockNode bbn)
protectedpure virtual

Implemented in BFRegCopyBefore, BFRegCopyAfter, and BFCopyRegWithOp.

Referenced by operator()().

◆ undoDDG()

void BFRegCopy::undoDDG ( )

Definition at line 86 of file BFRegCopy.cc.

86  {
87 
89 
90 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
91  std::cerr << "\t\tUndid merge for copy for: " << mn_.toString()
92  << " reg copy: " << regCopy_->toString() << std::endl;
93 #endif
96  delete regCopy_;
97 }

References assert, BFOptimization::ddg(), BF2Scheduler::deletingNode(), MoveNode::isScheduled(), mn_, regCopy_, DataDependenceGraph::removeNode(), BFOptimization::sched_, and MoveNode::toString().

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

Here is the call graph for this function:

◆ undoOnlyMe()

void BFRegCopy::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 81 of file BFRegCopy.cc.

81  {
82  undoSplit();
83  undoDDG();
84 }

References undoDDG(), and undoSplit().

Here is the call graph for this function:

◆ undoSplit()

virtual void BFRegCopy::undoSplit ( )
protectedpure virtual

Implemented in BFRegCopyBefore, BFRegCopyAfter, and BFCopyRegWithOp.

Referenced by undoOnlyMe().

Member Data Documentation

◆ lc_

int BFRegCopy::lc_
protected

Definition at line 71 of file BFRegCopy.hh.

Referenced by BFRegCopyAfter::splitMove().

◆ mn_

MoveNode& BFRegCopy::mn_
protected

◆ regCopy_

MoveNode* BFRegCopy::regCopy_
protected

The documentation for this class was generated from the following files:
TTAProgram::Move::copy
std::shared_ptr< Move > copy() const
Definition: Move.cc:413
BF2Scheduler::deletingNode
void deletingNode(MoveNode *deletedNode)
Definition: BF2Scheduler.cc:1633
DataDependenceGraph::lastScheduledRegisterWrites
NodeSet lastScheduledRegisterWrites(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
Definition: DataDependenceGraph.cc:1206
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
LiveRangeData::MoveNodeUseSet
std::set< MoveNodeUse > MoveNodeUseSet
Definition: LiveRangeData.hh:51
TTAProgram::Move::isReturn
bool isReturn() const
Definition: Move.cc:259
BoostGraph< MoveNode, DataDependenceEdge >::NodeSet
std::set< MoveNode *, typename MoveNode ::Comparator > NodeSet
Definition: BoostGraph.hh:86
MoveNodeUse
Definition: MoveNodeUse.hh:20
TTAProgram::AnnotatedInstructionElement::setAnnotation
void setAnnotation(const ProgramAnnotation &annotation)
Definition: AnnotatedInstructionElement.cc:79
LiveRangeData::regDefines_
MoveNodeUseMapSet regDefines_
Definition: LiveRangeData.hh:78
MoveNode
Definition: MoveNode.hh:65
DataDependenceEdge::EDGE_REGISTER
@ EDGE_REGISTER
Definition: DataDependenceEdge.hh:53
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
DataDependenceGraph::lastScheduledRegisterKill
MoveNode * lastScheduledRegisterKill(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
Definition: DataDependenceGraph.cc:1285
BFConnectNodes
Definition: BFConnectNodes.hh:38
BasicBlockNode::basicBlock
TTAProgram::BasicBlock & basicBlock()
Definition: BasicBlockNode.cc:126
assert
#define assert(condition)
Definition: Application.hh:86
TTAProgram::BasicBlock::liveRangeData_
LiveRangeData * liveRangeData_
Definition: BasicBlock.hh:111
LiveRangeData::regFirstDefines_
MoveNodeUseMapSet regFirstDefines_
Definition: LiveRangeData.hh:87
DataDependenceGraph::removeNode
void removeNode(MoveNode &node)
Definition: DataDependenceGraph.cc:2843
BasicBlockNode
Definition: BasicBlockNode.hh:64
LiveRangeData::regLastUses_
MoveNodeUseMapSet regLastUses_
Definition: LiveRangeData.hh:79
BFRegCopy::undoDDG
void undoDDG()
Definition: BFRegCopy.cc:86
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
BFRegCopy::regCopy_
MoveNode * regCopy_
Definition: BFRegCopy.hh:70
BFRegCopy::undoSplit
virtual void undoSplit()=0
DataDependenceEdge::DEP_WAW
@ DEP_WAW
Definition: DataDependenceEdge.hh:49
BFOptimization::BFOptimization
BFOptimization(BF2Scheduler &sched)
Definition: BFOptimization.hh:75
BFClearLiveRangeUse
Definition: BFClearLiveRangeUse.hh:39
DataDependenceGraph::addNode
void addNode(MoveNode &moveNode)
Definition: DataDependenceGraph.cc:144
MoveNode::move
TTAProgram::Move & move()
TTAProgram::ProgramAnnotation::ANN_STACKFRAME_PROCEDURE_RETURN
@ ANN_STACKFRAME_PROCEDURE_RETURN
precedure return jmp
Definition: ProgramAnnotation.hh:76
BFRegCopy::mn_
MoveNode & mn_
Definition: BFRegCopy.hh:69
BFInsertLiveRangeUse
Definition: BFInsertLiveRangeUse.hh:39
DataDependenceGraph::firstScheduledRegisterWrites
NodeSet firstScheduledRegisterWrites(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
Definition: DataDependenceGraph.cc:1245
DataDependenceEdge
Definition: DataDependenceEdge.hh:43
MoveNode::isScheduled
bool isScheduled() const
Definition: MoveNode.cc:409
TTAProgram::ProgramAnnotation::ANN_CONNECTIVITY_MOVE
@ ANN_CONNECTIVITY_MOVE
A reg to reg move that was added because of missing connectivity between the original target and dest...
Definition: ProgramAnnotation.hh:123
BFRegCopy::splitMove
virtual bool splitMove(BasicBlockNode &bbn)=0
TTAProgram::ProgramAnnotation
Definition: ProgramAnnotation.hh:49
DataDependenceEdge::DEP_WAR
@ DEP_WAR
Definition: DataDependenceEdge.hh:48
Reversible::runPostChild
bool runPostChild(Reversible *preChild)
Definition: Reversible.cc:139
DataDependenceGraph::lastScheduledRegisterReads
NodeSet lastScheduledRegisterReads(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
Definition: DataDependenceGraph.cc:1080
DataDependenceGraph::getBasicBlockNode
const BasicBlockNode & getBasicBlockNode(const MoveNode &mn) const
Definition: DataDependenceGraph.cc:186
LiveRangeData::regFirstUses_
MoveNodeUseMapSet regFirstUses_
Definition: LiveRangeData.hh:86
BFRegCopy::lc_
int lc_
Definition: BFRegCopy.hh:71