[Mesa-dev] [PATCH v0] nir: mako all the intrinsics

Jason Ekstrand jason at jlekstrand.net
Fri Mar 16 19:13:18 UTC 2018


On Fri, Mar 16, 2018 at 11:53 AM, Dylan Baker <dylan at pnwbakers.com> wrote:

> Quoting Jason Ekstrand (2018-03-16 11:38:47)
> > On Fri, Mar 16, 2018 at 11:28 AM, Dylan Baker <dylan at pnwbakers.com>
> wrote:
> >
> >     intr_opcodes = {
> >         'nop': Intrinsic('nop', flags=[CAN_ELIMINATE]),
> >         ...
> >     }
> >
> >     I prefer this since each dictionary is clearly created without a
> function
> >     obscuring what's actually going on. If you dislike having to repeat
> the
> >     name you
> >     could even do something like:
> >     intr_opcodes = [
> >         'nop': Intrinsic('nop', flags=[CAN_ELIMINATE]),
> >         ...
> >     ]
> >     intr_opcodes = {i.name: i for i in intr_opcodes}
> >
> >
> > I'm not sure what I think about this.  On the one hand, having the
> dictionary
> > explicitly declared is nice.  On the other hand, in nir_opcodes.py we
> have a
> > bunch of other helper functions we declare along the way to help with
> specific
> > kinds of opcodes.  It's not as practical to do this if everything is
> inside of
> > a dictionary declaration.
>
> Why not?
>
> def make_op(name, *args):
>     return Intrinsic(name, foo='bar', *args)
>
> intr_opcodes = [
>     make_op('nop', ...),
> ]
>

Because it's nice to keep the definition of the wrapper close to where it's
used.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180316/7af30598/attachment.html>


More information about the mesa-dev mailing list