summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TargetSchedule.cpp12
-rw-r--r--llvm/lib/CodeGen/TargetSubtargetInfo.cpp12
-rw-r--r--llvm/lib/MC/MCSchedule.cpp26
3 files changed, 31 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/TargetSchedule.cpp b/llvm/lib/CodeGen/TargetSchedule.cpp
index 2709df5697b..3cff31ad493 100644
--- a/llvm/lib/CodeGen/TargetSchedule.cpp
+++ b/llvm/lib/CodeGen/TargetSchedule.cpp
@@ -322,7 +322,7 @@ computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx,
return 0;
}
-Optional<double>
+double
TargetSchedModel::computeReciprocalThroughput(const MachineInstr *MI) const {
if (hasInstrItineraries()) {
unsigned SchedClass = MI->getDesc().getSchedClass();
@@ -332,10 +332,11 @@ TargetSchedModel::computeReciprocalThroughput(const MachineInstr *MI) const {
if (hasInstrSchedModel())
return MCSchedModel::getReciprocalThroughput(*STI, *resolveSchedClass(MI));
- return Optional<double>();
+
+ return 0.0;
}
-Optional<double>
+double
TargetSchedModel::computeReciprocalThroughput(unsigned Opcode) const {
unsigned SchedClass = TII->get(Opcode).getSchedClass();
if (hasInstrItineraries())
@@ -346,10 +347,11 @@ TargetSchedModel::computeReciprocalThroughput(unsigned Opcode) const {
if (SCDesc.isValid() && !SCDesc.isVariant())
return MCSchedModel::getReciprocalThroughput(*STI, SCDesc);
}
- return Optional<double>();
+
+ return 0.0;
}
-Optional<double>
+double
TargetSchedModel::computeReciprocalThroughput(const MCInst &MI) const {
if (hasInstrSchedModel())
return SchedModel.getReciprocalThroughput(*STI, *TII, MI);
diff --git a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp
index 97ca707a738..fa29c05fd6c 100644
--- a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp
+++ b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp
@@ -67,13 +67,12 @@ bool TargetSubtargetInfo::useAA() const {
return false;
}
-static std::string createSchedInfoStr(unsigned Latency,
- Optional<double> RThroughput) {
+static std::string createSchedInfoStr(unsigned Latency, double RThroughput) {
static const char *SchedPrefix = " sched: [";
std::string Comment;
raw_string_ostream CS(Comment);
- if (RThroughput.hasValue())
- CS << SchedPrefix << Latency << format(":%2.2f", RThroughput.getValue())
+ if (RThroughput != 0.0)
+ CS << SchedPrefix << Latency << format(":%2.2f", RThroughput)
<< "]";
else
CS << SchedPrefix << Latency << ":?]";
@@ -90,7 +89,7 @@ std::string TargetSubtargetInfo::getSchedInfoStr(const MachineInstr &MI) const {
TargetSchedModel TSchedModel;
TSchedModel.init(this);
unsigned Latency = TSchedModel.computeInstrLatency(&MI);
- Optional<double> RThroughput = TSchedModel.computeReciprocalThroughput(&MI);
+ double RThroughput = TSchedModel.computeReciprocalThroughput(&MI);
return createSchedInfoStr(Latency, RThroughput);
}
@@ -109,8 +108,7 @@ std::string TargetSubtargetInfo::getSchedInfoStr(MCInst const &MCI) const {
getInstrInfo()->get(MCI.getOpcode()).getSchedClass());
} else
return std::string();
- Optional<double> RThroughput =
- TSchedModel.computeReciprocalThroughput(MCI);
+ double RThroughput = TSchedModel.computeReciprocalThroughput(MCI);
return createSchedInfoStr(Latency, RThroughput);
}
diff --git a/llvm/lib/MC/MCSchedule.cpp b/llvm/lib/MC/MCSchedule.cpp
index e3fa76ee03c..929bd7f6046 100644
--- a/llvm/lib/MC/MCSchedule.cpp
+++ b/llvm/lib/MC/MCSchedule.cpp
@@ -85,7 +85,7 @@ int MCSchedModel::computeInstrLatency(const MCSubtargetInfo &STI,
llvm_unreachable("unsupported variant scheduling class");
}
-Optional<double>
+double
MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI,
const MCSchedClassDesc &SCDesc) {
Optional<double> Throughput;
@@ -99,18 +99,25 @@ MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI,
double Temp = NumUnits * 1.0 / I->Cycles;
Throughput = Throughput ? std::min(Throughput.getValue(), Temp) : Temp;
}
- return Throughput ? 1 / Throughput.getValue() : Throughput;
+ if (Throughput.hasValue())
+ return 1.0 / Throughput.getValue();
+
+ // If no throughput value was calculated, assume that we can execute at the
+ // maximum issue width scaled by number of micro-ops for the schedule class.
+ return ((double)SCDesc.NumMicroOps) / SM.IssueWidth;
}
-Optional<double>
+double
MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI,
const MCInstrInfo &MCII,
const MCInst &Inst) const {
- Optional<double> Throughput;
unsigned SchedClass = MCII.get(Inst.getOpcode()).getSchedClass();
const MCSchedClassDesc *SCDesc = getSchedClassDesc(SchedClass);
+
+ // If there's no valid class, assume that the instruction executes/completes
+ // at the maximum issue width.
if (!SCDesc->isValid())
- return Throughput;
+ return 1.0 / IssueWidth;
unsigned CPUID = getProcessorID();
while (SCDesc->isVariant()) {
@@ -124,7 +131,7 @@ MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI,
llvm_unreachable("unsupported variant scheduling class");
}
-Optional<double>
+double
MCSchedModel::getReciprocalThroughput(unsigned SchedClass,
const InstrItineraryData &IID) {
Optional<double> Throughput;
@@ -136,5 +143,10 @@ MCSchedModel::getReciprocalThroughput(unsigned SchedClass,
double Temp = countPopulation(I->getUnits()) * 1.0 / I->getCycles();
Throughput = Throughput ? std::min(Throughput.getValue(), Temp) : Temp;
}
- return Throughput ? 1 / Throughput.getValue() : Throughput;
+ if (Throughput.hasValue())
+ return 1.0 / Throughput.getValue();
+
+ // If there are no execution resources specified for this class, then assume
+ // that it can execute at the maximum default issue width.
+ return 1.0 / DefaultIssueWidth;
}
OpenPOWER on IntegriCloud