1 //===---------------------------- Context.h ---------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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
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"
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
,
36 : DispatchWidth(DW
), RegisterFileSize(RFS
), LoadQueueSize(LQS
),
37 StoreQueueSize(SQS
), AssumeNoAlias(NoAlias
) {}
38 unsigned DispatchWidth
;
39 unsigned RegisterFileSize
;
40 unsigned LoadQueueSize
;
41 unsigned StoreQueueSize
;
46 SmallVector
<std::unique_ptr
<HardwareUnit
>, 4> Hardware
;
47 const MCRegisterInfo
&MRI
;
48 const MCSubtargetInfo
&STI
;
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
,
68 #endif // LLVM_MCA_CONTEXT_H