summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2015-12-16 18:31:01 +0000
committerTom Stellard <thomas.stellard@amd.com>2015-12-16 18:31:01 +0000
commit5ce530608f4acfbb76e47757c07b6d349aacb8c0 (patch)
tree5cd8f735bbfded93c176dc442938c528581b56f5 /llvm/lib/CodeGen/MachineScheduler.cpp
parentd6f5f24a298f70485c24ab31496b44cf6fd501ef (diff)
downloadbcm5719-llvm-5ce530608f4acfbb76e47757c07b6d349aacb8c0.tar.gz
bcm5719-llvm-5ce530608f4acfbb76e47757c07b6d349aacb8c0.zip
MachineScheduler: Add a target hook for deciding which RegPressure sets to
increase Summary: This patch adds a function called getRegPressureSetScore() to TargetRegisterInfo. The MachineScheduler uses this when comparing instruction that increase the register pressure of different sets to determine which set is safer to increase. This hook is useful for GPU targets where the number of registers in the class is not the best metric for determing which presser set is safer to increase. Future work may include adding more parameters to this function, like for example, the current pressure level of the set or the amount that the pressure will be increased/decreased. Reviewers: qcolombet, escha, arsenm, atrick, MatzeB Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14806 llvm-svn: 255795
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index a13dab3fe78..bcee15c7c75 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -2579,11 +2579,13 @@ static bool tryPressure(const PressureChange &TryP,
const PressureChange &CandP,
GenericSchedulerBase::SchedCandidate &TryCand,
GenericSchedulerBase::SchedCandidate &Cand,
- GenericSchedulerBase::CandReason Reason) {
- int TryRank = TryP.getPSetOrMax();
- int CandRank = CandP.getPSetOrMax();
+ GenericSchedulerBase::CandReason Reason,
+ const TargetRegisterInfo *TRI,
+ const MachineFunction &MF) {
+ unsigned TryPSet = TryP.getPSetOrMax();
+ unsigned CandPSet = CandP.getPSetOrMax();
// If both candidates affect the same set, go with the smallest increase.
- if (TryRank == CandRank) {
+ if (TryPSet == CandPSet) {
return tryLess(TryP.getUnitInc(), CandP.getUnitInc(), TryCand, Cand,
Reason);
}
@@ -2593,6 +2595,13 @@ static bool tryPressure(const PressureChange &TryP,
Reason)) {
return true;
}
+
+ int TryRank = TryP.isValid() ? TRI->getRegPressureSetScore(MF, TryPSet) :
+ std::numeric_limits<int>::max();
+
+ int CandRank = CandP.isValid() ? TRI->getRegPressureSetScore(MF, CandPSet) :
+ std::numeric_limits<int>::max();
+
// If the candidates are decreasing pressure, reverse priority.
if (TryP.getUnitInc() < 0)
std::swap(TryRank, CandRank);
@@ -2695,13 +2704,15 @@ void GenericScheduler::tryCandidate(SchedCandidate &Cand,
// Avoid exceeding the target's limit.
if (DAG->isTrackingPressure() && tryPressure(TryCand.RPDelta.Excess,
Cand.RPDelta.Excess,
- TryCand, Cand, RegExcess))
+ TryCand, Cand, RegExcess, TRI,
+ DAG->MF))
return;
// Avoid increasing the max critical pressure in the scheduled region.
if (DAG->isTrackingPressure() && tryPressure(TryCand.RPDelta.CriticalMax,
Cand.RPDelta.CriticalMax,
- TryCand, Cand, RegCritical))
+ TryCand, Cand, RegCritical, TRI,
+ DAG->MF))
return;
// For loops that are acyclic path limited, aggressively schedule for latency.
@@ -2737,7 +2748,8 @@ void GenericScheduler::tryCandidate(SchedCandidate &Cand,
// Avoid increasing the max pressure of the entire region.
if (DAG->isTrackingPressure() && tryPressure(TryCand.RPDelta.CurrentMax,
Cand.RPDelta.CurrentMax,
- TryCand, Cand, RegMax))
+ TryCand, Cand, RegMax, TRI,
+ DAG->MF))
return;
// Avoid critical resource consumption and balance the schedule.
OpenPOWER on IntegriCloud