diff options
author | Fangrui Song <maskray@google.com> | 2020-06-11 09:05:59 -0700 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2020-06-11 09:10:50 -0700 |
commit | 5ee571735ddf1f81db3df5d7328c86432209e3b4 (patch) | |
tree | a72f05bd6df7120d77a0961d0c52c5febea81275 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | fac7259c81671c37140374f3e6ec1fc7472c677c (diff) | |
download | llvm-5ee571735ddf1f81db3df5d7328c86432209e3b4.zip llvm-5ee571735ddf1f81db3df5d7328c86432209e3b4.tar.gz llvm-5ee571735ddf1f81db3df5d7328c86432209e3b4.tar.bz2 |
[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, #4
400078: 62 10 00 91 add x2, x3, #4
// llvm-objdump, if we change to print a word instead of bytes in the future
0: 91001062 add x2, x3, #4
400078: 91001062 add x2, x3, #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
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 70ab0a1..fbc0f01 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -741,9 +741,11 @@ public: dumpBytes(Bytes, OS); } - // The output of printInst starts with a tab. Print some spaces so that - // the tab has 1 column and advances to the target tab stop. - unsigned TabStop = NoShowRawInsn ? 16 : 40; + // The output of printInst starts with a tab. Print some spaces so that the + // tab has 1 column and advances to the target tab stop. Give more columns + // to x86 which may encode an instruction with many bytes. + unsigned TabStop = + NoShowRawInsn ? 16 : STI.getTargetTriple().isX86() ? 40 : 24; unsigned Column = OS.tell() - Start; OS.indent(Column < TabStop - 1 ? TabStop - 1 - Column : 7 - Column % 8); |