Skip to content

Commit 99ec6f8

Browse files
authored
[LoongArch][MC] Add support for disassembly option "no-aliases" (#132900)
This parallels the GNU Binutils feature's usage. A hidden command-line option `--loongarch-no-aliases` is also added, similar to how `--loongarch-numeric-reg` is for the `numeric` option.
1 parent f7a3334 commit 99ec6f8

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchInstPrinter.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ using namespace llvm;
2525
#define PRINT_ALIAS_INSTR
2626
#include "LoongArchGenAsmWriter.inc"
2727

28+
static cl::opt<bool>
29+
NoAliases("loongarch-no-aliases",
30+
cl::desc("Disable the emission of assembler pseudo instructions"),
31+
cl::init(false), cl::Hidden);
32+
2833
static cl::opt<bool>
2934
NumericReg("loongarch-numeric-reg",
3035
cl::desc("Print numeric register names rather than the ABI "
@@ -37,6 +42,11 @@ static cl::opt<bool>
3742
// be an easier way to allow these options in all these tools, without doing it
3843
// this way.
3944
bool LoongArchInstPrinter::applyTargetSpecificCLOption(StringRef Opt) {
45+
if (Opt == "no-aliases") {
46+
PrintAliases = false;
47+
return true;
48+
}
49+
4050
if (Opt == "numeric") {
4151
NumericReg = true;
4252
return true;
@@ -49,7 +59,7 @@ void LoongArchInstPrinter::printInst(const MCInst *MI, uint64_t Address,
4959
StringRef Annot,
5060
const MCSubtargetInfo &STI,
5161
raw_ostream &O) {
52-
if (!printAliasInstr(MI, Address, STI, O))
62+
if (!PrintAliases || NoAliases || !printAliasInstr(MI, Address, STI, O))
5363
printInstruction(MI, Address, STI, O);
5464
printAnnotation(O, Annot);
5565
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# RUN: llvm-mc --triple=loongarch32 --loongarch-no-aliases %s \
2+
# RUN: | FileCheck %s
3+
# RUN: llvm-mc --triple=loongarch32 -M no-aliases %s \
4+
# RUN: | FileCheck %s
5+
# RUN: llvm-mc --triple=loongarch32 --filetype=obj %s -o %t.32
6+
# RUN: llvm-objdump -d -M no-aliases %t.32 | FileCheck %s
7+
8+
# RUN: llvm-mc --triple=loongarch64 --loongarch-no-aliases %s \
9+
# RUN: | FileCheck %s
10+
# RUN: llvm-mc --triple=loongarch64 -M no-aliases %s \
11+
# RUN: | FileCheck %s
12+
# RUN: llvm-mc --triple=loongarch64 --filetype=obj %s -o %t.64
13+
# RUN: llvm-objdump -d -M no-aliases %t.64 | FileCheck %s
14+
15+
# Also test passing multiple disassembly options at once.
16+
# RUN: llvm-objdump -d -M no-aliases,numeric %t.64 | FileCheck --check-prefix=CHECK-NUMERIC %s
17+
18+
foo:
19+
# CHECK: or $a0, $r21, $zero
20+
# CHECK-NEXT: jirl $zero, $ra, 0
21+
# CHECK-NUMERIC: or $r4, $r21, $r0
22+
# CHECK-NUMERIC-NEXT: jirl $r0, $r1, 0
23+
move $a0, $r21
24+
ret

0 commit comments

Comments
 (0)