summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCSchedule.cpp
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-03-13 15:22:13 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-03-13 15:22:13 +0000
commit30c1ba4834a9666ef5536a35c445cd8e91fcd0f5 (patch)
tree275508c1c5ca028ca1addf748b2d9b296745bb48 /llvm/lib/MC/MCSchedule.cpp
parent8150810556479b04e00578c9d7d4c30814898694 (diff)
downloadbcm5719-llvm-30c1ba4834a9666ef5536a35c445cd8e91fcd0f5.tar.gz
bcm5719-llvm-30c1ba4834a9666ef5536a35c445cd8e91fcd0f5.zip
[MC] Move the instruction latency computation from TargetSchedModel to MCSchedModel.
The goal is to make the latency information accessible through the MCSchedModel interface. This is particularly important for tools like llvm-mca that only have access to the MCSchedModel API. This partially fixes PR36676. No functional change intended. Differential Revision: https://reviews.llvm.org/D44383 llvm-svn: 327406
Diffstat (limited to 'llvm/lib/MC/MCSchedule.cpp')
-rw-r--r--llvm/lib/MC/MCSchedule.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCSchedule.cpp b/llvm/lib/MC/MCSchedule.cpp
index f3919427bf0..653049cc267 100644
--- a/llvm/lib/MC/MCSchedule.cpp
+++ b/llvm/lib/MC/MCSchedule.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCSchedule.h"
+#include "llvm/MC/MCSubtargetInfo.h"
#include <type_traits>
using namespace llvm;
@@ -32,3 +33,19 @@ const MCSchedModel MCSchedModel::Default = {DefaultIssueWidth,
0,
0,
nullptr};
+
+int MCSchedModel::computeInstrLatency(const MCSubtargetInfo &STI,
+ const MCSchedClassDesc &SCDesc) {
+ int Latency = 0;
+ for (unsigned DefIdx = 0, DefEnd = SCDesc.NumWriteLatencyEntries;
+ DefIdx != DefEnd; ++DefIdx) {
+ // Lookup the definition's write latency in SubtargetInfo.
+ const MCWriteLatencyEntry *WLEntry =
+ STI.getWriteLatencyEntry(&SCDesc, DefIdx);
+ // Early exit if we found an invalid latency.
+ if (WLEntry->Cycles < 0)
+ return WLEntry->Cycles;
+ Latency = std::max(Latency, static_cast<int>(WLEntry->Cycles));
+ }
+ return Latency;
+}
OpenPOWER on IntegriCloud