LLVM 22.0.0git
Context.h
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_MCA_CONTEXT_H
18#define LLVM_MCA_CONTEXT_H
19
24#include "llvm/MCA/Pipeline.h"
25#include "llvm/MCA/SourceMgr.h"
27#include <memory>
28
29namespace llvm {
30namespace mca {
31
32/// This is a convenience struct to hold the parameters necessary for creating
33/// the pre-built "default" out-of-order pipeline.
35 PipelineOptions(unsigned UOPQSize, unsigned DecThr, unsigned DW, unsigned RFS,
36 unsigned LQS, unsigned SQS, bool NoAlias,
37 bool ShouldEnableBottleneckAnalysis = false)
38 : MicroOpQueueSize(UOPQSize), DecodersThroughput(DecThr),
40 StoreQueueSize(SQS), AssumeNoAlias(NoAlias),
41 EnableBottleneckAnalysis(ShouldEnableBottleneckAnalysis) {}
43 unsigned DecodersThroughput; // Instructions per cycle.
44 unsigned DispatchWidth;
46 unsigned LoadQueueSize;
50};
51
52class Context {
54 const MCRegisterInfo &MRI;
55 const MCSubtargetInfo &STI;
56
57public:
58 Context(const MCRegisterInfo &R, const MCSubtargetInfo &S) : MRI(R), STI(S) {}
59 Context(const Context &C) = delete;
60 Context &operator=(const Context &C) = delete;
61
62 const MCRegisterInfo &getMCRegisterInfo() const { return MRI; }
63 const MCSubtargetInfo &getMCSubtargetInfo() const { return STI; }
64
65 void addHardwareUnit(std::unique_ptr<HardwareUnit> H) {
66 Hardware.push_back(std::move(H));
67 }
68
69 /// Construct a basic pipeline for simulating an out-of-order pipeline.
70 /// This pipeline consists of Fetch, Dispatch, Execute, and Retire stages.
71 LLVM_ABI std::unique_ptr<Pipeline>
73 CustomBehaviour &CB);
74
75 /// Construct a basic pipeline for simulating an in-order pipeline.
76 /// This pipeline consists of Fetch, InOrderIssue, and Retire stages.
77 LLVM_ABI std::unique_ptr<Pipeline>
79 CustomBehaviour &CB);
80};
81
82} // namespace mca
83} // namespace llvm
84#endif // LLVM_MCA_CONTEXT_H
unsigned const MachineRegisterInfo * MRI
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the base class CustomBehaviour which can be inherited from by specific targets (ex.
This file defines a base class for describing a simulated hardware unit.
This file contains abstract class SourceMgr and the default implementation, CircularSourceMgr.
#define H(x, y, z)
Definition: MD5.cpp:57
This file implements an ordered container of stages that simulate the pipeline of a hardware backend.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Generic base class for all target subtargets.
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
const MCSubtargetInfo & getMCSubtargetInfo() const
Definition: Context.h:63
LLVM_ABI std::unique_ptr< Pipeline > createInOrderPipeline(const PipelineOptions &Opts, SourceMgr &SrcMgr, CustomBehaviour &CB)
Construct a basic pipeline for simulating an in-order pipeline.
Definition: Context.cpp:73
const MCRegisterInfo & getMCRegisterInfo() const
Definition: Context.h:62
Context & operator=(const Context &C)=delete
Context(const MCRegisterInfo &R, const MCSubtargetInfo &S)
Definition: Context.h:58
void addHardwareUnit(std::unique_ptr< HardwareUnit > H)
Definition: Context.h:65
LLVM_ABI std::unique_ptr< Pipeline > createDefaultPipeline(const PipelineOptions &Opts, SourceMgr &SrcMgr, CustomBehaviour &CB)
Construct a basic pipeline for simulating an out-of-order pipeline.
Definition: Context.cpp:32
Context(const Context &C)=delete
Class which can be overriden by targets to enforce instruction dependencies and behaviours that aren'...
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
SourceMgr SrcMgr
Definition: Error.cpp:24
This is a convenience struct to hold the parameters necessary for creating the pre-built "default" ou...
Definition: Context.h:34
PipelineOptions(unsigned UOPQSize, unsigned DecThr, unsigned DW, unsigned RFS, unsigned LQS, unsigned SQS, bool NoAlias, bool ShouldEnableBottleneckAnalysis=false)
Definition: Context.h:35
unsigned DecodersThroughput
Definition: Context.h:43
Abstracting the input code sequence (a sequence of MCInst) and assigning unique identifiers to every ...
Definition: SourceMgr.h:29