1 //===--------------------- RegisterFileStatistics.h -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This view collects and prints register file usage statistics.
13 /// Example (-mcpu=btver2):
14 /// ========================
16 /// Register File statistics:
17 /// Total number of mappings created: 6
18 /// Max number of mappings used: 3
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
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
34 //===----------------------------------------------------------------------===//
36 #ifndef LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
37 #define LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
39 #include "Views/View.h"
40 #include "llvm/ADT/SmallVector.h"
41 #include "llvm/MC/MCSubtargetInfo.h"
46 class RegisterFileStatistics : public View {
47 const llvm::MCSubtargetInfo &STI;
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;
56 struct MoveEliminationInfo {
57 unsigned TotalMoveEliminationCandidates;
58 unsigned TotalMovesEliminated;
59 unsigned TotalMovesThatPropagateZero;
60 unsigned MaxMovesEliminatedPerCycle;
61 unsigned CurrentMovesEliminated;
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;
68 void updateRegisterFileUsage(ArrayRef<unsigned> UsedPhysRegs);
69 void updateMoveElimInfo(const Instruction &Inst);
72 RegisterFileStatistics(const llvm::MCSubtargetInfo &sti);
74 void onCycleEnd() override;
75 void onEvent(const HWInstructionEvent &Event) override;
76 void printView(llvm::raw_ostream &OS) const override;