1*0b57cec5SDimitry Andric //===--------------------- RegisterFileStatistics.h -------------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric /// \file 9*0b57cec5SDimitry Andric /// 10*0b57cec5SDimitry Andric /// This view collects and prints register file usage statistics. 11*0b57cec5SDimitry Andric /// 12*0b57cec5SDimitry Andric /// Example (-mcpu=btver2): 13*0b57cec5SDimitry Andric /// ======================== 14*0b57cec5SDimitry Andric /// 15*0b57cec5SDimitry Andric /// Register File statistics: 16*0b57cec5SDimitry Andric /// Total number of mappings created: 6 17*0b57cec5SDimitry Andric /// Max number of mappings used: 3 18*0b57cec5SDimitry Andric /// 19*0b57cec5SDimitry Andric /// * Register File #1 -- FpuPRF: 20*0b57cec5SDimitry Andric /// Number of physical registers: 72 21*0b57cec5SDimitry Andric /// Total number of mappings created: 0 22*0b57cec5SDimitry Andric /// Max number of mappings used: 0 23*0b57cec5SDimitry Andric /// Number of optimizable moves: 200 24*0b57cec5SDimitry Andric /// Number of moves eliminated: 200 (100.0%) 25*0b57cec5SDimitry Andric /// Number of zero moves: 200 (100.0%) 26*0b57cec5SDimitry Andric /// Max moves eliminated per cycle: 2 27*0b57cec5SDimitry Andric /// 28*0b57cec5SDimitry Andric /// * Register File #2 -- IntegerPRF: 29*0b57cec5SDimitry Andric /// Number of physical registers: 64 30*0b57cec5SDimitry Andric /// Total number of mappings created: 6 31*0b57cec5SDimitry Andric /// Max number of mappings used: 3 32*0b57cec5SDimitry Andric // 33*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 34*0b57cec5SDimitry Andric 35*0b57cec5SDimitry Andric #ifndef LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H 36*0b57cec5SDimitry Andric #define LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H 37*0b57cec5SDimitry Andric 38*0b57cec5SDimitry Andric #include "Views/View.h" 39*0b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h" 40*0b57cec5SDimitry Andric #include "llvm/MC/MCSubtargetInfo.h" 41*0b57cec5SDimitry Andric 42*0b57cec5SDimitry Andric namespace llvm { 43*0b57cec5SDimitry Andric namespace mca { 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andric class RegisterFileStatistics : public View { 46*0b57cec5SDimitry Andric const llvm::MCSubtargetInfo &STI; 47*0b57cec5SDimitry Andric 48*0b57cec5SDimitry Andric // Used to track the number of physical registers used in a register file. 49*0b57cec5SDimitry Andric struct RegisterFileUsage { 50*0b57cec5SDimitry Andric unsigned TotalMappings; 51*0b57cec5SDimitry Andric unsigned MaxUsedMappings; 52*0b57cec5SDimitry Andric unsigned CurrentlyUsedMappings; 53*0b57cec5SDimitry Andric }; 54*0b57cec5SDimitry Andric 55*0b57cec5SDimitry Andric struct MoveEliminationInfo { 56*0b57cec5SDimitry Andric unsigned TotalMoveEliminationCandidates; 57*0b57cec5SDimitry Andric unsigned TotalMovesEliminated; 58*0b57cec5SDimitry Andric unsigned TotalMovesThatPropagateZero; 59*0b57cec5SDimitry Andric unsigned MaxMovesEliminatedPerCycle; 60*0b57cec5SDimitry Andric unsigned CurrentMovesEliminated; 61*0b57cec5SDimitry Andric }; 62*0b57cec5SDimitry Andric 63*0b57cec5SDimitry Andric // There is one entry for each register file implemented by the processor. 64*0b57cec5SDimitry Andric llvm::SmallVector<RegisterFileUsage, 4> PRFUsage; 65*0b57cec5SDimitry Andric llvm::SmallVector<MoveEliminationInfo, 4> MoveElimInfo; 66*0b57cec5SDimitry Andric 67*0b57cec5SDimitry Andric void updateRegisterFileUsage(ArrayRef<unsigned> UsedPhysRegs); 68*0b57cec5SDimitry Andric void updateMoveElimInfo(const Instruction &Inst); 69*0b57cec5SDimitry Andric 70*0b57cec5SDimitry Andric public: 71*0b57cec5SDimitry Andric RegisterFileStatistics(const llvm::MCSubtargetInfo &sti); 72*0b57cec5SDimitry Andric 73*0b57cec5SDimitry Andric void onCycleEnd() override; 74*0b57cec5SDimitry Andric void onEvent(const HWInstructionEvent &Event) override; 75*0b57cec5SDimitry Andric void printView(llvm::raw_ostream &OS) const override; 76*0b57cec5SDimitry Andric }; 77*0b57cec5SDimitry Andric } // namespace mca 78*0b57cec5SDimitry Andric } // namespace llvm 79*0b57cec5SDimitry Andric 80*0b57cec5SDimitry Andric #endif 81