This is an archive of the discontinued LLVM Phabricator instance.

Teach the MLIR AsmPrinter to correctly escape asm names that use invalid characters.
ClosedPublic

Authored by lattner on Mar 10 2020, 6:24 AM.

Diff Detail

Event Timeline

lattner created this revision.Mar 10 2020, 6:24 AM
Herald added a project: Restricted Project. · View Herald Transcript
rriddle added a comment.EditedMar 10 2020, 10:18 AM

What is the benefit of doing this vs. just rejecting/ignoring the name? Do we need to support the weird cases?

rriddle added a comment.EditedMar 10 2020, 10:21 PM

What is the benefit of doing this vs. just rejecting/ignoring the name? Do we need to support the weird cases?

Also, what about using a string as the escape mechanism? We already do this for other things.

%"a .^x" : i32

Who should own the complexity (and the definition of what a valid asm name is): the core, or all clients?

Also, what about using a string as the escape mechanism?

I'm open to this. This this what Swift does, where you can have an identifier x, or you can have an identifier x that allows a very generous grammar within it.

In this case, I don't think we want to promise to dialects that the textual IR will persist an arbitrary grammar. I think it is better to keep the asm format simple, and force dialects who care about this stuff (none of them today, and almost none of them in the future) to own the autorenaming complexity.

River, does this patch LGTY? It is pretty straight-forward.

rriddle accepted this revision.Mar 11 2020, 5:07 PM

Sorry, I forgot to hit submit. Avoiding the use of string is fine for now, as it keeps this specific to this one part of the printer.

mlir/lib/IR/AsmPrinter.cpp
763

Please use /// for top-level comments.

788

nit: auto -> char?

This revision is now accepted and ready to land.Mar 11 2020, 5:07 PM
lattner marked an inline comment as done.Mar 12 2020, 10:25 PM

Thanks River!

This revision was automatically updated to reflect the committed changes.