LLVM 24.0.0git
Context.cpp
Go to the documentation of this file.
1//===---------------------------- Context.cpp -------------------*- 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#include "llvm/MCA/Context.h"
27
28namespace llvm {
29namespace mca {
30
31std::unique_ptr<Pipeline>
33 CustomBehaviour &CB) {
34 const MCSchedModel &SM = STI.getSchedModel();
35
36 if (!SM.isOutOfOrder())
37 return createInOrderPipeline(Opts, SrcMgr, CB);
38
39 // Create the hardware units defining the backend.
40 auto RCU = std::make_unique<RetireControlUnit>(SM);
41 auto PRF = std::make_unique<RegisterFile>(SM, MRI, Opts.RegisterFileSize);
42 auto LSU = std::make_unique<LSUnit>(SM, Opts.LoadQueueSize,
43 Opts.StoreQueueSize, Opts.AssumeNoAlias);
44 auto HWS =
45 std::make_unique<Scheduler>(SM, *LSU, Opts.ReservationStationScaleFactor);
46
47 // Create the pipeline stages.
48 auto Fetch = std::make_unique<EntryStage>(SrcMgr);
49 auto Dispatch =
50 std::make_unique<DispatchStage>(STI, MRI, Opts.DispatchWidth, *RCU, *PRF);
51 auto Execute =
52 std::make_unique<ExecuteStage>(*HWS, Opts.EnableBottleneckAnalysis);
53 auto Retire = std::make_unique<RetireStage>(*RCU, *PRF, *LSU);
54
55 // Pass the ownership of all the hardware units to this Context.
56 addHardwareUnit(std::move(RCU));
57 addHardwareUnit(std::move(PRF));
58 addHardwareUnit(std::move(LSU));
59 addHardwareUnit(std::move(HWS));
60
61 // Build the pipeline.
62 auto StagePipeline = std::make_unique<Pipeline>();
63 StagePipeline->appendStage(std::move(Fetch));
64 if (Opts.MicroOpQueueSize)
65 StagePipeline->appendStage(std::make_unique<MicroOpQueueStage>(
67 StagePipeline->appendStage(std::move(Dispatch));
68 StagePipeline->appendStage(std::move(Execute));
69 StagePipeline->appendStage(std::move(Retire));
70 return StagePipeline;
71}
72
73std::unique_ptr<Pipeline>
75 CustomBehaviour &CB) {
76 const MCSchedModel &SM = STI.getSchedModel();
77 auto PRF = std::make_unique<RegisterFile>(SM, MRI, Opts.RegisterFileSize);
78 auto LSU = std::make_unique<LSUnit>(SM, Opts.LoadQueueSize,
79 Opts.StoreQueueSize, Opts.AssumeNoAlias);
80
81 // Create the pipeline stages.
82 auto Entry = std::make_unique<EntryStage>(SrcMgr);
83 auto InOrderIssue = std::make_unique<InOrderIssueStage>(
84 STI, *PRF, CB, *LSU, Opts.ReservationStationScaleFactor);
85 auto StagePipeline = std::make_unique<Pipeline>();
86
87 // Pass the ownership of all the hardware units to this Context.
88 addHardwareUnit(std::move(PRF));
89 addHardwareUnit(std::move(LSU));
90
91 // Build the pipeline.
92 StagePipeline->appendStage(std::move(Entry));
93 StagePipeline->appendStage(std::move(InOrderIssue));
94 return StagePipeline;
95}
96
97} // namespace mca
98} // namespace llvm
This file models the dispatch component of an instruction pipeline.
This file defines the Entry stage of an instruction pipeline.
This file defines the execution stage of a default instruction pipeline.
InOrderIssueStage implements an in-order execution pipeline.
This file defines a class for holding ownership of various simulated hardware units.
A scheduler for Processor Resource Units and Processor Resource Groups.
This file defines a stage that implements a queue of micro opcodes.
static bool Execute(ProcessInfo &PI, StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env, ArrayRef< std::optional< StringRef > > Redirects, unsigned MemoryLimit, std::string *ErrMsg, BitVector *AffinityMask, bool DetachProcess)
This file defines a register mapping file class.
This file simulates the hardware responsible for retiring instructions.
This file defines the retire stage of a default instruction pipeline.
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:74
void addHardwareUnit(std::unique_ptr< HardwareUnit > H)
Definition Context.h:66
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
Class which can be overriden by targets to enforce instruction dependencies and behaviours that aren'...
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI SourceMgr SrcMgr
Definition Error.cpp:24
Machine model for scheduling, bundling, and heuristics.
Definition MCSchedule.h:274
bool isOutOfOrder() const
Return true if machine supports out of order execution.
Definition MCSchedule.h:369
This is a convenience struct to hold the parameters necessary for creating the pre-built "default" ou...
Definition Context.h:34
float ReservationStationScaleFactor
Definition Context.h:50
Abstracting the input code sequence (a sequence of MCInst) and assigning unique identifiers to every ...
Definition SourceMgr.h:29