mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 21:29:41 +00:00
TargetSchedule: factor out common code; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237376 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e9c8191eeb
commit
be4ab8dafe
@ -40,6 +40,9 @@ class TargetSchedModel {
|
|||||||
SmallVector<unsigned, 16> ResourceFactors;
|
SmallVector<unsigned, 16> ResourceFactors;
|
||||||
unsigned MicroOpFactor; // Multiply to normalize microops to resource units.
|
unsigned MicroOpFactor; // Multiply to normalize microops to resource units.
|
||||||
unsigned ResourceLCM; // Resource units per cycle. Latency normalization factor.
|
unsigned ResourceLCM; // Resource units per cycle. Latency normalization factor.
|
||||||
|
|
||||||
|
unsigned computeInstrLatency(const MCSchedClassDesc &SCDesc) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TargetSchedModel(): SchedModel(MCSchedModel::GetDefaultSchedModel()), STI(nullptr), TII(nullptr) {}
|
TargetSchedModel(): SchedModel(MCSchedModel::GetDefaultSchedModel()), STI(nullptr), TII(nullptr) {}
|
||||||
|
|
||||||
|
@ -224,6 +224,19 @@ unsigned TargetSchedModel::computeOperandLatency(
|
|||||||
return DefMI->isTransient() ? 0 : TII->defaultDefLatency(SchedModel, DefMI);
|
return DefMI->isTransient() ? 0 : TII->defaultDefLatency(SchedModel, DefMI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned
|
||||||
|
TargetSchedModel::computeInstrLatency(const MCSchedClassDesc &SCDesc) const {
|
||||||
|
unsigned Latency = 0;
|
||||||
|
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, capLatency(WLEntry->Cycles));
|
||||||
|
}
|
||||||
|
return Latency;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const {
|
unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const {
|
||||||
assert(hasInstrSchedModel() && "Only call this function with a SchedModel");
|
assert(hasInstrSchedModel() && "Only call this function with a SchedModel");
|
||||||
|
|
||||||
@ -231,16 +244,8 @@ unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const {
|
|||||||
const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SCIdx);
|
const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SCIdx);
|
||||||
unsigned Latency = 0;
|
unsigned Latency = 0;
|
||||||
|
|
||||||
if (SCDesc->isValid() && !SCDesc->isVariant()) {
|
if (SCDesc->isValid() && !SCDesc->isVariant())
|
||||||
for (unsigned DefIdx = 0, DefEnd = SCDesc->NumWriteLatencyEntries;
|
return computeInstrLatency(*SCDesc);
|
||||||
DefIdx != DefEnd; ++DefIdx) {
|
|
||||||
// Lookup the definition's write latency in SubtargetInfo.
|
|
||||||
const MCWriteLatencyEntry *WLEntry =
|
|
||||||
STI->getWriteLatencyEntry(SCDesc, DefIdx);
|
|
||||||
Latency = std::max(Latency, capLatency(WLEntry->Cycles));
|
|
||||||
}
|
|
||||||
return Latency;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(Latency && "No MI sched latency");
|
assert(Latency && "No MI sched latency");
|
||||||
return 0;
|
return 0;
|
||||||
@ -257,17 +262,8 @@ TargetSchedModel::computeInstrLatency(const MachineInstr *MI,
|
|||||||
|
|
||||||
if (hasInstrSchedModel()) {
|
if (hasInstrSchedModel()) {
|
||||||
const MCSchedClassDesc *SCDesc = resolveSchedClass(MI);
|
const MCSchedClassDesc *SCDesc = resolveSchedClass(MI);
|
||||||
if (SCDesc->isValid()) {
|
if (SCDesc->isValid())
|
||||||
unsigned Latency = 0;
|
return computeInstrLatency(*SCDesc);
|
||||||
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, capLatency(WLEntry->Cycles));
|
|
||||||
}
|
|
||||||
return Latency;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TII->defaultDefLatency(SchedModel, MI);
|
return TII->defaultDefLatency(SchedModel, MI);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user