[Mesa-dev] [PATCH 01/12] nir: Get rid of function overloads

Kenneth Graunke kenneth at whitecape.org
Sat Dec 26 23:32:07 PST 2015


On Saturday, December 26, 2015 11:09:24 AM PST Jason Ekstrand wrote:
> When Connor originally drafted NIR, he copied the same function+overload
> system that GLSL IR had with a few names changed.  However, this
> double-indirection is not really needed and has only served to confuse
> people.  Instead, let's just have functions which may not have unique names
> and may or may not have an implementation.  If someone wants to do overload
> resolving, they can hav a hash table based function+overload system in the
> overload resolving pass.  There's no good reason to keep it in core NIR.

Yeah, this is a good idea.  Overloading/overriding should be restricted
to the language frontends - a middle IR shouldn't even be aware of it.
Calls should simply point to their functions, and names should be
irrelevant other than debug prints.

I suppose the utility of it is for implementing cross-module linking.
The current NIR code doesn't seem useful for SPIR-V, and I think
everybody is happy to leave the intricacies of GLSL linking in GLSL IR.
So there isn't much point in keeping it.

Plus, this doesn't stop us from doing it if we ever want to: we just
need to make a small data structure with a pointer to the nir_function
and any additional information needed for the language-specific linking
steps.  It'd just be off-to-the-side rather than baked in.

Patch 1 is:
Acked-by: Kenneth Graunke <kenneth at whitecape.org>

Patch 2 and patch 9 are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

FWIW, I went and compared this to GLSL IR - NIR actually has an extra
layer.  It seems to be:

- ir_function           -> nir_function
- ir_function_signature -> nir_function_overload
- exec_list body        -> nir_function_impl

(GLSL IR only needs to store a linked list of ir_instructions, since
variable declarations and the like are stored there.  In NIR, they're
stored in a separate list, so it gets expanded to an "impl" struct.)

This patch squashes the first two together, i.e.

- ir_function + ir_function_signature -> nir_function
- exec_list body                      -> nir_function_impl

which seems quite reasonable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151226/201d1cba/attachment.sig>


More information about the mesa-dev mailing list