summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-mca')
-rw-r--r--llvm/tools/llvm-mca/DispatchStage.cpp15
-rw-r--r--llvm/tools/llvm-mca/DispatchStage.h1
-rw-r--r--llvm/tools/llvm-mca/DispatchStatistics.cpp4
-rw-r--r--llvm/tools/llvm-mca/DispatchStatistics.h6
-rw-r--r--llvm/tools/llvm-mca/ExecuteStage.cpp8
-rw-r--r--llvm/tools/llvm-mca/HWEventListener.h4
-rw-r--r--llvm/tools/llvm-mca/InstructionTables.cpp7
-rw-r--r--llvm/tools/llvm-mca/RegisterFileStatistics.cpp3
-rw-r--r--llvm/tools/llvm-mca/RegisterFileStatistics.h2
-rw-r--r--llvm/tools/llvm-mca/ResourcePressureView.cpp2
-rw-r--r--llvm/tools/llvm-mca/ResourcePressureView.h2
-rw-r--r--llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp3
-rw-r--r--llvm/tools/llvm-mca/RetireControlUnitStatistics.h2
-rw-r--r--llvm/tools/llvm-mca/RetireStage.cpp2
-rw-r--r--llvm/tools/llvm-mca/SchedulerStatistics.cpp2
-rw-r--r--llvm/tools/llvm-mca/SchedulerStatistics.h4
-rw-r--r--llvm/tools/llvm-mca/Stage.cpp5
-rw-r--r--llvm/tools/llvm-mca/Stage.h6
-rw-r--r--llvm/tools/llvm-mca/SummaryView.cpp2
-rw-r--r--llvm/tools/llvm-mca/SummaryView.h2
-rw-r--r--llvm/tools/llvm-mca/TimelineView.cpp2
-rw-r--r--llvm/tools/llvm-mca/TimelineView.h2
22 files changed, 40 insertions, 46 deletions
diff --git a/llvm/tools/llvm-mca/DispatchStage.cpp b/llvm/tools/llvm-mca/DispatchStage.cpp
index 21eef3d93d6..99cf8e077d1 100644
--- a/llvm/tools/llvm-mca/DispatchStage.cpp
+++ b/llvm/tools/llvm-mca/DispatchStage.cpp
@@ -30,12 +30,7 @@ namespace mca {
void DispatchStage::notifyInstructionDispatched(const InstRef &IR,
ArrayRef<unsigned> UsedRegs) {
LLVM_DEBUG(dbgs() << "[E] Instruction Dispatched: " << IR << '\n');
- notifyInstructionEvent(HWInstructionDispatchedEvent(IR, UsedRegs));
-}
-
-void DispatchStage::notifyStallEvent(const HWStallEvent &Event) {
- for (HWEventListener *Listener : getListeners())
- Listener->onStallEvent(Event);
+ notifyEvent<HWInstructionEvent>(HWInstructionDispatchedEvent(IR, UsedRegs));
}
bool DispatchStage::checkPRF(const InstRef &IR) {
@@ -47,7 +42,8 @@ bool DispatchStage::checkPRF(const InstRef &IR) {
const unsigned RegisterMask = PRF.isAvailable(RegDefs);
// A mask with all zeroes means: register files are available.
if (RegisterMask) {
- notifyStallEvent(HWStallEvent(HWStallEvent::RegisterFileStall, IR));
+ notifyEvent<HWStallEvent>(
+ HWStallEvent(HWStallEvent::RegisterFileStall, IR));
return false;
}
@@ -58,7 +54,8 @@ bool DispatchStage::checkRCU(const InstRef &IR) {
const unsigned NumMicroOps = IR.getInstruction()->getDesc().NumMicroOps;
if (RCU.isAvailable(NumMicroOps))
return true;
- notifyStallEvent(HWStallEvent(HWStallEvent::RetireControlUnitStall, IR));
+ notifyEvent<HWStallEvent>(
+ HWStallEvent(HWStallEvent::RetireControlUnitStall, IR));
return false;
}
@@ -66,7 +63,7 @@ bool DispatchStage::checkScheduler(const InstRef &IR) {
HWStallEvent::GenericEventType Event;
const bool Ready = SC.canBeDispatched(IR, Event);
if (!Ready)
- notifyStallEvent(HWStallEvent(Event, IR));
+ notifyEvent<HWStallEvent>(HWStallEvent(Event, IR));
return Ready;
}
diff --git a/llvm/tools/llvm-mca/DispatchStage.h b/llvm/tools/llvm-mca/DispatchStage.h
index fff9a2bb114..65ac2bc7314 100644
--- a/llvm/tools/llvm-mca/DispatchStage.h
+++ b/llvm/tools/llvm-mca/DispatchStage.h
@@ -64,7 +64,6 @@ class DispatchStage : public Stage {
void dispatch(InstRef IR);
void updateRAWDependencies(ReadState &RS, const llvm::MCSubtargetInfo &STI);
- void notifyStallEvent(const HWStallEvent &Event);
void notifyInstructionDispatched(const InstRef &IR,
llvm::ArrayRef<unsigned> UsedPhysRegs);
diff --git a/llvm/tools/llvm-mca/DispatchStatistics.cpp b/llvm/tools/llvm-mca/DispatchStatistics.cpp
index da852454e8f..4bddbef9a0c 100644
--- a/llvm/tools/llvm-mca/DispatchStatistics.cpp
+++ b/llvm/tools/llvm-mca/DispatchStatistics.cpp
@@ -20,12 +20,12 @@ using namespace llvm;
namespace mca {
-void DispatchStatistics::onStallEvent(const HWStallEvent &Event) {
+void DispatchStatistics::onEvent(const HWStallEvent &Event) {
if (Event.Type < HWStallEvent::LastGenericEvent)
HWStalls[Event.Type]++;
}
-void DispatchStatistics::onInstructionEvent(const HWInstructionEvent &Event) {
+void DispatchStatistics::onEvent(const HWInstructionEvent &Event) {
if (Event.Type == HWInstructionEvent::Dispatched)
++NumDispatched;
}
diff --git a/llvm/tools/llvm-mca/DispatchStatistics.h b/llvm/tools/llvm-mca/DispatchStatistics.h
index 7b98a848df6..1e389d54766 100644
--- a/llvm/tools/llvm-mca/DispatchStatistics.h
+++ b/llvm/tools/llvm-mca/DispatchStatistics.h
@@ -66,14 +66,14 @@ public:
: 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);
diff --git a/llvm/tools/llvm-mca/ExecuteStage.cpp b/llvm/tools/llvm-mca/ExecuteStage.cpp
index c446ad67725..f2e458dcabd 100644
--- a/llvm/tools/llvm-mca/ExecuteStage.cpp
+++ b/llvm/tools/llvm-mca/ExecuteStage.cpp
@@ -154,13 +154,15 @@ bool ExecuteStage::execute(InstRef &IR) {
void ExecuteStage::notifyInstructionExecuted(const InstRef &IR) {
HWS.onInstructionExecuted(IR);
LLVM_DEBUG(dbgs() << "[E] Instruction Executed: " << IR << '\n');
- notifyInstructionEvent(HWInstructionEvent(HWInstructionEvent::Executed, IR));
+ notifyEvent<HWInstructionEvent>(
+ HWInstructionEvent(HWInstructionEvent::Executed, IR));
RCU.onInstructionExecuted(IR.getInstruction()->getRCUTokenID());
}
void ExecuteStage::notifyInstructionReady(const InstRef &IR) {
LLVM_DEBUG(dbgs() << "[E] Instruction Ready: " << IR << '\n');
- notifyInstructionEvent(HWInstructionEvent(HWInstructionEvent::Ready, IR));
+ notifyEvent<HWInstructionEvent>(
+ HWInstructionEvent(HWInstructionEvent::Ready, IR));
}
void ExecuteStage::notifyResourceAvailable(const ResourceRef &RR) {
@@ -180,7 +182,7 @@ void ExecuteStage::notifyInstructionIssued(
dbgs() << " cycles: " << Resource.second << '\n';
}
});
- notifyInstructionEvent(HWInstructionIssuedEvent(IR, Used));
+ notifyEvent<HWInstructionEvent>(HWInstructionIssuedEvent(IR, Used));
}
void ExecuteStage::notifyReservedBuffers(ArrayRef<uint64_t> Buffers) {
diff --git a/llvm/tools/llvm-mca/HWEventListener.h b/llvm/tools/llvm-mca/HWEventListener.h
index c7384d51b13..aa3e6dcf19a 100644
--- a/llvm/tools/llvm-mca/HWEventListener.h
+++ b/llvm/tools/llvm-mca/HWEventListener.h
@@ -120,8 +120,8 @@ public:
virtual void onCycleBegin() {}
virtual void onCycleEnd() {}
- virtual void onInstructionEvent(const HWInstructionEvent &Event) {}
- virtual void onStallEvent(const HWStallEvent &Event) {}
+ virtual void onEvent(const HWInstructionEvent &Event) {}
+ virtual void onEvent(const HWStallEvent &Event) {}
using ResourceRef = std::pair<uint64_t, uint64_t>;
virtual void onResourceAvailable(const ResourceRef &RRef) {}
diff --git a/llvm/tools/llvm-mca/InstructionTables.cpp b/llvm/tools/llvm-mca/InstructionTables.cpp
index 652ef201388..c7cce7cafa0 100644
--- a/llvm/tools/llvm-mca/InstructionTables.cpp
+++ b/llvm/tools/llvm-mca/InstructionTables.cpp
@@ -39,9 +39,8 @@ void InstructionTables::run() {
if (!Resource.second.size())
continue;
double Cycles = static_cast<double>(Resource.second.size());
- unsigned Index =
- std::distance(Masks.begin(), std::find(Masks.begin(), Masks.end(),
- Resource.first));
+ unsigned Index = std::distance(
+ Masks.begin(), std::find(Masks.begin(), Masks.end(), Resource.first));
const MCProcResourceDesc &ProcResource = *SM.getProcResource(Index);
unsigned NumUnits = ProcResource.NumUnits;
if (!ProcResource.SubUnitsIdxBegin) {
@@ -73,7 +72,7 @@ void InstructionTables::run() {
InstRef IR(SR.first, Inst.get());
HWInstructionIssuedEvent Event(IR, UsedResources);
for (std::unique_ptr<View> &Listener : Views)
- Listener->onInstructionEvent(Event);
+ Listener->onEvent(Event);
S.updateNext();
}
}
diff --git a/llvm/tools/llvm-mca/RegisterFileStatistics.cpp b/llvm/tools/llvm-mca/RegisterFileStatistics.cpp
index 46302bf41b2..1b07bf9a3b3 100644
--- a/llvm/tools/llvm-mca/RegisterFileStatistics.cpp
+++ b/llvm/tools/llvm-mca/RegisterFileStatistics.cpp
@@ -39,8 +39,7 @@ void RegisterFileStatistics::initializeRegisterFileInfo() {
std::fill(RegisterFiles.begin(), RegisterFiles.end(), Empty);
}
-void RegisterFileStatistics::onInstructionEvent(
- const HWInstructionEvent &Event) {
+void RegisterFileStatistics::onEvent(const HWInstructionEvent &Event) {
switch (Event.Type) {
default:
break;
diff --git a/llvm/tools/llvm-mca/RegisterFileStatistics.h b/llvm/tools/llvm-mca/RegisterFileStatistics.h
index d36b61ecd2b..cbe816cd333 100644
--- a/llvm/tools/llvm-mca/RegisterFileStatistics.h
+++ b/llvm/tools/llvm-mca/RegisterFileStatistics.h
@@ -58,7 +58,7 @@ public:
initializeRegisterFileInfo();
}
- void onInstructionEvent(const HWInstructionEvent &Event) override;
+ void onEvent(const HWInstructionEvent &Event) override;
void printView(llvm::raw_ostream &OS) const override;
};
diff --git a/llvm/tools/llvm-mca/ResourcePressureView.cpp b/llvm/tools/llvm-mca/ResourcePressureView.cpp
index 37bb059c907..fe9d5b7fabc 100644
--- a/llvm/tools/llvm-mca/ResourcePressureView.cpp
+++ b/llvm/tools/llvm-mca/ResourcePressureView.cpp
@@ -40,7 +40,7 @@ void ResourcePressureView::initialize() {
std::fill(ResourceUsage.begin(), ResourceUsage.end(), 0.0);
}
-void ResourcePressureView::onInstructionEvent(const HWInstructionEvent &Event) {
+void ResourcePressureView::onEvent(const HWInstructionEvent &Event) {
// We're only interested in Issue events.
if (Event.Type != HWInstructionEvent::Issued)
return;
diff --git a/llvm/tools/llvm-mca/ResourcePressureView.h b/llvm/tools/llvm-mca/ResourcePressureView.h
index c15cf1832ad..fe1c6af5e6f 100644
--- a/llvm/tools/llvm-mca/ResourcePressureView.h
+++ b/llvm/tools/llvm-mca/ResourcePressureView.h
@@ -96,7 +96,7 @@ public:
initialize();
}
- void onInstructionEvent(const HWInstructionEvent &Event) override;
+ void onEvent(const HWInstructionEvent &Event) override;
void printView(llvm::raw_ostream &OS) const override {
unsigned Executions = Source.getNumIterations();
diff --git a/llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp b/llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp
index 5d3632f14a4..edb855e11e8 100644
--- a/llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp
+++ b/llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp
@@ -19,8 +19,7 @@ using namespace llvm;
namespace mca {
-void RetireControlUnitStatistics::onInstructionEvent(
- const HWInstructionEvent &Event) {
+void RetireControlUnitStatistics::onEvent(const HWInstructionEvent &Event) {
if (Event.Type == HWInstructionEvent::Retired)
++NumRetired;
}
diff --git a/llvm/tools/llvm-mca/RetireControlUnitStatistics.h b/llvm/tools/llvm-mca/RetireControlUnitStatistics.h
index 5c91af532ec..1f03e7efe88 100644
--- a/llvm/tools/llvm-mca/RetireControlUnitStatistics.h
+++ b/llvm/tools/llvm-mca/RetireControlUnitStatistics.h
@@ -47,7 +47,7 @@ class RetireControlUnitStatistics : public View {
public:
RetireControlUnitStatistics() : NumRetired(0), NumCycles(0) {}
- void onInstructionEvent(const HWInstructionEvent &Event) override;
+ void onEvent(const HWInstructionEvent &Event) override;
void onCycleBegin() override { NumCycles++; }
diff --git a/llvm/tools/llvm-mca/RetireStage.cpp b/llvm/tools/llvm-mca/RetireStage.cpp
index 0d1f4e43035..b4dcc286035 100644
--- a/llvm/tools/llvm-mca/RetireStage.cpp
+++ b/llvm/tools/llvm-mca/RetireStage.cpp
@@ -49,7 +49,7 @@ void RetireStage::notifyInstructionRetired(const InstRef &IR) {
for (const std::unique_ptr<WriteState> &WS : IR.getInstruction()->getDefs())
PRF.removeRegisterWrite(*WS.get(), FreedRegs, !Desc.isZeroLatency());
- notifyInstructionEvent(HWInstructionRetiredEvent(IR, FreedRegs));
+ notifyEvent<HWInstructionEvent>(HWInstructionRetiredEvent(IR, FreedRegs));
}
} // namespace mca
diff --git a/llvm/tools/llvm-mca/SchedulerStatistics.cpp b/llvm/tools/llvm-mca/SchedulerStatistics.cpp
index dc38f6889c9..5c6d22a7181 100644
--- a/llvm/tools/llvm-mca/SchedulerStatistics.cpp
+++ b/llvm/tools/llvm-mca/SchedulerStatistics.cpp
@@ -19,7 +19,7 @@ using namespace llvm;
namespace mca {
-void SchedulerStatistics::onInstructionEvent(const HWInstructionEvent &Event) {
+void SchedulerStatistics::onEvent(const HWInstructionEvent &Event) {
if (Event.Type == HWInstructionEvent::Issued)
++NumIssued;
}
diff --git a/llvm/tools/llvm-mca/SchedulerStatistics.h b/llvm/tools/llvm-mca/SchedulerStatistics.h
index 08d8a349437..7383c54a161 100644
--- a/llvm/tools/llvm-mca/SchedulerStatistics.h
+++ b/llvm/tools/llvm-mca/SchedulerStatistics.h
@@ -65,9 +65,9 @@ class SchedulerStatistics : public View {
public:
SchedulerStatistics(const llvm::MCSubtargetInfo &STI)
- : SM(STI.getSchedModel()), NumIssued(0), NumCycles(0) { }
+ : SM(STI.getSchedModel()), NumIssued(0), NumCycles(0) {}
- void onInstructionEvent(const HWInstructionEvent &Event) override;
+ void onEvent(const HWInstructionEvent &Event) override;
void onCycleBegin() override { NumCycles++; }
diff --git a/llvm/tools/llvm-mca/Stage.cpp b/llvm/tools/llvm-mca/Stage.cpp
index cfcb3f8bde0..7ead940e63c 100644
--- a/llvm/tools/llvm-mca/Stage.cpp
+++ b/llvm/tools/llvm-mca/Stage.cpp
@@ -24,9 +24,4 @@ void Stage::addListener(HWEventListener *Listener) {
Listeners.insert(Listener);
}
-void Stage::notifyInstructionEvent(const HWInstructionEvent &Event) {
- for (HWEventListener *Listener : Listeners)
- Listener->onInstructionEvent(Event);
-}
-
} // namespace mca
diff --git a/llvm/tools/llvm-mca/Stage.h b/llvm/tools/llvm-mca/Stage.h
index 2719376f757..80d4906ec9b 100644
--- a/llvm/tools/llvm-mca/Stage.h
+++ b/llvm/tools/llvm-mca/Stage.h
@@ -55,7 +55,11 @@ public:
/// Add a listener to receive callbacks during the execution of this stage.
void addListener(HWEventListener *Listener);
- virtual void notifyInstructionEvent(const HWInstructionEvent &Event);
+ /// Notify listeners of a particular hardware event.
+ template <typename EventT> void notifyEvent(const EventT &Event) {
+ for (HWEventListener *Listener : Listeners)
+ Listener->onEvent(Event);
+ }
};
} // namespace mca
diff --git a/llvm/tools/llvm-mca/SummaryView.cpp b/llvm/tools/llvm-mca/SummaryView.cpp
index 5cb5c23c973..01399055c4f 100644
--- a/llvm/tools/llvm-mca/SummaryView.cpp
+++ b/llvm/tools/llvm-mca/SummaryView.cpp
@@ -32,7 +32,7 @@ SummaryView::SummaryView(const llvm::MCSchedModel &Model, const SourceMgr &S,
computeProcResourceMasks(SM, ProcResourceMasks);
}
-void SummaryView::onInstructionEvent(const HWInstructionEvent &Event) {
+void SummaryView::onEvent(const HWInstructionEvent &Event) {
// We are only interested in the "instruction dispatched" events generated by
// the dispatch stage for instructions that are part of iteration #0.
if (Event.Type != HWInstructionEvent::Dispatched)
diff --git a/llvm/tools/llvm-mca/SummaryView.h b/llvm/tools/llvm-mca/SummaryView.h
index 04f4a871247..b799ce3aa74 100644
--- a/llvm/tools/llvm-mca/SummaryView.h
+++ b/llvm/tools/llvm-mca/SummaryView.h
@@ -67,7 +67,7 @@ public:
void onCycleEnd() override { ++TotalCycles; }
- void onInstructionEvent(const HWInstructionEvent &Event) override;
+ void onEvent(const HWInstructionEvent &Event) override;
void printView(llvm::raw_ostream &OS) const override;
};
diff --git a/llvm/tools/llvm-mca/TimelineView.cpp b/llvm/tools/llvm-mca/TimelineView.cpp
index 8087ea97e3c..6e75cac0d43 100644
--- a/llvm/tools/llvm-mca/TimelineView.cpp
+++ b/llvm/tools/llvm-mca/TimelineView.cpp
@@ -34,7 +34,7 @@ void TimelineView::initialize(unsigned MaxIterations) {
std::fill(WaitTime.begin(), WaitTime.end(), NullWTEntry);
}
-void TimelineView::onInstructionEvent(const HWInstructionEvent &Event) {
+void TimelineView::onEvent(const HWInstructionEvent &Event) {
const unsigned Index = Event.IR.getSourceIndex();
if (CurrentCycle >= MaxCycle || Index >= Timeline.size())
return;
diff --git a/llvm/tools/llvm-mca/TimelineView.h b/llvm/tools/llvm-mca/TimelineView.h
index 1a85ca1de64..e53c23ec1cc 100644
--- a/llvm/tools/llvm-mca/TimelineView.h
+++ b/llvm/tools/llvm-mca/TimelineView.h
@@ -174,7 +174,7 @@ public:
// Event handlers.
void onCycleEnd() override { ++CurrentCycle; }
- void onInstructionEvent(const HWInstructionEvent &Event) override;
+ void onEvent(const HWInstructionEvent &Event) override;
// print functionalities.
void printTimeline(llvm::raw_ostream &OS) const;
OpenPOWER on IntegriCloud