[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / tools / llvm-mca / Views / RegisterFileStatistics.h
bloba2273dd48b221ccb7c6adc412e41094ae6969dd6
1 //===--------------------- RegisterFileStatistics.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 view collects and prints register file usage statistics.
11 ///
12 /// Example (-mcpu=btver2):
13 /// ========================
14 ///
15 /// Register File statistics:
16 /// Total number of mappings created: 6
17 /// Max number of mappings used: 3
18 ///
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
27 ///
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"
42 namespace llvm {
43 namespace mca {
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);
70 public:
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;
77 } // namespace mca
78 } // namespace llvm
80 #endif