This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Add getBody() method to SingleImplicitBlockTerminator op trait.
ClosedPublic

Authored by pifon2a on Apr 25 2020, 8:46 AM.

Details

Summary

Many ops with this trait have getBody() and getBodyBuilder() methods defined in extraClassDeclaration in tablegen. getBody() implementation is the same accross all these ops, but getBodyBuilder() can return builders with varying insertion points set. In this PR, getBody() is moved into SingleImplicitBlockTerminator struct and getBodyBuilder() is replaced with OpBuilder::atBlock(End|Terminator)(op.getBody);.

Diff Detail

Event Timeline

pifon2a created this revision.Apr 25 2020, 8:46 AM
pifon2a edited reviewers, added: mehdi_amini; removed: nicolasvasilache.Apr 25 2020, 8:47 AM
mehdi_amini accepted this revision.Apr 25 2020, 10:23 AM

LGTM, thanks!

mlir/include/mlir/IR/Builders.h
214

laster -> last?

rriddle requested changes to this revision.Apr 25 2020, 11:42 AM
rriddle added inline comments.
mlir/include/mlir/IR/Builders.h
212

This seems weird. I would expect you to just do block->getTerminator()

mlir/include/mlir/IR/OpDefinition.h
1098

This is not applicable to all users of this trait, e.g. IfOp. SingleBlockImplicitTerminator does not imply a single region.

This revision now requires changes to proceed.Apr 25 2020, 11:42 AM
DavidTruby resigned from this revision.Apr 27 2020, 4:28 AM
pifon2a updated this revision to Diff 260282.Apr 27 2020, 4:54 AM

Addressed River's comment.

pifon2a updated this revision to Diff 260289.Apr 27 2020, 5:36 AM
pifon2a marked 3 inline comments as done.

More comments.

herhut accepted this revision.Apr 27 2020, 7:12 AM

Nice, thanks!

rriddle accepted this revision.Apr 27 2020, 11:26 AM

Looks great, thanks for the cleanup! LGTM after resolving the comments about assert messages

mlir/include/mlir/IR/Builders.h
213

nit: Please update all of the asserts to start with lowercase and end with no period.

This revision is now accepted and ready to land.Apr 27 2020, 11:26 AM
pifon2a updated this revision to Diff 260412.Apr 27 2020, 12:47 PM

Addressed the comments.

pifon2a marked an inline comment as done.Apr 27 2020, 12:48 PM
This revision was automatically updated to reflect the committed changes.