This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tblgen] Move `GenRegistration` and `GenNameParser` implementations into `TableGen` library
AbandonedPublic

Authored by zero9178 on Aug 3 2022, 9:11 AM.

Details

Summary

These utilities are declared in the header mlir/TableGen/GenInfo.h and mlir/TableGen/GenNameParser.h. Despite this, their implementations are in mlir-tablegen.cpp, making it not possible to use them by simply linking against the MLIRTableGen target.

This patch fixes that by moving the implementations of those classes into a source file part of the MLIRTableGen target. Note that having them both be implemented in the same source file is necessary at this moment due to requiring access to the managed static generatorRegistry.

Diff Detail

Event Timeline

zero9178 created this revision.Aug 3 2022, 9:11 AM
zero9178 requested review of this revision.Aug 3 2022, 9:12 AM

What is the use case you want to unblock with this?

Mogball accepted this revision.Aug 3 2022, 9:13 AM
This revision is now accepted and ready to land.Aug 3 2022, 9:13 AM

What is the use case you want to unblock with this?

Being able to use these in downstream TableGen backends. The registration mechanism used here is very convenient.

Being able to use these in downstream TableGen backends. The registration mechanism used here is very convenient.

OK but I don't think this patch is the best way to achieve this: what about modeling this with what we did with the OptMainLib instead?

Being able to use these in downstream TableGen backends. The registration mechanism used here is very convenient.

OK but I don't think this patch is the best way to achieve this: what about modeling this with what we did with the OptMainLib instead?

That's true, this is essentially the bare minimum to run a similar setup.
I've posted https://reviews.llvm.org/D131112 as an alternative with your suggestion implemented.