[PATCH] D151457: [TableGen] Add !getdagargs and !getdagnames
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 09:06:33 PDT 2023
simon_tatham added inline comments.
================
Comment at: llvm/docs/TableGen/ProgRef.rst:1718-1720
+ from the given *dag* node. Due to limitations of the type system, if not
+ all arguments are not of the specified type or derived from the specified
+ base class, an error is reported. However, ``?`` is allowed.
----------------
That seems quite restrictive – it means this system can't be used at all in any context where the arguments to a dag are intentionally heterogeneous.
A couple of possible alternatives:
1. Make `!getdagargs<T>(dag)` return `?` without error for each argument whose type isn't `T` or a subtype.
2. Instead of an operator to fetch all the arguments at once, have an operator to fetch just one at a time, say `!getdagarg<T>(dag, index)`. Then if I have a dag operator that always expects a Foo and a Bar, I can call `!getdagarg<Foo>(d, 0)` and `!getdagarg<Bar>(d, 1)`.
With option 2, if there were also an operator to return the //number// of arguments, then you could still get a list of all of them using `!foreach`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151457/new/
https://reviews.llvm.org/D151457
More information about the llvm-commits
mailing list