[PATCH] D46409: [llvm-mca] Add descriptive names for the TimelineView report characters. NFC.

Matt Davis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 3 15:28:42 PDT 2018


mattd created this revision.
mattd added reviewers: andreadb, courbet, RKSimon.
Herald added subscribers: gbedwell, tschuett.

This change makes the TimelineView source simpler to read and easier to modify in the future.
This patch introduces a class of static chars used as the display values in the TimelineView report, this change just eliminates a few magic characters.


https://reviews.llvm.org/D46409

Files:
  tools/llvm-mca/TimelineView.cpp
  tools/llvm-mca/TimelineView.h


Index: tools/llvm-mca/TimelineView.h
===================================================================
--- tools/llvm-mca/TimelineView.h
+++ tools/llvm-mca/TimelineView.h
@@ -152,6 +152,16 @@
 
   void initialize(unsigned MaxIterations);
 
+  // Display characters for the TimelineView report output.
+  struct DisplayChar {
+    static const char Dispatched = 'D';
+    static const char Executed = 'E';
+    static const char Retired = 'R';
+    static const char Waiting = '='; // Instruction is waiting in the scheduler.
+    static const char Executing = 'e';
+    static const char RetireLag = '-'; // The instruction is waiting to retire.
+  };
+
 public:
   TimelineView(const llvm::MCSubtargetInfo &sti, llvm::MCInstPrinter &Printer,
                const SourceMgr &Sequence, unsigned MaxIterations,
Index: tools/llvm-mca/TimelineView.cpp
===================================================================
--- tools/llvm-mca/TimelineView.cpp
+++ tools/llvm-mca/TimelineView.cpp
@@ -153,28 +153,28 @@
   OS << '[' << Iteration << ',' << SourceIndex << "]\t";
   for (unsigned I = 0, E = Entry.CycleDispatched; I < E; ++I)
     OS << ((I % 5 == 0) ? '.' : ' ');
-  OS << 'D';
+  OS << TimelineView::DisplayChar::Dispatched;
   if (Entry.CycleDispatched != Entry.CycleExecuted) {
     // Zero latency instructions have the same value for CycleDispatched,
     // CycleIssued and CycleExecuted.
     for (unsigned I = Entry.CycleDispatched + 1, E = Entry.CycleIssued; I < E;
          ++I)
-      OS << '=';
+      OS << TimelineView::DisplayChar::Waiting;
     if (Entry.CycleIssued == Entry.CycleExecuted)
-      OS << 'E';
+      OS << TimelineView::DisplayChar::DisplayChar::Executed;
     else {
       if (Entry.CycleDispatched != Entry.CycleIssued)
-        OS << 'e';
+        OS << TimelineView::DisplayChar::Executing;
       for (unsigned I = Entry.CycleIssued + 1, E = Entry.CycleExecuted; I < E;
            ++I)
-        OS << 'e';
-      OS << 'E';
+        OS << TimelineView::DisplayChar::Executing;
+      OS << TimelineView::DisplayChar::Executed;
     }
   }
 
   for (unsigned I = Entry.CycleExecuted + 1, E = Entry.CycleRetired; I < E; ++I)
-    OS << '-';
-  OS << 'R';
+    OS << TimelineView::DisplayChar::RetireLag;
+  OS << TimelineView::DisplayChar::Retired;
 
   // Skip other columns.
   for (unsigned I = Entry.CycleRetired + 1, E = LastCycle; I <= E; ++I)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46409.145108.patch
Type: text/x-patch
Size: 2397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180503/b2dacadb/attachment.bin>


More information about the llvm-commits mailing list