LLVM  8.0.1
ExecuteStage.h
Go to the documentation of this file.
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 a default 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_MCA_EXECUTE_STAGE_H
19 #define LLVM_MCA_EXECUTE_STAGE_H
20 
21 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/MCA/Instruction.h"
24 #include "llvm/MCA/Stages/Stage.h"
25 
26 namespace llvm {
27 namespace mca {
28 
29 class ExecuteStage final : public Stage {
30  Scheduler &HWS;
31 
32  Error issueInstruction(InstRef &IR);
33 
34  // Called at the beginning of each cycle to issue already dispatched
35  // instructions to the underlying pipelines.
36  Error issueReadyInstructions();
37 
38  // Used to notify instructions eliminated at register renaming stage.
39  Error handleInstructionEliminated(InstRef &IR);
40 
41  ExecuteStage(const ExecuteStage &Other) = delete;
42  ExecuteStage &operator=(const ExecuteStage &Other) = delete;
43 
44 public:
45  ExecuteStage(Scheduler &S) : Stage(), HWS(S) {}
46 
47  // This stage works under the assumption that the Pipeline will eventually
48  // execute a retire stage. We don't need to check if pipelines and/or
49  // schedulers have instructions to process, because those instructions are
50  // also tracked by the retire control unit. That means,
51  // RetireControlUnit::hasWorkToComplete() is responsible for checking if there
52  // are still instructions in-flight in the out-of-order backend.
53  bool hasWorkToComplete() const override { return false; }
54  bool isAvailable(const InstRef &IR) const override;
55 
56  // Notifies the scheduler that a new cycle just started.
57  //
58  // This method notifies the scheduler that a new cycle started.
59  // This method is also responsible for notifying listeners about instructions
60  // state changes, and processor resources freed by the scheduler.
61  // Instructions that transitioned to the 'Executed' state are automatically
62  // moved to the next stage (i.e. RetireStage).
63  Error cycleStart() override;
64  Error execute(InstRef &IR) override;
65 
67  const InstRef &IR,
68  MutableArrayRef<std::pair<ResourceRef, ResourceCycles>> Used) const;
69  void notifyInstructionExecuted(const InstRef &IR) const;
70  void notifyInstructionReady(const InstRef &IR) const;
71  void notifyResourceAvailable(const ResourceRef &RR) const;
72 
73  // Notify listeners that buffered resources have been consumed or freed.
74  void notifyReservedOrReleasedBuffers(const InstRef &IR, bool Reserved) const;
75 };
76 
77 } // namespace mca
78 } // namespace llvm
79 
80 #endif // LLVM_MCA_EXECUTE_STAGE_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void notifyInstructionReady(const InstRef &IR) const
bool isAvailable(const InstRef &IR) const override
Returns true if it can execute IR during this cycle.
An InstRef contains both a SourceMgr index and Instruction pair.
Definition: Instruction.h:478
Error cycleStart() override
Called once at the start of each cycle.
void notifyResourceAvailable(const ResourceRef &RR) const
void notifyInstructionIssued(const InstRef &IR, MutableArrayRef< std::pair< ResourceRef, ResourceCycles >> Used) const
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:784
This file defines a stage.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:291
Class Scheduler is responsible for issuing instructions to pipeline resources.
Definition: Scheduler.h:87
void notifyReservedOrReleasedBuffers(const InstRef &IR, bool Reserved) const
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
bool hasWorkToComplete() const override
Returns true if some instructions are still executing this stage.
Definition: ExecuteStage.h:53
void notifyInstructionExecuted(const InstRef &IR) const
ExecuteStage(Scheduler &S)
Definition: ExecuteStage.h:45
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
A scheduler for Processor Resource Units and Processor Resource Groups.
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
Statically lint checks LLVM IR
Definition: Lint.cpp:193