diff options
| author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-04-12 07:21:39 +0000 |
|---|---|---|
| committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-04-12 07:21:39 +0000 |
| commit | e8f1ac7063c9d3fb09d7df081356508bcece3ec8 (patch) | |
| tree | 3dd131df120cf29290db575d282e43870458b29a /llvm/lib/Target | |
| parent | 46300d1ff66d2d3ea4deb48cb5f304b16382867f (diff) | |
| download | bcm5719-llvm-e8f1ac7063c9d3fb09d7df081356508bcece3ec8.tar.gz bcm5719-llvm-e8f1ac7063c9d3fb09d7df081356508bcece3ec8.zip | |
[MachineScheduler] NFC refactoring
This patch makes tryCandidate() virtual and some utility functions like
tryLess(), tryGreater(), ... externally available (used to be static).
This makes it possible for a target to derive a new MachineSchedStrategy from
GenericScheduler and reuse most parts.
It was necessary to wrap functions with the same names in
AMDGPU/SIMachineScheduler in a local namespace.
Review: Andy Trick, Florian Hahn
https://reviews.llvm.org/D43329
llvm-svn: 329884
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp index 6b67b76652e..528ce52b453 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp @@ -154,6 +154,8 @@ static const char *getReasonStr(SIScheduleCandReason Reason) { #endif +namespace llvm { +namespace SISched { static bool tryLess(int TryVal, int CandVal, SISchedulerCandidate &TryCand, SISchedulerCandidate &Cand, @@ -187,6 +189,8 @@ static bool tryGreater(int TryVal, int CandVal, Cand.setRepeat(Reason); return false; } +} // end namespace SISched +} // end namespace llvm // SIScheduleBlock // @@ -212,7 +216,8 @@ void SIScheduleBlock::tryCandidateTopDown(SISchedCandidate &Cand, } if (Cand.SGPRUsage > 60 && - tryLess(TryCand.SGPRUsage, Cand.SGPRUsage, TryCand, Cand, RegUsage)) + SISched::tryLess(TryCand.SGPRUsage, Cand.SGPRUsage, + TryCand, Cand, RegUsage)) return; // Schedule low latency instructions as top as possible. @@ -230,21 +235,22 @@ void SIScheduleBlock::tryCandidateTopDown(SISchedCandidate &Cand, // could go quite high, thus above the arbitrary limit of 60 will encourage // use the already loaded constants (in order to release some SGPRs) before // loading more. - if (tryLess(TryCand.HasLowLatencyNonWaitedParent, - Cand.HasLowLatencyNonWaitedParent, - TryCand, Cand, SIScheduleCandReason::Depth)) + if (SISched::tryLess(TryCand.HasLowLatencyNonWaitedParent, + Cand.HasLowLatencyNonWaitedParent, + TryCand, Cand, SIScheduleCandReason::Depth)) return; - if (tryGreater(TryCand.IsLowLatency, Cand.IsLowLatency, - TryCand, Cand, SIScheduleCandReason::Depth)) + if (SISched::tryGreater(TryCand.IsLowLatency, Cand.IsLowLatency, + TryCand, Cand, SIScheduleCandReason::Depth)) return; if (TryCand.IsLowLatency && - tryLess(TryCand.LowLatencyOffset, Cand.LowLatencyOffset, - TryCand, Cand, SIScheduleCandReason::Depth)) + SISched::tryLess(TryCand.LowLatencyOffset, Cand.LowLatencyOffset, + TryCand, Cand, SIScheduleCandReason::Depth)) return; - if (tryLess(TryCand.VGPRUsage, Cand.VGPRUsage, TryCand, Cand, RegUsage)) + if (SISched::tryLess(TryCand.VGPRUsage, Cand.VGPRUsage, + TryCand, Cand, RegUsage)) return; // Fall through to original instruction order. @@ -1576,19 +1582,19 @@ bool SIScheduleBlockScheduler::tryCandidateLatency(SIBlockSchedCandidate &Cand, } // Try to hide high latencies. - if (tryLess(TryCand.LastPosHighLatParentScheduled, - Cand.LastPosHighLatParentScheduled, TryCand, Cand, Latency)) + if (SISched::tryLess(TryCand.LastPosHighLatParentScheduled, + Cand.LastPosHighLatParentScheduled, TryCand, Cand, Latency)) return true; // Schedule high latencies early so you can hide them better. - if (tryGreater(TryCand.IsHighLatency, Cand.IsHighLatency, - TryCand, Cand, Latency)) + if (SISched::tryGreater(TryCand.IsHighLatency, Cand.IsHighLatency, + TryCand, Cand, Latency)) return true; - if (TryCand.IsHighLatency && tryGreater(TryCand.Height, Cand.Height, - TryCand, Cand, Depth)) + if (TryCand.IsHighLatency && SISched::tryGreater(TryCand.Height, Cand.Height, + TryCand, Cand, Depth)) return true; - if (tryGreater(TryCand.NumHighLatencySuccessors, - Cand.NumHighLatencySuccessors, - TryCand, Cand, Successor)) + if (SISched::tryGreater(TryCand.NumHighLatencySuccessors, + Cand.NumHighLatencySuccessors, + TryCand, Cand, Successor)) return true; return false; } @@ -1600,17 +1606,17 @@ bool SIScheduleBlockScheduler::tryCandidateRegUsage(SIBlockSchedCandidate &Cand, return true; } - if (tryLess(TryCand.VGPRUsageDiff > 0, Cand.VGPRUsageDiff > 0, - TryCand, Cand, RegUsage)) + if (SISched::tryLess(TryCand.VGPRUsageDiff > 0, Cand.VGPRUsageDiff > 0, + TryCand, Cand, RegUsage)) return true; - if (tryGreater(TryCand.NumSuccessors > 0, - Cand.NumSuccessors > 0, - TryCand, Cand, Successor)) + if (SISched::tryGreater(TryCand.NumSuccessors > 0, + Cand.NumSuccessors > 0, + TryCand, Cand, Successor)) return true; - if (tryGreater(TryCand.Height, Cand.Height, TryCand, Cand, Depth)) + if (SISched::tryGreater(TryCand.Height, Cand.Height, TryCand, Cand, Depth)) return true; - if (tryLess(TryCand.VGPRUsageDiff, Cand.VGPRUsageDiff, - TryCand, Cand, RegUsage)) + if (SISched::tryLess(TryCand.VGPRUsageDiff, Cand.VGPRUsageDiff, + TryCand, Cand, RegUsage)) return true; return false; } |

