blob: a9a4ac9a33dc68d37fdcb9642b5a7b35a4c3ef9f [file] [log] [blame]
Matt Davis248acf62018-06-14 20:58:54 +00001//===--------------------- RetireControlUnitStatistics.cpp ------*- C++ -*-===//
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9/// \file
Andrea Di Biagio53e6ade2018-03-09 12:50:42 +000010///
Andrea Di Biagiof41ad5c2018-04-11 12:12:53 +000011/// This file implements the RetireControlUnitStatistics interface.
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000012///
13//===----------------------------------------------------------------------===//
14
Matt Davis10aa09f2018-08-24 20:24:53 +000015#include "Views/RetireControlUnitStatistics.h"
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000016#include "llvm/Support/Format.h"
17
18using namespace llvm;
19
20namespace mca {
21
Matt Davis0906a7f2018-07-12 16:56:17 +000022void RetireControlUnitStatistics::onEvent(const HWInstructionEvent &Event) {
Andrea Di Biagio1cc29c02018-04-11 11:37:46 +000023 if (Event.Type == HWInstructionEvent::Retired)
Clement Courbet844f22d2018-03-13 13:11:01 +000024 ++NumRetired;
Clement Courbet844f22d2018-03-13 13:11:01 +000025}
26
Andrea Di Biagiodb158be2018-10-22 16:28:07 +000027void RetireControlUnitStatistics::printView(raw_ostream &OS) const {
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000028 std::string Buffer;
29 raw_string_ostream TempStream(Buffer);
30 TempStream << "\n\nRetire Control Unit - "
31 << "number of cycles where we saw N instructions retired:\n";
32 TempStream << "[# retired], [# cycles]\n";
33
34 for (const std::pair<unsigned, unsigned> &Entry : RetiredPerCycle) {
35 TempStream << " " << Entry.first;
36 if (Entry.first < 10)
37 TempStream << ", ";
38 else
39 TempStream << ", ";
40 TempStream << Entry.second << " ("
41 << format("%.1f", ((double)Entry.second / NumCycles) * 100.0)
42 << "%)\n";
43 }
44
45 TempStream.flush();
46 OS << Buffer;
47}
48
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000049} // namespace mca