[PATCH] D103005: [AArch64] Support llvm-mc/llvm-objdump -M no-aliases

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 10:50:05 PDT 2021


MaskRay updated this revision to Diff 348019.
MaskRay added a comment.

Prefer -mtriple=aarch64 (generic ELF) to a Linux oriented triple.
Using a generic ELF triple emphasizes that the test is portable across various ELF OSes not just Linux glibc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103005

Files:
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
  llvm/test/MC/AArch64/alias-addsubimm.s


Index: llvm/test/MC/AArch64/alias-addsubimm.s
===================================================================
--- llvm/test/MC/AArch64/alias-addsubimm.s
+++ llvm/test/MC/AArch64/alias-addsubimm.s
@@ -1,4 +1,5 @@
-// RUN: llvm-mc -triple=aarch64-none-linux-gnu < %s | FileCheck %s
+// RUN: llvm-mc -triple=aarch64 < %s | FileCheck %s --check-prefixes=CHECK,ALIAS
+// RUN: llvm-mc -triple=aarch64 -M no-aliases < %s | FileCheck %s --check-prefixes=CHECK,NOALIAS
 // RUN: not llvm-mc -mattr=+no-neg-immediates -triple=aarch64-none-linux-gnu < %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-NEG-IMM
 
         add w0, w2, #4096
@@ -103,23 +104,31 @@
 // CHECK: adds x2, x5, #0
         adds x2, x5, #0
 
-// CHECK: {{adds xzr,|cmn}} x5, #5
-// CHECK: {{adds xzr,|cmn}} x5, #5
+// ALIAS: cmn x5, #5
+// ALIAS: cmn x5, #5
+// NOALIAS: adds xzr, x5, #5
+// NOALIAS: adds xzr, x5, #5
 // CHECK-NO-NEG-IMM: instruction requires: NegativeImmediates
         cmn x5, #5
         cmp x5, #-5
-// CHECK: {{subs xzr,|cmp}} x6, #4095
-// CHECK: {{subs xzr,|cmp}} x6, #4095
+// ALIAS: cmp x6, #4095
+// ALIAS: cmp x6, #4095
+// NOALIAS: subs xzr, x6, #4095
+// NOALIAS: subs xzr, x6, #4095
 // CHECK-NO-NEG-IMM: instruction requires: NegativeImmediates
         cmp x6, #4095
         cmn x6, #-4095
-// CHECK: {{adds wzr,|cmn}} w7, #5
-// CHECK: {{adds wzr,|cmn}} w7, #5
+// ALIAS: cmn w7, #5
+// ALIAS: cmn w7, #5
+// NOALIAS: adds wzr, w7, #5
+// NOALIAS: adds wzr, w7, #5
 // CHECK-NO-NEG-IMM: instruction requires: NegativeImmediates
         cmn w7, #5
         cmp w7, #-5
-// CHECK: {{subs wzr,|cmp}} w8, #4095
-// CHECK: {{subs wzr,|cmp}} w8, #4095
+// ALIAS: cmp w8, #4095
+// ALIAS: cmp w8, #4095
+// NOALIAS: subs wzr, w8, #4095
+// NOALIAS: subs wzr, w8, #4095
 // CHECK-NO-NEG-IMM: instruction requires: NegativeImmediates
         cmp w8, #4095
         cmn w8, #-4095
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
===================================================================
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
@@ -25,6 +25,8 @@
   AArch64InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
                      const MCRegisterInfo &MRI);
 
+  bool applyTargetSpecificCLOption(StringRef Opt) override;
+
   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
                  const MCSubtargetInfo &STI, raw_ostream &O) override;
   void printRegName(raw_ostream &OS, unsigned RegNo) const override;
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
===================================================================
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
@@ -51,6 +51,14 @@
                                                  const MCRegisterInfo &MRI)
     : AArch64InstPrinter(MAI, MII, MRI) {}
 
+bool AArch64InstPrinter::applyTargetSpecificCLOption(StringRef Opt) {
+  if (Opt == "no-aliases") {
+    PrintAliases = false;
+    return true;
+  }
+  return false;
+}
+
 void AArch64InstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
   // This is for .cfi directives.
   OS << getRegisterName(RegNo);
@@ -296,7 +304,7 @@
     return;
   }
 
-  if (!printAliasInstr(MI, Address, STI, O))
+  if (!PrintAliases || !printAliasInstr(MI, Address, STI, O))
     printInstruction(MI, Address, STI, O);
 
   printAnnotation(O, Annot);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103005.348019.patch
Type: text/x-patch
Size: 3494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210526/ea91b23d/attachment.bin>


More information about the llvm-commits mailing list