From d56595184b5c5edc138c6ae677a1ac38a9a31581 Mon Sep 17 00:00:00 2001 From: "Andrew V. Tischenko" Date: Tue, 1 Aug 2017 09:15:43 +0000 Subject: Support itineraries in TargetSubtargetInfo::getSchedInfoStr - Now if the given instr does not have sched model then we try to calculate the latecy/throughput with help of itineraries. Differential Revision https://reviews.llvm.org/D35997 llvm-svn: 309666 --- llvm/lib/CodeGen/TargetSubtargetInfo.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/TargetSubtargetInfo.cpp') diff --git a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp index f6d5bc80ddf..859fac3cd63 100644 --- a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp +++ b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp @@ -11,13 +11,14 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/ADT/Optional.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/TargetSchedule.h" #include "llvm/MC/MCInst.h" -#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetInstrInfo.h" #include using namespace llvm; @@ -93,9 +94,15 @@ std::string TargetSubtargetInfo::getSchedInfoStr(MCInst const &MCI) const { // that could be changed during the compilation TargetSchedModel TSchedModel; TSchedModel.init(getSchedModel(), this, getInstrInfo()); - if (!TSchedModel.hasInstrSchedModel()) + unsigned Latency; + if (TSchedModel.hasInstrSchedModel()) + Latency = TSchedModel.computeInstrLatency(MCI.getOpcode()); + else if (TSchedModel.hasInstrItineraries()) { + auto *ItinData = TSchedModel.getInstrItineraries(); + Latency = ItinData->getStageLatency( + getInstrInfo()->get(MCI.getOpcode()).getSchedClass()); + } else return std::string(); - unsigned Latency = TSchedModel.computeInstrLatency(MCI.getOpcode()); Optional RThroughput = TSchedModel.computeInstrRThroughput(MCI.getOpcode()); return createSchedInfoStr(Latency, RThroughput); -- cgit v1.2.3