From 21595f4d2b38e435d566db12b903904694915255 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Thu, 25 Oct 2018 11:51:34 +0000 Subject: [PATCH] [llvm-mca] Removed a couple of redundant method declarations, and simplified code in ResourcePressureView. NFC llvm-svn: 345259 --- tools/llvm-mca/Views/ResourcePressureView.cpp | 13 ++++++++----- tools/llvm-mca/Views/ResourcePressureView.h | 19 +++++-------------- .../Views/RetireControlUnitStatistics.h | 2 -- tools/llvm-mca/Views/SchedulerStatistics.h | 2 -- tools/llvm-mca/Views/SummaryView.h | 1 - tools/llvm-mca/include/InstrBuilder.h | 16 ++-------------- tools/llvm-mca/lib/InstrBuilder.cpp | 8 ++++++++ 7 files changed, 23 insertions(+), 38 deletions(-) diff --git a/tools/llvm-mca/Views/ResourcePressureView.cpp b/tools/llvm-mca/Views/ResourcePressureView.cpp index 17c801259d9..e71825b07c7 100644 --- a/tools/llvm-mca/Views/ResourcePressureView.cpp +++ b/tools/llvm-mca/Views/ResourcePressureView.cpp @@ -20,7 +20,10 @@ namespace mca { using namespace llvm; -void ResourcePressureView::initialize() { +ResourcePressureView::ResourcePressureView(const llvm::MCSubtargetInfo &sti, + llvm::MCInstPrinter &Printer, + const SourceMgr &Sequence) + : STI(sti), MCIP(Printer), Source(Sequence) { // Populate the map of resource descriptors. unsigned R2VIndex = 0; const MCSchedModel &SM = STI.getSchedModel(); @@ -92,8 +95,7 @@ static void printResourcePressure(formatted_raw_ostream &OS, double Pressure, OS.PadToColumn(Col); } -void ResourcePressureView::printResourcePressurePerIteration( - raw_ostream &OS, unsigned Executions) const { +void ResourcePressureView::printResourcePressurePerIter(raw_ostream &OS) const { std::string Buffer; raw_string_ostream TempStream(Buffer); formatted_raw_ostream FOS(TempStream); @@ -126,6 +128,7 @@ void ResourcePressureView::printResourcePressurePerIteration( FOS << '\n'; FOS.flush(); + const unsigned Executions = Source.getNumIterations(); for (unsigned I = 0, E = NumResourceUnits; I < E; ++I) { double Usage = ResourceUsage[I + Source.size() * E]; printResourcePressure(FOS, Usage / Executions, (I + 1) * 7); @@ -135,8 +138,7 @@ void ResourcePressureView::printResourcePressurePerIteration( OS << Buffer; } -void ResourcePressureView::printResourcePressurePerInstruction( - raw_ostream &OS, unsigned Executions) const { +void ResourcePressureView::printResourcePressurePerInst(raw_ostream &OS) const { std::string Buffer; raw_string_ostream TempStream(Buffer); formatted_raw_ostream FOS(TempStream); @@ -149,6 +151,7 @@ void ResourcePressureView::printResourcePressurePerInstruction( raw_string_ostream InstrStream(Instruction); unsigned InstrIndex = 0; + const unsigned Executions = Source.getNumIterations(); for (const MCInst &MCI : Source) { unsigned BaseEltIdx = InstrIndex * NumResourceUnits; for (unsigned J = 0; J < NumResourceUnits; ++J) { diff --git a/tools/llvm-mca/Views/ResourcePressureView.h b/tools/llvm-mca/Views/ResourcePressureView.h index ad9c29a55e5..d413bcd80fd 100644 --- a/tools/llvm-mca/Views/ResourcePressureView.h +++ b/tools/llvm-mca/Views/ResourcePressureView.h @@ -82,26 +82,17 @@ class ResourcePressureView : public View { std::vector ResourceUsage; unsigned NumResourceUnits; - const llvm::MCInst &GetMCInstFromIndex(unsigned Index) const; - void printResourcePressurePerIteration(llvm::raw_ostream &OS, - unsigned Executions) const; - void printResourcePressurePerInstruction(llvm::raw_ostream &OS, - unsigned Executions) const; - void initialize(); + void printResourcePressurePerIter(llvm::raw_ostream &OS) const; + void printResourcePressurePerInst(llvm::raw_ostream &OS) const; public: ResourcePressureView(const llvm::MCSubtargetInfo &sti, - llvm::MCInstPrinter &Printer, const SourceMgr &SM) - : STI(sti), MCIP(Printer), Source(SM) { - initialize(); - } + llvm::MCInstPrinter &Printer, const SourceMgr &SM); void onEvent(const HWInstructionEvent &Event) override; - void printView(llvm::raw_ostream &OS) const override { - unsigned Executions = Source.getNumIterations(); - printResourcePressurePerIteration(OS, Executions); - printResourcePressurePerInstruction(OS, Executions); + printResourcePressurePerIter(OS); + printResourcePressurePerInst(OS); } }; } // namespace mca diff --git a/tools/llvm-mca/Views/RetireControlUnitStatistics.h b/tools/llvm-mca/Views/RetireControlUnitStatistics.h index 0531e389c90..e9be542a786 100644 --- a/tools/llvm-mca/Views/RetireControlUnitStatistics.h +++ b/tools/llvm-mca/Views/RetireControlUnitStatistics.h @@ -48,9 +48,7 @@ public: RetireControlUnitStatistics() : NumRetired(0), NumCycles(0) {} void onEvent(const HWInstructionEvent &Event) override; - void onCycleBegin() override { NumCycles++; } - void onCycleEnd() override { updateHistograms(); } void printView(llvm::raw_ostream &OS) const override; diff --git a/tools/llvm-mca/Views/SchedulerStatistics.h b/tools/llvm-mca/Views/SchedulerStatistics.h index de70db26ed4..3515546f083 100644 --- a/tools/llvm-mca/Views/SchedulerStatistics.h +++ b/tools/llvm-mca/Views/SchedulerStatistics.h @@ -70,9 +70,7 @@ public: Usage(STI.getSchedModel().NumProcResourceKinds, {0, 0, 0}) {} void onEvent(const HWInstructionEvent &Event) override; - void onCycleBegin() override { NumCycles++; } - void onCycleEnd() override { updateHistograms(); } // Increases the number of used scheduler queue slots of every buffered diff --git a/tools/llvm-mca/Views/SummaryView.h b/tools/llvm-mca/Views/SummaryView.h index 13875976d39..3d4585e1d5a 100644 --- a/tools/llvm-mca/Views/SummaryView.h +++ b/tools/llvm-mca/Views/SummaryView.h @@ -66,7 +66,6 @@ public: unsigned Width); void onCycleEnd() override { ++TotalCycles; } - void onEvent(const HWInstructionEvent &Event) override; void printView(llvm::raw_ostream &OS) const override; diff --git a/tools/llvm-mca/include/InstrBuilder.h b/tools/llvm-mca/include/InstrBuilder.h index 31c52702058..0fd97cb1ed5 100644 --- a/tools/llvm-mca/include/InstrBuilder.h +++ b/tools/llvm-mca/include/InstrBuilder.h @@ -62,20 +62,8 @@ class InstrBuilder { const llvm::MCInst &MCI) const; public: - InstrBuilder(const llvm::MCSubtargetInfo &sti, const llvm::MCInstrInfo &mcii, - const llvm::MCRegisterInfo &mri, - const llvm::MCInstrAnalysis &mcia) - : STI(sti), MCII(mcii), MRI(mri), MCIA(mcia) { - computeProcResourceMasks(STI.getSchedModel(), ProcResourceMasks); - } - - // Returns an array of processor resource masks. - // Masks are computed by function mca::computeProcResourceMasks. see - // Support.h for a description of how masks are computed and how masks can be - // used to solve set membership problems. - llvm::ArrayRef getProcResourceMasks() const { - return ProcResourceMasks; - } + InstrBuilder(const llvm::MCSubtargetInfo &STI, const llvm::MCInstrInfo &MCII, + const llvm::MCRegisterInfo &RI, const llvm::MCInstrAnalysis &IA); void clear() { VariantDescriptors.shrink_and_clear(); } diff --git a/tools/llvm-mca/lib/InstrBuilder.cpp b/tools/llvm-mca/lib/InstrBuilder.cpp index 55f1ebf6e8a..3768c2e7088 100644 --- a/tools/llvm-mca/lib/InstrBuilder.cpp +++ b/tools/llvm-mca/lib/InstrBuilder.cpp @@ -26,6 +26,14 @@ namespace mca { using namespace llvm; +InstrBuilder::InstrBuilder(const llvm::MCSubtargetInfo &sti, + const llvm::MCInstrInfo &mcii, + const llvm::MCRegisterInfo &mri, + const llvm::MCInstrAnalysis &mcia) + : STI(sti), MCII(mcii), MRI(mri), MCIA(mcia) { + computeProcResourceMasks(STI.getSchedModel(), ProcResourceMasks); +} + static void initializeUsedResources(InstrDesc &ID, const MCSchedClassDesc &SCDesc, const MCSubtargetInfo &STI,