summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCSchedule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCSchedule.cpp')
-rw-r--r--llvm/lib/MC/MCSchedule.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCSchedule.cpp b/llvm/lib/MC/MCSchedule.cpp
index 653049cc267..a91bb862f09 100644
--- a/llvm/lib/MC/MCSchedule.cpp
+++ b/llvm/lib/MC/MCSchedule.cpp
@@ -49,3 +49,27 @@ int MCSchedModel::computeInstrLatency(const MCSubtargetInfo &STI,
}
return Latency;
}
+
+
+Optional<double>
+MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI,
+ const MCSchedClassDesc &SCDesc) {
+ Optional<double> Throughput;
+ const MCSchedModel &SchedModel = STI.getSchedModel();
+
+ 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())
+ return 1 / Throughput.getValue();
+ return Throughput;
+}
OpenPOWER on IntegriCloud