OpenASIP 2.2
Loading...
Searching...
No Matches
RegisterRenamer.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 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 * @file RegisterRenamer.hh
26 *
27 * Declaration of RegisterRenamer class.
28 *
29 * @author Heikki Kultala 2009-2011 (hkultala-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_REGISTER_RENAMER_HH
34#define TTA_REGISTER_RENAMER_HH
35
36#include <climits>
37
38#include "TCEString.hh"
39#include <set>
40#include "MachinePart.hh"
42
43namespace TTAMachine {
44 class Machine;
45 class RegisterFile;
46 class Bus;
47}
48
49namespace TTAProgram {
50 class TerminalRegister;
51 class BasicBlock;
52}
53
54struct LiveRange;
56class MoveNode;
58
60public:
61 typedef std::set<const TTAMachine::RegisterFile*,
63
66 unsigned int freeGPRCount() const { return freeGPRs_.size(); }
67
69
71 MoveNode& node, bool loopScheduling,
72 bool allowSameRf, bool differentRfOnlyDirectlyReachable,
73 int earliestCycle=-1);
74
76 MoveNode& node, bool loopScheduling,
77 bool allowSameRf, bool differentRfOnlyDirectlyReachable,
78 int latestCycle = INT_MAX);
79
80 void setSelector(MoveNodeSelector* selector);
81
82 // typedef std::pair<DataDependenceGraph::NodeSet,
83 //DataDependenceGraph::NodeSet> LiveRange;
84
85 bool renameLiveRange(
86 LiveRange& liveRange, const TCEString& newReg, bool usedBefore,
87 bool usedAfter, bool loopScheduling);
88
89 std::set<TCEString> findPartiallyUsedRegistersAfterCycle(
90 int bitWidth, int latestCycle) const;
91
92 std::set<TCEString> findFreeRegisters(int bitWidth) const;
93
95 const RegisterFileSet& rfs, int latestCycle) const;
96
97 std::set<TCEString> findFreeRegistersInRF(
98 const RegisterFileSet& rfs) const;
99
100 RegisterFileSet findConnectedRFs(LiveRange& lr, bool allowLimm);
101
103
104 void renamedToRegister(const TCEString& newReg);
105 void revertedRenameToRegister(const TCEString& reg);
106private:
107
108
109 std::set<TCEString> registersOfRFs(const RegisterFileSet& rfs) const;
110
112
114 const RegisterFileSet& rfs, int earliestCycle,
115 const DataDependenceGraph::NodeSet& guardMoves) const;
116
117 std::set<TCEString> findPartiallyUsedRegistersBeforeCycle(
118 int bitWidth, int earliestCycle,
119 const DataDependenceGraph::NodeSet& guardMoves) const;
120
121 std::set<TCEString> findFreeGuardRegisters(
122 const DataDependenceGraph::NodeSet& guardUseNodes,
123 int bitWidth, const RegisterFileSet& rfs) const;
124
125 std::set<TCEString> findGuardRegisters(
126 const DataDependenceGraph::NodeSet& guardMoves,
127 const RegisterFileSet& rfs) const;
128
129 std::set<TCEString> findGuardRegisters(
130 const TTAMachine::Bus& bus,
131 const RegisterFileSet& rfs) const;
132
134 LiveRange& liveRange,
135 const TCEString& newReg,
137 int loopDepth) const;
138
139 void initialize();
140 std::set<TCEString> allNormalGPRs_;
141 std::set<TCEString> freeGPRs_;
142
143 // already usd by the reg renamer, but can be reused of liveranges
144 // cannot overlap?
145 std::set<TCEString> usedGPRs_;
146
147 // used partially by original code;
148 // used at beginning of bb, free at end.
149 std::set<TCEString> onlyBeginPartiallyUsedRegs_;
150 // used at end of bb, free at begin.
151 std::set<TCEString> onlyEndPartiallyUsedRegs_;
152 std::set<TCEString> onlyMidPartiallyUsedRegs_;
153
154 static std::map<const TTAMachine::Machine*,
155 std::set <const TTAMachine::RegisterFile*,
158 std::set <const TTAMachine::RegisterFile*,
160
164
166};
167
168#endif
TTAMachine::Machine * machine
the architecture definition of the estimated processor
std::set< GraphNode *, typename GraphNode::Comparator > NodeSet
Definition Graph.hh:53
std::set< TCEString > findPartiallyUsedRegistersInRFBeforeCycle(const RegisterFileSet &rfs, int earliestCycle, const DataDependenceGraph::NodeSet &guardMoves) const
void revertedRenameToRegister(const TCEString &reg)
MoveNodeSelector * selector_
std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > tempRegFiles_
std::set< TCEString > findPartiallyUsedRegistersBeforeCycle(int bitWidth, int earliestCycle, const DataDependenceGraph::NodeSet &guardMoves) const
DataDependenceGraph * ddg_
std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > RegisterFileSet
TTAProgram::BasicBlock & bb()
std::set< TCEString > allNormalGPRs_
static std::map< const TTAMachine::Machine *, std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > > tempRegFileCache_
To avoid reanalysing machine every time hen new rr created.
std::set< TCEString > freeGPRs_
bool renameLiveRange(LiveRange &liveRange, const TCEString &newReg, bool usedBefore, bool usedAfter, bool loopScheduling)
bool renameDestinationRegister(MoveNode &node, bool loopScheduling, bool allowSameRf, bool differentRfOnlyDirectlyReachable, int earliestCycle=-1)
std::set< TCEString > findFreeGuardRegisters(const DataDependenceGraph::NodeSet &guardUseNodes, int bitWidth, const RegisterFileSet &rfs) const
void setSelector(MoveNodeSelector *selector)
std::set< TCEString > onlyEndPartiallyUsedRegs_
bool renameSourceRegister(MoveNode &node, bool loopScheduling, bool allowSameRf, bool differentRfOnlyDirectlyReachable, int latestCycle=INT_MAX)
std::set< TCEString > registersOfRFs(const RegisterFileSet &rfs) const
std::set< TCEString > findFreeRegistersInRF(const RegisterFileSet &rfs) const
std::set< TCEString > onlyBeginPartiallyUsedRegs_
unsigned int freeGPRCount() const
std::set< TCEString > findGuardRegisters(const DataDependenceGraph::NodeSet &guardMoves, const RegisterFileSet &rfs) const
std::set< TCEString > findPartiallyUsedRegistersAfterCycle(int bitWidth, int latestCycle) const
std::set< TCEString > findFreeRegisters(int bitWidth) const
const TTAMachine::Machine & machine_
std::set< TCEString > findPartiallyUsedRegistersInRFAfterCycle(const RegisterFileSet &rfs, int latestCycle) const
TTAProgram::BasicBlock & bb_
void renamedToRegister(const TCEString &newReg)
std::set< TCEString > onlyMidPartiallyUsedRegs_
RegisterFileSet findConnectedRFs(LiveRange &lr, bool allowLimm)
std::set< TCEString > usedGPRs_
void updateAntiEdgesFromLRTo(LiveRange &liveRange, const TCEString &newReg, TTAProgram::BasicBlock &bb, int loopDepth) const