OSDN Git Service

[llvm-mca] Fix header comments. NFC.
[android-x86/external-llvm.git] / tools / llvm-mca / Stage.h
1 //===---------------------- Stage.h -----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// This file defines a stage.
12 /// A chain of stages compose an instruction pipeline.
13 ///
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_TOOLS_LLVM_MCA_STAGE_H
17 #define LLVM_TOOLS_LLVM_MCA_STAGE_H
18
19 #include <set>
20
21 namespace mca {
22
23 class HWEventListener;
24 class InstRef;
25
26 class Stage {
27   std::set<HWEventListener *> Listeners;
28   Stage(const Stage &Other) = delete;
29   Stage &operator=(const Stage &Other) = delete;
30
31 public:
32   Stage();
33   virtual ~Stage() = default;
34
35   /// Called prior to preExecute to ensure that the stage can operate.
36   /// TODO: Remove this logic once backend::run and backend::runCycle become
37   /// one routine.
38   virtual bool isReady() const { return true; }
39
40   /// Called as a setup phase to prepare for the main stage execution.
41   virtual void preExecute(const InstRef &IR) {}
42
43   /// Called as a cleanup and finalization phase after main stage execution.
44   virtual void postExecute(const InstRef &IR) {}
45
46   /// The primary action that this stage performs.
47   virtual bool execute(InstRef &IR) = 0;
48
49   /// Add a listener to receive callbaks during the execution of this stage.
50   void addListener(HWEventListener *Listener);
51 };
52
53 } // namespace mca
54 #endif // LLVM_TOOLS_LLVM_MCA_STAGE_H