[llvm-exegesis] Implements a cache of Instruction objects.
[llvm-core.git] / tools / llvm-mca / Views / RegisterFileStatistics.h
blob1e89d66dc50e87427085f82166fed0589149399c
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 ///
25 /// * Register File #2 -- IntegerPRF:
26 /// Number of physical registers: 64
27 /// Total number of mappings created: 6
28 /// Max number of mappings used: 3
30 //===----------------------------------------------------------------------===//
32 #ifndef LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
33 #define LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H
35 #include "Views/View.h"
36 #include "llvm/ADT/SmallVector.h"
37 #include "llvm/MC/MCSubtargetInfo.h"
39 namespace mca {
41 class RegisterFileStatistics : public View {
42 const llvm::MCSubtargetInfo &STI;
44 // Used to track the number of physical registers used in a register file.
45 struct RegisterFileUsage {
46 unsigned TotalMappings;
47 unsigned MaxUsedMappings;
48 unsigned CurrentlyUsedMappings;
51 // There is one entry for each register file implemented by the processor.
52 llvm::SmallVector<RegisterFileUsage, 4> RegisterFiles;
54 public:
55 RegisterFileStatistics(const llvm::MCSubtargetInfo &sti);
57 void onEvent(const HWInstructionEvent &Event) override;
58 void printView(llvm::raw_ostream &OS) const override;
60 } // namespace mca
62 #endif