OpenASIP 2.2
Loading...
Searching...
No Matches
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) {}
MoveNode & mn_
Definition BFRegCopy.hh:69

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 =
110
111 MoveNode* lastScheduledKill0 =
112 ddg().lastScheduledRegisterKill(rf, index);
113
114 for (auto i: firstScheduledDefs0) {
115 if (!ddg().exclusingGuards(*i, useMove)) {
116 DataDependenceEdge* war =
120 runPostChild(new BFConnectNodes(sched_, useMove, *i, war));
121 }
122 if (!ddg().exclusingGuards(*i, defMove)) {
123 DataDependenceEdge* waw =
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 =
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 =
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
167 bbn.basicBlock().liveRangeData_->regLastUses_[regName];
169 sched_, lastReads0, MoveNodeUse(useMove)));
170 }
171
172 // last write, for WaW defs
175
176 if (useMove.move().isUnconditional()) {
179
180 runPostChild(new BFClearLiveRangeUse(sched_, firstReads));
181 runPostChild(new BFClearLiveRangeUse(sched_, firstDefs));
182 // TODO: what about updating the kill bookkeeping?
183 }
184
187 sched_, firstDefs, MoveNodeUse(defMove)));
188 }
189}
BF2Scheduler & sched_
DataDependenceGraph & ddg()
TTAProgram::BasicBlock & basicBlock()
NodeSet lastScheduledRegisterWrites(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
NodeSet firstScheduledRegisterWrites(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
NodeSet lastScheduledRegisterReads(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
MoveNode * lastScheduledRegisterKill(const TTAMachine::BaseRegisterFile &rf, int registerIndex) const
std::set< GraphNode *, typename GraphNode::Comparator > NodeSet
Definition Graph.hh:53
bool runPostChild(Reversible *preChild)
LiveRangeData * liveRangeData_
MoveNodeUseMapSet regFirstUses_
MoveNodeUseMapSet regLastUses_
std::set< MoveNodeUse > MoveNodeUseSet
MoveNodeUseMapSet regFirstDefines_
MoveNodeUseMapSet regDefines_

References BasicBlockNode::basicBlock(), BFOptimization::ddg(), DataDependenceEdge::DEP_WAR, DataDependenceEdge::DEP_WAW, DataDependenceEdge::EDGE_REGISTER, DataDependenceGraph::exclusingGuards(), 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_; }
MoveNode * regCopy_
Definition BFRegCopy.hh:70

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}
virtual bool splitMove(BasicBlockNode &bbn)=0
void undoDDG()
Definition BFRegCopy.cc:86
void addNode(MoveNode &moveNode)
const BasicBlockNode & getBasicBlockNode(const MoveNode &mn) const
TTAProgram::Move & move()
void setAnnotation(const ProgramAnnotation &annotation)
bool isReturn() const
Definition Move.cc:259
std::shared_ptr< Move > copy() const
Definition Move.cc:413
@ ANN_STACKFRAME_PROCEDURE_RETURN
precedure return jmp
@ ANN_CONNECTIVITY_MOVE
A reg to reg move that was added because of missing connectivity between the original target and dest...

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 BFCopyRegWithOp, BFRegCopyAfter, and BFRegCopyBefore.

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}
#define assert(condition)
void deletingNode(MoveNode *deletedNode)
void removeNode(MoveNode &node)
std::string toString() const
Definition MoveNode.cc:576
bool isScheduled() const
Definition MoveNode.cc:409

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}
virtual void undoSplit()=0

References undoDDG(), and undoSplit().

Here is the call graph for this function:

◆ undoSplit()

virtual void BFRegCopy::undoSplit ( )
protectedpure virtual

Implemented in BFCopyRegWithOp, BFRegCopyAfter, and BFRegCopyBefore.

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: