1 //===---------------------- Stage.h -----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file defines a stage.
12 /// A chain of stages compose an instruction pipeline.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TOOLS_LLVM_MCA_STAGE_H
17 #define LLVM_TOOLS_LLVM_MCA_STAGE_H
23 class HWEventListener;
27 std::set<HWEventListener *> Listeners;
28 Stage(const Stage &Other) = delete;
29 Stage &operator=(const Stage &Other) = delete;
33 virtual ~Stage() = default;
35 /// Called prior to preExecute to ensure that the stage can operate.
36 /// TODO: Remove this logic once backend::run and backend::runCycle become
38 virtual bool isReady() const { return true; }
40 /// Called as a setup phase to prepare for the main stage execution.
41 virtual void preExecute(const InstRef &IR) {}
43 /// Called as a cleanup and finalization phase after main stage execution.
44 virtual void postExecute(const InstRef &IR) {}
46 /// The primary action that this stage performs.
47 virtual bool execute(InstRef &IR) = 0;
49 /// Add a listener to receive callbaks during the execution of this stage.
50 void addListener(HWEventListener *Listener);
54 #endif // LLVM_TOOLS_LLVM_MCA_STAGE_H