This is an archive of the discontinued LLVM Phabricator instance.

Version 0.5 of the "TableGen Backend Developer's Guide"
ClosedPublic

Authored by Paul-C-Anagnostopoulos on Sep 21 2020, 11:02 AM.

Details

Summary

This is version 0.5 of the new document titled "TableGen Backend Developer's Guide." It is a first cut a describing how to write a new backend for TableGen. It describes the data structures available to the backend, but not in complete detail. That is left to the Doxygen pages. It also discusses various top-level concepts related to accessing classes and records, fields, and error messages.

Two other documents are updated to refer to the new document. And there is a backend skeleton C++ file.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2020, 11:02 AM
Paul-C-Anagnostopoulos requested review of this revision.Sep 21 2020, 11:02 AM

Very cool! + @jpienaar in case you're interested.

llvm/docs/TableGen/BackEnds.rst
17

Might mention MLIR as well, which uses TableGen extensively as the basis for its ODS system:
https://mlir.llvm.org/docs/OpDefinitions/

llvm/lib/TableGen/TableGenBackendSkeleton.cpp
1

I think that adding an example backend is a good idea, but please make it valid C++ code that follows the coding standard etc.

llvm/docs/TableGen/BackEnds.rst
17

I will add a mention of MLIR.

llvm/lib/TableGen/TableGenBackendSkeleton.cpp
1

Hmm. Then I have to replace all the metasyntactic items with syntactically-valid items. The idea was to have the compilation fail if someone forgot to replace one of the meta items with their real item. How about if I use real items but uppercase them all so they stand out? I would note that convention in the initial comment.

I think that just naming it something obvious like "SkeletonEmitter" is enough. That allows you to follow the naming convention. The problem with doing something weird here is that people may propagate the weirdness. We would like to encourage people to follow best practices by default.

Okay, I will do that.

I addressed the first round of comments.

Is there a reason why MLIR patches can't be mixed with other patches? I need to update the "Operation Definition Specification" document to refer to the new TableGen documents.

No reason that i'm aware of. Feel free to mix mlir updates in.

Paul-C-Anagnostopoulos set the repository for this revision to rG LLVM Github Monorepo.

Updated two MLIR documentation files to refer to the new TableGen documents.

Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2020, 9:02 AM
lattner accepted this revision.Sep 22 2020, 10:21 AM

very nice

This revision is now accepted and ready to land.Sep 22 2020, 10:21 AM

Thanks! I've pushed the patch.

Indeed, thanks this is super nice (I missed the ping here but saw the commit on GitHub and pointed folks to it)

Thanks! If anyone has comments or suggestions, please feel free to post them at llvm-dev.