[llvm-branch-commits] [llvm-branch] r86101 - in /llvm/branches/Apple/Leela/lib/CodeGen: AggressiveAntiDepBreaker.cpp AggressiveAntiDepBreaker.h PostRASchedulerList.cpp
Bill Wendling
isanbard at gmail.com
Wed Nov 4 17:27:38 PST 2009
Author: void
Date: Wed Nov 4 19:27:38 2009
New Revision: 86101
URL: http://llvm.org/viewvc/llvm-project?rev=86101&view=rev
Log:
$ svn merge -c 86098 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r86098 into '.':
U lib/CodeGen/AggressiveAntiDepBreaker.cpp
U lib/CodeGen/PostRASchedulerList.cpp
U lib/CodeGen/AggressiveAntiDepBreaker.h
Modified:
llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.cpp
llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.h
llvm/branches/Apple/Leela/lib/CodeGen/PostRASchedulerList.cpp
Modified: llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=86101&r1=86100&r2=86101&view=diff
==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.cpp Wed Nov 4 19:27:38 2009
@@ -491,8 +491,9 @@
}
bool AggressiveAntiDepBreaker::FindSuitableFreeRegisters(
- unsigned AntiDepGroupIndex,
- std::map<unsigned, unsigned> &RenameMap) {
+ unsigned AntiDepGroupIndex,
+ RenameOrderType& RenameOrder,
+ std::map<unsigned, unsigned> &RenameMap) {
unsigned *KillIndices = State->GetKillIndices();
unsigned *DefIndices = State->GetDefIndices();
std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>&
@@ -547,22 +548,41 @@
if (Regs.size() > 1)
return false;
- // Check each possible rename register for SuperReg. If that register
- // is available, and the corresponding registers are available for
- // the other group subregisters, then we can use those registers to
- // rename.
- DEBUG(errs() << "\tFind Register:");
+ // Check each possible rename register for SuperReg in round-robin
+ // order. If that register is available, and the corresponding
+ // registers are available for the other group subregisters, then we
+ // can use those registers to rename.
BitVector SuperBV = RenameRegisterMap[SuperReg];
- for (int r = SuperBV.find_first(); r != -1; r = SuperBV.find_next(r)) {
- const unsigned Reg = (unsigned)r;
+ const TargetRegisterClass *SuperRC =
+ TRI->getPhysicalRegisterRegClass(SuperReg, MVT::Other);
+
+ const TargetRegisterClass::iterator RB = SuperRC->allocation_order_begin(MF);
+ const TargetRegisterClass::iterator RE = SuperRC->allocation_order_end(MF);
+ if (RB == RE) {
+ DEBUG(errs() << "\tEmpty Regclass!!\n");
+ return false;
+ }
+
+ if (RenameOrder.count(SuperRC) == 0)
+ RenameOrder.insert(RenameOrderType::value_type(SuperRC, RE));
+
+ DEBUG(errs() << "\tFind Register:");
+
+ const TargetRegisterClass::iterator OrigR = RenameOrder.at(SuperRC);
+ const TargetRegisterClass::iterator EndR = ((OrigR == RE) ? RB : OrigR);
+ TargetRegisterClass::iterator R = OrigR;
+ do {
+ if (R == RB) R = RE;
+ --R;
+ const unsigned Reg = *R;
// Don't replace a register with itself.
if (Reg == SuperReg) continue;
-
+
DEBUG(errs() << " " << TRI->getName(Reg));
-
+
// If Reg is dead and Reg's most recent def is not before
- // SuperRegs's kill, it's safe to replace SuperReg with
- // Reg. We must also check all subregisters of Reg.
+ // SuperRegs's kill, it's safe to replace SuperReg with Reg. We
+ // must also check all subregisters of Reg.
if (State->IsLive(Reg) || (KillIndices[SuperReg] > DefIndices[Reg])) {
DEBUG(errs() << "(live)");
continue;
@@ -580,13 +600,15 @@
if (found)
continue;
}
-
+
if (Reg != 0) {
DEBUG(errs() << '\n');
+ RenameOrder.erase(SuperRC);
+ RenameOrder.insert(RenameOrderType::value_type(SuperRC, R));
RenameMap.insert(std::pair<unsigned, unsigned>(SuperReg, Reg));
return true;
}
- }
+ } while (R != EndR);
DEBUG(errs() << '\n');
@@ -627,6 +649,9 @@
State = new AggressiveAntiDepState(*SavedState);
}
}
+
+ // For each regclass the next register to use for renaming.
+ RenameOrderType RenameOrder;
// ...need a map from MI to SUnit.
std::map<MachineInstr *, SUnit *> MISUnitMap;
@@ -738,7 +763,7 @@
// Look for a suitable register to use to break the anti-dependence.
std::map<unsigned, unsigned> RenameMap;
- if (FindSuitableFreeRegisters(GroupIndex, RenameMap)) {
+ if (FindSuitableFreeRegisters(GroupIndex, RenameOrder, RenameMap)) {
DEBUG(errs() << "\tBreaking anti-dependence edge on "
<< TRI->getName(AntiDepReg) << ":");
Modified: llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.h?rev=86101&r1=86100&r2=86101&view=diff
==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.h (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/AggressiveAntiDepBreaker.h Wed Nov 4 19:27:38 2009
@@ -155,6 +155,9 @@
void FinishBlock();
private:
+ typedef std::map<const TargetRegisterClass *,
+ TargetRegisterClass::const_iterator> RenameOrderType;
+
/// IsImplicitDefUse - Return true if MO represents a register
/// that is both implicitly used and defined in MI
bool IsImplicitDefUse(MachineInstr *MI, MachineOperand& MO);
@@ -169,6 +172,7 @@
void ScanInstruction(MachineInstr *MI, unsigned Count);
BitVector GetRenameRegisters(unsigned Reg);
bool FindSuitableFreeRegisters(unsigned AntiDepGroupIndex,
+ RenameOrderType& RenameOrder,
std::map<unsigned, unsigned> &RenameMap);
};
}
Modified: llvm/branches/Apple/Leela/lib/CodeGen/PostRASchedulerList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/PostRASchedulerList.cpp?rev=86101&r1=86100&r2=86101&view=diff
==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/PostRASchedulerList.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/PostRASchedulerList.cpp Wed Nov 4 19:27:38 2009
@@ -770,7 +770,8 @@
// just advance the current cycle and try again.
DEBUG(errs() << "*** Stall in cycle " << CurCycle << '\n');
HazardRec->AdvanceCycle();
- ++NumStalls;
+ if (!IgnoreAntiDep)
+ ++NumStalls;
} else {
// Otherwise, we have no instructions to issue and we have instructions
// that will fault if we don't do this right. This is the case for
@@ -778,7 +779,8 @@
DEBUG(errs() << "*** Emitting noop in cycle " << CurCycle << '\n');
HazardRec->EmitNoop();
Sequence.push_back(0); // NULL here means noop
- ++NumNoops;
+ if (!IgnoreAntiDep)
+ ++NumNoops;
}
++CurCycle;
More information about the llvm-branch-commits
mailing list