Path: blob/main/contrib/llvm-project/llvm/tools/llvm-mca/Views/RegisterFileStatistics.h
96353 views
//===--------------------- RegisterFileStatistics.h -------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7/// \file8///9/// This view collects and prints register file usage statistics.10///11/// Example (-mcpu=btver2):12/// ========================13///14/// Register File statistics:15/// Total number of mappings created: 616/// Max number of mappings used: 317///18/// * Register File #1 -- FpuPRF:19/// Number of physical registers: 7220/// Total number of mappings created: 021/// Max number of mappings used: 022/// Number of optimizable moves: 20023/// Number of moves eliminated: 200 (100.0%)24/// Number of zero moves: 200 (100.0%)25/// Max moves eliminated per cycle: 226///27/// * Register File #2 -- IntegerPRF:28/// Number of physical registers: 6429/// Total number of mappings created: 630/// Max number of mappings used: 331//32//===----------------------------------------------------------------------===//3334#ifndef LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H35#define LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H3637#include "llvm/ADT/SmallVector.h"38#include "llvm/MC/MCSubtargetInfo.h"39#include "llvm/MCA/View.h"4041namespace llvm {42namespace mca {4344class RegisterFileStatistics : public View {45const llvm::MCSubtargetInfo &STI;4647// Used to track the number of physical registers used in a register file.48struct RegisterFileUsage {49unsigned TotalMappings;50unsigned MaxUsedMappings;51unsigned CurrentlyUsedMappings;52};5354struct MoveEliminationInfo {55unsigned TotalMoveEliminationCandidates;56unsigned TotalMovesEliminated;57unsigned TotalMovesThatPropagateZero;58unsigned MaxMovesEliminatedPerCycle;59unsigned CurrentMovesEliminated;60};6162// There is one entry for each register file implemented by the processor.63llvm::SmallVector<RegisterFileUsage, 4> PRFUsage;64llvm::SmallVector<MoveEliminationInfo, 4> MoveElimInfo;6566void updateRegisterFileUsage(ArrayRef<unsigned> UsedPhysRegs);67void updateMoveElimInfo(const Instruction &Inst);6869public:70RegisterFileStatistics(const llvm::MCSubtargetInfo &sti);7172void onCycleEnd() override;73void onEvent(const HWInstructionEvent &Event) override;74void printView(llvm::raw_ostream &OS) const override;75StringRef getNameAsString() const override {76return "RegisterFileStatistics";77}78bool isSerializable() const override { return false; }79};80} // namespace mca81} // namespace llvm8283#endif848586