diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-13 16:28:55 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-13 16:28:55 +0000 |
commit | 7faea7cb53276a604875a7d64e78a37728cb3f96 (patch) | |
tree | 1c77a2189b21e2b73f926e7500e215b366bcebbc /llvm/lib/MC/MCSchedule.cpp | |
parent | b9f4b70f20fd2429187c45e12101ad92c5f6fe7a (diff) | |
download | bcm5719-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/MC/MCSchedule.cpp')
-rw-r--r-- | llvm/lib/MC/MCSchedule.cpp | 24 |
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; +} |