1//===--------------------- RetireControlUnitStatistics.h --------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9///
10/// This file defines class RetireControlUnitStatistics: a view that knows how
11/// to print general statistics related to the retire control unit.
12///
13/// Example:
14/// ========
15///
16/// Retire Control Unit - number of cycles where we saw N instructions retired:
17/// [# retired], [# cycles]
18/// 0, 109 (17.9%)
19/// 1, 102 (16.7%)
20/// 2, 399 (65.4%)
21///
22/// Total ROB Entries: 64
23/// Max Used ROB Entries: 35 ( 54.7% )
24/// Average Used ROB Entries per cy: 32 ( 50.0% )
25///
26//===----------------------------------------------------------------------===//
27
28#ifndef LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
29#define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
30
31#include "llvm/MC/MCSchedule.h"
32#include "llvm/MCA/View.h"
33#include <map>
34
35namespace llvm {
36namespace mca {
37
38class RetireControlUnitStatistics : public View {
39 using Histogram = std::map<unsigned, unsigned>;
40 Histogram RetiredPerCycle;
41
42 unsigned NumRetired;
43 unsigned NumCycles;
44 unsigned TotalROBEntries;
45 unsigned EntriesInUse;
46 unsigned MaxUsedEntries;
47 unsigned SumOfUsedEntries;
48
49public:
50 RetireControlUnitStatistics(const MCSchedModel &SM);
51
52 void onEvent(const HWInstructionEvent &Event) override;
53 void onCycleEnd() override;
54 void printView(llvm::raw_ostream &OS) const override;
55 StringRef getNameAsString() const override {
56 return "RetireControlUnitStatistics";
57 }
58 bool isSerializable() const override { return false; }
59};
60
61} // namespace mca
62} // namespace llvm
63
64#endif
65