[llvm] r329711 - [llvm-mca] Simplify code. NFC
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 10 08:14:15 PDT 2018
Author: adibiagio
Date: Tue Apr 10 08:14:15 2018
New Revision: 329711
URL: http://llvm.org/viewvc/llvm-project?rev=329711&view=rev
Log:
[llvm-mca] Simplify code. NFC
Modified:
llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp
Modified: llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp?rev=329711&r1=329710&r2=329711&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp (original)
+++ llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp Tue Apr 10 08:14:15 2018
@@ -83,6 +83,22 @@ static void printColumnNames(raw_string_
}
}
+static void printResourcePressure(raw_string_ostream &OS, double Pressure) {
+ if (!Pressure) {
+ OS << " - ";
+ return;
+ }
+
+ // Round to the value to the nearest hundredth and then print it.
+ OS << format("%.2f", floor((Pressure * 100) + 0.5)/100);
+ if (Pressure < 10.0)
+ OS << " ";
+ else if (Pressure < 100.0)
+ OS << " ";
+ else
+ OS << ' ';
+}
+
void ResourcePressureView::printResourcePressurePerIteration(
raw_ostream &OS, unsigned Executions) const {
std::string Buffer;
@@ -114,20 +130,7 @@ void ResourcePressureView::printResource
for (unsigned I = 0, E = NumResourceUnits; I < E; ++I) {
double Usage = ResourceUsage[I + Source.size() * E];
- if (!Usage) {
- TempStream << " - ";
- continue;
- }
-
- double Pressure = Usage / Executions;
- // Round to the value to the nearest hundredth and then print it.
- TempStream << format("%.2f", floor((Pressure * 100) + 0.5)/100);
- if (Pressure < 10.0)
- TempStream << " ";
- else if (Pressure < 100.0)
- TempStream << " ";
- else
- TempStream << ' ';
+ printResourcePressure(TempStream, Usage / Executions);
}
TempStream.flush();
@@ -146,22 +149,7 @@ void ResourcePressureView::printResource
for (unsigned I = 0, E = Source.size(); I < E; ++I) {
for (unsigned J = 0; J < NumResourceUnits; ++J) {
double Usage = ResourceUsage[J + I * NumResourceUnits];
- if (!Usage) {
- TempStream << " - ";
- } else {
- double Pressure = Usage / Executions;
- if (Pressure < 0.005) {
- TempStream << " - ";
- } else {
- TempStream << format("%.2f", Pressure);
- if (Pressure < 10.0)
- TempStream << " ";
- else if (Pressure < 100.0)
- TempStream << " ";
- else
- TempStream << ' ';
- }
- }
+ printResourcePressure(TempStream, Usage / Executions);
}
MCIP.printInst(&Source.getMCInstFromIndex(I), TempStream, "", STI);
More information about the llvm-commits
mailing list