[llvm-mca] Add a flag -instruction-info to enable/disable the instruction info view.
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 26 Mar 2018 13:44:54 +0000 (13:44 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 26 Mar 2018 13:44:54 +0000 (13:44 +0000)
llvm-svn: 328493

llvm/docs/CommandGuide/llvm-mca.rst
llvm/test/tools/llvm-mca/X86/BtVer2/instruction-info-view.s [new file with mode: 0644]
llvm/tools/llvm-mca/llvm-mca.cpp

index b4730cb..97a27f0 100644 (file)
@@ -128,6 +128,10 @@ option specifies "``-``", then the output will also be sent to standard output.
 
   Enable the resource pressure view. This is enabled by default.
 
+.. option:: -instruction-info
+
+  Enable the instruction info view. This is enabled by default.
+
 .. option:: -instruction-tables
 
   Prints resource pressure information based on the static information
diff --git a/llvm/test/tools/llvm-mca/X86/BtVer2/instruction-info-view.s b/llvm/test/tools/llvm-mca/X86/BtVer2/instruction-info-view.s
new file mode 100644 (file)
index 0000000..e039d29
--- /dev/null
@@ -0,0 +1,23 @@
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure=false -instruction-info=true < %s | FileCheck %s --check-prefix=ENABLED
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure=false -instruction-info=false < %s | FileCheck %s -check-prefix=DISABLED
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure=false -instruction-info < %s | FileCheck %s -check-prefix=ENABLED
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure=false < %s | FileCheck %s -check-prefix=ENABLED
+
+vmulps   %xmm0, %xmm1, %xmm2
+vhaddps  %xmm2, %xmm2, %xmm3
+vhaddps  %xmm3, %xmm3, %xmm4
+
+# DISABLED-NOT: Instruction Info:
+
+# ENABLED:      Instruction Info:
+# ENABLED-NEXT: [1]: #uOps
+# ENABLED-NEXT: [2]: Latency
+# ENABLED-NEXT: [3]: RThroughput
+# ENABLED-NEXT: [4]: MayLoad
+# ENABLED-NEXT: [5]: MayStore
+# ENABLED-NEXT: [6]: HasSideEffects
+
+# ENABLED:      [1]    [2]    [3]    [4]    [5]    [6] Instructions:
+# ENABLED-NEXT:  1      2     1.00                     vmulps  %xmm0, %xmm1, %xmm2
+# ENABLED-NEXT:  1      3     1.00                     vhaddps %xmm2, %xmm2, %xmm3
+# ENABLED-NEXT:  1      3     1.00                     vhaddps %xmm3, %xmm3, %xmm4
index 127b22f..cae4c27 100644 (file)
@@ -131,6 +131,11 @@ static cl::opt<bool>
                            cl::desc("Print instruction tables"),
                            cl::init(false));
 
+static cl::opt<bool>
+    PrintInstructionInfoView("instruction-info",
+                             cl::desc("Print the instruction info view"),
+                             cl::init(true));
+
 static const Target *getTarget(const char *ProgName) {
   TripleName = Triple::normalize(TripleName);
   if (TripleName.empty())
@@ -336,9 +341,13 @@ int main(int argc, char **argv) {
 
   if (PrintInstructionTables) {
     mca::InstructionTables IT(STI->getSchedModel(), *IB, *S);
+
+    if (PrintInstructionInfoView) {
+      mca::InstructionInfoView IIV(*STI, *MCII, *S, *IP);
+      IT.addEventListener(&IIV);
+    }
+
     mca::ResourcePressureView RPV(*STI, *IP, *S);
-    mca::InstructionInfoView IIV(*STI, *MCII, *S, *IP);
-    IT.addEventListener(&IIV);
     IT.addEventListener(&RPV);
     IT.run();
     RPV.printView(TOF->os());
@@ -355,8 +364,9 @@ int main(int argc, char **argv) {
 
   Printer->addView(llvm::make_unique<mca::SummaryView>(*S, Width));
 
-  Printer->addView(
-      llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, *S, *IP));
+  if (PrintInstructionInfoView)
+    Printer->addView(
+        llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, *S, *IP));
 
   if (PrintModeVerbose)
     Printer->addView(llvm::make_unique<mca::BackendStatistics>(*STI));