diff options
author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-08-03 10:43:05 +0000 |
---|---|---|
committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-08-03 10:43:05 +0000 |
commit | f107b7275c7f4dfc6aea1461201ff30f421bd0e9 (patch) | |
tree | 7bb62faa6ca6c6bac0be6f5ebd72b586ad61549d /llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp | |
parent | dcf6706e5279921f0fcdd4e060dcfd51f822a8db (diff) | |
download | bcm5719-llvm-f107b7275c7f4dfc6aea1461201ff30f421bd0e9.tar.gz bcm5719-llvm-f107b7275c7f4dfc6aea1461201ff30f421bd0e9.zip |
[SystemZ] Improve handling of instructions which expand to several groups
Some instructions expand to more than one decoder group.
This has been hitherto ignored, but is handled with this patch.
Review: Ulrich Weigand
https://reviews.llvm.org/D50187
llvm-svn: 338849
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp')
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp b/llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp index b9e5788cf01..2e3e56280f9 100644 --- a/llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp +++ b/llvm/lib/Target/SystemZ/SystemZHazardRecognizer.cpp @@ -49,14 +49,14 @@ getNumDecoderSlots(SUnit *SU) const { if (!SC->isValid()) return 0; // IMPLICIT_DEF / KILL -- will not make impact in output. - if (SC->BeginGroup) { - if (!SC->EndGroup) - return 2; // Cracked instruction - else - return 3; // Expanded/group-alone instruction - } - - return 1; // Normal instruction + assert((SC->NumMicroOps != 2 || (SC->BeginGroup && !SC->EndGroup)) && + "Only cracked instruction can have 2 uops."); + assert((SC->NumMicroOps < 3 || (SC->BeginGroup && SC->EndGroup)) && + "Expanded instructions always group alone."); + assert((SC->NumMicroOps < 3 || (SC->NumMicroOps % 3 == 0)) && + "Expanded instructions fill the group(s)."); + + return SC->NumMicroOps; } unsigned SystemZHazardRecognizer::getCurrCycleIdx(SUnit *SU) const { @@ -139,16 +139,22 @@ void SystemZHazardRecognizer::nextGroup() { LLVM_DEBUG(dumpCurrGroup("Completed decode group")); LLVM_DEBUG(CurGroupDbg = "";); - GrpCount++; + int NumGroups = ((CurrGroupSize > 3) ? (CurrGroupSize / 3) : 1); + assert((CurrGroupSize <= 3 || CurrGroupSize % 3 == 0) && + "Current decoder group bad."); // Reset counter for next group. CurrGroupSize = 0; CurrGroupHas4RegOps = false; + GrpCount += ((unsigned) NumGroups); + // Decrease counters for execution units by one. for (unsigned i = 0; i < SchedModel->getNumProcResourceKinds(); ++i) if (ProcResourceCounters[i] > 0) - ProcResourceCounters[i]--; + ProcResourceCounters[i] = + ((ProcResourceCounters[i] > NumGroups) ? + (ProcResourceCounters[i] - NumGroups) : 0); // Clear CriticalResourceIdx if it is now below the threshold. if (CriticalResourceIdx != UINT_MAX && @@ -323,13 +329,13 @@ EmitInstruction(SUnit *SU) { // in current group. CurrGroupSize += getNumDecoderSlots(SU); CurrGroupHas4RegOps |= has4RegOps(SU->getInstr()); - unsigned GroupLim = - ((CurrGroupHas4RegOps && getNumDecoderSlots(SU) < 3) ? 2 : 3); - assert (CurrGroupSize <= GroupLim && "SU does not fit into decoder group!"); + unsigned GroupLim = (CurrGroupHas4RegOps ? 2 : 3); + assert((CurrGroupSize <= GroupLim || CurrGroupSize == getNumDecoderSlots(SU)) + && "SU does not fit into decoder group!"); // Check if current group is now full/ended. If so, move on to next // group to be ready to evaluate more candidates. - if (CurrGroupSize == GroupLim || SC->EndGroup) + if (CurrGroupSize >= GroupLim || SC->EndGroup) nextGroup(); } |