2017-02-28 06:45:06 +08:00
|
|
|
//===- llvm/Target/TargetSchedule.cpp - Sched Machine Model ---------------===//
|
2012-09-15 04:26:46 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-09-15 04:26:46 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements a wrapper around MCSchedModel that allows the interface
|
|
|
|
// to benefit from information currently only available in TargetInstrInfo.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/CodeGen/TargetSchedule.h"
|
2017-02-28 06:45:06 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
2017-11-08 09:01:31 +08:00
|
|
|
#include "llvm/CodeGen/TargetInstrInfo.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
|
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
2017-02-28 06:45:06 +08:00
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
|
|
|
#include "llvm/MC/MCInstrItineraries.h"
|
|
|
|
#include "llvm/MC/MCSchedule.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2017-02-28 06:45:06 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2017-02-28 06:45:06 +08:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdint>
|
2012-09-15 04:26:46 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2012-10-04 08:24:34 +08:00
|
|
|
static cl::opt<bool> EnableSchedModel("schedmodel", cl::Hidden, cl::init(true),
|
2012-09-15 04:26:46 +08:00
|
|
|
cl::desc("Use TargetSchedModel for latency lookup"));
|
|
|
|
|
2012-09-18 12:03:34 +08:00
|
|
|
static cl::opt<bool> EnableSchedItins("scheditins", cl::Hidden, cl::init(true),
|
|
|
|
cl::desc("Use InstrItineraryData for latency lookup"));
|
|
|
|
|
2012-10-10 07:44:26 +08:00
|
|
|
bool TargetSchedModel::hasInstrSchedModel() const {
|
|
|
|
return EnableSchedModel && SchedModel.hasInstrSchedModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetSchedModel::hasInstrItineraries() const {
|
|
|
|
return EnableSchedItins && !InstrItins.isEmpty();
|
|
|
|
}
|
|
|
|
|
2012-11-06 15:10:38 +08:00
|
|
|
static unsigned gcd(unsigned Dividend, unsigned Divisor) {
|
|
|
|
// Dividend and Divisor will be naturally swapped as needed.
|
2017-02-28 06:45:06 +08:00
|
|
|
while (Divisor) {
|
2012-11-06 15:10:38 +08:00
|
|
|
unsigned Rem = Dividend % Divisor;
|
|
|
|
Dividend = Divisor;
|
|
|
|
Divisor = Rem;
|
|
|
|
};
|
|
|
|
return Dividend;
|
|
|
|
}
|
2017-02-28 06:45:06 +08:00
|
|
|
|
2012-11-06 15:10:38 +08:00
|
|
|
static unsigned lcm(unsigned A, unsigned B) {
|
|
|
|
unsigned LCM = (uint64_t(A) * B) / gcd(A, B);
|
|
|
|
assert((LCM >= A && LCM >= B) && "LCM overflow");
|
|
|
|
return LCM;
|
|
|
|
}
|
|
|
|
|
2018-04-09 03:56:04 +08:00
|
|
|
void TargetSchedModel::init(const TargetSubtargetInfo *TSInfo) {
|
|
|
|
STI = TSInfo;
|
|
|
|
SchedModel = TSInfo->getSchedModel();
|
|
|
|
TII = TSInfo->getInstrInfo();
|
2012-09-15 04:26:46 +08:00
|
|
|
STI->initInstrItins(InstrItins);
|
2012-11-06 15:10:38 +08:00
|
|
|
|
|
|
|
unsigned NumRes = SchedModel.getNumProcResourceKinds();
|
|
|
|
ResourceFactors.resize(NumRes);
|
|
|
|
ResourceLCM = SchedModel.IssueWidth;
|
|
|
|
for (unsigned Idx = 0; Idx < NumRes; ++Idx) {
|
|
|
|
unsigned NumUnits = SchedModel.getProcResource(Idx)->NumUnits;
|
|
|
|
if (NumUnits > 0)
|
|
|
|
ResourceLCM = lcm(ResourceLCM, NumUnits);
|
|
|
|
}
|
|
|
|
MicroOpFactor = ResourceLCM / SchedModel.IssueWidth;
|
|
|
|
for (unsigned Idx = 0; Idx < NumRes; ++Idx) {
|
|
|
|
unsigned NumUnits = SchedModel.getProcResource(Idx)->NumUnits;
|
|
|
|
ResourceFactors[Idx] = NumUnits ? (ResourceLCM / NumUnits) : 0;
|
|
|
|
}
|
2012-09-15 04:26:46 +08:00
|
|
|
}
|
2012-09-18 12:03:34 +08:00
|
|
|
|
2017-03-28 04:46:37 +08:00
|
|
|
/// Returns true only if instruction is specified as single issue.
|
|
|
|
bool TargetSchedModel::mustBeginGroup(const MachineInstr *MI,
|
|
|
|
const MCSchedClassDesc *SC) const {
|
|
|
|
if (hasInstrSchedModel()) {
|
|
|
|
if (!SC)
|
|
|
|
SC = resolveSchedClass(MI);
|
|
|
|
if (SC->isValid())
|
|
|
|
return SC->BeginGroup;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetSchedModel::mustEndGroup(const MachineInstr *MI,
|
|
|
|
const MCSchedClassDesc *SC) const {
|
|
|
|
if (hasInstrSchedModel()) {
|
|
|
|
if (!SC)
|
|
|
|
SC = resolveSchedClass(MI);
|
|
|
|
if (SC->isValid())
|
|
|
|
return SC->EndGroup;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-06 15:10:38 +08:00
|
|
|
unsigned TargetSchedModel::getNumMicroOps(const MachineInstr *MI,
|
|
|
|
const MCSchedClassDesc *SC) const {
|
2012-10-10 13:43:09 +08:00
|
|
|
if (hasInstrItineraries()) {
|
|
|
|
int UOps = InstrItins.getNumMicroOps(MI->getDesc().getSchedClass());
|
2016-06-30 08:01:54 +08:00
|
|
|
return (UOps >= 0) ? UOps : TII->getNumMicroOps(&InstrItins, *MI);
|
2012-10-10 13:43:09 +08:00
|
|
|
}
|
2012-10-11 13:37:06 +08:00
|
|
|
if (hasInstrSchedModel()) {
|
2012-11-06 15:10:38 +08:00
|
|
|
if (!SC)
|
|
|
|
SC = resolveSchedClass(MI);
|
|
|
|
if (SC->isValid())
|
|
|
|
return SC->NumMicroOps;
|
2012-10-11 13:37:06 +08:00
|
|
|
}
|
|
|
|
return MI->isTransient() ? 0 : 1;
|
2012-10-10 13:43:09 +08:00
|
|
|
}
|
|
|
|
|
2012-10-18 01:27:10 +08:00
|
|
|
// The machine model may explicitly specify an invalid latency, which
|
|
|
|
// effectively means infinite latency. Since users of the TargetSchedule API
|
|
|
|
// don't know how to handle this, we convert it to a very large latency that is
|
|
|
|
// easy to distinguish when debugging the DAG but won't induce overflow.
|
2013-06-15 12:49:57 +08:00
|
|
|
static unsigned capLatency(int Cycles) {
|
2012-10-18 01:27:10 +08:00
|
|
|
return Cycles >= 0 ? Cycles : 1000;
|
|
|
|
}
|
|
|
|
|
2012-09-18 12:03:34 +08:00
|
|
|
/// Return the MCSchedClassDesc for this instruction. Some SchedClasses require
|
|
|
|
/// evaluation of predicates that depend on instruction operands or flags.
|
|
|
|
const MCSchedClassDesc *TargetSchedModel::
|
|
|
|
resolveSchedClass(const MachineInstr *MI) const {
|
|
|
|
// Get the definition's scheduling class descriptor from this machine model.
|
|
|
|
unsigned SchedClass = MI->getDesc().getSchedClass();
|
|
|
|
const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SchedClass);
|
2013-04-13 14:07:45 +08:00
|
|
|
if (!SCDesc->isValid())
|
|
|
|
return SCDesc;
|
2012-09-18 12:03:34 +08:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
unsigned NIter = 0;
|
|
|
|
#endif
|
|
|
|
while (SCDesc->isVariant()) {
|
|
|
|
assert(++NIter < 6 && "Variants are nested deeper than the magic number");
|
|
|
|
|
|
|
|
SchedClass = STI->resolveSchedClass(SchedClass, MI, this);
|
|
|
|
SCDesc = SchedModel.getSchedClassDesc(SchedClass);
|
|
|
|
}
|
|
|
|
return SCDesc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Find the def index of this operand. This index maps to the machine model and
|
|
|
|
/// is independent of use operands. Def operands may be reordered with uses or
|
|
|
|
/// merged with uses without affecting the def index (e.g. before/after
|
|
|
|
/// regalloc). However, an instruction's def operands must never be reordered
|
|
|
|
/// with respect to each other.
|
|
|
|
static unsigned findDefIdx(const MachineInstr *MI, unsigned DefOperIdx) {
|
|
|
|
unsigned DefIdx = 0;
|
|
|
|
for (unsigned i = 0; i != DefOperIdx; ++i) {
|
|
|
|
const MachineOperand &MO = MI->getOperand(i);
|
|
|
|
if (MO.isReg() && MO.isDef())
|
|
|
|
++DefIdx;
|
|
|
|
}
|
|
|
|
return DefIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Find the use index of this operand. This is independent of the instruction's
|
|
|
|
/// def operands.
|
2012-09-19 02:20:02 +08:00
|
|
|
///
|
|
|
|
/// Note that uses are not determined by the operand's isUse property, which
|
|
|
|
/// is simply the inverse of isDef. Here we consider any readsReg operand to be
|
|
|
|
/// a "use". The machine model allows an operand to be both a Def and Use.
|
2012-09-18 12:03:34 +08:00
|
|
|
static unsigned findUseIdx(const MachineInstr *MI, unsigned UseOperIdx) {
|
|
|
|
unsigned UseIdx = 0;
|
|
|
|
for (unsigned i = 0; i != UseOperIdx; ++i) {
|
|
|
|
const MachineOperand &MO = MI->getOperand(i);
|
2016-08-24 10:32:29 +08:00
|
|
|
if (MO.isReg() && MO.readsReg() && !MO.isDef())
|
2012-09-18 12:03:34 +08:00
|
|
|
++UseIdx;
|
|
|
|
}
|
|
|
|
return UseIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Top-level API for clients that know the operand indices.
|
|
|
|
unsigned TargetSchedModel::computeOperandLatency(
|
|
|
|
const MachineInstr *DefMI, unsigned DefOperIdx,
|
2013-06-15 12:49:57 +08:00
|
|
|
const MachineInstr *UseMI, unsigned UseOperIdx) const {
|
2012-09-18 12:03:34 +08:00
|
|
|
|
2013-06-15 12:49:57 +08:00
|
|
|
if (!hasInstrSchedModel() && !hasInstrItineraries())
|
2016-06-30 08:01:54 +08:00
|
|
|
return TII->defaultDefLatency(SchedModel, *DefMI);
|
2012-09-18 12:03:34 +08:00
|
|
|
|
2012-10-10 07:44:26 +08:00
|
|
|
if (hasInstrItineraries()) {
|
2012-10-04 08:24:34 +08:00
|
|
|
int OperLatency = 0;
|
|
|
|
if (UseMI) {
|
2016-06-30 08:01:54 +08:00
|
|
|
OperLatency = TII->getOperandLatency(&InstrItins, *DefMI, DefOperIdx,
|
|
|
|
*UseMI, UseOperIdx);
|
2012-09-18 12:03:34 +08:00
|
|
|
}
|
2012-10-04 08:24:34 +08:00
|
|
|
else {
|
|
|
|
unsigned DefClass = DefMI->getDesc().getSchedClass();
|
|
|
|
OperLatency = InstrItins.getOperandCycle(DefClass, DefOperIdx);
|
2012-09-19 02:20:02 +08:00
|
|
|
}
|
2012-10-04 08:24:34 +08:00
|
|
|
if (OperLatency >= 0)
|
|
|
|
return OperLatency;
|
2012-09-18 12:03:34 +08:00
|
|
|
|
2012-10-04 08:24:34 +08:00
|
|
|
// No operand latency was found.
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned InstrLatency = TII->getInstrLatency(&InstrItins, *DefMI);
|
2012-10-04 08:24:34 +08:00
|
|
|
|
|
|
|
// Expected latency is the max of the stage latency and itinerary props.
|
2012-10-10 07:44:32 +08:00
|
|
|
// Rather than directly querying InstrItins stage latency, we call a TII
|
|
|
|
// hook to allow subtargets to specialize latency. This hook is only
|
|
|
|
// applicable to the InstrItins model. InstrSchedModel should model all
|
|
|
|
// special cases without TII hooks.
|
2016-06-30 08:01:54 +08:00
|
|
|
InstrLatency =
|
|
|
|
std::max(InstrLatency, TII->defaultDefLatency(SchedModel, *DefMI));
|
2012-10-04 08:24:34 +08:00
|
|
|
return InstrLatency;
|
2012-09-18 12:03:34 +08:00
|
|
|
}
|
2013-06-15 12:49:57 +08:00
|
|
|
// hasInstrSchedModel()
|
2012-10-04 08:24:34 +08:00
|
|
|
const MCSchedClassDesc *SCDesc = resolveSchedClass(DefMI);
|
|
|
|
unsigned DefIdx = findDefIdx(DefMI, DefOperIdx);
|
|
|
|
if (DefIdx < SCDesc->NumWriteLatencyEntries) {
|
|
|
|
// Lookup the definition's write latency in SubtargetInfo.
|
|
|
|
const MCWriteLatencyEntry *WLEntry =
|
|
|
|
STI->getWriteLatencyEntry(SCDesc, DefIdx);
|
|
|
|
unsigned WriteID = WLEntry->WriteResourceID;
|
2013-06-15 12:49:57 +08:00
|
|
|
unsigned Latency = capLatency(WLEntry->Cycles);
|
2012-10-04 08:24:34 +08:00
|
|
|
if (!UseMI)
|
|
|
|
return Latency;
|
|
|
|
|
|
|
|
// Lookup the use's latency adjustment in SubtargetInfo.
|
|
|
|
const MCSchedClassDesc *UseDesc = resolveSchedClass(UseMI);
|
|
|
|
if (UseDesc->NumReadAdvanceEntries == 0)
|
|
|
|
return Latency;
|
|
|
|
unsigned UseIdx = findUseIdx(UseMI, UseOperIdx);
|
2013-06-18 05:45:18 +08:00
|
|
|
int Advance = STI->getReadAdvanceCycles(UseDesc, UseIdx, WriteID);
|
|
|
|
if (Advance > 0 && (unsigned)Advance > Latency) // unsigned wrap
|
|
|
|
return 0;
|
|
|
|
return Latency - Advance;
|
2012-09-18 12:03:34 +08:00
|
|
|
}
|
2012-10-04 08:24:34 +08:00
|
|
|
// If DefIdx does not exist in the model (e.g. implicit defs), then return
|
|
|
|
// unit latency (defaultDefLatency may be too conservative).
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if (SCDesc->isValid() && !DefMI->getOperand(DefOperIdx).isImplicit()
|
2013-09-26 02:14:12 +08:00
|
|
|
&& !DefMI->getDesc().OpInfo[DefOperIdx].isOptionalDef()
|
|
|
|
&& SchedModel.isComplete()) {
|
2015-07-18 01:50:11 +08:00
|
|
|
errs() << "DefIdx " << DefIdx << " exceeds machine model writes for "
|
2016-01-05 22:50:15 +08:00
|
|
|
<< *DefMI << " (Try with MCSchedModel.CompleteModel set to false)";
|
2015-07-18 01:50:11 +08:00
|
|
|
llvm_unreachable("incomplete machine model");
|
2012-10-04 08:24:34 +08:00
|
|
|
}
|
|
|
|
#endif
|
2013-03-17 02:58:57 +08:00
|
|
|
// FIXME: Automatically giving all implicit defs defaultDefLatency is
|
|
|
|
// undesirable. We should only do it for defs that are known to the MC
|
|
|
|
// desc like flags. Truly implicit defs should get 1 cycle latency.
|
2016-06-30 08:01:54 +08:00
|
|
|
return DefMI->isTransient() ? 0 : TII->defaultDefLatency(SchedModel, *DefMI);
|
2012-09-18 12:03:34 +08:00
|
|
|
}
|
2012-10-10 07:44:32 +08:00
|
|
|
|
2015-05-15 02:01:13 +08:00
|
|
|
unsigned
|
|
|
|
TargetSchedModel::computeInstrLatency(const MCSchedClassDesc &SCDesc) const {
|
2018-03-13 23:22:13 +08:00
|
|
|
return capLatency(MCSchedModel::computeInstrLatency(*STI, SCDesc));
|
2015-05-15 02:01:13 +08:00
|
|
|
}
|
|
|
|
|
2014-08-04 05:35:39 +08:00
|
|
|
unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const {
|
|
|
|
assert(hasInstrSchedModel() && "Only call this function with a SchedModel");
|
|
|
|
unsigned SCIdx = TII->get(Opcode).getSchedClass();
|
2018-05-31 21:30:42 +08:00
|
|
|
return capLatency(SchedModel.computeInstrLatency(*STI, SCIdx));
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetSchedModel::computeInstrLatency(const MCInst &Inst) const {
|
|
|
|
if (hasInstrSchedModel())
|
|
|
|
return capLatency(SchedModel.computeInstrLatency(*STI, *TII, Inst));
|
|
|
|
return computeInstrLatency(Inst.getOpcode());
|
2014-08-04 05:35:39 +08:00
|
|
|
}
|
|
|
|
|
2013-09-30 23:28:56 +08:00
|
|
|
unsigned
|
|
|
|
TargetSchedModel::computeInstrLatency(const MachineInstr *MI,
|
|
|
|
bool UseDefaultDefLatency) const {
|
2012-10-10 13:43:18 +08:00
|
|
|
// For the itinerary model, fall back to the old subtarget hook.
|
|
|
|
// Allow subtargets to compute Bundle latencies outside the machine model.
|
2013-09-30 23:28:56 +08:00
|
|
|
if (hasInstrItineraries() || MI->isBundle() ||
|
|
|
|
(!hasInstrSchedModel() && !UseDefaultDefLatency))
|
2016-06-30 08:01:54 +08:00
|
|
|
return TII->getInstrLatency(&InstrItins, *MI);
|
2012-10-10 13:43:18 +08:00
|
|
|
|
2012-10-10 07:44:32 +08:00
|
|
|
if (hasInstrSchedModel()) {
|
|
|
|
const MCSchedClassDesc *SCDesc = resolveSchedClass(MI);
|
2015-05-15 02:01:13 +08:00
|
|
|
if (SCDesc->isValid())
|
|
|
|
return computeInstrLatency(*SCDesc);
|
2012-10-10 07:44:32 +08:00
|
|
|
}
|
2016-06-30 08:01:54 +08:00
|
|
|
return TII->defaultDefLatency(SchedModel, *MI);
|
2012-10-10 07:44:32 +08:00
|
|
|
}
|
2012-10-10 13:43:09 +08:00
|
|
|
|
|
|
|
unsigned TargetSchedModel::
|
|
|
|
computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx,
|
|
|
|
const MachineInstr *DepMI) const {
|
2016-06-21 16:09:58 +08:00
|
|
|
if (!SchedModel.isOutOfOrder())
|
2012-10-10 13:43:09 +08:00
|
|
|
return 1;
|
|
|
|
|
2016-06-21 16:09:58 +08:00
|
|
|
// Out-of-order processor can dispatch WAW dependencies in the same cycle.
|
2012-10-10 13:43:09 +08:00
|
|
|
|
|
|
|
// Treat predication as a data dependency for out-of-order cpus. In-order
|
|
|
|
// cpus do not need to treat predicated writes specially.
|
|
|
|
//
|
|
|
|
// TODO: The following hack exists because predication passes do not
|
|
|
|
// correctly append imp-use operands, and readsReg() strangely returns false
|
|
|
|
// for predicated defs.
|
|
|
|
unsigned Reg = DefMI->getOperand(DefOperIdx).getReg();
|
2017-10-11 07:50:49 +08:00
|
|
|
const MachineFunction &MF = *DefMI->getMF();
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
|
2016-02-23 10:46:52 +08:00
|
|
|
if (!DepMI->readsRegister(Reg, TRI) && TII->isPredicated(*DepMI))
|
2012-10-10 13:43:09 +08:00
|
|
|
return computeInstrLatency(DefMI);
|
|
|
|
|
|
|
|
// If we have a per operand scheduling model, check if this def is writing
|
|
|
|
// an unbuffered resource. If so, it treated like an in-order cpu.
|
|
|
|
if (hasInstrSchedModel()) {
|
|
|
|
const MCSchedClassDesc *SCDesc = resolveSchedClass(DefMI);
|
2012-10-11 13:37:06 +08:00
|
|
|
if (SCDesc->isValid()) {
|
|
|
|
for (const MCWriteProcResEntry *PRI = STI->getWriteProcResBegin(SCDesc),
|
|
|
|
*PRE = STI->getWriteProcResEnd(SCDesc); PRI != PRE; ++PRI) {
|
2013-06-15 12:49:57 +08:00
|
|
|
if (!SchedModel.getProcResource(PRI->ProcResourceIdx)->BufferSize)
|
2012-10-11 13:37:06 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2012-10-10 13:43:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2017-04-14 15:44:23 +08:00
|
|
|
|
2018-06-06 07:34:45 +08:00
|
|
|
double
|
2018-04-16 01:32:17 +08:00
|
|
|
TargetSchedModel::computeReciprocalThroughput(const MachineInstr *MI) const {
|
|
|
|
if (hasInstrItineraries()) {
|
|
|
|
unsigned SchedClass = MI->getDesc().getSchedClass();
|
|
|
|
return MCSchedModel::getReciprocalThroughput(SchedClass,
|
|
|
|
*getInstrItineraries());
|
2017-04-14 15:44:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hasInstrSchedModel())
|
2018-03-14 00:28:55 +08:00
|
|
|
return MCSchedModel::getReciprocalThroughput(*STI, *resolveSchedClass(MI));
|
2018-06-06 07:34:45 +08:00
|
|
|
|
|
|
|
return 0.0;
|
2017-04-14 15:44:23 +08:00
|
|
|
}
|
|
|
|
|
2018-06-06 07:34:45 +08:00
|
|
|
double
|
2018-04-16 01:32:17 +08:00
|
|
|
TargetSchedModel::computeReciprocalThroughput(unsigned Opcode) const {
|
2017-04-14 15:44:23 +08:00
|
|
|
unsigned SchedClass = TII->get(Opcode).getSchedClass();
|
|
|
|
if (hasInstrItineraries())
|
2018-04-16 01:32:17 +08:00
|
|
|
return MCSchedModel::getReciprocalThroughput(SchedClass,
|
|
|
|
*getInstrItineraries());
|
2017-04-14 15:44:23 +08:00
|
|
|
if (hasInstrSchedModel()) {
|
2018-03-14 00:28:55 +08:00
|
|
|
const MCSchedClassDesc &SCDesc = *SchedModel.getSchedClassDesc(SchedClass);
|
|
|
|
if (SCDesc.isValid() && !SCDesc.isVariant())
|
|
|
|
return MCSchedModel::getReciprocalThroughput(*STI, SCDesc);
|
2017-04-14 15:44:23 +08:00
|
|
|
}
|
2018-06-06 07:34:45 +08:00
|
|
|
|
|
|
|
return 0.0;
|
2017-04-14 15:44:23 +08:00
|
|
|
}
|
2018-05-31 21:30:42 +08:00
|
|
|
|
2018-06-06 07:34:45 +08:00
|
|
|
double
|
2018-05-31 21:30:42 +08:00
|
|
|
TargetSchedModel::computeReciprocalThroughput(const MCInst &MI) const {
|
|
|
|
if (hasInstrSchedModel())
|
|
|
|
return SchedModel.getReciprocalThroughput(*STI, *TII, MI);
|
|
|
|
return computeReciprocalThroughput(MI.getOpcode());
|
|
|
|
}
|
|
|
|
|