This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] ODS TypeDef documentation
ClosedPublic

Authored by jdd on Oct 14 2020, 7:23 PM.

Details

Summary

Adds documentation for the new ODS TypeDef support.

Diff Detail

Event Timeline

jdd created this revision.Oct 14 2020, 7:23 PM
jdd requested review of this revision.Oct 14 2020, 7:23 PM
jdd added a comment.Oct 14 2020, 7:26 PM

I'm working on this in this branch: https://github.com/teqdruid/llvm-project/tree/ods-types-doc. It may be faster to edit directly. I can either push this branch upstream or give reviews/editors access to my fork.

mehdi_amini added inline comments.Oct 15 2020, 4:32 PM
mlir/docs/OpDefinitions.md
1415

As a title, it may be more clear to expand this.

The name "TypeDef" is a bit confusing to me by the way, as it first got me to think about C++ typedefs.

1433
1454

(offtopic with the doc)
Have you thought / planned for declarative assembly?

1462–1463

How does it work when there is no printer/parser for a Type?

1538

Nit: can you wrap this line?

jdd marked 5 inline comments as done.Oct 15 2020, 4:46 PM
jdd added inline comments.
mlir/docs/OpDefinitions.md
1415

Yeah, well 'Type' was already taken in ODS.

1454

I had a way to do this in my original patch, but it wasn't not consistent with the Op declarative format so we decided to remove it.

jdd updated this revision to Diff 298519.Oct 15 2020, 4:48 PM
jdd marked 2 inline comments as done.
  • Updating doc as per Mehdi's comments
jdd added a comment.EditedOct 15 2020, 4:51 PM

Also, this documentation is very slightly wrong without https://reviews.llvm.org/D89438

rriddle accepted this revision.Oct 18 2020, 3:56 PM

LGTM for the current documentation after resolving comments. The questions related to where the methods are generated and merging TypeDef with something else aren't blocking on this revision.

mlir/docs/OpDefinitions.md
1415

The use of Data is weird to me given that not all types represent "Data". I would just remove it.

1415

Can you merge the tablegen TypeDef class with DialectType?

1433

The indent here is off.

1437

Can you just make this one line?

1449

LLVM/MLIR don't have code on the same line as the if, can you add a newline to each of these.

1468

is in -> as in

1479

nit: Set ... to generate or Setting ... will generate.

1482

nit: Use a -> Use the

1524

nit: StorageAllocator allocator -> StorageAllocator &allocator

1532–1533
1547

Why are they placed in the dialect's namespace and not local/static to where the .inc file is included?

1580

nit: Drop the extra newlines here.

This revision is now accepted and ready to land.Oct 18 2020, 3:56 PM
jdd updated this revision to Diff 298908.Oct 18 2020, 5:01 PM
jdd marked 7 inline comments as done.
  • Changes based on River's feedback.
mlir/docs/OpDefinitions.md
1415

RE merging: I'm not sure what the implications of that would be. Was also considering having TypeDef extend Type and make it have a predicate which only matches itself. Either way, I'm considering both future improvements.

1547

They're declared in the header file so you don't have to #include the cpp in the same place as you put your Dialect::parseType definition.

rriddle added inline comments.Oct 18 2020, 5:05 PM
mlir/docs/OpDefinitions.md
1547

For the general infra we should try as hard as possible not to expose internal implementation details to public users. In most cases(all the ones that I can think of both upstream and downstream), the user wouldn't want to expose these methods and they would also be included in the same file as the parseType/printType implementations. If a user wants to do that differently, they can always manually expose it themselves but I wouldn't want that to be the default.

jdd added inline comments.Oct 18 2020, 5:18 PM
mlir/docs/OpDefinitions.md
1547

In understand but couldn't think of an alternative since I didn't want to require users to include the implementation in the same file as Dialect::parseType. Though maybe that's appropriate. Isolate all the Type code to one cpp file.

This revision was automatically updated to reflect the committed changes.