[llvm-mca] Move the logic that prints scheduler statistics from BackendStatistics to its own view.

Added flag -scheduler-stats to print scheduler related statistics.

llvm-svn: 329792
diff --git a/llvm/tools/llvm-mca/BackendStatistics.cpp b/llvm/tools/llvm-mca/BackendStatistics.cpp
index c189a3a..4e378b1 100644
--- a/llvm/tools/llvm-mca/BackendStatistics.cpp
+++ b/llvm/tools/llvm-mca/BackendStatistics.cpp
@@ -21,42 +21,11 @@
 namespace mca {
 
 void BackendStatistics::onInstructionEvent(const HWInstructionEvent &Event) {
-  switch (Event.Type) {
-  default:
-    break;
-  case HWInstructionEvent::Retired: {
+  if (Event.Type == HWInstructionEvent::Retired)
     ++NumRetired;
-    break;
-  }
-  case HWInstructionEvent::Issued:
-    ++NumIssued;
-  }
 }
 
-void BackendStatistics::onReservedBuffers(ArrayRef<unsigned> Buffers) {
-  for (const unsigned Buffer : Buffers) {
-    if (BufferedResources.find(Buffer) != BufferedResources.end()) {
-      BufferUsage &BU = BufferedResources[Buffer];
-      BU.SlotsInUse++;
-      BU.MaxUsedSlots = std::max(BU.MaxUsedSlots, BU.SlotsInUse);
-      continue;
-    }
-
-    BufferedResources.insert(
-        std::pair<unsigned, BufferUsage>(Buffer, {1U, 1U}));
-  }
-}
-
-void BackendStatistics::onReleasedBuffers(ArrayRef<unsigned> Buffers) {
-  for (const unsigned Buffer : Buffers) {
-    assert(BufferedResources.find(Buffer) != BufferedResources.end() &&
-           "Buffered resource not in map?");
-    BufferUsage &BU = BufferedResources[Buffer];
-    BU.SlotsInUse--;
-  }
-}
-
-void BackendStatistics::printRetireUnitStatistics(llvm::raw_ostream &OS) const {
+void BackendStatistics::printView(llvm::raw_ostream &OS) const {
   std::string Buffer;
   raw_string_ostream TempStream(Buffer);
   TempStream << "\n\nRetire Control Unit - "
@@ -78,46 +47,4 @@
   OS << Buffer;
 }
 
-void BackendStatistics::printSchedulerStatistics(llvm::raw_ostream &OS) const {
-  std::string Buffer;
-  raw_string_ostream TempStream(Buffer);
-  TempStream << "\n\nSchedulers - number of cycles where we saw N instructions "
-                "issued:\n";
-  TempStream << "[# issued], [# cycles]\n";
-  for (const std::pair<unsigned, unsigned> &Entry : IssuedPerCycle) {
-    TempStream << " " << Entry.first << ",          " << Entry.second << "  ("
-               << format("%.1f", ((double)Entry.second / NumCycles) * 100)
-               << "%)\n";
-  }
-
-  TempStream.flush();
-  OS << Buffer;
-}
-
-void BackendStatistics::printSchedulerUsage(raw_ostream &OS,
-                                            const MCSchedModel &SM) const {
-  std::string Buffer;
-  raw_string_ostream TempStream(Buffer);
-  TempStream << "\n\nScheduler's queue usage:\n";
-  // Early exit if no buffered resources were consumed.
-  if (BufferedResources.empty()) {
-    TempStream << "No scheduler resources used.\n";
-    TempStream.flush();
-    OS << Buffer;
-    return;
-  }
-
-  for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) {
-    const MCProcResourceDesc &ProcResource = *SM.getProcResource(I);
-    if (ProcResource.BufferSize <= 0)
-      continue;
-
-    const BufferUsage &BU = BufferedResources.lookup(I);
-    TempStream << ProcResource.Name << ",  " << BU.MaxUsedSlots << '/'
-               << ProcResource.BufferSize << '\n';
-  }
-
-  TempStream.flush();
-  OS << Buffer;
-}
 } // namespace mca