This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add `OpAsmPrinter::printOptionalLocationSpecifier`
ClosedPublic

Authored by Mogball on Sep 29 2022, 2:44 PM.

Details

Summary

This is the corresponding method to
OpAsmParser::parseOptionalLocationSpecifier that prints a location
loc(...) based on the op printing flags. Together, these two functions
allow propagating user-level location info outside of their usual spots.

Diff Detail

Event Timeline

Mogball created this revision.Sep 29 2022, 2:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 2:44 PM
Mogball requested review of this revision.Sep 29 2022, 2:44 PM
rriddle added inline comments.Sep 29 2022, 2:51 PM
mlir/include/mlir/IR/OpImplementation.h
333

I would drop the allowAlias. Locations printed this way should never be deferred, and should always allow aliases.

mlir/lib/IR/AsmPrinter.cpp
567

This should use printAttribute on the provided location, otherwise this will break if there is a deferred alias.

Mogball marked 2 inline comments as done.Sep 29 2022, 3:34 PM
Mogball updated this revision to Diff 464073.Sep 29 2022, 3:39 PM

review comments

Mogball updated this revision to Diff 464074.Sep 29 2022, 3:42 PM

forgot = 0

rriddle accepted this revision.Sep 29 2022, 3:44 PM
rriddle added inline comments.
mlir/include/mlir/IR/OpImplementation.h
330–331

I would drop this. The part about aliases isn't completely relevant to users here.

mlir/test/lib/Dialect/Test/TestDialect.cpp
1039

Can you move the encoding part to later and just grab the SMLoc here? Encoding involves uniquing the attribute (+ some other stuff), which we should only do if we need to (i.e. in the else branch here). It's good to keep this clean in case people look at it as an example usage.

This revision is now accepted and ready to land.Sep 29 2022, 3:44 PM
Mogball updated this revision to Diff 464077.Sep 29 2022, 3:57 PM
Mogball marked 2 inline comments as done.

review comments

This revision was landed with ongoing or failed builds.Sep 29 2022, 3:58 PM
This revision was automatically updated to reflect the committed changes.