OpenASIP 2.2
Loading...
Searching...
No Matches
BFPushAntidepDown.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 BFPushAntidepDown.cc
27 *
28 * Definition of BFPushAntidepDown class.
29 *
30 * Tries to reschedule a move into later cycle to allow move which has an
31 * antidep to it to be scheduler later.
32 *
33 * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
34 * @note rating: red
35 */
36
37#include "BFPushAntidepDown.hh"
38
41#include "MoveNode.hh"
42#include "Move.hh"
43#include "Bus.hh"
44
45#include "BF2Scheduler.hh"
46#include "MoveNodeDuplicator.hh"
47#include "UniversalMachine.hh"
48
49//#define DEBUG_BUBBLEFISH_SCHEDULER
50
51bool
53 if (mn_.move().isControlFlowMove()) {
54#ifdef DEBUG_BUBBLEFISH_SCHEDULER
55 std::cerr << "\t\t\tCannot reschedule control flow move!" << std::endl;
56#endif
57 return false;
58 }
59
60 if (&mn_ == sched_.guardWriteNode()) {
61#ifdef DEBUG_BUBBLEFISH_SCHEDULER
62 std::cerr << "\t\t|TCannot reschedule guard write move!" << std::endl;
63#endif
64 return false;
65 }
66
68
69 int ddgLC = ddg().latestCycle(mn_);
70 int ddgEC = ddg().earliestCycle(mn_);
71
72 // first try to schedule top-down close to the optimal as possible
73 int prefEc = newLC_ - lat_ +1;
74 if (ddgEC > prefEc) {
75 prefEc = ddgEC;
76 }
77
78 int ec = rmEC(prefEc, mn_);
79 if (ec <= std::min(ddgLC,sched_.maximumAllowedCycle()) && ec != -1) {
80#ifdef DEBUG_BUBBLEFISH_SCHEDULER
81 std::cerr << "\t\t\t\t\ttopdown resched: " << ec << std::endl;
82#endif
83 assign(ec, mn_);
84 return true;
85 } else {
86 // topdown failed, bottom-up then be it
87 int lc = rmLC(
88 (std::min(ddgLC, sched_.maximumAllowedCycle())),mn_);
89#ifdef DEBUG_BUBBLEFISH_SCHEDULER
90 std::cerr << "\t\t\t\tbottomup resched ddglc: " << ddgLC << " latest_: "
91 << sched_.maximumAllowedCycle() << " lc: " << lc << std::endl;
92#endif
93 if (lc < ddgEC || lc == oldCycle_) {
94#ifdef DEBUG_BUBBLEFISH_SCHEDULER
95 std::cerr << "\t\tPushing down antidep dest: " << mn_.toString()
96 << " failed lc: "<< lc << " ddgEC: " << ddgEC << std::endl;
97 std::cerr << "\t\tPushAntidepsDown seting to old bus: "
98 << mn_.toString() << " to bus "
99 << oldBus_->name() << std::endl;
100#endif
101#ifdef DEBUG_BUBBLEFISH_SCHEDULER
103#endif
104 assign(oldCycle_, mn_, oldBus_, NULL, NULL, prologBus_,
106 return false;
107 }
108 assert(lc != -1);
109 assign(lc, mn_);
110#ifdef DEBUG_BUBBLEFISH_SCHEDULER
111 std::cerr << "\t\tPushed antidep down: " << mn_.toString() << " bus: "
112 << mn_.move().bus().name() << std::endl;
113#endif
114 return true;
115 }
116 return false;
117}
#define assert(condition)
int maximumAllowedCycle() const
MoveNode * guardWriteNode()
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)
DataDependenceGraph & ddg()
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 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 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)
const TTAMachine::Bus * prologBus_
const TTAMachine::Bus * oldBus_
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
int earliestCycle(const MoveNode &moveNode, unsigned int ii=UINT_MAX, bool ignoreRegWaRs=false, bool ignoreRegWaWs=false, bool ignoreGuards=false, bool ignoreFUDeps=false, bool ignoreSameOperationEdges=false, bool assumeBypassing=false) const
std::string toString() const
Definition MoveNode.cc:576
TTAProgram::Move & move()
virtual TCEString name() const
bool isControlFlowMove() const
Definition Move.cc:233
const TTAMachine::Bus & bus() const
Definition Move.cc:373