]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-mca/Views/RegisterFileStatistics.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / llvm-mca / Views / RegisterFileStatistics.h
1 //===--------------------- RegisterFileStatistics.h -------------*- C++ -*-===//
2 //
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
10 ///
11 /// This view collects and prints register file usage statistics.
12 ///
13 /// Example  (-mcpu=btver2):
14 /// ========================
15 ///
16 /// Register File statistics:
17 /// Total number of mappings created:    6
18 /// Max number of mappings used:         3
19 ///
20 /// *  Register File #1 -- FpuPRF:
21 ///    Number of physical registers:     72
22 ///    Total number of mappings created: 0
23 ///    Max number of mappings used:      0
24 ///    Number of optimizable moves:      200
25 ///    Number of moves eliminated:       200 (100.0%)
26 ///    Number of zero moves:             200 (100.0%)
27 ///    Max moves eliminated per cycle:   2
28 ///
29 /// *  Register File #2 -- IntegerPRF:
30 ///    Number of physical registers:     64
31 ///    Total number of mappings created: 6
32 ///    Max number of mappings used:      3
33 //
34 //===----------------------------------------------------------------------===//
35
36 #ifndef LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
37 #define LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
38
39 #include "Views/View.h"
40 #include "llvm/ADT/SmallVector.h"
41 #include "llvm/MC/MCSubtargetInfo.h"
42
43 namespace llvm {
44 namespace mca {
45
46 class RegisterFileStatistics : public View {
47   const llvm::MCSubtargetInfo &STI;
48
49   // Used to track the number of physical registers used in a register file.
50   struct RegisterFileUsage {
51     unsigned TotalMappings;
52     unsigned MaxUsedMappings;
53     unsigned CurrentlyUsedMappings;
54   };
55
56   struct MoveEliminationInfo {
57     unsigned TotalMoveEliminationCandidates;
58     unsigned TotalMovesEliminated;
59     unsigned TotalMovesThatPropagateZero;
60     unsigned MaxMovesEliminatedPerCycle;
61     unsigned CurrentMovesEliminated;
62   };
63
64   // There is one entry for each register file implemented by the processor.
65   llvm::SmallVector<RegisterFileUsage, 4> PRFUsage;
66   llvm::SmallVector<MoveEliminationInfo, 4> MoveElimInfo;
67
68   void updateRegisterFileUsage(ArrayRef<unsigned> UsedPhysRegs);
69   void updateMoveElimInfo(const Instruction &Inst);
70
71 public:
72   RegisterFileStatistics(const llvm::MCSubtargetInfo &sti);
73
74   void onCycleEnd() override;
75   void onEvent(const HWInstructionEvent &Event) override;
76   void printView(llvm::raw_ostream &OS) const override;
77 };
78 } // namespace mca
79 } // namespace llvm
80
81 #endif