nir,vtn: Add exported bool to nir_function

For optimizing libraries.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25498>
This commit is contained in:
Alyssa Rosenzweig 2023-10-12 12:03:11 -04:00 committed by Marge Bot
parent 103d20e657
commit 6014f745d5
4 changed files with 13 additions and 3 deletions

View file

@ -503,6 +503,9 @@ nir_function_create(nir_shader *shader, const char *name)
func->dont_inline = false;
func->should_inline = false;
/* Only meaningful for shader libraries, so don't export by default. */
func->is_exported = false;
return func;
}

View file

@ -3465,6 +3465,8 @@ typedef struct nir_function {
nir_function_impl *impl;
bool is_entrypoint;
/* from SPIR-V linkage, only for libraries */
bool is_exported;
bool is_preamble;
/* from SPIR-V function control */
bool should_inline;

View file

@ -2224,9 +2224,13 @@ print_function(nir_function *function, print_state *state)
{
FILE *fp = state->fp;
fprintf(fp, "decl_function %s (%d params) %s", function->name,
function->num_params, function->dont_inline ? "(noinline)" :
function->should_inline ? "(inline)" : "");
/* clang-format off */
fprintf(fp, "decl_function %s (%d params)%s%s", function->name,
function->num_params,
function->dont_inline ? " (noinline)" :
function->should_inline ? " (inline)" : "",
function->is_exported ? " (exported)" : "");
/* clang-format on */
fprintf(fp, "\n");

View file

@ -203,6 +203,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
func->should_inline = b->func->control & SpvFunctionControlInlineMask;
func->dont_inline = b->func->control & SpvFunctionControlDontInlineMask;
func->is_exported = b->func->linkage == SpvLinkageTypeExport;
func->num_params = num_params;
func->params = ralloc_array(b->shader, nir_parameter, num_params);