OSDN Git Service

[llvm-mca] Remove unused flag -verbose. NFC
[android-x86/external-llvm.git] / tools / llvm-mca / RetireControlUnitStatistics.cpp
1 //===--------------------- RetireControlUnitStatistics.cpp ---------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 /// \file
11 ///
12 /// This file implements the RetireControlUnitStatistics interface.
13 ///
14 //===----------------------------------------------------------------------===//
15
16 #include "RetireControlUnitStatistics.h"
17 #include "llvm/Support/Format.h"
18
19 using namespace llvm;
20
21 namespace mca {
22
23 void RetireControlUnitStatistics::onInstructionEvent(
24     const HWInstructionEvent &Event) {
25   if (Event.Type == HWInstructionEvent::Retired)
26     ++NumRetired;
27 }
28
29 void RetireControlUnitStatistics::printView(llvm::raw_ostream &OS) const {
30   std::string Buffer;
31   raw_string_ostream TempStream(Buffer);
32   TempStream << "\n\nRetire Control Unit - "
33              << "number of cycles where we saw N instructions retired:\n";
34   TempStream << "[# retired], [# cycles]\n";
35
36   for (const std::pair<unsigned, unsigned> &Entry : RetiredPerCycle) {
37     TempStream << " " << Entry.first;
38     if (Entry.first < 10)
39       TempStream << ",           ";
40     else
41       TempStream << ",          ";
42     TempStream << Entry.second << "  ("
43                << format("%.1f", ((double)Entry.second / NumCycles) * 100.0)
44                << "%)\n";
45   }
46
47   TempStream.flush();
48   OS << Buffer;
49 }
50
51 } // namespace mca