diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /lib/CodeGen/TargetSchedule.cpp | |
parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) |
Notes
Diffstat (limited to 'lib/CodeGen/TargetSchedule.cpp')
-rw-r--r-- | lib/CodeGen/TargetSchedule.cpp | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/lib/CodeGen/TargetSchedule.cpp b/lib/CodeGen/TargetSchedule.cpp index 9210ea8a83f6..86dbf1b2aeab 100644 --- a/lib/CodeGen/TargetSchedule.cpp +++ b/lib/CodeGen/TargetSchedule.cpp @@ -16,15 +16,15 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineOperand.h" +#include "llvm/CodeGen/TargetInstrInfo.h" +#include "llvm/CodeGen/TargetRegisterInfo.h" +#include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/MC/MCInstrDesc.h" #include "llvm/MC/MCInstrItineraries.h" #include "llvm/MC/MCSchedule.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Target/TargetInstrInfo.h" -#include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/Target/TargetSubtargetInfo.h" #include <algorithm> #include <cassert> #include <cstdint> @@ -316,7 +316,7 @@ computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx, // correctly append imp-use operands, and readsReg() strangely returns false // for predicated defs. unsigned Reg = DefMI->getOperand(DefOperIdx).getReg(); - const MachineFunction &MF = *DefMI->getParent()->getParent(); + const MachineFunction &MF = *DefMI->getMF(); const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); if (!DepMI->readsRegister(Reg, TRI) && TII->isPredicated(*DepMI)) return computeInstrLatency(DefMI); @@ -339,42 +339,46 @@ computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx, static Optional<double> getRThroughputFromItineraries(unsigned schedClass, const InstrItineraryData *IID){ - double Unknown = std::numeric_limits<double>::infinity(); - double Throughput = Unknown; + Optional<double> Throughput; for (const InstrStage *IS = IID->beginStage(schedClass), *E = IID->endStage(schedClass); IS != E; ++IS) { - unsigned Cycles = IS->getCycles(); - if (!Cycles) - continue; - Throughput = - std::min(Throughput, countPopulation(IS->getUnits()) * 1.0 / Cycles); + if (IS->getCycles()) { + double Temp = countPopulation(IS->getUnits()) * 1.0 / IS->getCycles(); + Throughput = Throughput.hasValue() + ? std::min(Throughput.getValue(), Temp) + : Temp; + } } - // We need reciprocal throughput that's why we return such value. - return 1 / Throughput; + if (Throughput.hasValue()) + // We need reciprocal throughput that's why we return such value. + return 1 / Throughput.getValue(); + return Throughput; } static Optional<double> getRThroughputFromInstrSchedModel(const MCSchedClassDesc *SCDesc, const TargetSubtargetInfo *STI, const MCSchedModel &SchedModel) { - double Unknown = std::numeric_limits<double>::infinity(); - double Throughput = Unknown; + Optional<double> Throughput; for (const MCWriteProcResEntry *WPR = STI->getWriteProcResBegin(SCDesc), *WEnd = STI->getWriteProcResEnd(SCDesc); WPR != WEnd; ++WPR) { - unsigned Cycles = WPR->Cycles; - if (!Cycles) - return Optional<double>(); - - unsigned NumUnits = - SchedModel.getProcResource(WPR->ProcResourceIdx)->NumUnits; - Throughput = std::min(Throughput, NumUnits * 1.0 / Cycles); + 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; + } } - // We need reciprocal throughput that's why we return such value. - return 1 / Throughput; + if (Throughput.hasValue()) + // We need reciprocal throughput that's why we return such value. + return 1 / Throughput.getValue(); + return Throughput; } Optional<double> |