Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 1 | //===--------------------- RetireControlUnitStatistics.cpp ---------------*- C++ |
| 2 | //-*-===// |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 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 |
Andrea Di Biagio | 53e6ade | 2018-03-09 12:50:42 +0000 | [diff] [blame] | 11 | /// |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 12 | /// This file implements the RetireControlUnitStatistics interface. |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 13 | /// |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 16 | #include "RetireControlUnitStatistics.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Format.h" |
| 18 | |
| 19 | using namespace llvm; |
| 20 | |
| 21 | namespace mca { |
| 22 | |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 23 | void RetireControlUnitStatistics::onInstructionEvent( |
| 24 | const HWInstructionEvent &Event) { |
Andrea Di Biagio | 1cc29c0 | 2018-04-11 11:37:46 +0000 | [diff] [blame] | 25 | if (Event.Type == HWInstructionEvent::Retired) |
Clement Courbet | 844f22d | 2018-03-13 13:11:01 +0000 | [diff] [blame] | 26 | ++NumRetired; |
Clement Courbet | 844f22d | 2018-03-13 13:11:01 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 29 | void RetireControlUnitStatistics::printView(llvm::raw_ostream &OS) const { |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 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 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 51 | } // namespace mca |