• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===---------------------- ExecuteStage.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 the execution stage of an instruction pipeline.
12 ///
13 /// The ExecuteStage is responsible for managing the hardware scheduler
14 /// and issuing notifications that an instruction has been executed.
15 ///
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H
19 #define LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H
20 
21 #include "Instruction.h"
22 #include "RetireControlUnit.h"
23 #include "Scheduler.h"
24 #include "Stage.h"
25 #include "llvm/ADT/ArrayRef.h"
26 
27 namespace mca {
28 
29 class ExecuteStage : public Stage {
30   // Owner will go away when we move listeners/eventing to the stages.
31   RetireControlUnit &RCU;
32   Scheduler &HWS;
33 
34   // The following routines are used to maintain the HWS.
35   void reclaimSchedulerResources();
36   void updateSchedulerQueues();
37   void issueReadyInstructions();
38 
39 public:
ExecuteStage(RetireControlUnit & R,Scheduler & S)40   ExecuteStage(RetireControlUnit &R, Scheduler &S) : Stage(), RCU(R), HWS(S) {}
41   ExecuteStage(const ExecuteStage &Other) = delete;
42   ExecuteStage &operator=(const ExecuteStage &Other) = delete;
43 
44   // The ExecuteStage will always complete all of its work per call to
45   // execute(), so it is never left in a 'to-be-processed' state.
hasWorkToComplete()46   virtual bool hasWorkToComplete() const override final { return false; }
47 
48   virtual void cycleStart() override final;
49   virtual bool execute(InstRef &IR) override final;
50 
51   void
52   notifyInstructionIssued(const InstRef &IR,
53                           llvm::ArrayRef<std::pair<ResourceRef, double>> Used);
54   void notifyInstructionExecuted(const InstRef &IR);
55   void notifyInstructionReady(const InstRef &IR);
56   void notifyResourceAvailable(const ResourceRef &RR);
57 
58   // Notify listeners that buffered resources were consumed.
59   void notifyReservedBuffers(llvm::ArrayRef<uint64_t> Buffers);
60 
61   // Notify listeners that buffered resources were freed.
62   void notifyReleasedBuffers(llvm::ArrayRef<uint64_t> Buffers);
63 };
64 
65 } // namespace mca
66 
67 #endif // LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H
68