OpenASIP 2.2
Loading...
Searching...
No Matches
BFPostpassLoopDRE.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 BFPostpassLoopDRE.cc
27 *
28 * Definition of BFPostpassLoopDRE class
29 *
30 * Performs a dead-result elimination of a loop-bypassed move.
31 * The move which is eliminated from the loop body is still left
32 * in the epilog, to have correct value for the register after
33 * the loop.
34 *
35 * This class is called in the postpass-bypass phase.
36 *
37 * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
38 * @note rating: red
39 */
40
41#include "BFPostpassLoopDRE.hh"
42
43#include "BF2Scheduler.hh"
45
46#include "BFPostpassDRE.hh"
47#include "BFUnscheduleMove.hh"
48
49#include "MoveNodeDuplicator.hh"
51
52
53bool
55 if (!sched_.killDeadResults()) {
56 return false;
57 }
58
59 if (!dreAllowed()) {
60 return false;
61 }
62
63 // Create a copy to prolog.
65 if (prologMN_ == NULL) {
66 return false;
67 }
68
70 if (prologRM()->canAssign(prologCycle, *prologMN_)) {
71 prologRM()->assign(prologCycle, *prologMN_);
72
73 // then remove
74 ddg().copyDepsOver(mn_, true, false);
75 ddg().dropNode(mn_);
77 return true;
78#ifdef DEBUG_BUBBLEFISH_SCHEDULER
79 } else {
80 std::cerr << "\t\t\t\tProlog cycle assign fail for loop-dre: "
82 << " prolog cycle: " << prologCycle << std::endl;
83#endif
84 }
85 return false;
86}
87
90 for (auto edge: edges) {
91 if (edge->edgeReason() == DataDependenceEdge::EDGE_OPERATION) {
92#ifdef DEBUG_BUBBLEFISH_SCHEDULER
93 std::cerr << "DRE not allowed due op edge: "
94 << edge->toString() << std::endl;
95#endif
96 return false;
97 }
98 if ((edge->edgeReason() == DataDependenceEdge::EDGE_REGISTER ||
99 edge->edgeReason() ==DataDependenceEdge::EDGE_RA) &&
100 edge->dependenceType() == DataDependenceEdge::DEP_RAW) {
101#ifdef DEBUG_BUBBLEFISH_SCHEDULER
102 std::cerr << "DRE not allowed due edge: "
103 << edge->toString() << std::endl;
104#endif
105 return false;
106 }
107 }
108 return true;
109}
110
void nodeResurrected(MoveNode &mn)
bool killDeadResults() const
void nodeKilled(MoveNode &mn)
static const int PROLOG_CYCLE_BIAS
BF2Scheduler & sched_
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)
SimpleResourceManager * prologRM() const
DataDependenceGraph & ddg()
MoveNodeDuplicator & duplicator() const
bool operator()() override
void undoOnlyMe() override
void restoreNodeFromParent(GraphNode &node)
virtual void dropNode(Node &node)
virtual EdgeSet outEdges(const Node &node) const
EdgeSet copyDepsOver(MoveNode &node, bool anti, bool raw)
std::set< GraphEdge *, typename GraphEdge::Comparator > EdgeSet
Definition Graph.hh:54
MoveNode * getMoveNode(MoveNode &mn)
std::string toString() const
Definition MoveNode.cc:576
virtual void assign(int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) override
virtual void unassign(MoveNode &node) override