OpenASIP  2.0
BFEarlyBypass.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2014 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 
25 /**
26  * @file BFEarlyBypass.cc
27  *
28  * Definition of BFEarlyBypass class
29  *
30  * Performs a bypass before scheduling an (operand) move
31  *
32  * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
33  * @note rating: red
34  */
35 
36 #include "BFEarlyBypass.hh"
37 #include "BFDREEarly.hh"
39 #include "DataDependenceGraph.hh"
40 #include "BF2Scheduler.hh"
41 #include "BF2ScheduleFront.hh"
42 #include "Machine.hh"
43 #include "BFMergeAndKeepUser.hh"
44 
45 //#define DEBUG_BUBBLEFISH_SCHEDULER
46 //#define DEBUG_LOOP_SCHEDULER
47 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
48 #define DEBUG_LOOP_SCHEDULER
49 #endif
50 
51 bool
53 
54 #ifdef DEBUG_LOOP_SCHEDULER
55  if (ii() != 0) {
56  std::cerr << "\t\t\tEarly bypass for: " << src_.toString()
57  << " to " << dst_.toString() << std::endl;
58  }
59 #endif
60  // Take the predecssors so that they can be notified because their
61  // antideps may change
63 
66  return false;
67  }
68 
69  // if alwayswriteresults, then must have exactly one result write.
70  if (targetMachine().alwaysWriteResults()) {
71  // if destination is variable, we have two variable writes. MUST DRE.
73  BFDREEarly* dre = new BFDREEarly(sched_,src_);
74  if (!runPostChild(dre)) {
75  undo();
76  return false;
77  }
78  }
79  // if destination is not variable, must NOT DRE.
80  } else {
81  BFDREEarly* dre = new BFDREEarly(sched_,src_);
82  runPostChild(dre);
83  }
85 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
86  std::cerr << "\t\tEarly bypass ok for: " << dst_.toString() << std::endl;
87 #endif
88 
89  // now notify antideps sources
90  for (auto i : pred) {
91  mightBeReady(*i);
92  }
93 
94  return true;
95 }
96 
97 void
100 }
BFMergeAndKeepUser.hh
BoostGraph::predecessors
virtual NodeSet predecessors(const Node &node, bool ignoreBackEdges=false, bool ignoreForwardEdges=false) const
MoveNode::isDestinationVariable
bool isDestinationVariable() const
Definition: MoveNode.cc:264
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
MachineConnectivityCheck.hh
BFOptimization::ii
unsigned int ii() const
Definition: BFOptimization.cc:85
BoostGraph< MoveNode, DataDependenceEdge >::NodeSet
std::set< MoveNode *, typename MoveNode ::Comparator > NodeSet
Definition: BoostGraph.hh:86
BF2ScheduleFront::undidBypass
void undidBypass(MoveNode &, MoveNode &dst)
Definition: BF2ScheduleFront.hh:67
BFEarlyBypass::dst_
MoveNode & dst_
Definition: BFEarlyBypass.hh:47
DataDependenceGraph.hh
BFEarlyBypass::operator()
bool operator()() override
Definition: BFEarlyBypass.cc:52
BFOptimization::targetMachine
const TTAMachine::Machine & targetMachine() const
Definition: BFOptimization.cc:81
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
BFEarlyBypass::src_
MoveNode & src_
Definition: BFEarlyBypass.hh:46
assert
#define assert(condition)
Definition: Application.hh:86
BFEarlyBypass.hh
BF2Scheduler.hh
BF2ScheduleFront::bypassed
void bypassed(MoveNode &src, MoveNode &dst)
Definition: BF2ScheduleFront.hh:63
Reversible::undo
virtual void undo()
Definition: Reversible.cc:69
BF2ScheduleFront.hh
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
Machine.hh
BFEarlyBypass::undoOnlyMe
void undoOnlyMe() override
Definition: BFEarlyBypass.cc:98
BFDREEarly
Definition: BFDREEarly.hh:40
BFDREEarly.hh
BF2Scheduler::currentFront
BF2ScheduleFront * currentFront()
Definition: BF2Scheduler.hh:188
Reversible::runPreChild
bool runPreChild(Reversible *preChild)
Definition: Reversible.cc:127
MoveNode::isScheduled
bool isScheduled() const
Definition: MoveNode.cc:409
Reversible::runPostChild
bool runPostChild(Reversible *preChild)
Definition: Reversible.cc:139
BFOptimization::mightBeReady
virtual void mightBeReady(MoveNode &mn)
Definition: BFOptimization.cc:953
BFMergeAndKeepUser
Definition: BFMergeAndKeepUser.hh:41