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