OpenASIP  2.0
BFRenameSource.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 BFRenameSource.cc
27  *
28  * Definition of BFRenameSource class
29  *
30  * Renames a liverange, starting from a register read.
31  * Class BFRenameLiverange to perform the actual work.
32  *
33  * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
34  * @note rating: red
35  */
36 
37 #include "BFRenameSource.hh"
38 #include "BFRenameLiveRange.hh"
39 #include "LiveRange.hh"
40 #include "Move.hh"
41 #include "Terminal.hh"
42 #include "BF2Scheduler.hh"
43 
45  int originalDDGLC, int targetCycle) :
46  BFOptimization(sched), mn_(mn),
47  originalDDGLC_(originalDDGLC),
48  targetCycle_(targetCycle) {}
49 
50 
52 
53  if (sched_.renamer() == nullptr) {
54  return false;
55  }
56 
57  // not yet working with loop scheduling
58  if (ii()) {
59  return false;
60  }
61 
62  TTAProgram::Move& m = mn_.move();
64  if (!t.isGPR()) {
65  return false;
66  }
67 
68  std::shared_ptr<LiveRange> liveRange(ddg().findLiveRange(mn_, false, false));
69  if (liveRange->writes.size() != 1 ||
70  liveRange->reads.empty() ||
71  !liveRange->guards.empty()) {
72  return false;
73  }
74 
75  for (auto i: liveRange->writes) {
76  if (i->isScheduled()) {
77  return false;
78  }
79  }
80 
81  // for reads.
82  for (auto i: liveRange->reads) {
83  if (i->isScheduled()) {
84  return false;
85  }
86  }
87 
88  // for reads.
89  for (auto i: liveRange->guards) {
90  if (i->isScheduled()) {
91  return false;
92  }
93  }
94 
95  return runPreChild(new BFRenameLiveRange(sched_, liveRange, targetCycle_));
96 }
BF2Scheduler::renamer
RegisterRenamer * renamer()
Definition: BF2Scheduler.hh:221
BFOptimization::ii
unsigned int ii() const
Definition: BFOptimization.cc:85
BFRenameSource::BFRenameSource
BFRenameSource(BF2Scheduler &sched, MoveNode &mn, int originalDDGLC, int targetCycle)
Definition: BFRenameSource.cc:44
MoveNode
Definition: MoveNode.hh:65
BFOptimization
Definition: BFOptimization.hh:73
Terminal.hh
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
BFRenameSource::targetCycle_
int targetCycle_
Definition: BFRenameSource.hh:54
BF2Scheduler.hh
BF2Scheduler
Definition: BF2Scheduler.hh:74
TTAProgram::Terminal::isGPR
virtual bool isGPR() const
Definition: Terminal.cc:107
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
LiveRange::writes
DataDependenceGraph::NodeSet writes
Definition: LiveRange.hh:39
TTAProgram::Move
Definition: Move.hh:55
BFRenameLiveRange
Definition: BFRenameLiveRange.hh:45
LiveRange::reads
DataDependenceGraph::NodeSet reads
Definition: LiveRange.hh:40
LiveRange::guards
DataDependenceGraph::NodeSet guards
Definition: LiveRange.hh:41
MoveNode::move
TTAProgram::Move & move()
BFRenameLiveRange.hh
BFRenameSource::mn_
MoveNode & mn_
Definition: BFRenameSource.hh:52
Reversible::runPreChild
bool runPreChild(Reversible *preChild)
Definition: Reversible.cc:127
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
Move.hh
LiveRange.hh
BFRenameSource.hh
BFRenameSource::operator()
virtual bool operator()()
Definition: BFRenameSource.cc:51