This revision adds the !find bang operator, which searches a source string for a target string.
I updated the TableGen Programmer's Reference and added a test.
Paths
| Differential D101318
[TableGen] Add the !find bang operator ClosedPublic Authored by Paul-C-Anagnostopoulos on Apr 26 2021, 12:18 PM.
Details Summary This revision adds the !find bang operator, which searches a source string for a target string. I updated the TableGen Programmer's Reference and added a test.
Diff Detail
Event TimelineComment Actions Do you have a use case in mind for this feature? (will it help tidy up existing tblgen files significantly? is it necessary to support some use case that's not possible to express currently but that's needed by you or others?) Comment Actions I added !find() to complement !substr(), so that TableGen would have the two most common string functions. I believe !find will be helpful with 'assert' as people begin adding assertions to TableGen files. Comment Actions
Fair enough - a general suggestion that these sort of tools aren't necessarily the place for adding a lot of speculative features. Usually we expect some in-tree motivating use case (one that you might/would implement/use) (potentially being used in a fairly-shortly-after follow-up commit) rather than building things that might be nice to have at some point. So perhaps if you're adding features you could use them in the existing tablegen files to clean them up/improve them in some way to motivate the work, demonstrate how to use the features, and evangelize them (having the existing files using the new features as intended helps other people pick up on them when they go to modify/add/etc to the existing usage). This revision is now accepted and ready to land.Apr 26 2021, 2:47 PM Comment Actions It makes good sense to spend some time now on additional TableGen file cleanup. There is one file with TODOs for assert, so I will start there. Comment Actions I will push this on Wednesday. @dblaikie: What is your opinion on adding an assertion to a TableGen file when the backend(s) are already checking the condition? I think putting the checking closer to the problem is a good thing, and may result in more specific error messages. But, on the other hand, one could argue that it's pointless work. Comment Actions
Seems plausibly useful - though no doubt send such changes for review by the specific tblgen authors to see what they think (I've never written/modified target tblgens - so I'm on the fringes of this work at best). This revision was landed with ongoing or failed builds.Apr 28 2021, 6:54 AM Closed by commit rG952c6ddd8b32: [TableGen] Add the !find bang operator (authored by Paul-C-Anagnostopoulos). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 341181 llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGParser.h
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/find.td
|