Skip to content

Commit 5ee5717

Browse files
committed
[llvm-objdump] Decrease instruction indentation for non-x86
Place the instruction at the 24th column (0-based indexing), matching GNU objdump ARM/AArch64/powerpc/etc when the address is low. This is beneficial for non-x86 targets which have short instruction lengths. ``` // GNU objdump AArch64 0: 91001062 add x2, x3, #0x4 400078: 91001062 add x2, x3, #0x4 // llvm-objdump, with this patch 0: 62 10 00 91 add x2, x3, rust-lang#4 400078: 62 10 00 91 add x2, x3, rust-lang#4 // llvm-objdump, if we change to print a word instead of bytes in the future 0: 91001062 add x2, x3, rust-lang#4 400078: 91001062 add x2, x3, rust-lang#4 // GNU objdump Thumb 0: bf00 nop // GNU objdump Power ISA 3.1 64-bit instruction // 0: 00 00 10 04 plwa r3,0 // 4: 00 00 60 a4 ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D81590
1 parent fac7259 commit 5ee5717

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t
2+
# RUN: llvm-objdump -d %t | tr '\t' '|' | FileCheck --match-full-lines --strict-whitespace %s
3+
4+
## Use '|' to show where the tabs line up.
5+
# CHECK:0000000000000000 <$x.0>:
6+
# CHECK-NEXT: 0: 62 10 00 91 |add|x2, x3, #4
7+
# CHECK-EMPTY:
8+
# CHECK-NEXT:0000000000000004 <$d.1>:
9+
# CHECK-NEXT: 4:|ff ff 00 00|.word|0x0000ffff
10+
11+
add x2, x3, #4
12+
.word 0xffff

llvm/tools/llvm-objdump/llvm-objdump.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,11 @@ class PrettyPrinter {
741741
dumpBytes(Bytes, OS);
742742
}
743743

744-
// The output of printInst starts with a tab. Print some spaces so that
745-
// the tab has 1 column and advances to the target tab stop.
746-
unsigned TabStop = NoShowRawInsn ? 16 : 40;
744+
// The output of printInst starts with a tab. Print some spaces so that the
745+
// tab has 1 column and advances to the target tab stop. Give more columns
746+
// to x86 which may encode an instruction with many bytes.
747+
unsigned TabStop =
748+
NoShowRawInsn ? 16 : STI.getTargetTriple().isX86() ? 40 : 24;
747749
unsigned Column = OS.tell() - Start;
748750
OS.indent(Column < TabStop - 1 ? TabStop - 1 - Column : 7 - Column % 8);
749751

0 commit comments

Comments
 (0)