mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
misched: Add computeInstrLatency to TargetSchedModel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c92d72abd0
commit
c0dfffa448
@ -74,6 +74,14 @@ public:
|
|||||||
const MachineInstr *UseMI, unsigned UseOperIdx,
|
const MachineInstr *UseMI, unsigned UseOperIdx,
|
||||||
bool FindMin) const;
|
bool FindMin) const;
|
||||||
|
|
||||||
|
/// \brief Compute the instruction latency based on the available machine
|
||||||
|
/// model.
|
||||||
|
///
|
||||||
|
/// Compute and return the expected latency of this instruction independent of
|
||||||
|
/// a particular use. computeOperandLatency is the prefered API, but this is
|
||||||
|
/// occasionally useful to help estimate instruction cost.
|
||||||
|
unsigned computeInstrLatency(const MachineInstr *MI) const;
|
||||||
|
|
||||||
/// \brief Identify the processor corresponding to the current subtarget.
|
/// \brief Identify the processor corresponding to the current subtarget.
|
||||||
unsigned getProcessorID() const { return SchedModel.getProcessorID(); }
|
unsigned getProcessorID() const { return SchedModel.getProcessorID(); }
|
||||||
|
|
||||||
|
@ -146,6 +146,10 @@ unsigned TargetSchedModel::computeOperandLatency(
|
|||||||
unsigned InstrLatency = TII->getInstrLatency(&InstrItins, DefMI);
|
unsigned InstrLatency = TII->getInstrLatency(&InstrItins, DefMI);
|
||||||
|
|
||||||
// Expected latency is the max of the stage latency and itinerary props.
|
// Expected latency is the max of the stage latency and itinerary props.
|
||||||
|
// 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.
|
||||||
if (!FindMin)
|
if (!FindMin)
|
||||||
InstrLatency = std::max(InstrLatency,
|
InstrLatency = std::max(InstrLatency,
|
||||||
TII->defaultDefLatency(&SchedModel, DefMI));
|
TII->defaultDefLatency(&SchedModel, DefMI));
|
||||||
@ -185,3 +189,23 @@ unsigned TargetSchedModel::computeOperandLatency(
|
|||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned TargetSchedModel::computeInstrLatency(const MachineInstr *MI) const {
|
||||||
|
if (hasInstrItineraries()) {
|
||||||
|
// For the itinerary model, fall back to the old subtarget hook.
|
||||||
|
return TII->getInstrLatency(&InstrItins, MI);
|
||||||
|
}
|
||||||
|
if (hasInstrSchedModel()) {
|
||||||
|
unsigned Latency = 0;
|
||||||
|
const MCSchedClassDesc *SCDesc = resolveSchedClass(MI);
|
||||||
|
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);
|
||||||
|
Latency = std::max(Latency, WLEntry->Cycles);
|
||||||
|
}
|
||||||
|
return Latency;
|
||||||
|
}
|
||||||
|
return TII->defaultDefLatency(&SchedModel, MI);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user