xref: /freebsd-src/contrib/llvm-project/llvm/tools/llvm-mca/Views/RetireControlUnitStatistics.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric //===--------------------- RetireControlUnitStatistics.h --------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric /// \file
90b57cec5SDimitry Andric ///
100b57cec5SDimitry Andric /// This file defines class RetireControlUnitStatistics: a view that knows how
110b57cec5SDimitry Andric /// to print general statistics related to the retire control unit.
120b57cec5SDimitry Andric ///
130b57cec5SDimitry Andric /// Example:
140b57cec5SDimitry Andric /// ========
150b57cec5SDimitry Andric ///
160b57cec5SDimitry Andric /// Retire Control Unit - number of cycles where we saw N instructions retired:
170b57cec5SDimitry Andric /// [# retired], [# cycles]
180b57cec5SDimitry Andric ///  0,           109  (17.9%)
190b57cec5SDimitry Andric ///  1,           102  (16.7%)
200b57cec5SDimitry Andric ///  2,           399  (65.4%)
210b57cec5SDimitry Andric ///
220b57cec5SDimitry Andric /// Total ROB Entries:                64
230b57cec5SDimitry Andric /// Max Used ROB Entries:             35  ( 54.7% )
240b57cec5SDimitry Andric /// Average Used ROB Entries per cy:  32  ( 50.0% )
250b57cec5SDimitry Andric ///
260b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric #ifndef LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
290b57cec5SDimitry Andric #define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric #include "llvm/MC/MCSchedule.h"
32*349cc55cSDimitry Andric #include "llvm/MCA/View.h"
330b57cec5SDimitry Andric #include <map>
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric namespace llvm {
360b57cec5SDimitry Andric namespace mca {
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric class RetireControlUnitStatistics : public View {
390b57cec5SDimitry Andric   using Histogram = std::map<unsigned, unsigned>;
400b57cec5SDimitry Andric   Histogram RetiredPerCycle;
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric   unsigned NumRetired;
430b57cec5SDimitry Andric   unsigned NumCycles;
440b57cec5SDimitry Andric   unsigned TotalROBEntries;
450b57cec5SDimitry Andric   unsigned EntriesInUse;
460b57cec5SDimitry Andric   unsigned MaxUsedEntries;
470b57cec5SDimitry Andric   unsigned SumOfUsedEntries;
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric public:
500b57cec5SDimitry Andric   RetireControlUnitStatistics(const MCSchedModel &SM);
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric   void onEvent(const HWInstructionEvent &Event) override;
530b57cec5SDimitry Andric   void onCycleEnd() override;
540b57cec5SDimitry Andric   void printView(llvm::raw_ostream &OS) const override;
getNameAsString()55e8d8bef9SDimitry Andric   StringRef getNameAsString() const override {
56e8d8bef9SDimitry Andric     return "RetireControlUnitStatistics";
57e8d8bef9SDimitry Andric   }
isSerializable()58fe6060f1SDimitry Andric   bool isSerializable() const override { return false; }
590b57cec5SDimitry Andric };
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric } // namespace mca
620b57cec5SDimitry Andric } // namespace llvm
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric #endif
65