summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetSchedule.cpp
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-03-13 16:28:55 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-03-13 16:28:55 +0000
commit7faea7cb53276a604875a7d64e78a37728cb3f96 (patch)
tree1c77a2189b21e2b73f926e7500e215b366bcebbc /llvm/lib/CodeGen/TargetSchedule.cpp
parentb9f4b70f20fd2429187c45e12101ad92c5f6fe7a (diff)
downloadbcm5719-llvm-7faea7cb53276a604875a7d64e78a37728cb3f96.tar.gz
bcm5719-llvm-7faea7cb53276a604875a7d64e78a37728cb3f96.zip
[MC] Move the reciprocal throughput computation from TargetSchedModel to MCSchedModel.
The goal is to make the reciprocal throughput computation accessible through the MCSchedModel interface. This is particularly important for llvm-mca because it can only query the MCSchedModel interface. No functional change intended. Differential Revision: https://reviews.llvm.org/D44392 llvm-svn: 327420
Diffstat (limited to 'llvm/lib/CodeGen/TargetSchedule.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetSchedule.cpp33
1 files changed, 4 insertions, 29 deletions
diff --git a/llvm/lib/CodeGen/TargetSchedule.cpp b/llvm/lib/CodeGen/TargetSchedule.cpp
index 432545bde1f..a811450c2ae 100644
--- a/llvm/lib/CodeGen/TargetSchedule.cpp
+++ b/llvm/lib/CodeGen/TargetSchedule.cpp
@@ -347,38 +347,13 @@ getRThroughputFromItineraries(unsigned schedClass,
return Throughput;
}
-static Optional<double>
-getRThroughputFromInstrSchedModel(const MCSchedClassDesc *SCDesc,
- const TargetSubtargetInfo *STI,
- const MCSchedModel &SchedModel) {
- Optional<double> Throughput;
-
- for (const MCWriteProcResEntry *WPR = STI->getWriteProcResBegin(SCDesc),
- *WEnd = STI->getWriteProcResEnd(SCDesc);
- WPR != WEnd; ++WPR) {
- if (WPR->Cycles) {
- unsigned NumUnits =
- SchedModel.getProcResource(WPR->ProcResourceIdx)->NumUnits;
- double Temp = NumUnits * 1.0 / WPR->Cycles;
- Throughput = Throughput.hasValue()
- ? std::min(Throughput.getValue(), Temp)
- : Temp;
- }
- }
- if (Throughput.hasValue())
- // We need reciprocal throughput that's why we return such value.
- return 1 / Throughput.getValue();
- return Throughput;
-}
-
Optional<double>
TargetSchedModel::computeInstrRThroughput(const MachineInstr *MI) const {
if (hasInstrItineraries())
return getRThroughputFromItineraries(MI->getDesc().getSchedClass(),
getInstrItineraries());
if (hasInstrSchedModel())
- return getRThroughputFromInstrSchedModel(resolveSchedClass(MI), STI,
- SchedModel);
+ return MCSchedModel::getReciprocalThroughput(*STI, *resolveSchedClass(MI));
return Optional<double>();
}
@@ -388,9 +363,9 @@ TargetSchedModel::computeInstrRThroughput(unsigned Opcode) const {
if (hasInstrItineraries())
return getRThroughputFromItineraries(SchedClass, getInstrItineraries());
if (hasInstrSchedModel()) {
- const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SchedClass);
- if (SCDesc->isValid() && !SCDesc->isVariant())
- return getRThroughputFromInstrSchedModel(SCDesc, STI, SchedModel);
+ const MCSchedClassDesc &SCDesc = *SchedModel.getSchedClassDesc(SchedClass);
+ if (SCDesc.isValid() && !SCDesc.isVariant())
+ return MCSchedModel::getReciprocalThroughput(*STI, SCDesc);
}
return Optional<double>();
}
OpenPOWER on IntegriCloud