OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
BFPostpassBypass Class Reference

#include <BFPostpassBypass.hh>

Inheritance diagram for BFPostpassBypass:
Inheritance graph
Collaboration diagram for BFPostpassBypass:
Collaboration graph

Public Member Functions

 BFPostpassBypass (BF2Scheduler &sched, MoveNode &src, MoveNode &dst, bool loopBypass)
 
bool operator() () override
 
void undoOnlyMe () override
 
bool dred () const
 
- 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

MoveNodesrc_
 
MoveNodedst_
 
bool dred_
 
bool loopBypass_
 

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 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 42 of file BFPostpassBypass.hh.

Constructor & Destructor Documentation

◆ BFPostpassBypass()

BFPostpassBypass::BFPostpassBypass ( BF2Scheduler sched,
MoveNode src,
MoveNode dst,
bool  loopBypass 
)
inline

Definition at line 44 of file BFPostpassBypass.hh.

47 :
48 BFOptimization(sched), src_(src), dst_(dst), dred_(false),
49 loopBypass_(loopBypass) {}

Member Function Documentation

◆ dred()

bool BFPostpassBypass::dred ( ) const
inline

Definition at line 52 of file BFPostpassBypass.hh.

52{ return dred_; }

References dred_.

◆ operator()()

bool BFPostpassBypass::operator() ( )
overridevirtual

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

Implements Reversible.

Definition at line 51 of file BFPostpassBypass.cc.

51 {
52
53
56#ifdef DEBUG_BUBBLEFISH_SCHEDULER
57 static int counter = 0;
58 static int counter2 = 0;
59#endif
60
61 int originalCycle = dst_.cycle();
62 int srcCycle = src_.cycle();
63
64 if (loopBypass_ && originalCycle >= (int)ii()) {
65#ifdef DEBUG_BUBBLEFISH_SCHEDULER
66 std::cerr << "too late cycle for loop bypass" << std::endl;
67#endif
68 return false;
69 }
70
72 &src_.move().source().functionUnit() : nullptr;
73
75 &dst_.move().destination().functionUnit() : nullptr;
76
77 if (!loopBypass_) {
79 } else {
81 }
83
84 if (!runPreChild(
86#ifdef DEBUG_BUBBLEFISH_SCHEDULER
87 std::cerr << "merge and keep fail." << src_.toString()
88 << " and " << dst_.toString() << std::endl;
89#endif
91 return false;
92 }
93
95
96#ifdef DEBUG_BUBBLEFISH_SCHEDULER
97 std::cerr << "\t\t\tTried ordinary dre: " << dred_ << std::endl;
98#endif
99 if (loopBypass_ && !dred_) {
100#ifdef DEBUG_BUBBLEFISH_SCHEDULER
101 std::cerr << "\t\t\tsrccycle: " << srcCycle << std::endl;
102#endif
103 if (srcCycle >= (int)ii()) {
105 new BFPostpassLoopDRE(sched_, src_, srcCycle));
106 } else {
107 if (ddg().latestCycle(src_) >= (signed)ii()) {
110 }
111 }
112 }
113
114 // TODO: try to DRE here
115
116 if (!dred_) {
117 // if returning the old fails, abort everything
118#ifdef DEBUG_BUBBLEFISH_SCHEDULER
119 std::cerr << "\t\t\tundoing unscheduling of src" << std::endl;
120#endif
121 // if not dre, return the result
122 if (!runPostChild(
123 new BFScheduleExact(sched_, src_, srcCycle, false, ssfu))) {
124#ifdef DEBUG_BUBBLEFISH_SCHEDULER
125 std::cerr << "Scheduling back src:" << src_.toString()
126 << " to cycle: " << srcCycle
127 << " after post-pass bypass move failed" << std::endl;
128 ddg().writeToDotFile("postpass_fail1.dot");
129#endif
130 undo();
131 return false;
132 }
133
134#ifdef DEBUG_BUBBLEFISH_SCHEDULER
135 std::cerr << "\t\t\tundid unscheduling of src" << std::endl;
136#endif
137 }
138
139 BFOptimization* schedDst = NULL;
140 if (dst_.move().isControlFlowMove() ||
141 (ii() != 0 &&
142 static_cast<DataDependenceGraph*>(ddg().rootGraph())->
143 writesJumpGuard(dst_))) {
144 if (!loopBypass_) {
145 schedDst = new BFScheduleExact(
146 sched_, dst_, originalCycle, false);
147 } else {
148 schedDst = new BFAssignToBody(
149 sched_, dst_, originalCycle, ssfu, ddfu);
150 }
151 } else {
152 if (!loopBypass_) {
153 schedDst = new BFScheduleExact(
154 sched_, dst_, originalCycle, false);
155 } else {
156 schedDst = new BFAssignToBody(
157 sched_, dst_, originalCycle, ssfu, ddfu);
158 }
159 }
160
161 if (!runPostChild(schedDst)) {
162#ifdef DEBUG_BUBBLEFISH_SCHEDULER
163 std::cerr << "\t\tScheduling post-pass bypassed move failed:"
164 << dst_.toString() << "cycle: " << originalCycle
165 << std::endl;
166 ddg().writeToDotFile("postpass_fail2.dot");
167#endif
168 undo();
169 return false;
170 }
171 return true;
172}
#define assert(condition)
unsigned int ii() const
BF2Scheduler & sched_
DataDependenceGraph & ddg()
virtual void writeToDotFile(const TCEString &fileName) const
int cycle() const
Definition MoveNode.cc:421
bool isDestinationOperation() const
std::string toString() const
Definition MoveNode.cc:576
TTAProgram::Move & move()
bool isSourceOperation() const
Definition MoveNode.cc:168
bool isScheduled() const
Definition MoveNode.cc:409
bool runPostChild(Reversible *preChild)
virtual void undo()
Definition Reversible.cc:69
void undoAndRemovePreChildren()
Definition Reversible.cc:80
bool runPreChild(Reversible *preChild)
bool isControlFlowMove() const
Definition Move.cc:233
Terminal & source() const
Definition Move.cc:302
Terminal & destination() const
Definition Move.cc:323
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition Terminal.cc:251

References assert, MoveNode::cycle(), BFOptimization::ddg(), TTAProgram::Move::destination(), dred_, dst_, TTAProgram::Terminal::functionUnit(), BFOptimization::ii(), TTAProgram::Move::isControlFlowMove(), MoveNode::isDestinationOperation(), MoveNode::isScheduled(), MoveNode::isSourceOperation(), loopBypass_, MoveNode::move(), Reversible::runPostChild(), Reversible::runPreChild(), BFOptimization::sched_, TTAProgram::Move::source(), src_, MoveNode::toString(), Reversible::undo(), Reversible::undoAndRemovePreChildren(), and GraphBase< GraphNode, GraphEdge >::writeToDotFile().

Here is the call graph for this function:

◆ undoOnlyMe()

void BFPostpassBypass::undoOnlyMe ( )
overridevirtual

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 174 of file BFPostpassBypass.cc.

174 {
175
176#ifdef DEBUG_BUBBLEFISH_SCHEDULER
177 std::cerr << "isloopbypass?" << loopBypass_ << std::endl;
178 std::cerr << "\t\t\tPerforming unmerge user of: "
179 << src_.toString() << " and: " << dst_.toString()
180 << std::endl;
181#endif
182#ifdef DEBUG_BUBBLEFISH_SCHEDULER
183 std::cerr << "\t\t\tPerformed unmerge user of: "
184 << src_.toString() << " and: " << dst_.toString()
185 << std::endl;
186#endif
187}

References dst_, loopBypass_, src_, and MoveNode::toString().

Here is the call graph for this function:

Member Data Documentation

◆ dred_

bool BFPostpassBypass::dred_
private

Definition at line 56 of file BFPostpassBypass.hh.

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

◆ dst_

MoveNode& BFPostpassBypass::dst_
private

Definition at line 55 of file BFPostpassBypass.hh.

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

◆ loopBypass_

bool BFPostpassBypass::loopBypass_
private

Definition at line 57 of file BFPostpassBypass.hh.

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

◆ src_

MoveNode& BFPostpassBypass::src_
private

Definition at line 54 of file BFPostpassBypass.hh.

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


The documentation for this class was generated from the following files: