]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/MCA/Context.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / MCA / Context.h
1 //===---------------------------- Context.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 class for holding ownership of various simulated
12 /// hardware units.  A Context also provides a utility routine for constructing
13 /// a default out-of-order pipeline with fetch, dispatch, execute, and retire
14 /// stages.
15 ///
16 //===----------------------------------------------------------------------===//
17
18 #ifndef LLVM_MCA_CONTEXT_H
19 #define LLVM_MCA_CONTEXT_H
20
21 #include "llvm/MC/MCRegisterInfo.h"
22 #include "llvm/MC/MCSubtargetInfo.h"
23 #include "llvm/MCA/HardwareUnits/HardwareUnit.h"
24 #include "llvm/MCA/InstrBuilder.h"
25 #include "llvm/MCA/Pipeline.h"
26 #include "llvm/MCA/SourceMgr.h"
27 #include <memory>
28
29 namespace llvm {
30 namespace mca {
31
32 /// This is a convenience struct to hold the parameters necessary for creating
33 /// the pre-built "default" out-of-order pipeline.
34 struct PipelineOptions {
35   PipelineOptions(unsigned DW, unsigned RFS, unsigned LQS, unsigned SQS,
36                   bool NoAlias)
37       : DispatchWidth(DW), RegisterFileSize(RFS), LoadQueueSize(LQS),
38         StoreQueueSize(SQS), AssumeNoAlias(NoAlias) {}
39   unsigned DispatchWidth;
40   unsigned RegisterFileSize;
41   unsigned LoadQueueSize;
42   unsigned StoreQueueSize;
43   bool AssumeNoAlias;
44 };
45
46 class Context {
47   SmallVector<std::unique_ptr<HardwareUnit>, 4> Hardware;
48   const MCRegisterInfo &MRI;
49   const MCSubtargetInfo &STI;
50
51 public:
52   Context(const MCRegisterInfo &R, const MCSubtargetInfo &S) : MRI(R), STI(S) {}
53   Context(const Context &C) = delete;
54   Context &operator=(const Context &C) = delete;
55
56   void addHardwareUnit(std::unique_ptr<HardwareUnit> H) {
57     Hardware.push_back(std::move(H));
58   }
59
60   /// Construct a basic pipeline for simulating an out-of-order pipeline.
61   /// This pipeline consists of Fetch, Dispatch, Execute, and Retire stages.
62   std::unique_ptr<Pipeline> createDefaultPipeline(const PipelineOptions &Opts,
63                                                   InstrBuilder &IB,
64                                                   SourceMgr &SrcMgr);
65 };
66
67 } // namespace mca
68 } // namespace llvm
69 #endif // LLVM_MCA_CONTEXT_H