This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add support for printing pcrel immediates as absolute addresses in llvm-objdump
ClosedPublic

Authored by craig.topper on Nov 25 2020, 6:12 PM.

Details

Summary

This makes the llvm-objdump output much more readable and closer to binutils objdump. This builds on https://reviews.llvm.org/D76591

It requires changing the OperandType for certain immediates to "OPERAND_PCREL" so tablegen will generate code to pass the instruction's address. This means we can't do the generic check on these instructions in verifyInstruction any more. Should I add it back with explicit opcode checks? Or should we add a new operand flag to control the passing of address instead of matching the name?

Diff Detail

Event Timeline

craig.topper created this revision.Nov 25 2020, 6:12 PM
craig.topper requested review of this revision.Nov 25 2020, 6:12 PM
MaskRay accepted this revision.Nov 25 2020, 8:59 PM
This revision is now accepted and ready to land.Nov 25 2020, 8:59 PM

@asb , @lenary , @luismarques does this look good to you?

We've been pretty consistent with trying to align our behaviour with the GNU tools, so these kinds of patches have always been welcome. I'm not sure if there are compatibility concerns with changing the behaviour now. Should we have a an option for changing the printing style, both for compatibility and personal preference?
About the verification, I'm not sure what the best approach is.

lld/test/ELF/riscv-undefined-weak.s
54–55

Does the printing change address that FIXME? That is, isn't 0x0 the address? (which is zero because the relocation hasn't yet been applied).

MaskRay added inline comments.Dec 3 2020, 10:20 AM
lld/test/ELF/riscv-undefined-weak.s
54–55

Right. The FIXME should be deleted.