aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-mca/llvm-mca.cpp
diff options
context:
space:
mode:
authorPatrick Holland <patrickeholland@gmail.com>2021-08-21 17:37:02 -0700
committerPatrick Holland <patrickeholland@gmail.com>2021-08-25 12:12:47 -0700
commitfe01014faa336d25543561fc65201dea7f424347 (patch)
tree33b5845b594976775366cfb538b184e8dfb87ac9 /llvm/tools/llvm-mca/llvm-mca.cpp
parentb72fd31bdaf2cba3bac03a1d83a231266160527c (diff)
downloadllvm-fe01014faa336d25543561fc65201dea7f424347.zip
llvm-fe01014faa336d25543561fc65201dea7f424347.tar.gz
llvm-fe01014faa336d25543561fc65201dea7f424347.tar.bz2
[MCA] Moved View.h and View.cpp from /tools/llvm-mca/ to /lib/MCA/.
Moved View.h and View.cpp from /tools/llvm-mca/Views/ to /lib/MCA/ and /include/llvm/MCA/. This is so that targets can define their own Views within the /lib/Target/ directory (so that the View can use backend functionality). To enable these Views within mca, targets will need to add them to the vector of Views returned by their target's CustomBehaviour::getViews() methods. Differential Revision: https://reviews.llvm.org/D108520
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r--llvm/tools/llvm-mca/llvm-mca.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 8a1b689..b75a639 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -591,6 +591,21 @@ int main(int argc, char **argv) {
mca::PipelinePrinter Printer(*P, *Region, RegionIdx, *STI, PO);
+ // Targets can define their own custom Views that exist within their
+ // /lib/Target/ directory so that the View can utilize their CustomBehaviour
+ // or other backend symbols / functionality that are not already exposed
+ // through one of the MC-layer classes. These Views will be initialized
+ // using the CustomBehaviour::getViews() variants.
+ // If a target makes a custom View that does not depend on their target
+ // CB or their backend, they should put the View within
+ // /tools/llvm-mca/Views/ instead.
+ if (!DisableCustomBehaviour) {
+ std::vector<std::unique_ptr<mca::View>> CBViews =
+ CB->getStartViews(*IP, Insts);
+ for (auto &CBView : CBViews)
+ Printer.addView(std::move(CBView));
+ }
+
// When we output JSON, we add a view that contains the instructions
// and CPU resource information.
if (PrintJson) {
@@ -616,6 +631,16 @@ int main(int argc, char **argv) {
Printer.addView(std::make_unique<mca::InstructionInfoView>(
*STI, *MCII, CE, ShowEncoding, Insts, *IP));
+ // Fetch custom Views that are to be placed after the InstructionInfoView.
+ // Refer to the comment paired with the CB->getStartViews(*IP, Insts); line
+ // for more info.
+ if (!DisableCustomBehaviour) {
+ std::vector<std::unique_ptr<mca::View>> CBViews =
+ CB->getPostInstrInfoViews(*IP, Insts);
+ for (auto &CBView : CBViews)
+ Printer.addView(std::move(CBView));
+ }
+
if (PrintDispatchStats)
Printer.addView(std::make_unique<mca::DispatchStatistics>());
@@ -640,6 +665,16 @@ int main(int argc, char **argv) {
TimelineMaxCycles));
}
+ // Fetch custom Views that are to be placed after all other Views.
+ // Refer to the comment paired with the CB->getStartViews(*IP, Insts); line
+ // for more info.
+ if (!DisableCustomBehaviour) {
+ std::vector<std::unique_ptr<mca::View>> CBViews =
+ CB->getEndViews(*IP, Insts);
+ for (auto &CBView : CBViews)
+ Printer.addView(std::move(CBView));
+ }
+
if (!runPipeline(*P))
return 1;