[PATCH] D119899: [TableGen] Add a library-based entry point for parsing td files

Jacques Pienaar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 07:59:33 PST 2022


jpienaar added a comment.

In D119899#3325086 <https://reviews.llvm.org/D119899#3325086>, @rriddle wrote:

> In D119899#3325071 <https://reviews.llvm.org/D119899#3325071>, @nhaehnle wrote:
>
>> I'm in favor of exposing this, I actually ran into this problem just yesterday in an external project.
>>
>> However, the proposed interface using a callback is strange. How about returning an `Expected<RecordKeeper>` instead?
>
> Ah, I think I would be fine going with something like that. The thing I like about the callback approach is that it has more explicit expectations around lifetime, which tablegen right now has a horrible notion of. Not shown here is that to actually properly invoke tablegen multiple times, you need to call llvm_shutdown/reset the global SrcMgr/etc.

Should all of that perhaps be happening inside this function? E.g., could we have this be "hermetic" and have the lifetime of everything tblgen side scoped to the call (e.g., you can walk over all the records inside but not keep any references to it). That way if this gets changed tblgen side, the users of this function don't need to be updated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119899/new/

https://reviews.llvm.org/D119899



More information about the llvm-commits mailing list