OpenASIP 2.2
Loading...
Searching...
No Matches
BFRemoveGuardsFromSuccs.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 BFRemoveGuardsFromSuccs.cc
27 *
28 * Definition of BFRemoveGuardsFromSuccs class
29 *
30 * When scheduling a move wihch writes a guard, check for the uses of the
31 * guard and try to remove those guad uses to allows scheduling this guard write
32 * later. Calls BFRemoveGuardFromSucc.
33 *
34 * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
35 * @note rating: red
36 */
37
41#include "Move.hh"
42#include <list>
44
46
48
49// std::list<BFRemoveGuardFromSucc*> guardRemoves;
50 std::list<MoveNode*> guardRemoveNodes;
51
52 for (auto e: outEdges) {
53 if (e->guardUse() &&
54 e->dependenceType() == DataDependenceEdge::DEP_RAW) {
55 MoveNode& head = ddg().headNode(*e);
56 if (head.move().isUnconditional()) {
57 std::cerr << "guard edge to uncond move?" << head.toString()
58 << std::endl;
59 continue;
60 }
61 if (head.isScheduled()) {
62 // this is not in critical path.
63 int cycle = head.cycle();
64 if (cycle > maxLC_ + head.guardLatency()) {
65 continue;
66 } else {
67 if (canBeSpeculated(head)) {
68 guardRemoveNodes.push_back(&head);
69 } else {
70 maxLC_ = std::min(
71 maxLC_, head.cycle() - head.guardLatency());
72 continue;
73 }
74 }
75 }
76 }
77 }
78
79 for (auto i: guardRemoveNodes) {
80 MoveNode& mn = *i;
81 if (mn.cycle() - mn.guardLatency() < maxLC_) {
83 }
84 }
85 if (postChildren_.empty()) {
86 return false;
87 }
88
89 // if could not improve schedule, return everything back the way it was
90 int ddglc = ddg().latestCycle(guardWrite_, ii(), false, false);
91 int rmlc = rm().latestCycle(ddglc, guardWrite_);
92 if (rmlc <= oldLC_) {
93 undo();
94 return false;
95 }
96
97 return true;
98}
unsigned int ii() const
BF2Scheduler & sched_
DataDependenceGraph & ddg()
SimpleResourceManager & rm() const
bool canBeSpeculated(const Operation &op)
virtual Node & headNode(const Edge &edge) const
virtual EdgeSet outEdges(const Node &node) const
int latestCycle(const MoveNode &moveNode, unsigned int ii=UINT_MAX, bool ignoreRegAntideps=false, bool ignoreUnscheduledSuccessors=true, bool ignoreGuards=false, bool ignoreFUDeps=false, bool ignoreSameOperationEdges=false) const
std::set< GraphEdge *, typename GraphEdge::Comparator > EdgeSet
Definition Graph.hh:54
int cycle() const
Definition MoveNode.cc:421
int guardLatency() const
Definition MoveNode.cc:779
std::string toString() const
Definition MoveNode.cc:576
TTAProgram::Move & move()
bool isScheduled() const
Definition MoveNode.cc:409
bool runPostChild(Reversible *preChild)
std::stack< Reversible * > postChildren_
Definition Reversible.hh:58
virtual void undo()
Definition Reversible.cc:69
virtual int latestCycle(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) const override
bool isUnconditional() const
Definition Move.cc:154