LLVM  13.0.0git
Pipeline.h
Go to the documentation of this file.
1 //===--------------------- Pipeline.h ---------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 ///
10 /// This file implements an ordered container of stages that simulate the
11 /// pipeline of a hardware backend.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_MCA_PIPELINE_H
16 #define LLVM_MCA_PIPELINE_H
17 
18 #include "llvm/MCA/Stages/Stage.h"
19 #include "llvm/Support/Error.h"
20 
21 namespace llvm {
22 namespace mca {
23 
24 class HWEventListener;
25 
26 /// A pipeline for a specific subtarget.
27 ///
28 /// It emulates an out-of-order execution of instructions. Instructions are
29 /// fetched from a MCInst sequence managed by an initial 'Fetch' stage.
30 /// Instructions are firstly fetched, then dispatched to the schedulers, and
31 /// then executed.
32 ///
33 /// This class tracks the lifetime of an instruction from the moment where
34 /// it gets dispatched to the schedulers, to the moment where it finishes
35 /// executing and register writes are architecturally committed.
36 /// In particular, it monitors changes in the state of every instruction
37 /// in flight.
38 ///
39 /// Instructions are executed in a loop of iterations. The number of iterations
40 /// is defined by the SourceMgr object, which is managed by the initial stage
41 /// of the instruction pipeline.
42 ///
43 /// The Pipeline entry point is method 'run()' which executes cycles in a loop
44 /// until there are new instructions to dispatch, and not every instruction
45 /// has been retired.
46 ///
47 /// Internally, the Pipeline collects statistical information in the form of
48 /// histograms. For example, it tracks how the dispatch group size changes
49 /// over time.
50 class Pipeline {
51  Pipeline(const Pipeline &P) = delete;
52  Pipeline &operator=(const Pipeline &P) = delete;
53 
54  /// An ordered list of stages that define this instruction pipeline.
56  std::set<HWEventListener *> Listeners;
57  unsigned Cycles;
58 
59  Error runCycle();
60  bool hasWorkToProcess();
61  void notifyCycleBegin();
62  void notifyCycleEnd();
63 
64 public:
65  Pipeline() : Cycles(0) {}
66  void appendStage(std::unique_ptr<Stage> S);
67 
68  /// Returns the total number of simulated cycles.
70 
71  void addEventListener(HWEventListener *Listener);
72 };
73 } // namespace mca
74 } // namespace llvm
75 
76 #endif // LLVM_MCA_PIPELINE_H
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
Error.h
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::mca::Pipeline::appendStage
void appendStage(std::unique_ptr< Stage > S)
Definition: Pipeline.cpp:75
llvm::mca::Pipeline::Pipeline
Pipeline()
Definition: Pipeline.h:65
Stage.h
llvm::mca::Pipeline
A pipeline for a specific subtarget.
Definition: Pipeline.h:50
llvm::mca::Pipeline::run
Expected< unsigned > run()
Returns the total number of simulated cycles.
Definition: Pipeline.cpp:37
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::mca::Pipeline::addEventListener
void addEventListener(HWEventListener *Listener)
Definition: Pipeline.cpp:24
llvm::mca::HWEventListener
Definition: HWEventListener.h:158