1 //===--------------------- RegisterFileStatistics.h -------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 /// This view collects and prints register file usage statistics.
12 /// Example (-mcpu=btver2):
13 /// ========================
15 /// Register File statistics:
16 /// Total number of mappings created: 6
17 /// Max number of mappings used: 3
19 /// * Register File #1 -- FpuPRF:
20 /// Number of physical registers: 72
21 /// Total number of mappings created: 0
22 /// Max number of mappings used: 0
23 /// Number of optimizable moves: 200
24 /// Number of moves eliminated: 200 (100.0%)
25 /// Number of zero moves: 200 (100.0%)
26 /// Max moves eliminated per cycle: 2
28 /// * Register File #2 -- IntegerPRF:
29 /// Number of physical registers: 64
30 /// Total number of mappings created: 6
31 /// Max number of mappings used: 3
33 //===----------------------------------------------------------------------===//
35 #ifndef LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
36 #define LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
38 #include "Views/View.h"
39 #include "llvm/ADT/SmallVector.h"
40 #include "llvm/MC/MCSubtargetInfo.h"
45 class RegisterFileStatistics
: public View
{
46 const llvm::MCSubtargetInfo
&STI
;
48 // Used to track the number of physical registers used in a register file.
49 struct RegisterFileUsage
{
50 unsigned TotalMappings
;
51 unsigned MaxUsedMappings
;
52 unsigned CurrentlyUsedMappings
;
55 struct MoveEliminationInfo
{
56 unsigned TotalMoveEliminationCandidates
;
57 unsigned TotalMovesEliminated
;
58 unsigned TotalMovesThatPropagateZero
;
59 unsigned MaxMovesEliminatedPerCycle
;
60 unsigned CurrentMovesEliminated
;
63 // There is one entry for each register file implemented by the processor.
64 llvm::SmallVector
<RegisterFileUsage
, 4> PRFUsage
;
65 llvm::SmallVector
<MoveEliminationInfo
, 4> MoveElimInfo
;
67 void updateRegisterFileUsage(ArrayRef
<unsigned> UsedPhysRegs
);
68 void updateMoveElimInfo(const Instruction
&Inst
);
71 RegisterFileStatistics(const llvm::MCSubtargetInfo
&sti
);
73 void onCycleEnd() override
;
74 void onEvent(const HWInstructionEvent
&Event
) override
;
75 void printView(llvm::raw_ostream
&OS
) const override
;