summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetSchedule.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-10-09 23:44:32 +0000
committerAndrew Trick <atrick@apple.com>2012-10-09 23:44:32 +0000
commit780fae8cd6bd791d75ded3a8c78938dcd406be88 (patch)
tree680a2fee272f53ca5e0e506ee08bf474237f3778 /llvm/lib/CodeGen/TargetSchedule.cpp
parent3b8085db785f9e17c15cc7088603b36e4fe5f746 (diff)
downloadbcm5719-llvm-780fae8cd6bd791d75ded3a8c78938dcd406be88.tar.gz
bcm5719-llvm-780fae8cd6bd791d75ded3a8c78938dcd406be88.zip
misched: Add computeInstrLatency to TargetSchedModel.
llvm-svn: 165566
Diffstat (limited to 'llvm/lib/CodeGen/TargetSchedule.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetSchedule.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetSchedule.cpp b/llvm/lib/CodeGen/TargetSchedule.cpp
index 6e7cccce421..cf9d059492b 100644
--- a/llvm/lib/CodeGen/TargetSchedule.cpp
+++ b/llvm/lib/CodeGen/TargetSchedule.cpp
@@ -146,6 +146,10 @@ unsigned TargetSchedModel::computeOperandLatency(
unsigned InstrLatency = TII->getInstrLatency(&InstrItins, DefMI);
// 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)
InstrLatency = std::max(InstrLatency,
TII->defaultDefLatency(&SchedModel, DefMI));
@@ -185,3 +189,23 @@ unsigned TargetSchedModel::computeOperandLatency(
#endif
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);
+}
OpenPOWER on IntegriCloud