misched: Handle "transient" non-instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165701 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick 2012-10-11 05:37:06 +00:00
parent 5e01f80bf8
commit 4903c15b7d
2 changed files with 25 additions and 17 deletions

View File

@ -563,6 +563,8 @@ TargetInstrInfoImpl::getNumMicroOps(const InstrItineraryData *ItinData,
/// Return the default expected latency for a def based on it's opcode. /// Return the default expected latency for a def based on it's opcode.
unsigned TargetInstrInfo::defaultDefLatency(const MCSchedModel *SchedModel, unsigned TargetInstrInfo::defaultDefLatency(const MCSchedModel *SchedModel,
const MachineInstr *DefMI) const { const MachineInstr *DefMI) const {
if (DefMI->isTransient())
return 0;
if (DefMI->mayLoad()) if (DefMI->mayLoad())
return SchedModel->LoadLatency; return SchedModel->LoadLatency;
if (isHighLatencyDef(DefMI->getOpcode())) if (isHighLatencyDef(DefMI->getOpcode()))

View File

@ -50,10 +50,12 @@ unsigned TargetSchedModel::getNumMicroOps(MachineInstr *MI) const {
int UOps = InstrItins.getNumMicroOps(MI->getDesc().getSchedClass()); int UOps = InstrItins.getNumMicroOps(MI->getDesc().getSchedClass());
return (UOps >= 0) ? UOps : TII->getNumMicroOps(&InstrItins, MI); return (UOps >= 0) ? UOps : TII->getNumMicroOps(&InstrItins, MI);
} }
if (hasInstrSchedModel()) if (hasInstrSchedModel()) {
return resolveSchedClass(MI)->NumMicroOps; const MCSchedClassDesc *SCDesc = resolveSchedClass(MI);
if (SCDesc->isValid())
return 1; return SCDesc->NumMicroOps;
}
return MI->isTransient() ? 0 : 1;
} }
/// If we can determine the operand latency from the def only, without machine /// If we can determine the operand latency from the def only, without machine
@ -199,7 +201,7 @@ unsigned TargetSchedModel::computeOperandLatency(
report_fatal_error(ss.str()); report_fatal_error(ss.str());
} }
#endif #endif
return 1; return DefMI->isTransient() ? 0 : 1;
} }
unsigned TargetSchedModel::computeInstrLatency(const MachineInstr *MI) const { unsigned TargetSchedModel::computeInstrLatency(const MachineInstr *MI) const {
@ -209,16 +211,18 @@ unsigned TargetSchedModel::computeInstrLatency(const MachineInstr *MI) const {
return TII->getInstrLatency(&InstrItins, MI); return TII->getInstrLatency(&InstrItins, MI);
if (hasInstrSchedModel()) { if (hasInstrSchedModel()) {
unsigned Latency = 0;
const MCSchedClassDesc *SCDesc = resolveSchedClass(MI); const MCSchedClassDesc *SCDesc = resolveSchedClass(MI);
for (unsigned DefIdx = 0, DefEnd = SCDesc->NumWriteLatencyEntries; if (SCDesc->isValid()) {
DefIdx != DefEnd; ++DefIdx) { unsigned Latency = 0;
// Lookup the definition's write latency in SubtargetInfo. for (unsigned DefIdx = 0, DefEnd = SCDesc->NumWriteLatencyEntries;
const MCWriteLatencyEntry *WLEntry = DefIdx != DefEnd; ++DefIdx) {
STI->getWriteLatencyEntry(SCDesc, DefIdx); // Lookup the definition's write latency in SubtargetInfo.
Latency = std::max(Latency, WLEntry->Cycles); const MCWriteLatencyEntry *WLEntry =
STI->getWriteLatencyEntry(SCDesc, DefIdx);
Latency = std::max(Latency, WLEntry->Cycles);
}
return Latency;
} }
return Latency;
} }
return TII->defaultDefLatency(&SchedModel, MI); return TII->defaultDefLatency(&SchedModel, MI);
} }
@ -251,10 +255,12 @@ computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx,
// an unbuffered resource. If so, it treated like an in-order cpu. // an unbuffered resource. If so, it treated like an in-order cpu.
if (hasInstrSchedModel()) { if (hasInstrSchedModel()) {
const MCSchedClassDesc *SCDesc = resolveSchedClass(DefMI); const MCSchedClassDesc *SCDesc = resolveSchedClass(DefMI);
for (const MCWriteProcResEntry *PRI = STI->getWriteProcResBegin(SCDesc), if (SCDesc->isValid()) {
*PRE = STI->getWriteProcResEnd(SCDesc); PRI != PRE; ++PRI) { for (const MCWriteProcResEntry *PRI = STI->getWriteProcResBegin(SCDesc),
if (!SchedModel.getProcResource(PRI->ProcResourceIdx)->IsBuffered) *PRE = STI->getWriteProcResEnd(SCDesc); PRI != PRE; ++PRI) {
return 1; if (!SchedModel.getProcResource(PRI->ProcResourceIdx)->IsBuffered)
return 1;
}
} }
} }
return 0; return 0;