This is an archive of the discontinued LLVM Phabricator instance.

[mlir][toy] Define a FuncOp operation in toy and drop the dependence on FuncOp
ClosedPublic

Authored by rriddle on Mar 8 2022, 4:27 PM.

Details

Summary

FuncOp is being moved out of the builtin dialect, and defining a custom
toy operation showcases various aspects of defining function-like operation
(e.g. inlining, passes, etc.).

Diff Detail

Event Timeline

rriddle created this revision.Mar 8 2022, 4:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2022, 4:27 PM
rriddle requested review of this revision.Mar 8 2022, 4:27 PM
rriddle updated this revision to Diff 413979.Mar 8 2022, 5:22 PM
rriddle edited the summary of this revision. (Show Details)

(some comments from the parent revision apply here but I don't repeat them)

mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
122

Interesting, the comment didn't match the implementation: the function wasn't added to the module...

mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
230

Is this necessary to get out of toy::FuncOp here?

rriddle updated this revision to Diff 415329.Mar 15 2022, 12:06 AM
rriddle marked an inline comment as done.
rriddle added inline comments.Mar 15 2022, 12:06 AM
mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
122

Yeah... I assume this was something from very early on that didn't get adapted as the contents of the function changed. Interestingly enough, the comment is now actually accurate.

mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
230

I adapted here because we already lower ReturnOp here, which needs to be lowered at the same time. We also use some FuncOp specific affine optimization passes right afterwards, so we would need to drop out of toy::FuncOp around this point anyways.

mehdi_amini accepted this revision.Mar 15 2022, 1:26 PM
This revision is now accepted and ready to land.Mar 15 2022, 1:26 PM