This is an archive of the discontinued LLVM Phabricator instance.

MC: Allow targets to stop symbol name quoting
ClosedPublic

Authored by arsenm on Apr 22 2015, 1:13 PM.

Details

Reviewers
arsenm
Summary

Currently symbol names are printed in quotes if it contains something
outside of the arbitrary set of characters that isAcceptableChar tests
for. On somem targets, it is never OK to print a symbol name in quotes
so allow targets to opt out of this behavior.

Diff Detail

Event Timeline

arsenm updated this revision to Diff 24254.Apr 22 2015, 1:13 PM
arsenm retitled this revision from to MC: Allow targets to stop symbol name quoting.
arsenm updated this object.
arsenm edited the test plan for this revision. (Show Details)
arsenm added a subscriber: Unknown Object (MLST).
arsenm updated this revision to Diff 24256.Apr 22 2015, 1:43 PM

Add change from missing file in first patch

This needs a testcase.

This function is used to print assembly. You have an assembler that can handle any characters in the name? How?

include/llvm/MC/MCSymbol.h
58

The comment is flipped, no?

arsenm updated this revision to Diff 24561.Apr 28 2015, 10:03 AM

Replace with virtual function on MCAsmInfo to allow targets to control when symbols are quoted.

Most of the patch is threading MCAsmInfo arguments through all of the uses of MCSymbol/MCExpr printing

rafael added inline comments.Apr 30 2015, 12:51 PM
lib/MC/MCSymbol.cpp
29

Can you pass a "const MCAsmInfo &" ?

For the debug uses (i.e., dump), they can just say

OS << Symbol->getName()

instead of

Symbol->print(OS, nullptr);

Looks a lot better now.

arsenm added inline comments.Apr 30 2015, 4:23 PM
lib/MC/MCSymbol.cpp
29

I don't think so. For MCSymbol specifically, that would work. Most of these changes are for printing the MCExpr / MCOperands, which don't have a simple getName way of printing them, so those are handled with a null check in the MCSymbol printing

arsenm updated this revision to Diff 24898.May 4 2015, 11:32 AM

Print getName() where possible instead

Sorry for the delay.

It is looking a lot better, but there are still cases where we are passing a MCAsmInfo and it is not used.

lib/MC/MCInst.cpp
18

This is just for debug, no? You can probably drop the MCAsmInfo from it.

44

This is just for debug, you can drop the MCAsmInfo.

lib/MC/MCSymbol.cpp
56

This can be just "OS << getName();".

I have rebased the patch to take a better look.

OK, here is an updated patch.

The change from yours are:

  • Note that empty names have to be quoted.
  • Keep the old debug code in place.

Does it work for what you need?

arsenm updated this revision to Diff 27151.Jun 4 2015, 2:57 PM

Update for trunk.

I tried to merge in your changes, but may have missed some with the nasty merge from all of these functions changing names.

I does look like you missed some cases. A new patch is attached.

Please make sure to git-clang-format your patches.

Cheers,
Rafael

arsenm accepted this revision.Jun 8 2015, 5:36 PM
arsenm added a reviewer: arsenm.

Thanks, r239370

This revision is now accepted and ready to land.Jun 8 2015, 5:36 PM
arsenm closed this revision.Jun 8 2015, 5:36 PM