[llvm-mca] Refactor event listeners to make the backend agnostic to event types.
Summary: This is a first step towards making the pipeline configurable.
Subscribers: llvm-commits, andreadb
Differential Revision: https://reviews.llvm.org/D44309
llvm-svn: 327389
diff --git a/llvm/tools/llvm-mca/Backend.h b/llvm/tools/llvm-mca/Backend.h
index dadab2d..c2532d8 100644
--- a/llvm/tools/llvm-mca/Backend.h
+++ b/llvm/tools/llvm-mca/Backend.h
@@ -23,6 +23,7 @@
namespace mca {
class HWEventListener;
+class HWInstructionEvent;
/// \brief An out of order backend for a specific subtarget.
///
@@ -71,6 +72,7 @@
RegisterFileSize, MaxRetirePerCycle, DispatchWidth, HWS.get())),
SM(Source), Cycles(0) {
IB = llvm::make_unique<InstrBuilder>(MCII, HWS->getProcResourceMasks());
+ HWS->setDispatchUnit(DU.get());
}
void run() {
@@ -80,6 +82,13 @@
unsigned getNumIterations() const { return SM.getNumIterations(); }
unsigned getNumInstructions() const { return SM.size(); }
+ const Instruction &getInstruction(unsigned Index) const {
+ const auto It = Instructions.find(Index);
+ assert(It != Instructions.end() && "no running instructions with index");
+ assert(It->second);
+ return *Instructions.find(Index)->second;
+ }
+ void eraseInstruction(unsigned Index) { Instructions.erase(Index); }
unsigned getNumCycles() const { return Cycles; }
unsigned getTotalRegisterMappingsCreated() const {
return DU->getTotalRegisterMappingsCreated();
@@ -122,14 +131,8 @@
void addEventListener(HWEventListener *Listener);
void notifyCycleBegin(unsigned Cycle);
- void notifyInstructionDispatched(unsigned Index);
- void notifyInstructionReady(unsigned Index);
- void notifyInstructionIssued(
- unsigned Index,
- const llvm::ArrayRef<std::pair<ResourceRef, unsigned>> &Used);
- void notifyInstructionExecuted(unsigned Index);
+ void notifyInstructionEvent(const HWInstructionEvent &Event);
void notifyResourceAvailable(const ResourceRef &RR);
- void notifyInstructionRetired(unsigned Index);
void notifyCycleEnd(unsigned Cycle);
};