[PATCH] D128030: [llvm-objdump] Default to --mattr=+all for AArch64

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 11:18:05 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG275862c75d9f: [llvm-objdump] Default to --mattr=+all for AArch64 (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D128030?vs=441461&id=441464#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128030/new/

https://reviews.llvm.org/D128030

Files:
  llvm/docs/CommandGuide/llvm-objdump.rst
  llvm/test/tools/llvm-objdump/ELF/AArch64/mattr.s
  llvm/tools/llvm-objdump/llvm-objdump.cpp


Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1690,9 +1690,12 @@
 
   // Package up features to be passed to target/subtarget
   SubtargetFeatures Features = Obj->getFeatures();
-  if (!MAttrs.empty())
+  if (!MAttrs.empty()) {
     for (unsigned I = 0; I != MAttrs.size(); ++I)
       Features.AddFeature(MAttrs[I]);
+  } else if (MCPU.empty() && Obj->getArch() == llvm::Triple::aarch64) {
+    Features.AddFeature("+all");
+  }
 
   std::unique_ptr<const MCRegisterInfo> MRI(
       TheTarget->createMCRegInfo(TripleName));
Index: llvm/test/tools/llvm-objdump/ELF/AArch64/mattr.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/ELF/AArch64/mattr.s
@@ -0,0 +1,21 @@
+## When --mattr and --mcpu are both empty, disassemble all known instructions.
+# RUN: llvm-mc -filetype=obj -triple=aarch64 -mattr=+all %s -o %t
+# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefixes=CHECK,ALL
+
+## If --mattr or --mcpu is specified, don't default to --mattr=+all.
+# RUN: llvm-objdump -d --no-show-raw-insn --mattr=+v8a %t | FileCheck %s --check-prefixes=CHECK,UNKNOWN
+# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=generic %t | FileCheck %s --check-prefixes=CHECK,UNKNOWN
+
+# CHECK-LABEL: <_start>:
+# ALL-NEXT:      bc.eq 0x4
+# ALL-NEXT:      irg x0, x1
+# ALL-NEXT:      mrs x0, RNDR
+# UNKNOWN-COUNT-2: <unknown>
+# UNKNOWN:       mrs x0, S3_3_C2_C4_0
+# CHECK-EMPTY:
+
+.globl _start
+_start:
+  bc.eq #4      // armv8.8-a hbc
+  irg x0, x1    // armv8.5-a mte
+  mrs x0, RNDR  // armv8.5-a rand
Index: llvm/docs/CommandGuide/llvm-objdump.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-objdump.rst
+++ llvm/docs/CommandGuide/llvm-objdump.rst
@@ -27,7 +27,11 @@
 
 .. option:: -d, --disassemble
 
-  Disassemble all executable sections found in the input files.
+  Disassemble all executable sections found in the input files. On some
+  architectures (AArch64, x86), all known instructions are disassembled by
+  default. On the others, :option:`--mcpu` or :option:`--mattr` is needed to
+  enable some instruction sets. Disabled instructions are displayed as
+  ``<unknown>``.
 
 .. option:: -D, --disassemble-all
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128030.441464.patch
Type: text/x-patch
Size: 2425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/2783fb4b/attachment.bin>


More information about the llvm-commits mailing list