brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 3de2a22 Raw
85 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8/// \file9///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:    617/// Max number of mappings used:         318///19/// *  Register File #1 -- FpuPRF:20///    Number of physical registers:     7221///    Total number of mappings created: 022///    Max number of mappings used:      023///    Number of optimizable moves:      20024///    Number of moves eliminated:       200 (100.0%)25///    Number of zero moves:             200 (100.0%)26///    Max moves eliminated per cycle:   227///28/// *  Register File #2 -- IntegerPRF:29///    Number of physical registers:     6430///    Total number of mappings created: 631///    Max number of mappings used:      332//33//===----------------------------------------------------------------------===//34 35#ifndef LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H36#define LLVM_TOOLS_LLVM_MCA_REGISTERFILESTATISTICS_H37 38#include "llvm/ADT/SmallVector.h"39#include "llvm/MC/MCSubtargetInfo.h"40#include "llvm/MCA/View.h"41 42namespace llvm {43namespace mca {44 45class RegisterFileStatistics : public View {46  const llvm::MCSubtargetInfo &STI;47 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;53  };54 55  struct MoveEliminationInfo {56    unsigned TotalMoveEliminationCandidates;57    unsigned TotalMovesEliminated;58    unsigned TotalMovesThatPropagateZero;59    unsigned MaxMovesEliminatedPerCycle;60    unsigned CurrentMovesEliminated;61  };62 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;66 67  void updateRegisterFileUsage(ArrayRef<unsigned> UsedPhysRegs);68  void updateMoveElimInfo(const Instruction &Inst);69 70public:71  RegisterFileStatistics(const llvm::MCSubtargetInfo &sti);72 73  void onCycleEnd() override;74  void onEvent(const HWInstructionEvent &Event) override;75  void printView(llvm::raw_ostream &OS) const override;76  StringRef getNameAsString() const override {77    return "RegisterFileStatistics";78  }79  bool isSerializable() const override { return false; }80};81} // namespace mca82} // namespace llvm83 84#endif85