[llvm-mca] Add HardwareUnit and Context classes.
authorMatt Davis <Matthew.Davis@sony.com>
Fri, 6 Jul 2018 18:03:14 +0000 (18:03 +0000)
committerMatt Davis <Matthew.Davis@sony.com>
Fri, 6 Jul 2018 18:03:14 +0000 (18:03 +0000)
commit362ea5f2c35ba021959367759899fb92a06a96f9
tree9cd55e024ed93ad8df3e723784ec8a6c1963abfb
parent42b5ef026908953c823b4849ea1b9d3955c5c172
[llvm-mca] Add HardwareUnit and Context classes.

This patch moves the construction of the default backend from llvm-mca.cpp and
into mca::Context. The Context class is responsible for holding ownership of
the simulated hardware components. These components are subclasses of
HardwareUnit. Right now the HardwareUnit is pretty bare-bones, but eventually
we might want to add some common functionality across all hardware components,
such as isReady() or something similar.

I have a feeling this patch will probably need some updates, but it's a start.
One thing I am not particularly fond of is the rather large interface for
createDefaultPipeline. That convenience routine takes a rather large set of
inputs from the llvm-mca driver, where many of those inputs are generated via
command line options.

One item I think we might want to change is the separating of ownership of
hardware components (owned by the context) and the pipeline (which owns
Stages). In short, a Pipeline owns Stages, a Context (currently) owns hardware.
The Pipeline's Stages make use of the components, and thus there is a lifetime
dependency generated. The components must outlive the pipeline. We could solve
this by having the Context also own the Pipeline, and not return a
unique_ptr<Pipeline>. Now that I think about it, I like that idea more.

Differential Revision: https://reviews.llvm.org/D48691

llvm-svn: 336456
llvm/tools/llvm-mca/CMakeLists.txt
llvm/tools/llvm-mca/Context.cpp [new file with mode: 0644]
llvm/tools/llvm-mca/Context.h [new file with mode: 0644]
llvm/tools/llvm-mca/HardwareUnit.cpp [new file with mode: 0644]
llvm/tools/llvm-mca/HardwareUnit.h [new file with mode: 0644]
llvm/tools/llvm-mca/RegisterFile.h
llvm/tools/llvm-mca/RetireControlUnit.h
llvm/tools/llvm-mca/Scheduler.h
llvm/tools/llvm-mca/llvm-mca.cpp