From b9acf13907c877a61abc37f2a9ec621ab0dd9d5b Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Sun, 15 Apr 2018 17:32:17 +0000 Subject: [MC] Moved all the remaining logic that computed instruction latency and reciprocal throughput from TargetSchedModel to MCSchedModel. TargetSchedModel now always delegates to MCSchedModel the computation of instruction latency and reciprocal throughput. No functional change intended. llvm-svn: 330099 --- llvm/lib/CodeGen/TargetSchedule.cpp | 45 +++++++------------------------- llvm/lib/CodeGen/TargetSubtargetInfo.cpp | 4 +-- 2 files changed, 12 insertions(+), 37 deletions(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/TargetSchedule.cpp b/llvm/lib/CodeGen/TargetSchedule.cpp index b8f284880af..5b6f72fbb35 100644 --- a/llvm/lib/CodeGen/TargetSchedule.cpp +++ b/llvm/lib/CodeGen/TargetSchedule.cpp @@ -260,16 +260,8 @@ TargetSchedModel::computeInstrLatency(const MCSchedClassDesc &SCDesc) const { unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const { assert(hasInstrSchedModel() && "Only call this function with a SchedModel"); - unsigned SCIdx = TII->get(Opcode).getSchedClass(); - const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SCIdx); - - if (!SCDesc->isValid()) - return 0; - if (!SCDesc->isVariant()) - return computeInstrLatency(*SCDesc); - - llvm_unreachable("No MI sched latency"); + return SchedModel.computeInstrLatency(*STI, SCIdx); } unsigned @@ -324,42 +316,25 @@ computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx, return 0; } -static Optional -getRThroughputFromItineraries(unsigned schedClass, - const InstrItineraryData *IID){ - Optional Throughput; - - for (const InstrStage *IS = IID->beginStage(schedClass), - *E = IID->endStage(schedClass); - IS != E; ++IS) { - if (IS->getCycles()) { - double Temp = countPopulation(IS->getUnits()) * 1.0 / IS->getCycles(); - Throughput = Throughput.hasValue() - ? std::min(Throughput.getValue(), Temp) - : Temp; - } +Optional +TargetSchedModel::computeReciprocalThroughput(const MachineInstr *MI) const { + if (hasInstrItineraries()) { + unsigned SchedClass = MI->getDesc().getSchedClass(); + return MCSchedModel::getReciprocalThroughput(SchedClass, + *getInstrItineraries()); } - if (Throughput.hasValue()) - // We need reciprocal throughput that's why we return such value. - return 1 / Throughput.getValue(); - return Throughput; -} -Optional -TargetSchedModel::computeInstrRThroughput(const MachineInstr *MI) const { - if (hasInstrItineraries()) - return getRThroughputFromItineraries(MI->getDesc().getSchedClass(), - getInstrItineraries()); if (hasInstrSchedModel()) return MCSchedModel::getReciprocalThroughput(*STI, *resolveSchedClass(MI)); return Optional(); } Optional -TargetSchedModel::computeInstrRThroughput(unsigned Opcode) const { +TargetSchedModel::computeReciprocalThroughput(unsigned Opcode) const { unsigned SchedClass = TII->get(Opcode).getSchedClass(); if (hasInstrItineraries()) - return getRThroughputFromItineraries(SchedClass, getInstrItineraries()); + return MCSchedModel::getReciprocalThroughput(SchedClass, + *getInstrItineraries()); if (hasInstrSchedModel()) { const MCSchedClassDesc &SCDesc = *SchedModel.getSchedClassDesc(SchedClass); if (SCDesc.isValid() && !SCDesc.isVariant()) diff --git a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp index 2b9cc64143d..6231402f043 100644 --- a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp +++ b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp @@ -90,7 +90,7 @@ std::string TargetSubtargetInfo::getSchedInfoStr(const MachineInstr &MI) const { TargetSchedModel TSchedModel; TSchedModel.init(this); unsigned Latency = TSchedModel.computeInstrLatency(&MI); - Optional RThroughput = TSchedModel.computeInstrRThroughput(&MI); + Optional RThroughput = TSchedModel.computeReciprocalThroughput(&MI); return createSchedInfoStr(Latency, RThroughput); } @@ -110,7 +110,7 @@ std::string TargetSubtargetInfo::getSchedInfoStr(MCInst const &MCI) const { } else return std::string(); Optional RThroughput = - TSchedModel.computeInstrRThroughput(MCI.getOpcode()); + TSchedModel.computeReciprocalThroughput(MCI.getOpcode()); return createSchedInfoStr(Latency, RThroughput); } -- cgit v1.2.3