diff options
Diffstat (limited to 'llvm/tools/llvm-mca')
-rw-r--r-- | llvm/tools/llvm-mca/InstructionTables.cpp | 9 | ||||
-rw-r--r-- | llvm/tools/llvm-mca/InstructionTables.h | 12 | ||||
-rw-r--r-- | llvm/tools/llvm-mca/llvm-mca.cpp | 13 |
3 files changed, 20 insertions, 14 deletions
diff --git a/llvm/tools/llvm-mca/InstructionTables.cpp b/llvm/tools/llvm-mca/InstructionTables.cpp index 044b516db5d..18691adfed1 100644 --- a/llvm/tools/llvm-mca/InstructionTables.cpp +++ b/llvm/tools/llvm-mca/InstructionTables.cpp @@ -69,12 +69,17 @@ void InstructionTables::run() { } } - // Now send a fake instruction issued event to all the listeners. + // Now send a fake instruction issued event to all the views. HWInstructionIssuedEvent Event(IR.first, UsedResources); - for (HWEventListener *Listener : Listeners) + for (std::unique_ptr<View> &Listener : Views) Listener->onInstructionEvent(Event); S.updateNext(); } } +void InstructionTables::printReport(llvm::raw_ostream &OS) const { + for (const std::unique_ptr<View> &V : Views) + V->printView(OS); +} + } // namespace mca diff --git a/llvm/tools/llvm-mca/InstructionTables.h b/llvm/tools/llvm-mca/InstructionTables.h index 97dd9b8fc58..200083d3715 100644 --- a/llvm/tools/llvm-mca/InstructionTables.h +++ b/llvm/tools/llvm-mca/InstructionTables.h @@ -17,9 +17,10 @@ #ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONTABLES_H #define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONTABLES_H -#include "HWEventListener.h" +#include "View.h" #include "InstrBuilder.h" #include "SourceMgr.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/MC/MCSchedule.h" namespace mca { @@ -28,19 +29,20 @@ class InstructionTables { const llvm::MCSchedModel &SM; InstrBuilder &IB; SourceMgr &S; - std::set<HWEventListener *> Listeners; + llvm::SmallVector<std::unique_ptr<View>, 8> Views; public: InstructionTables(const llvm::MCSchedModel &Model, InstrBuilder &Builder, SourceMgr &Source) : SM(Model), IB(Builder), S(Source) {} - void addEventListener(HWEventListener *Listener) { - if (Listener) - Listeners.insert(Listener); + void addView(std::unique_ptr<View> V) { + Views.emplace_back(std::move(V)); } void run(); + + void printReport(llvm::raw_ostream &OS) const; }; } // namespace mca diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp index cae4c2741b1..49d50476354 100644 --- a/llvm/tools/llvm-mca/llvm-mca.cpp +++ b/llvm/tools/llvm-mca/llvm-mca.cpp @@ -273,8 +273,8 @@ int main(int argc, char **argv) { std::unique_ptr<buffer_ostream> BOS; - std::unique_ptr<mca::SourceMgr> S = - llvm::make_unique<mca::SourceMgr>(PrintInstructionTables ? 1 : Iterations); + std::unique_ptr<mca::SourceMgr> S = llvm::make_unique<mca::SourceMgr>( + PrintInstructionTables ? 1 : Iterations); MCStreamerWrapper Str(Ctx, S->getSequence()); std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); @@ -343,14 +343,13 @@ int main(int argc, char **argv) { mca::InstructionTables IT(STI->getSchedModel(), *IB, *S); if (PrintInstructionInfoView) { - mca::InstructionInfoView IIV(*STI, *MCII, *S, *IP); - IT.addEventListener(&IIV); + IT.addView( + llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, *S, *IP)); } - mca::ResourcePressureView RPV(*STI, *IP, *S); - IT.addEventListener(&RPV); + IT.addView(llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, *S)); IT.run(); - RPV.printView(TOF->os()); + IT.printReport(TOF->os()); TOF->keep(); return 0; } |