This is an archive of the discontinued LLVM Phabricator instance.

[mlir] support data layout specs on ModuleOp
ClosedPublic

Authored by ftynse on Mar 12 2021, 5:57 AM.

Details

Summary

ModuleOp is a natural place to provide scoped data layout information. However,
it is undesirable for ModuleOp to implement the entirety of
DataLayoutOpInterface because that would require either pushing the interface
inside the IR library instead of a separate library, or putting the default
implementation of the interface as inline functions in headers leading to
binary bloat. Instead, ModuleOp accepts an arbitrary data layout spec attribute
and has a dedicated hook to extract it, and DataLayout is modified to know
about ModuleOp particularities.

Diff Detail

Event Timeline

ftynse created this revision.Mar 12 2021, 5:57 AM
ftynse requested review of this revision.Mar 12 2021, 5:57 AM
ftynse updated this revision to Diff 330223.Mar 12 2021, 5:58 AM

a bit more doc

ftynse updated this revision to Diff 331247.Mar 17 2021, 5:40 AM

forgot to git-add a test

herhut added a subscriber: herhut.Mar 19 2021, 8:58 AM
herhut added inline comments.
mlir/docs/DataLayout.md
30
194

I don't under stand the otherwise here. Is it "otherwise if it is a..." ?

mlir/lib/Interfaces/DataLayoutInterfaces.cpp
136

For skip this would need to be a continue. Should this not skip the module op if it is not top-level? So a nested ModuleOp that has no data layout needs to be skipped.

ftynse updated this revision to Diff 332273.Mar 22 2021, 6:57 AM
ftynse marked 3 inline comments as done.

Address review.

mlir/lib/Interfaces/DataLayoutInterfaces.cpp
136

No, it shouldn't. We can have null layouts in the middle and should handle them. It only skips the top-level module because it is most likely the one implicitly added when parsing the IR and using its location is very confusing. And we cannot continue because we are in the lambda. Extended comment to explain this.

nicolasvasilache accepted this revision.Mar 23 2021, 1:43 AM
This revision is now accepted and ready to land.Mar 23 2021, 1:43 AM
herhut accepted this revision.Mar 24 2021, 3:51 AM
herhut added inline comments.
mlir/lib/Interfaces/DataLayoutInterfaces.cpp
136

Thank you for clarifying this.

This revision was automatically updated to reflect the committed changes.