OpenASIP
2.0
|
#include <RegisterRenamer.hh>
Public Types | |
typedef std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > | RegisterFileSet |
Public Member Functions | |
RegisterRenamer (const TTAMachine::Machine &machine, TTAProgram::BasicBlock &bb) | |
unsigned int | freeGPRCount () const |
void | initialize (DataDependenceGraph &ddg) |
bool | renameDestinationRegister (MoveNode &node, bool loopScheduling, bool allowSameRf, bool differentRfOnlyDirectlyReachable, int earliestCycle=-1) |
bool | renameSourceRegister (MoveNode &node, bool loopScheduling, bool allowSameRf, bool differentRfOnlyDirectlyReachable, int latestCycle=INT_MAX) |
void | setSelector (MoveNodeSelector *selector) |
bool | renameLiveRange (LiveRange &liveRange, const TCEString &newReg, bool usedBefore, bool usedAfter, bool loopScheduling) |
std::set< TCEString > | findPartiallyUsedRegistersAfterCycle (int bitWidth, int latestCycle) const |
std::set< TCEString > | findFreeRegisters (int bitWidth) const |
std::set< TCEString > | findPartiallyUsedRegistersInRFAfterCycle (const RegisterFileSet &rfs, int latestCycle) const |
std::set< TCEString > | findFreeRegistersInRF (const RegisterFileSet &rfs) const |
RegisterFileSet | findConnectedRFs (LiveRange &lr, bool allowLimm) |
TTAProgram::BasicBlock & | bb () |
void | renamedToRegister (const TCEString &newReg) |
void | revertedRenameToRegister (const TCEString ®) |
Private Member Functions | |
std::set< TCEString > | registersOfRFs (const RegisterFileSet &rfs) const |
void | initializeFreeRegisters () |
std::set< TCEString > | findPartiallyUsedRegistersInRFBeforeCycle (const RegisterFileSet &rfs, int earliestCycle, const DataDependenceGraph::NodeSet &guardMoves) const |
std::set< TCEString > | findPartiallyUsedRegistersBeforeCycle (int bitWidth, int earliestCycle, const DataDependenceGraph::NodeSet &guardMoves) const |
std::set< TCEString > | findFreeGuardRegisters (const DataDependenceGraph::NodeSet &guardUseNodes, int bitWidth, const RegisterFileSet &rfs) const |
std::set< TCEString > | findGuardRegisters (const DataDependenceGraph::NodeSet &guardMoves, const RegisterFileSet &rfs) const |
std::set< TCEString > | findGuardRegisters (const TTAMachine::Bus &bus, const RegisterFileSet &rfs) const |
void | updateAntiEdgesFromLRTo (LiveRange &liveRange, const TCEString &newReg, TTAProgram::BasicBlock &bb, int loopDepth) const |
void | initialize () |
Private Attributes | |
std::set< TCEString > | allNormalGPRs_ |
std::set< TCEString > | freeGPRs_ |
std::set< TCEString > | usedGPRs_ |
std::set< TCEString > | onlyBeginPartiallyUsedRegs_ |
std::set< TCEString > | onlyEndPartiallyUsedRegs_ |
std::set< TCEString > | onlyMidPartiallyUsedRegs_ |
std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > | tempRegFiles_ |
const TTAMachine::Machine & | machine_ |
TTAProgram::BasicBlock & | bb_ |
DataDependenceGraph * | ddg_ |
MoveNodeSelector * | selector_ |
Static Private Attributes | |
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. More... | |
Definition at line 59 of file RegisterRenamer.hh.
typedef std::set<const TTAMachine::RegisterFile*, TTAMachine::MachinePart::Comparator> RegisterRenamer::RegisterFileSet |
Definition at line 62 of file RegisterRenamer.hh.
RegisterRenamer::RegisterRenamer | ( | const TTAMachine::Machine & | machine, |
TTAProgram::BasicBlock & | bb | ||
) |
Constructor.
machine | machine for which we are scheudling |
RegisterRenamer::RegisterRenamer(const TTAMachine::Machine& machine) : machine_(machine) { initialize(); } Constructor.
machine | machine for which we are scheudling |
Definition at line 74 of file RegisterRenamer.cc.
References initialize().
|
inline |
Definition at line 102 of file RegisterRenamer.hh.
References bb_.
Referenced by BFRenameLiveRange::operator()(), and updateAntiEdgesFromLRTo().
RegisterRenamer::RegisterFileSet RegisterRenamer::findConnectedRFs | ( | LiveRange & | lr, |
bool | allowLimm | ||
) |
Definition at line 1206 of file RegisterRenamer.cc.
References assert, MachineConnectivityCheck::canAnyPortWriteToDestination(), MachineConnectivityCheck::canSourceWriteToAnyDestinationPort(), TTAMachine::Machine::Navigator< ComponentType >::count(), MachineConnectivityCheck::findReadPorts(), MachineConnectivityCheck::findWritePorts(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, LiveRange::reads, TTAMachine::Machine::registerFileNavigator(), TTAMachine::BaseRegisterFile::width(), and LiveRange::writes.
Referenced by BFRenameLiveRange::operator()(), renameDestinationRegister(), and renameSourceRegister().
|
private |
Definition at line 437 of file RegisterRenamer.cc.
References findFreeRegisters(), findFreeRegistersInRF(), findGuardRegisters(), and SetTools::intersection().
Referenced by renameDestinationRegister().
std::set< TCEString > RegisterRenamer::findFreeRegisters | ( | int | bitWidth | ) | const |
Definition at line 418 of file RegisterRenamer.cc.
References freeGPRs_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Machine::registerFileNavigator(), and TTAMachine::BaseRegisterFile::width().
Referenced by findFreeGuardRegisters(), renameDestinationRegister(), and renameSourceRegister().
std::set< TCEString > RegisterRenamer::findFreeRegistersInRF | ( | const RegisterFileSet & | rfs | ) | const |
Definition at line 223 of file RegisterRenamer.cc.
References freeGPRs_, SetTools::intersection(), and registersOfRFs().
Referenced by findFreeGuardRegisters(), BFRenameLiveRange::operator()(), renameDestinationRegister(), and renameSourceRegister().
|
private |
Definition at line 1270 of file RegisterRenamer.cc.
References assert, TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), TTAProgram::Move::isUnconditional(), MoveNode::move(), and TTAMachine::Guard::parentBus().
Referenced by findFreeGuardRegisters(), findPartiallyUsedRegistersBeforeCycle(), and findPartiallyUsedRegistersInRFBeforeCycle().
|
private |
Finds registers which can guard moves from the given bus.
Definition at line 1302 of file RegisterRenamer.cc.
References TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), TTAMachine::Guard::isInverted(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), and DisassemblyRegister::registerName().
std::set< TCEString > RegisterRenamer::findPartiallyUsedRegistersAfterCycle | ( | int | bitWidth, |
int | latestCycle | ||
) | const |
Definition at line 394 of file RegisterRenamer.cc.
References AssocTools::append(), ddg_, DataDependenceGraph::firstRegisterCycle(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, onlyEndPartiallyUsedRegs_, onlyMidPartiallyUsedRegs_, TTAMachine::Machine::registerFileNavigator(), usedGPRs_, and TTAMachine::BaseRegisterFile::width().
Referenced by renameSourceRegister().
|
private |
Definition at line 341 of file RegisterRenamer.cc.
References AssocTools::append(), ddg_, findGuardRegisters(), SetTools::intersection(), TTAMachine::Machine::Navigator< ComponentType >::item(), DataDependenceGraph::lastRegisterCycle(), machine_, onlyBeginPartiallyUsedRegs_, onlyMidPartiallyUsedRegs_, TTAMachine::Machine::registerFileNavigator(), usedGPRs_, and TTAMachine::BaseRegisterFile::width().
Referenced by renameDestinationRegister().
std::set< TCEString > RegisterRenamer::findPartiallyUsedRegistersInRFAfterCycle | ( | const RegisterFileSet & | rfs, |
int | latestCycle | ||
) | const |
Finds registers which are used but only after given earliestCycle.
Definition at line 310 of file RegisterRenamer.cc.
References AssocTools::append(), ddg_, DataDependenceGraph::firstRegisterCycle(), SetTools::intersection(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, onlyEndPartiallyUsedRegs_, onlyMidPartiallyUsedRegs_, TTAMachine::Machine::registerFileNavigator(), registersOfRFs(), and usedGPRs_.
Referenced by BFRenameLiveRange::operator()(), and renameSourceRegister().
|
private |
Finds registers which are used but only before given earliestCycle.
Definition at line 260 of file RegisterRenamer.cc.
References AssocTools::append(), ddg_, findGuardRegisters(), SetTools::intersection(), TTAMachine::Machine::Navigator< ComponentType >::item(), DataDependenceGraph::lastRegisterCycle(), machine_, onlyBeginPartiallyUsedRegs_, onlyMidPartiallyUsedRegs_, TTAMachine::Machine::registerFileNavigator(), registersOfRFs(), and usedGPRs_.
Referenced by renameDestinationRegister().
|
inline |
|
private |
Definition at line 87 of file RegisterRenamer.cc.
References allNormalGPRs_, AssocTools::containsKey(), machine_, TTAMachine::Machine::registerFileNavigator(), DisassemblyRegister::registerName(), TTAMachine::BaseRegisterFile::size(), tempRegFileCache_, tempRegFiles_, and MachineConnectivityCheck::tempRegisterFiles().
Referenced by RegisterRenamer().
void RegisterRenamer::initialize | ( | DataDependenceGraph & | ddg | ) |
Definition at line 81 of file RegisterRenamer.cc.
References ddg_, and initializeFreeRegisters().
Referenced by BUBasicBlockScheduler::handleDDG(), BasicBlockScheduler::handleDDG(), BUBasicBlockScheduler::handleLoopDDG(), BasicBlockScheduler::handleLoopDDG(), and BF2Scheduler::scheduleDDG().
|
private |
Definition at line 114 of file RegisterRenamer.cc.
References allNormalGPRs_, assert, bb_, ddg_, TTAProgram::Move::destination(), freeGPRs_, TTAProgram::Terminal::index(), TTAProgram::Terminal::isGPR(), TTAProgram::BasicBlock::liveRangeData_, MoveNode::move(), BoostGraph< GraphNode, GraphEdge >::node(), BoostGraph< GraphNode, GraphEdge >::nodeCount(), onlyBeginPartiallyUsedRegs_, onlyEndPartiallyUsedRegs_, onlyMidPartiallyUsedRegs_, LiveRangeData::regDefines_, LiveRangeData::regDefReaches_, LiveRangeData::regFirstUses_, TTAProgram::Terminal::registerFile(), DisassemblyRegister::registerName(), LiveRangeData::registersUsedAfter_, LiveRangeData::regLastUses_, and TTAProgram::Move::source().
Referenced by initialize().
|
private |
Definition at line 233 of file RegisterRenamer.cc.
References AssocTools::containsKey(), DisassemblyRegister::registerName(), TTAMachine::BaseRegisterFile::size(), tempRegFiles_, and TTAMachine::RegisterFile::zeroRegister().
Referenced by findFreeRegistersInRF(), findPartiallyUsedRegistersInRFAfterCycle(), and findPartiallyUsedRegistersInRFBeforeCycle().
bool RegisterRenamer::renameDestinationRegister | ( | MoveNode & | node, |
bool | loopScheduling, | ||
bool | allowSameRf, | ||
bool | differentRfOnlyDirectlyReachable, | ||
int | earliestCycle = -1 |
||
) |
Renames destination register of a move (from the move itself and from all other moves in same liverange)
Definition at line 458 of file RegisterRenamer.cc.
References ddg_, TTAProgram::Move::destination(), findConnectedRFs(), findFreeGuardRegisters(), findFreeRegisters(), findFreeRegistersInRF(), DataDependenceGraph::findLiveRange(), findPartiallyUsedRegistersBeforeCycle(), findPartiallyUsedRegistersInRFBeforeCycle(), LiveRange::firstCycle(), LiveRange::guards, TTAProgram::Terminal::isGPR(), MoveNode::isMove(), MoveNode::move(), LiveRange::noneScheduled(), TTAProgram::Terminal::registerFile(), renameLiveRange(), tempRegFiles_, TTAMachine::BaseRegisterFile::width(), and LiveRange::writes.
Referenced by BasicBlockScheduler::scheduleMove(), and BUBasicBlockScheduler::scheduleMove().
void RegisterRenamer::renamedToRegister | ( | const TCEString & | newReg | ) |
Definition at line 1094 of file RegisterRenamer.cc.
References freeGPRs_, onlyBeginPartiallyUsedRegs_, onlyEndPartiallyUsedRegs_, onlyMidPartiallyUsedRegs_, and usedGPRs_.
Referenced by BFRenameLiveRange::renameLiveRange(), and renameLiveRange().
bool RegisterRenamer::renameLiveRange | ( | LiveRange & | liveRange, |
const TCEString & | newReg, | ||
bool | usedBefore, | ||
bool | usedAfter, | ||
bool | loopScheduling | ||
) |
Definition at line 714 of file RegisterRenamer.cc.
References assert, bb_, TTAProgram::Move::bus(), BoostGraph< GraphNode, GraphEdge >::connectNodes(), ddg_, DataDependenceEdge::DEP_WAR, DataDependenceEdge::DEP_WAW, TTAProgram::Move::destination(), DataDependenceGraph::destRenamed(), DataDependenceEdge::EDGE_REGISTER, TTAMachine::RegisterFile::firstReadPort(), DataDependenceGraph::firstScheduledRegisterWrites(), TTAMachine::RegisterFile::firstWritePort(), TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), DataDependenceGraph::guardRenamed(), LiveRange::guards, BoostGraph< GraphNode, GraphEdge >::hasPath(), TTAMachine::Guard::isInverted(), TTAMachine::Machine::Navigator< ComponentType >::item(), DataDependenceGraph::lastScheduledRegisterGuardReads(), DataDependenceGraph::lastScheduledRegisterReads(), DataDependenceGraph::lastScheduledRegisterWrites(), TTAProgram::BasicBlock::liveRangeData_, machine_, MoveNodeSelector::mightBeReady(), MoveNode::move(), TTAMachine::Component::name(), TTAMachine::Guard::parentBus(), TTAMachine::Port::parentUnit(), TTAProgram::Terminal::port(), BoostGraph< GraphNode, GraphEdge >::predecessors(), LiveRange::reads, LiveRangeData::regDefines_, LiveRangeData::regFirstDefines_, LiveRangeData::regFirstUses_, TTAMachine::RegisterGuard::registerFile(), TTAMachine::Machine::registerFileNavigator(), TTAMachine::RegisterGuard::registerIndex(), LiveRangeData::regKills_, LiveRangeData::regLastKills_, LiveRangeData::regLastUses_, renamedToRegister(), BoostGraph< GraphNode, GraphEdge >::rootGraph(), selector_, TTAProgram::Move::setDestination(), TTAProgram::Move::setGuard(), TTAProgram::Move::setSource(), TTAProgram::Move::source(), DataDependenceGraph::sourceRenamed(), BoostGraph< GraphNode, GraphEdge >::successors(), MoveNode::toString(), updateAntiEdgesFromLRTo(), and LiveRange::writes.
Referenced by renameDestinationRegister(), and renameSourceRegister().
bool RegisterRenamer::renameSourceRegister | ( | MoveNode & | node, |
bool | loopScheduling, | ||
bool | allowSameRf, | ||
bool | differentRfOnlyDirectlyReachable, | ||
int | latestCycle = INT_MAX |
||
) |
Renames source register of a move (from the move itself and from all other moves in same liverange)
Definition at line 617 of file RegisterRenamer.cc.
References ddg_, findConnectedRFs(), findFreeRegisters(), findFreeRegistersInRF(), DataDependenceGraph::findLiveRange(), findPartiallyUsedRegistersAfterCycle(), findPartiallyUsedRegistersInRFAfterCycle(), TTAProgram::Terminal::isGPR(), MoveNode::isMove(), LiveRange::lastCycle(), MoveNode::move(), LiveRange::noneScheduled(), TTAProgram::Terminal::registerFile(), renameLiveRange(), TTAProgram::Move::source(), tempRegFiles_, TTAMachine::BaseRegisterFile::width(), and LiveRange::writes.
Referenced by BasicBlockScheduler::scheduleMove(), and BUBasicBlockScheduler::scheduleMove().
void RegisterRenamer::revertedRenameToRegister | ( | const TCEString & | reg | ) |
Definition at line 1106 of file RegisterRenamer.cc.
References bb_, freeGPRs_, TTAProgram::BasicBlock::liveRangeData_, LiveRangeData::regDefines_, LiveRangeData::regFirstDefines_, LiveRangeData::regFirstUses_, and LiveRangeData::regLastUses_.
Referenced by BFRenameLiveRange::undoOnlyMe().
void RegisterRenamer::setSelector | ( | MoveNodeSelector * | selector | ) |
Registers the selector being used to the bypasser.
If the bypasser has been registered to the selector, bypasses can notify the selector about dependence changes. Currently it notifies the successors of a node being removed due dead result elimination.
selector | selector which bypasser notifies on some dependence changes. |
Definition at line 1126 of file RegisterRenamer.cc.
References selector_.
Referenced by BUBasicBlockScheduler::handleDDG(), BasicBlockScheduler::handleDDG(), BUBasicBlockScheduler::handleLoopDDG(), BasicBlockScheduler::handleLoopDDG(), BF2Scheduler::handleLoopDDG(), and BF2Scheduler::scheduleDDG().
|
private |
Updates antidep edges from this liverange to first def of some other bb.
liveRange | liverange which is the origin of the deps |
newReg | name of the new register |
bb | destination BB where to draw the edges to @loopDepth loop depth of added edges. |
Definition at line 1139 of file RegisterRenamer.cc.
References bb(), DataDependenceGraph::connectOrDeleteEdge(), ddg_, DataDependenceEdge::DEP_WAR, DataDependenceEdge::DEP_WAW, DataDependenceEdge::EDGE_REGISTER, LiveRange::guards, BoostGraph< GraphNode, GraphEdge >::hasNode(), TTAProgram::BasicBlock::liveRangeData_, MoveNodeUse::mn(), MoveNodeUse::pseudo(), LiveRange::reads, LiveRangeData::regFirstDefines_, and LiveRange::writes.
Referenced by renameLiveRange().
|
private |
Definition at line 140 of file RegisterRenamer.hh.
Referenced by initialize(), and initializeFreeRegisters().
|
private |
Definition at line 162 of file RegisterRenamer.hh.
Referenced by bb(), initializeFreeRegisters(), renameLiveRange(), and revertedRenameToRegister().
|
private |
Definition at line 163 of file RegisterRenamer.hh.
Referenced by findPartiallyUsedRegistersAfterCycle(), findPartiallyUsedRegistersBeforeCycle(), findPartiallyUsedRegistersInRFAfterCycle(), findPartiallyUsedRegistersInRFBeforeCycle(), initialize(), initializeFreeRegisters(), renameDestinationRegister(), renameLiveRange(), renameSourceRegister(), and updateAntiEdgesFromLRTo().
|
private |
Definition at line 141 of file RegisterRenamer.hh.
Referenced by findFreeRegisters(), findFreeRegistersInRF(), freeGPRCount(), initializeFreeRegisters(), renamedToRegister(), and revertedRenameToRegister().
|
private |
Definition at line 161 of file RegisterRenamer.hh.
Referenced by findConnectedRFs(), findFreeRegisters(), findPartiallyUsedRegistersAfterCycle(), findPartiallyUsedRegistersBeforeCycle(), findPartiallyUsedRegistersInRFAfterCycle(), findPartiallyUsedRegistersInRFBeforeCycle(), initialize(), and renameLiveRange().
|
private |
Definition at line 149 of file RegisterRenamer.hh.
Referenced by findPartiallyUsedRegistersBeforeCycle(), findPartiallyUsedRegistersInRFBeforeCycle(), initializeFreeRegisters(), and renamedToRegister().
|
private |
Definition at line 151 of file RegisterRenamer.hh.
Referenced by findPartiallyUsedRegistersAfterCycle(), findPartiallyUsedRegistersInRFAfterCycle(), initializeFreeRegisters(), and renamedToRegister().
|
private |
Definition at line 152 of file RegisterRenamer.hh.
Referenced by findPartiallyUsedRegistersAfterCycle(), findPartiallyUsedRegistersBeforeCycle(), findPartiallyUsedRegistersInRFAfterCycle(), findPartiallyUsedRegistersInRFBeforeCycle(), initializeFreeRegisters(), and renamedToRegister().
|
private |
Definition at line 165 of file RegisterRenamer.hh.
Referenced by renameLiveRange(), and setSelector().
|
staticprivate |
To avoid reanalysing machine every time hen new rr created.
Definition at line 157 of file RegisterRenamer.hh.
Referenced by initialize().
|
private |
Definition at line 159 of file RegisterRenamer.hh.
Referenced by initialize(), registersOfRFs(), renameDestinationRegister(), and renameSourceRegister().
|
private |
Definition at line 145 of file RegisterRenamer.hh.
Referenced by findPartiallyUsedRegistersAfterCycle(), findPartiallyUsedRegistersBeforeCycle(), findPartiallyUsedRegistersInRFAfterCycle(), findPartiallyUsedRegistersInRFBeforeCycle(), and renamedToRegister().