[llvm-mca] Simplify eventing by adding an onEvent templated method.

Summary:
This patch eliminates some redundancy in iterating across Listeners for the
Instruction and Stall HWEvents, by introducing a template onEvent routine.
This change was suggested by @courbet in https://reviews.llvm.org/D48576.  I
 hope that this patch addresses that suggestion appropriately.  I do like this
change better than what we had previously.


Reviewers: andreadb, courbet, RKSimon

Reviewed By: andreadb, courbet

Subscribers: javed.absar, tschuett, gbedwell, llvm-commits, courbet

Differential Revision: https://reviews.llvm.org/D48672

llvm-svn: 336916
diff --git a/llvm/tools/llvm-mca/DispatchStatistics.h b/llvm/tools/llvm-mca/DispatchStatistics.h
index 7b98a84..1e389d5 100644
--- a/llvm/tools/llvm-mca/DispatchStatistics.h
+++ b/llvm/tools/llvm-mca/DispatchStatistics.h
@@ -66,14 +66,14 @@
       : NumDispatched(0), NumCycles(0),
         HWStalls(HWStallEvent::LastGenericEvent) {}
 
-  void onInstructionEvent(const HWInstructionEvent &Event) override;
+  void onEvent(const HWStallEvent &Event) override;
+
+  void onEvent(const HWInstructionEvent &Event) override;
 
   void onCycleBegin() override { NumCycles++; }
 
   void onCycleEnd() override { updateHistograms(); }
 
-  void onStallEvent(const HWStallEvent &Event) override;
-
   void printView(llvm::raw_ostream &OS) const override {
     printDispatchStalls(OS);
     printDispatchHistogram(OS);