LLVM  8.0.1
Context.cpp
Go to the documentation of this file.
1 //===---------------------------- Context.cpp -------------------*- 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 #include "llvm/MCA/Context.h"
26 
27 namespace llvm {
28 namespace mca {
29 
30 std::unique_ptr<Pipeline>
32  SourceMgr &SrcMgr) {
33  const MCSchedModel &SM = STI.getSchedModel();
34 
35  // Create the hardware units defining the backend.
36  auto RCU = llvm::make_unique<RetireControlUnit>(SM);
37  auto PRF = llvm::make_unique<RegisterFile>(SM, MRI, Opts.RegisterFileSize);
38  auto LSU = llvm::make_unique<LSUnit>(SM, Opts.LoadQueueSize,
39  Opts.StoreQueueSize, Opts.AssumeNoAlias);
40  auto HWS = llvm::make_unique<Scheduler>(SM, *LSU);
41 
42  // Create the pipeline stages.
43  auto Fetch = llvm::make_unique<EntryStage>(SrcMgr);
44  auto Dispatch = llvm::make_unique<DispatchStage>(STI, MRI, Opts.DispatchWidth,
45  *RCU, *PRF);
46  auto Execute = llvm::make_unique<ExecuteStage>(*HWS);
47  auto Retire = llvm::make_unique<RetireStage>(*RCU, *PRF);
48 
49  // Pass the ownership of all the hardware units to this Context.
50  addHardwareUnit(std::move(RCU));
51  addHardwareUnit(std::move(PRF));
52  addHardwareUnit(std::move(LSU));
53  addHardwareUnit(std::move(HWS));
54 
55  // Build the pipeline.
56  auto StagePipeline = llvm::make_unique<Pipeline>();
57  StagePipeline->appendStage(std::move(Fetch));
58  StagePipeline->appendStage(std::move(Dispatch));
59  StagePipeline->appendStage(std::move(Execute));
60  StagePipeline->appendStage(std::move(Retire));
61  return StagePipeline;
62 }
63 
64 } // namespace mca
65 } // namespace llvm
This file defines the retire stage of a default instruction pipeline.
void addHardwareUnit(std::unique_ptr< HardwareUnit > H)
Definition: Context.h:56
This class represents lattice values for constants.
Definition: AllocatorList.h:24
SourceMgr SrcMgr
Definition: Error.cpp:24
This file simulates the hardware responsible for retiring instructions.
A builder class that knows how to construct Instruction objects.
Definition: InstrBuilder.h:39
std::unique_ptr< Pipeline > createDefaultPipeline(const PipelineOptions &Opts, InstrBuilder &IB, SourceMgr &SrcMgr)
Construct a basic pipeline for simulating an out-of-order pipeline.
Definition: Context.cpp:31
This is a convenience struct to hold the parameters necessary for creating the pre-built "default" ou...
Definition: Context.h:34
This file defines the execution stage of a default instruction pipeline.
This file defines a class for holding ownership of various simulated hardware units.
This file defines the Entry stage of an instruction pipeline.
This file defines a register mapping file class.
This file models the dispatch component of an instruction pipeline.
A scheduler for Processor Resource Units and Processor Resource Groups.
Machine model for scheduling, bundling, and heuristics.
Definition: MCSchedule.h:244
const MCSchedModel & getSchedModel() const
Get the machine model for this subtarget&#39;s CPU.