[PATCH] D151457: [TableGen] Add !getdagargs and !getdagnames
Michael Liao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 18:52:36 PDT 2023
hliao 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.
----------------
simon_tatham wrote:
> 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`.
Yes, for completeness, `!getdagarg(arg, name)` and `!getdagarg(arg, idx)` (without casting to `T`) are the 2nd part I was preparing together with `!getdagname(arg, idx)`.
I will update the patch to allow arguments with non-common type returned as `?`.
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