This is an archive of the discontinued LLVM Phabricator instance.

Document CMake Changes Needed to Generate Attribute Code from TableGen
ClosedPublic

Authored by andrej on Jul 13 2023, 4:17 PM.

Details

Summary

I've been struggling with generating the C++ class declarations and definitions for custom attributes from TableGen, as described on this documentation page: https://mlir.llvm.org/docs/DefiningDialects/AttributesAndTypes/#adding-a-new-attribute-or-type-definition

The code for custom types is automatically generated when the MLIR Dialect is added with add_mlir_dialect() in the CMake file.

The same is not the case for custom attributes. I think people could benefit from learning how to adjsut their CMakeLists.txt to automatically generate the classes as described on that documentation page. This change adds the necessary information for this.

makslevental on Discord was so kind to help me figure this out myself

Diff Detail

Event Timeline

andrej created this revision.Jul 13 2023, 4:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 4:17 PM
andrej requested review of this revision.Jul 13 2023, 4:17 PM
makslevental accepted this revision.Jul 13 2023, 5:54 PM
makslevental added inline comments.
mlir/docs/DefiningDialects/AttributesAndTypes.md
51

I would phrase this as something like

One difference is that triggering C++ codegen for Attributes will require...

192

nit: wherever

This revision is now accepted and ready to land.Jul 13 2023, 5:54 PM