diff options
author | Jason Ekstrand <[email protected]> | 2015-12-26 10:00:47 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-12-28 09:59:53 -0800 |
commit | 237f2f2d8b45d9d956102eec6f9be63193e5269b (patch) | |
tree | 1b092bc0121132385b14f3a7ca6c9e7898fd365f | |
parent | 109c348284843054f708f4403260739b7db18275 (diff) |
nir: Get rid of function overloads
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.
Reviewed-by: Connor Abbott <[email protected]>
Acked-by: Kenneth Graunke <[email protected]>
ir3 bits are
Reviewed-by: Rob Clark <[email protected]>
59 files changed, 313 insertions, 386 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index 2cb723c5793..01426e86e61 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -1972,8 +1972,7 @@ tgsi_to_nir(const void *tgsi_tokens, options); nir_function *func = nir_function_create(s, "main"); - nir_function_overload *overload = nir_function_overload_create(func); - nir_function_impl *impl = nir_function_impl_create(overload); + nir_function_impl *impl = nir_function_impl_create(func); nir_builder_init(&c->build, impl); c->build.cursor = nir_after_cf_list(&impl->body); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 44c74b84e34..224f7806b3c 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -2351,10 +2351,10 @@ emit_instructions(struct ir3_compile *ctx) nir_function_impl *fxn = NULL; /* Find the main function: */ - nir_foreach_overload(ctx->s, overload) { - compile_assert(ctx, strcmp(overload->function->name, "main") == 0); - compile_assert(ctx, overload->impl); - fxn = overload->impl; + nir_foreach_function(ctx->s, function) { + compile_assert(ctx, strcmp(function->name, "main") == 0); + compile_assert(ctx, function->impl); + fxn = function->impl; break; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c b/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c index 4ec0e2bd2ac..6eee2ebbab6 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c @@ -328,9 +328,9 @@ ir3_nir_lower_if_else(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress |= lower_if_else_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + progress |= lower_if_else_impl(function->impl); } return progress; diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c index a1ec4c70918..6d9a624c9b0 100644 --- a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c +++ b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c @@ -712,12 +712,12 @@ vc4_nir_lower_blend_block(nir_block *block, void *state) void vc4_nir_lower_blend(struct vc4_compile *c) { - nir_foreach_overload(c->s, overload) { - if (overload->impl) { - nir_foreach_block(overload->impl, + nir_foreach_function(c->s, function) { + if (function->impl) { + nir_foreach_block(function->impl, vc4_nir_lower_blend_block, c); - nir_metadata_preserve(overload->impl, + nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance); } diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_io.c b/src/gallium/drivers/vc4/vc4_nir_lower_io.c index 465b28840b4..bf6631e944e 100644 --- a/src/gallium/drivers/vc4/vc4_nir_lower_io.c +++ b/src/gallium/drivers/vc4/vc4_nir_lower_io.c @@ -467,8 +467,8 @@ vc4_nir_lower_io_impl(struct vc4_compile *c, nir_function_impl *impl) void vc4_nir_lower_io(struct vc4_compile *c) { - nir_foreach_overload(c->s, overload) { - if (overload->impl) - vc4_nir_lower_io_impl(c, overload->impl); + nir_foreach_function(c->s, function) { + if (function->impl) + vc4_nir_lower_io_impl(c, function->impl); } } diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c b/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c index 54873e6186a..2490819c297 100644 --- a/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c +++ b/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c @@ -165,8 +165,8 @@ vc4_nir_lower_txf_ms_impl(struct vc4_compile *c, nir_function_impl *impl) void vc4_nir_lower_txf_ms(struct vc4_compile *c) { - nir_foreach_overload(c->s, overload) { - if (overload->impl) - vc4_nir_lower_txf_ms_impl(c, overload->impl); + nir_foreach_function(c->s, function) { + if (function->impl) + vc4_nir_lower_txf_ms_impl(c, function->impl); } } diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index d11c4e3b7ca..da0d21111a0 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1705,10 +1705,10 @@ nir_to_qir(struct vc4_compile *c) ntq_setup_registers(c, &c->s->registers); /* Find the main function and emit the body. */ - nir_foreach_overload(c->s, overload) { - assert(strcmp(overload->function->name, "main") == 0); - assert(overload->impl); - ntq_emit_impl(c, overload->impl); + nir_foreach_function(c->s, function) { + assert(strcmp(function->name, "main") == 0); + assert(function->impl); + ntq_emit_impl(c, function->impl); } } @@ -1735,10 +1735,10 @@ static int count_nir_instrs(nir_shader *nir) { int count = 0; - nir_foreach_overload(nir, overload) { - if (!overload->impl) + nir_foreach_function(nir, function) { + if (!function->impl) continue; - nir_foreach_block(overload->impl, count_nir_instrs_in_block, &count); + nir_foreach_block(function->impl, count_nir_instrs_in_block, &count); } return count; } diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 0f0f4a133e0..0d1d0f4e282 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -70,10 +70,9 @@ public: virtual void visit(ir_dereference_array *); virtual void visit(ir_barrier *); - void create_function(ir_function *ir); + void create_function(ir_function_signature *ir); private: - void create_overload(ir_function_signature *ir, nir_function *function); void add_instr(nir_instr *instr, unsigned num_components); nir_ssa_def *evaluate_rvalue(ir_rvalue *ir); @@ -430,60 +429,50 @@ nir_visitor::visit(ir_variable *ir) ir_visitor_status nir_function_visitor::visit_enter(ir_function *ir) { - visitor->create_function(ir); - return visit_continue_with_parent; -} - - -void -nir_visitor::create_function(ir_function *ir) -{ - nir_function *func = nir_function_create(this->shader, ir->name); foreach_in_list(ir_function_signature, sig, &ir->signatures) { - create_overload(sig, func); + visitor->create_function(sig); } + return visit_continue_with_parent; } - - void -nir_visitor::create_overload(ir_function_signature *ir, nir_function *function) +nir_visitor::create_function(ir_function_signature *ir) { if (ir->is_intrinsic) return; - nir_function_overload *overload = nir_function_overload_create(function); + nir_function *func = nir_function_create(shader, ir->function_name()); unsigned num_params = ir->parameters.length(); - overload->num_params = num_params; - overload->params = ralloc_array(shader, nir_parameter, num_params); + func->num_params = num_params; + func->params = ralloc_array(shader, nir_parameter, num_params); unsigned i = 0; foreach_in_list(ir_variable, param, &ir->parameters) { switch (param->data.mode) { case ir_var_function_in: - overload->params[i].param_type = nir_parameter_in; + func->params[i].param_type = nir_parameter_in; break; case ir_var_function_out: - overload->params[i].param_type = nir_parameter_out; + func->params[i].param_type = nir_parameter_out; break; case ir_var_function_inout: - overload->params[i].param_type = nir_parameter_inout; + func->params[i].param_type = nir_parameter_inout; break; default: unreachable("not reached"); } - overload->params[i].type = param->type; + func->params[i].type = param->type; i++; } - overload->return_type = ir->return_type; + func->return_type = ir->return_type; - _mesa_hash_table_insert(this->overload_table, ir, overload); + _mesa_hash_table_insert(this->overload_table, ir, func); } void @@ -503,13 +492,13 @@ nir_visitor::visit(ir_function_signature *ir) _mesa_hash_table_search(this->overload_table, ir); assert(entry); - nir_function_overload *overload = (nir_function_overload *) entry->data; + nir_function *func = (nir_function *) entry->data; if (ir->is_defined) { - nir_function_impl *impl = nir_function_impl_create(overload); + nir_function_impl *impl = nir_function_impl_create(func); this->impl = impl; - unsigned num_params = overload->num_params; + unsigned num_params = func->num_params; impl->num_params = num_params; impl->params = ralloc_array(this->shader, nir_variable *, num_params); unsigned i = 0; @@ -519,13 +508,13 @@ nir_visitor::visit(ir_function_signature *ir) i++; } - if (overload->return_type == glsl_type::void_type) { + if (func->return_type == glsl_type::void_type) { impl->return_var = NULL; } else { impl->return_var = ralloc(this->shader, nir_variable); impl->return_var->name = ralloc_strdup(impl->return_var, "return_var"); - impl->return_var->type = overload->return_type; + impl->return_var->type = func->return_type; } this->is_global = false; @@ -536,7 +525,7 @@ nir_visitor::visit(ir_function_signature *ir) this->is_global = true; } else { - overload->impl = NULL; + func->impl = NULL; } } @@ -1082,7 +1071,7 @@ nir_visitor::visit(ir_call *ir) struct hash_entry *entry = _mesa_hash_table_search(this->overload_table, ir->callee); assert(entry); - nir_function_overload *callee = (nir_function_overload *) entry->data; + nir_function *callee = (nir_function *) entry->data; nir_call_instr *instr = nir_call_instr_create(this->shader, callee); diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index 35fc1de2e01..60395ae3ab0 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -163,7 +163,7 @@ nir_variable * nir_local_variable_create(nir_function_impl *impl, const struct glsl_type *type, const char *name) { - nir_variable *var = rzalloc(impl->overload->function->shader, nir_variable); + nir_variable *var = rzalloc(impl->function->shader, nir_variable); var->name = ralloc_strdup(var, name); var->type = type; var->data.mode = nir_var_local; @@ -179,31 +179,17 @@ nir_function_create(nir_shader *shader, const char *name) nir_function *func = ralloc(shader, nir_function); exec_list_push_tail(&shader->functions, &func->node); - exec_list_make_empty(&func->overload_list); + func->name = ralloc_strdup(func, name); func->shader = shader; + func->num_params = 0; + func->params = NULL; + func->return_type = glsl_void_type(); + func->impl = NULL; return func; } -nir_function_overload * -nir_function_overload_create(nir_function *func) -{ - void *mem_ctx = ralloc_parent(func); - - nir_function_overload *overload = ralloc(mem_ctx, nir_function_overload); - - overload->num_params = 0; - overload->params = NULL; - overload->return_type = glsl_void_type(); - overload->impl = NULL; - - exec_list_push_tail(&func->overload_list, &overload->node); - overload->function = func; - - return overload; -} - void nir_src_copy(nir_src *dest, const nir_src *src, void *mem_ctx) { dest->is_ssa = src->is_ssa; @@ -268,16 +254,16 @@ cf_init(nir_cf_node *node, nir_cf_node_type type) } nir_function_impl * -nir_function_impl_create(nir_function_overload *overload) +nir_function_impl_create(nir_function *function) { - assert(overload->impl == NULL); + assert(function->impl == NULL); - void *mem_ctx = ralloc_parent(overload); + void *mem_ctx = ralloc_parent(function); nir_function_impl *impl = ralloc(mem_ctx, nir_function_impl); - overload->impl = impl; - impl->overload = overload; + function->impl = impl; + impl->function = function; cf_init(&impl->cf_node, nir_cf_node_function); @@ -474,7 +460,7 @@ nir_intrinsic_instr_create(nir_shader *shader, nir_intrinsic_op op) } nir_call_instr * -nir_call_instr_create(nir_shader *shader, nir_function_overload *callee) +nir_call_instr_create(nir_shader *shader, nir_function *callee) { nir_call_instr *instr = ralloc(shader, nir_call_instr); instr_init(&instr->instr, nir_instr_type_call); diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 9dbda448dd6..562c5c5cc8c 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -65,7 +65,6 @@ name(const in_type *parent) \ return exec_node_data(out_type, parent, field); \ } -struct nir_function_overload; struct nir_function; struct nir_shader; struct nir_instr; @@ -785,7 +784,7 @@ typedef struct { nir_deref_var **params; nir_deref_var *return_deref; - struct nir_function_overload *callee; + struct nir_function *callee; } nir_call_instr; #define INTRINSIC(name, num_srcs, src_components, has_dest, dest_components, \ @@ -1339,8 +1338,8 @@ typedef enum { typedef struct { nir_cf_node cf_node; - /** pointer to the overload of which this is an implementation */ - struct nir_function_overload *overload; + /** pointer to the function of which this is an implementation */ + struct nir_function *function; struct exec_list body; /** < list of nir_cf_node */ @@ -1425,31 +1424,23 @@ typedef struct { const struct glsl_type *type; } nir_parameter; -typedef struct nir_function_overload { +typedef struct nir_function { struct exec_node node; + const char *name; + struct nir_shader *shader; + unsigned num_params; nir_parameter *params; const struct glsl_type *return_type; - nir_function_impl *impl; /** < NULL if the overload is only declared yet */ - - /** pointer to the function of which this is an overload */ - struct nir_function *function; -} nir_function_overload; - -typedef struct nir_function { - struct exec_node node; - - struct exec_list overload_list; /** < list of nir_function_overload */ - const char *name; - struct nir_shader *shader; + /** The implementation of this function. + * + * If the function is only declared and not implemented, this is NULL. + */ + nir_function_impl *impl; } nir_function; -#define nir_function_first_overload(func) \ - exec_node_data(nir_function_overload, \ - exec_list_get_head(&(func)->overload_list), node) - typedef struct nir_shader_compiler_options { bool lower_ffma; bool lower_flrp; @@ -1610,10 +1601,8 @@ typedef struct nir_shader { gl_shader_stage stage; } nir_shader; -#define nir_foreach_overload(shader, overload) \ - foreach_list_typed(nir_function, func, node, &(shader)->functions) \ - foreach_list_typed(nir_function_overload, overload, node, \ - &(func)->overload_list) +#define nir_foreach_function(shader, func) \ + foreach_list_typed(nir_function, func, node, &(shader)->functions) nir_shader *nir_shader_create(void *mem_ctx, gl_shader_stage stage, @@ -1649,10 +1638,7 @@ nir_variable *nir_local_variable_create(nir_function_impl *impl, /** creates a function and adds it to the shader's list of functions */ nir_function *nir_function_create(nir_shader *shader, const char *name); -/** creates a null function returning null */ -nir_function_overload *nir_function_overload_create(nir_function *func); - -nir_function_impl *nir_function_impl_create(nir_function_overload *func); +nir_function_impl *nir_function_impl_create(nir_function *func); nir_block *nir_block_create(nir_shader *shader); nir_if *nir_if_create(nir_shader *shader); @@ -1677,7 +1663,7 @@ nir_intrinsic_instr *nir_intrinsic_instr_create(nir_shader *shader, nir_intrinsic_op op); nir_call_instr *nir_call_instr_create(nir_shader *shader, - nir_function_overload *callee); + nir_function *callee); nir_tex_instr *nir_tex_instr_create(nir_shader *shader, unsigned num_srcs); diff --git a/src/glsl/nir/nir_algebraic.py b/src/glsl/nir/nir_algebraic.py index bbf4f08ef92..a30652f2afd 100644 --- a/src/glsl/nir/nir_algebraic.py +++ b/src/glsl/nir/nir_algebraic.py @@ -276,9 +276,9 @@ ${pass_name}(nir_shader *shader) condition_flags[${index}] = ${condition}; % endfor - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress |= ${pass_name}_impl(overload->impl, condition_flags); + nir_foreach_function(shader, function) { + if (function->impl) + progress |= ${pass_name}_impl(function->impl, condition_flags); } return progress; diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index 5883d86e907..ee6131a089f 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -40,7 +40,7 @@ nir_builder_init(nir_builder *build, nir_function_impl *impl) { memset(build, 0, sizeof(*build)); build->impl = impl; - build->shader = impl->overload->function->shader; + build->shader = impl->function->shader; } static inline void diff --git a/src/glsl/nir/nir_clone.c b/src/glsl/nir/nir_clone.c index 33ff5261b21..5eff743d835 100644 --- a/src/glsl/nir/nir_clone.c +++ b/src/glsl/nir/nir_clone.c @@ -420,7 +420,7 @@ clone_jump(clone_state *state, const nir_jump_instr *jmp) static nir_call_instr * clone_call(clone_state *state, const nir_call_instr *call) { - nir_function_overload *ncallee = lookup_ptr(state, call->callee); + nir_function *ncallee = lookup_ptr(state, call->callee); nir_call_instr *ncall = nir_call_instr_create(state->ns, ncallee); for (unsigned i = 0; i < ncall->num_params; i++) @@ -547,9 +547,9 @@ clone_cf_list(clone_state *state, struct exec_list *dst, static nir_function_impl * clone_function_impl(clone_state *state, const nir_function_impl *fi, - nir_function_overload *nfo) + nir_function *nfxn) { - nir_function_impl *nfi = nir_function_impl_create(nfo); + nir_function_impl *nfi = nir_function_impl_create(nfxn); clone_var_list(state, &nfi->locals, &fi->locals); clone_reg_list(state, &nfi->registers, &fi->registers); @@ -588,39 +588,27 @@ clone_function_impl(clone_state *state, const nir_function_impl *fi, return nfi; } -static nir_function_overload * -clone_function_overload(clone_state *state, const nir_function_overload *fo, - nir_function *nfxn) +static nir_function * +clone_function(clone_state *state, const nir_function *fxn, nir_shader *ns) { - nir_function_overload *nfo = nir_function_overload_create(nfxn); + assert(ns == state->ns); + nir_function *nfxn = nir_function_create(ns, fxn->name); /* Needed for call instructions */ - store_ptr(state, nfo, fo); + store_ptr(state, nfxn, fxn); - nfo->num_params = fo->num_params; - nfo->params = ralloc_array(state->ns, nir_parameter, fo->num_params); - memcpy(nfo->params, fo->params, sizeof(nir_parameter) * fo->num_params); + nfxn->num_params = fxn->num_params; + nfxn->params = ralloc_array(state->ns, nir_parameter, fxn->num_params); + memcpy(nfxn->params, fxn->params, sizeof(nir_parameter) * fxn->num_params); - nfo->return_type = fo->return_type; + nfxn->return_type = fxn->return_type; /* At first glance, it looks like we should clone the function_impl here. * However, call instructions need to be able to reference at least the - * overload and those will get processed as we clone the function_impl's. + * function and those will get processed as we clone the function_impl's. * We stop here and do function_impls as a second pass. */ - return nfo; -} - -static nir_function * -clone_function(clone_state *state, const nir_function *fxn, nir_shader *ns) -{ - assert(ns == state->ns); - nir_function *nfxn = nir_function_create(ns, fxn->name); - - foreach_list_typed(nir_function_overload, fo, node, &fxn->overload_list) - clone_function_overload(state, fo, nfxn); - return nfxn; } @@ -639,18 +627,18 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s) clone_var_list(&state, &ns->globals, &s->globals); clone_var_list(&state, &ns->system_values, &s->system_values); - /* Go through and clone functions and overloads */ + /* Go through and clone functions */ foreach_list_typed(nir_function, fxn, node, &s->functions) clone_function(&state, fxn, ns); - /* Only after all overloads are cloned can we clone the actual function + /* Only after all functions are cloned can we clone the actual function * implementations. This is because nir_call_instr's need to reference the - * overloads of other functions and we don't know what order the functions + * functions of other functions and we don't know what order the functions * will have in the list. */ - nir_foreach_overload(s, fo) { - nir_function_overload *nfo = lookup_ptr(&state, fo); - clone_function_impl(&state, fo->impl, nfo); + nir_foreach_function(s, fxn) { + nir_function *nfxn = lookup_ptr(&state, fxn); + clone_function_impl(&state, fxn->impl, nfxn); } clone_reg_list(&state, &ns->registers, &s->registers); diff --git a/src/glsl/nir/nir_dominance.c b/src/glsl/nir/nir_dominance.c index af4caae0055..b345b85e8a0 100644 --- a/src/glsl/nir/nir_dominance.c +++ b/src/glsl/nir/nir_dominance.c @@ -221,9 +221,9 @@ nir_calc_dominance_impl(nir_function_impl *impl) void nir_calc_dominance(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_calc_dominance_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + nir_calc_dominance_impl(function->impl); } } @@ -277,7 +277,7 @@ dump_block_dom(nir_block *block, void *state) void nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp) { - fprintf(fp, "digraph doms_%s {\n", impl->overload->function->name); + fprintf(fp, "digraph doms_%s {\n", impl->function->name); nir_foreach_block(impl, dump_block_dom, fp); fprintf(fp, "}\n\n"); } @@ -285,9 +285,9 @@ nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp) void nir_dump_dom_tree(nir_shader *shader, FILE *fp) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_dump_dom_tree_impl(overload->impl, fp); + nir_foreach_function(shader, function) { + if (function->impl) + nir_dump_dom_tree_impl(function->impl, fp); } } @@ -315,9 +315,9 @@ nir_dump_dom_frontier_impl(nir_function_impl *impl, FILE *fp) void nir_dump_dom_frontier(nir_shader *shader, FILE *fp) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_dump_dom_frontier_impl(overload->impl, fp); + nir_foreach_function(shader, function) { + if (function->impl) + nir_dump_dom_frontier_impl(function->impl, fp); } } @@ -335,7 +335,7 @@ dump_block_succs(nir_block *block, void *state) void nir_dump_cfg_impl(nir_function_impl *impl, FILE *fp) { - fprintf(fp, "digraph cfg_%s {\n", impl->overload->function->name); + fprintf(fp, "digraph cfg_%s {\n", impl->function->name); nir_foreach_block(impl, dump_block_succs, fp); fprintf(fp, "}\n\n"); } @@ -343,8 +343,8 @@ nir_dump_cfg_impl(nir_function_impl *impl, FILE *fp) void nir_dump_cfg(nir_shader *shader, FILE *fp) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_dump_cfg_impl(overload->impl, fp); + nir_foreach_function(shader, function) { + if (function->impl) + nir_dump_cfg_impl(function->impl, fp); } } diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c index f2797f72c8e..8bc9f24e406 100644 --- a/src/glsl/nir/nir_from_ssa.c +++ b/src/glsl/nir/nir_from_ssa.c @@ -798,8 +798,8 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, bool phi_webs_only) void nir_convert_from_ssa(nir_shader *shader, bool phi_webs_only) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_convert_from_ssa_impl(overload->impl, phi_webs_only); + nir_foreach_function(shader, function) { + if (function->impl) + nir_convert_from_ssa_impl(function->impl, phi_webs_only); } } diff --git a/src/glsl/nir/nir_gs_count_vertices.c b/src/glsl/nir/nir_gs_count_vertices.c index 1c360673ddc..db15d160ee7 100644 --- a/src/glsl/nir/nir_gs_count_vertices.c +++ b/src/glsl/nir/nir_gs_count_vertices.c @@ -55,15 +55,15 @@ nir_gs_count_vertices(const nir_shader *shader) { int count = -1; - nir_foreach_overload(shader, overload) { - if (!overload->impl) + nir_foreach_function(shader, function) { + if (!function->impl) continue; /* set_vertex_count intrinsics only appear in predecessors of the * end block. So we don't need to walk all of them. */ struct set_entry *entry; - set_foreach(overload->impl->end_block->predecessors, entry) { + set_foreach(function->impl->end_block->predecessors, entry) { nir_block *block = (nir_block *) entry->key; nir_foreach_instr_reverse(block, instr) { diff --git a/src/glsl/nir/nir_lower_alu_to_scalar.c b/src/glsl/nir/nir_lower_alu_to_scalar.c index d267ca383ab..0a27e66cf0f 100644 --- a/src/glsl/nir/nir_lower_alu_to_scalar.c +++ b/src/glsl/nir/nir_lower_alu_to_scalar.c @@ -203,8 +203,8 @@ nir_lower_alu_to_scalar_impl(nir_function_impl *impl) void nir_lower_alu_to_scalar(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_lower_alu_to_scalar_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + nir_lower_alu_to_scalar_impl(function->impl); } } diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c index 40ca3de96cf..259c154149b 100644 --- a/src/glsl/nir/nir_lower_atomics.c +++ b/src/glsl/nir/nir_lower_atomics.c @@ -156,10 +156,10 @@ nir_lower_atomics(nir_shader *shader, .shader_program = shader_program, }; - nir_foreach_overload(shader, overload) { - if (overload->impl) { - nir_foreach_block(overload->impl, lower_block, (void *) &state); - nir_metadata_preserve(overload->impl, nir_metadata_block_index | + nir_foreach_function(shader, function) { + if (function->impl) { + nir_foreach_block(function->impl, lower_block, (void *) &state); + nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance); } } diff --git a/src/glsl/nir/nir_lower_clip.c b/src/glsl/nir/nir_lower_clip.c index 46301351c96..f84a02410a8 100644 --- a/src/glsl/nir/nir_lower_clip.c +++ b/src/glsl/nir/nir_lower_clip.c @@ -143,9 +143,9 @@ find_output(nir_shader *shader, unsigned drvloc) .drvloc = drvloc, }; - nir_foreach_overload(shader, overload) { - if (overload->impl) { - nir_foreach_block_reverse(overload->impl, + nir_foreach_function(shader, function) { + if (function->impl) { + nir_foreach_block_reverse(function->impl, find_output_in_block, &state); } } @@ -257,9 +257,9 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables) out[1] = create_clipdist_var(shader, ++maxloc, true, VARYING_SLOT_CLIP_DIST1); - nir_foreach_overload(shader, overload) { - if (!strcmp(overload->function->name, "main")) - lower_clip_vs(overload->impl, ucp_enables, cv, out); + nir_foreach_function(shader, function) { + if (!strcmp(function->name, "main")) + lower_clip_vs(function->impl, ucp_enables, cv, out); } } @@ -331,8 +331,8 @@ nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables) create_clipdist_var(shader, ++maxloc, false, VARYING_SLOT_CLIP_DIST1); - nir_foreach_overload(shader, overload) { - if (!strcmp(overload->function->name, "main")) - lower_clip_fs(overload->impl, ucp_enables, in); + nir_foreach_function(shader, function) { + if (!strcmp(function->name, "main")) + lower_clip_fs(function->impl, ucp_enables, in); } } diff --git a/src/glsl/nir/nir_lower_global_vars_to_local.c b/src/glsl/nir/nir_lower_global_vars_to_local.c index d549ee79bb4..7b4cd4ee8dc 100644 --- a/src/glsl/nir/nir_lower_global_vars_to_local.c +++ b/src/glsl/nir/nir_lower_global_vars_to_local.c @@ -82,10 +82,10 @@ nir_lower_global_vars_to_local(nir_shader *shader) state.var_func_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); - nir_foreach_overload(shader, overload) { - if (overload->impl) { - state.impl = overload->impl; - nir_foreach_block(overload->impl, mark_global_var_uses_block, &state); + nir_foreach_function(shader, function) { + if (function->impl) { + state.impl = function->impl; + nir_foreach_block(function->impl, mark_global_var_uses_block, &state); } } diff --git a/src/glsl/nir/nir_lower_gs_intrinsics.c b/src/glsl/nir/nir_lower_gs_intrinsics.c index 13254599088..fdff1656b4d 100644 --- a/src/glsl/nir/nir_lower_gs_intrinsics.c +++ b/src/glsl/nir/nir_lower_gs_intrinsics.c @@ -200,18 +200,18 @@ nir_lower_gs_intrinsics(nir_shader *shader) exec_list_push_tail(&shader->globals, &var->node); state.vertex_count_var = var; - nir_foreach_overload(shader, overload) { - if (overload->impl) { + nir_foreach_function(shader, function) { + if (function->impl) { nir_builder b; - nir_builder_init(&b, overload->impl); + nir_builder_init(&b, function->impl); state.builder = &b; - nir_foreach_block(overload->impl, rewrite_intrinsics, &state); + nir_foreach_block(function->impl, rewrite_intrinsics, &state); /* This only works because we have a single main() function. */ - append_set_vertex_count(overload->impl->end_block, &state); + append_set_vertex_count(function->impl->end_block, &state); - nir_metadata_preserve(overload->impl, 0); + nir_metadata_preserve(function->impl, 0); } } diff --git a/src/glsl/nir/nir_lower_idiv.c b/src/glsl/nir/nir_lower_idiv.c index f64b3eac8a0..a084ad9c0e5 100644 --- a/src/glsl/nir/nir_lower_idiv.c +++ b/src/glsl/nir/nir_lower_idiv.c @@ -144,8 +144,8 @@ convert_impl(nir_function_impl *impl) void nir_lower_idiv(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - convert_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + convert_impl(function->impl); } } diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c index a3565cc52ea..80c5151f0ea 100644 --- a/src/glsl/nir/nir_lower_io.c +++ b/src/glsl/nir/nir_lower_io.c @@ -304,9 +304,9 @@ void nir_lower_io(nir_shader *shader, nir_variable_mode mode, int (*type_size)(const struct glsl_type *)) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_lower_io_impl(overload->impl, mode, type_size); + nir_foreach_function(shader, function) { + if (function->impl) + nir_lower_io_impl(function->impl, mode, type_size); } } diff --git a/src/glsl/nir/nir_lower_load_const_to_scalar.c b/src/glsl/nir/nir_lower_load_const_to_scalar.c index 84d0c1453cb..1eeed13cbac 100644 --- a/src/glsl/nir/nir_lower_load_const_to_scalar.c +++ b/src/glsl/nir/nir_lower_load_const_to_scalar.c @@ -82,8 +82,8 @@ nir_lower_load_const_to_scalar_impl(nir_function_impl *impl) void nir_lower_load_const_to_scalar(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_lower_load_const_to_scalar_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + nir_lower_load_const_to_scalar_impl(function->impl); } } diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c b/src/glsl/nir/nir_lower_locals_to_regs.c index 3e21ac0cdd5..51b0fa733f2 100644 --- a/src/glsl/nir/nir_lower_locals_to_regs.c +++ b/src/glsl/nir/nir_lower_locals_to_regs.c @@ -348,7 +348,7 @@ nir_lower_locals_to_regs_impl(nir_function_impl *impl) { struct locals_to_regs_state state; - state.shader = impl->overload->function->shader; + state.shader = impl->function->shader; state.impl = impl; state.progress = false; state.regs_table = _mesa_hash_table_create(NULL, hash_deref, derefs_equal); @@ -387,9 +387,9 @@ nir_lower_locals_to_regs(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress = nir_lower_locals_to_regs_impl(overload->impl) || progress; + nir_foreach_function(shader, function) { + if (function->impl) + progress = nir_lower_locals_to_regs_impl(function->impl) || progress; } return progress; diff --git a/src/glsl/nir/nir_lower_outputs_to_temporaries.c b/src/glsl/nir/nir_lower_outputs_to_temporaries.c index 9441f4762b6..71b06b81fcc 100644 --- a/src/glsl/nir/nir_lower_outputs_to_temporaries.c +++ b/src/glsl/nir/nir_lower_outputs_to_temporaries.c @@ -105,27 +105,27 @@ nir_lower_outputs_to_temporaries(nir_shader *shader) exec_list_push_tail(&shader->outputs, &output->node); } - nir_foreach_overload(shader, overload) { - if (overload->impl == NULL) + nir_foreach_function(shader, function) { + if (function->impl == NULL) continue; if (shader->stage == MESA_SHADER_GEOMETRY) { /* For geometry shaders, we have to emit the output copies right * before each EmitVertex call. */ - nir_foreach_block(overload->impl, emit_output_copies_block, &state); - } else if (strcmp(overload->function->name, "main") == 0) { + nir_foreach_block(function->impl, emit_output_copies_block, &state); + } else if (strcmp(function->name, "main") == 0) { /* For all other shader types, we need to do the copies right before * the jumps to the end block. */ struct set_entry *block_entry; - set_foreach(overload->impl->end_block->predecessors, block_entry) { + set_foreach(function->impl->end_block->predecessors, block_entry) { struct nir_block *block = (void *)block_entry->key; emit_output_copies(nir_after_block_before_jump(block), &state); } } - nir_metadata_preserve(overload->impl, nir_metadata_block_index | + nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance); } diff --git a/src/glsl/nir/nir_lower_phis_to_scalar.c b/src/glsl/nir/nir_lower_phis_to_scalar.c index 2f5927f6406..dd2abcf72f8 100644 --- a/src/glsl/nir/nir_lower_phis_to_scalar.c +++ b/src/glsl/nir/nir_lower_phis_to_scalar.c @@ -286,8 +286,8 @@ lower_phis_to_scalar_impl(nir_function_impl *impl) void nir_lower_phis_to_scalar(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - lower_phis_to_scalar_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + lower_phis_to_scalar_impl(function->impl); } } diff --git a/src/glsl/nir/nir_lower_samplers.c b/src/glsl/nir/nir_lower_samplers.c index 2aab305e6cc..95ea072bdfd 100644 --- a/src/glsl/nir/nir_lower_samplers.c +++ b/src/glsl/nir/nir_lower_samplers.c @@ -180,8 +180,8 @@ void nir_lower_samplers(nir_shader *shader, const struct gl_shader_program *shader_program) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - lower_impl(overload->impl, shader_program, shader->stage); + nir_foreach_function(shader, function) { + if (function->impl) + lower_impl(function->impl, shader_program, shader->stage); } } diff --git a/src/glsl/nir/nir_lower_system_values.c b/src/glsl/nir/nir_lower_system_values.c index 402f98e319c..2bd787d3574 100644 --- a/src/glsl/nir/nir_lower_system_values.c +++ b/src/glsl/nir/nir_lower_system_values.c @@ -87,9 +87,9 @@ nir_lower_system_values(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress = convert_impl(overload->impl) || progress; + nir_foreach_function(shader, function) { + if (function->impl) + progress = convert_impl(function->impl) || progress; } exec_list_make_empty(&shader->system_values); diff --git a/src/glsl/nir/nir_lower_tex.c b/src/glsl/nir/nir_lower_tex.c index 93ebf8e78a9..ae24fb2e16a 100644 --- a/src/glsl/nir/nir_lower_tex.c +++ b/src/glsl/nir/nir_lower_tex.c @@ -346,9 +346,9 @@ nir_lower_tex(nir_shader *shader, const nir_lower_tex_options *options) state.options = options; state.progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_lower_tex_impl(overload->impl, &state); + nir_foreach_function(shader, function) { + if (function->impl) + nir_lower_tex_impl(function->impl, &state); } return state.progress; diff --git a/src/glsl/nir/nir_lower_to_source_mods.c b/src/glsl/nir/nir_lower_to_source_mods.c index 94c7e36d4d8..6c4e1f0d3f3 100644 --- a/src/glsl/nir/nir_lower_to_source_mods.c +++ b/src/glsl/nir/nir_lower_to_source_mods.c @@ -189,8 +189,8 @@ nir_lower_to_source_mods_impl(nir_function_impl *impl) void nir_lower_to_source_mods(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_lower_to_source_mods_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + nir_lower_to_source_mods_impl(function->impl); } } diff --git a/src/glsl/nir/nir_lower_two_sided_color.c b/src/glsl/nir/nir_lower_two_sided_color.c index 7df12e070f1..1294cb89004 100644 --- a/src/glsl/nir/nir_lower_two_sided_color.c +++ b/src/glsl/nir/nir_lower_two_sided_color.c @@ -204,9 +204,9 @@ nir_lower_two_sided_color(nir_shader *shader) if (setup_inputs(&state) != 0) return; - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_lower_two_sided_color_impl(overload->impl, &state); + nir_foreach_function(shader, function) { + if (function->impl) + nir_lower_two_sided_color_impl(function->impl, &state); } } diff --git a/src/glsl/nir/nir_lower_var_copies.c b/src/glsl/nir/nir_lower_var_copies.c index a9017de5449..350e99c3423 100644 --- a/src/glsl/nir/nir_lower_var_copies.c +++ b/src/glsl/nir/nir_lower_var_copies.c @@ -183,8 +183,8 @@ lower_var_copies_impl(nir_function_impl *impl) void nir_lower_var_copies(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - lower_var_copies_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + lower_var_copies_impl(function->impl); } } diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c index 3ec0e1d9960..75d31ff60af 100644 --- a/src/glsl/nir/nir_lower_vars_to_ssa.c +++ b/src/glsl/nir/nir_lower_vars_to_ssa.c @@ -887,7 +887,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl) { struct lower_variables_state state; - state.shader = impl->overload->function->shader; + state.shader = impl->function->shader; state.dead_ctx = ralloc_context(state.shader); state.impl = impl; @@ -966,8 +966,8 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl) void nir_lower_vars_to_ssa(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_lower_vars_to_ssa_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + nir_lower_vars_to_ssa_impl(function->impl); } } diff --git a/src/glsl/nir/nir_lower_vec_to_movs.c b/src/glsl/nir/nir_lower_vec_to_movs.c index 736a66c8639..06d627900c6 100644 --- a/src/glsl/nir/nir_lower_vec_to_movs.c +++ b/src/glsl/nir/nir_lower_vec_to_movs.c @@ -217,7 +217,7 @@ lower_vec_to_movs_block(nir_block *block, void *void_state) { struct vec_to_movs_state *state = void_state; nir_function_impl *impl = state->impl; - nir_shader *shader = impl->overload->function->shader; + nir_shader *shader = impl->function->shader; nir_foreach_instr_safe(block, instr) { if (instr->type != nir_instr_type_alu) @@ -301,9 +301,9 @@ nir_lower_vec_to_movs(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress = nir_lower_vec_to_movs_impl(overload->impl) || progress; + nir_foreach_function(shader, function) { + if (function->impl) + progress = nir_lower_vec_to_movs_impl(function->impl) || progress; } return progress; diff --git a/src/glsl/nir/nir_metadata.c b/src/glsl/nir/nir_metadata.c index d5324b35a78..61aae73221e 100644 --- a/src/glsl/nir/nir_metadata.c +++ b/src/glsl/nir/nir_metadata.c @@ -63,9 +63,9 @@ nir_metadata_preserve(nir_function_impl *impl, nir_metadata preserved) void nir_metadata_set_validation_flag(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) { - overload->impl->valid_metadata |= nir_metadata_not_properly_reset; + nir_foreach_function(shader, function) { + if (function->impl) { + function->impl->valid_metadata |= nir_metadata_not_properly_reset; } } } @@ -80,9 +80,9 @@ nir_metadata_set_validation_flag(nir_shader *shader) void nir_metadata_check_validation_flag(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) { - assert(!(overload->impl->valid_metadata & + nir_foreach_function(shader, function) { + if (function->impl) { + assert(!(function->impl->valid_metadata & nir_metadata_not_properly_reset)); } } diff --git a/src/glsl/nir/nir_move_vec_src_uses_to_dest.c b/src/glsl/nir/nir_move_vec_src_uses_to_dest.c index 4c9032dfaf3..b5186e6e944 100644 --- a/src/glsl/nir/nir_move_vec_src_uses_to_dest.c +++ b/src/glsl/nir/nir_move_vec_src_uses_to_dest.c @@ -190,8 +190,8 @@ nir_move_vec_src_uses_to_dest_impl(nir_shader *shader, nir_function_impl *impl) void nir_move_vec_src_uses_to_dest(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_move_vec_src_uses_to_dest_impl(shader, overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + nir_move_vec_src_uses_to_dest_impl(shader, function->impl); } } diff --git a/src/glsl/nir/nir_normalize_cubemap_coords.c b/src/glsl/nir/nir_normalize_cubemap_coords.c index 7385576a223..9c15eb8c15c 100644 --- a/src/glsl/nir/nir_normalize_cubemap_coords.c +++ b/src/glsl/nir/nir_normalize_cubemap_coords.c @@ -111,9 +111,9 @@ nir_normalize_cubemap_coords(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress = normalize_cubemap_coords_impl(overload->impl) || progress; + nir_foreach_function(shader, function) { + if (function->impl) + progress = normalize_cubemap_coords_impl(function->impl) || progress; } return progress; diff --git a/src/glsl/nir/nir_opt_constant_folding.c b/src/glsl/nir/nir_opt_constant_folding.c index 007b81cfd41..28a73f86f95 100644 --- a/src/glsl/nir/nir_opt_constant_folding.c +++ b/src/glsl/nir/nir_opt_constant_folding.c @@ -192,9 +192,9 @@ nir_opt_constant_folding(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress |= nir_opt_constant_folding_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + progress |= nir_opt_constant_folding_impl(function->impl); } return progress; diff --git a/src/glsl/nir/nir_opt_copy_propagate.c b/src/glsl/nir/nir_opt_copy_propagate.c index cfc8e331128..d99f78ddb36 100644 --- a/src/glsl/nir/nir_opt_copy_propagate.c +++ b/src/glsl/nir/nir_opt_copy_propagate.c @@ -281,8 +281,8 @@ nir_copy_prop(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl && nir_copy_prop_impl(overload->impl)) + nir_foreach_function(shader, function) { + if (function->impl && nir_copy_prop_impl(function->impl)) progress = true; } diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c index 93a6635337a..364fb023dce 100644 --- a/src/glsl/nir/nir_opt_cse.c +++ b/src/glsl/nir/nir_opt_cse.c @@ -83,9 +83,9 @@ nir_opt_cse(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress |= nir_opt_cse_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + progress |= nir_opt_cse_impl(function->impl); } return progress; diff --git a/src/glsl/nir/nir_opt_dce.c b/src/glsl/nir/nir_opt_dce.c index 603252825c3..32436c18b60 100644 --- a/src/glsl/nir/nir_opt_dce.c +++ b/src/glsl/nir/nir_opt_dce.c @@ -174,8 +174,8 @@ bool nir_opt_dce(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl && nir_opt_dce_impl(overload->impl)) + nir_foreach_function(shader, function) { + if (function->impl && nir_opt_dce_impl(function->impl)) progress = true; } diff --git a/src/glsl/nir/nir_opt_dead_cf.c b/src/glsl/nir/nir_opt_dead_cf.c index 356e926ffe3..4cc6798702b 100644 --- a/src/glsl/nir/nir_opt_dead_cf.c +++ b/src/glsl/nir/nir_opt_dead_cf.c @@ -350,9 +350,9 @@ nir_opt_dead_cf(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) - if (overload->impl) - progress |= opt_dead_cf_impl(overload->impl); + nir_foreach_function(shader, function) + if (function->impl) + progress |= opt_dead_cf_impl(function->impl); return progress; } diff --git a/src/glsl/nir/nir_opt_gcm.c b/src/glsl/nir/nir_opt_gcm.c index 5b412eebc32..a8779ce5b84 100644 --- a/src/glsl/nir/nir_opt_gcm.c +++ b/src/glsl/nir/nir_opt_gcm.c @@ -487,8 +487,8 @@ opt_gcm_impl(nir_function_impl *impl) void nir_opt_gcm(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - opt_gcm_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + opt_gcm_impl(function->impl); } } diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c index 90902b97ffc..0fc658df861 100644 --- a/src/glsl/nir/nir_opt_peephole_select.c +++ b/src/glsl/nir/nir_opt_peephole_select.c @@ -247,9 +247,9 @@ nir_opt_peephole_select(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress |= nir_opt_peephole_select_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + progress |= nir_opt_peephole_select_impl(function->impl); } return progress; diff --git a/src/glsl/nir/nir_opt_remove_phis.c b/src/glsl/nir/nir_opt_remove_phis.c index 66d37544115..646183707bd 100644 --- a/src/glsl/nir/nir_opt_remove_phis.c +++ b/src/glsl/nir/nir_opt_remove_phis.c @@ -121,9 +121,9 @@ nir_opt_remove_phis(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) - if (overload->impl) - progress = remove_phis_impl(overload->impl) || progress; + nir_foreach_function(shader, function) + if (function->impl) + progress = remove_phis_impl(function->impl) || progress; return progress; } diff --git a/src/glsl/nir/nir_opt_undef.c b/src/glsl/nir/nir_opt_undef.c index 4ab27a8c9d5..374564d34c5 100644 --- a/src/glsl/nir/nir_opt_undef.c +++ b/src/glsl/nir/nir_opt_undef.c @@ -90,11 +90,11 @@ nir_opt_undef(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) { - nir_foreach_block(overload->impl, opt_undef_block, &progress); + nir_foreach_function(shader, function) { + if (function->impl) { + nir_foreach_block(function->impl, opt_undef_block, &progress); if (progress) - nir_metadata_preserve(overload->impl, + nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance); } diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c index 56e570504d7..80638ed58f2 100644 --- a/src/glsl/nir/nir_print.c +++ b/src/glsl/nir/nir_print.c @@ -644,7 +644,7 @@ print_call_instr(nir_call_instr *instr, print_state *state) { FILE *fp = state->fp; - fprintf(fp, "call %s ", instr->callee->function->name); + fprintf(fp, "call %s ", instr->callee->name); for (unsigned i = 0; i < instr->num_params; i++) { if (i != 0) @@ -910,7 +910,7 @@ print_function_impl(nir_function_impl *impl, print_state *state) { FILE *fp = state->fp; - fprintf(fp, "\nimpl %s ", impl->overload->function->name); + fprintf(fp, "\nimpl %s ", impl->function->name); for (unsigned i = 0; i < impl->num_params; i++) { if (i != 0) @@ -948,18 +948,17 @@ print_function_impl(nir_function_impl *impl, print_state *state) } static void -print_function_overload(nir_function_overload *overload, - print_state *state) +print_function(nir_function *function, print_state *state) { FILE *fp = state->fp; - fprintf(fp, "decl_overload %s ", overload->function->name); + fprintf(fp, "decl_function %s ", function->name); - for (unsigned i = 0; i < overload->num_params; i++) { + for (unsigned i = 0; i < function->num_params; i++) { if (i != 0) fprintf(fp, ", "); - switch (overload->params[i].param_type) { + switch (function->params[i].param_type) { case nir_parameter_in: fprintf(fp, "in "); break; @@ -973,33 +972,25 @@ print_function_overload(nir_function_overload *overload, unreachable("Invalid parameter type"); } - glsl_print_type(overload->params[i].type, fp); + glsl_print_type(function->params[i].type, fp); } - if (overload->return_type != NULL) { - if (overload->num_params != 0) + if (function->return_type != NULL) { + if (function->num_params != 0) fprintf(fp, ", "); fprintf(fp, "returning "); - glsl_print_type(overload->return_type, fp); + glsl_print_type(function->return_type, fp); } fprintf(fp, "\n"); - if (overload->impl != NULL) { - print_function_impl(overload->impl, state); + if (function->impl != NULL) { + print_function_impl(function->impl, state); return; } } static void -print_function(nir_function *func, print_state *state) -{ - foreach_list_typed(nir_function_overload, overload, node, &func->overload_list) { - print_function_overload(overload, state); - } -} - -static void init_print_state(print_state *state, nir_shader *shader, FILE *fp) { state->fp = fp; diff --git a/src/glsl/nir/nir_remove_dead_variables.c b/src/glsl/nir/nir_remove_dead_variables.c index 8f0833c7e24..db754e56b1c 100644 --- a/src/glsl/nir/nir_remove_dead_variables.c +++ b/src/glsl/nir/nir_remove_dead_variables.c @@ -90,9 +90,9 @@ add_var_use_block(nir_block *block, void *state) static void add_var_use_shader(nir_shader *shader, struct set *live) { - nir_foreach_overload(shader, overload) { - if (overload->impl) { - nir_foreach_block(overload->impl, add_var_use_block, live); + nir_foreach_function(shader, function) { + if (function->impl) { + nir_foreach_block(function->impl, add_var_use_block, live); } } } @@ -125,10 +125,10 @@ nir_remove_dead_variables(nir_shader *shader) progress = remove_dead_vars(&shader->globals, live) || progress; - nir_foreach_overload(shader, overload) { - if (overload->impl) { - if (remove_dead_vars(&overload->impl->locals, live)) { - nir_metadata_preserve(overload->impl, nir_metadata_block_index | + nir_foreach_function(shader, function) { + if (function->impl) { + if (remove_dead_vars(&function->impl->locals, live)) { + nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance | nir_metadata_live_ssa_defs); progress = true; diff --git a/src/glsl/nir/nir_split_var_copies.c b/src/glsl/nir/nir_split_var_copies.c index bfbef72c1ab..6fdaefa32c8 100644 --- a/src/glsl/nir/nir_split_var_copies.c +++ b/src/glsl/nir/nir_split_var_copies.c @@ -276,9 +276,9 @@ nir_split_var_copies(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress = split_var_copies_impl(overload->impl) || progress; + nir_foreach_function(shader, function) { + if (function->impl) + progress = split_var_copies_impl(function->impl) || progress; } return progress; diff --git a/src/glsl/nir/nir_sweep.c b/src/glsl/nir/nir_sweep.c index 5a22f509f50..0710bdba7c7 100644 --- a/src/glsl/nir/nir_sweep.c +++ b/src/glsl/nir/nir_sweep.c @@ -137,13 +137,10 @@ static void sweep_function(nir_shader *nir, nir_function *f) { ralloc_steal(nir, f); + ralloc_steal(nir, f->params); - foreach_list_typed(nir_function_overload, overload, node, &f->overload_list) { - ralloc_steal(nir, overload); - ralloc_steal(nir, overload->params); - if (overload->impl) - sweep_impl(nir, overload->impl); - } + if (f->impl) + sweep_impl(nir, f->impl); } void diff --git a/src/glsl/nir/nir_to_ssa.c b/src/glsl/nir/nir_to_ssa.c index b089df79fcf..44a50547738 100644 --- a/src/glsl/nir/nir_to_ssa.c +++ b/src/glsl/nir/nir_to_ssa.c @@ -529,8 +529,8 @@ nir_convert_to_ssa_impl(nir_function_impl *impl) void nir_convert_to_ssa(nir_shader *shader) { - nir_foreach_overload(shader, overload) { - if (overload->impl) - nir_convert_to_ssa_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + nir_convert_to_ssa_impl(function->impl); } } diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c index da920557d20..e4db68db3c0 100644 --- a/src/glsl/nir/nir_validate.c +++ b/src/glsl/nir/nir_validate.c @@ -929,17 +929,17 @@ postvalidate_ssa_defs_block(nir_block *block, void *state) static void validate_function_impl(nir_function_impl *impl, validate_state *state) { - assert(impl->overload->impl == impl); + assert(impl->function->impl == impl); assert(impl->cf_node.parent == NULL); - assert(impl->num_params == impl->overload->num_params); + assert(impl->num_params == impl->function->num_params); for (unsigned i = 0; i < impl->num_params; i++) - assert(impl->params[i]->type == impl->overload->params[i].type); + assert(impl->params[i]->type == impl->function->params[i].type); - if (glsl_type_is_void(impl->overload->return_type)) + if (glsl_type_is_void(impl->function->return_type)) assert(impl->return_var == NULL); else - assert(impl->return_var->type == impl->overload->return_type); + assert(impl->return_var->type == impl->function->return_type); assert(exec_list_is_empty(&impl->end_block->instr_list)); assert(impl->end_block->successors[0] == NULL); @@ -981,20 +981,11 @@ validate_function_impl(nir_function_impl *impl, validate_state *state) } static void -validate_function_overload(nir_function_overload *overload, - validate_state *state) -{ - if (overload->impl != NULL) - validate_function_impl(overload->impl, state); -} - -static void validate_function(nir_function *func, validate_state *state) { - exec_list_validate(&func->overload_list); - foreach_list_typed(nir_function_overload, overload, node, &func->overload_list) { - assert(overload->function == func); - validate_function_overload(overload, state); + if (func->impl != NULL) { + assert(func->impl->function == func); + validate_function_impl(func->impl, state); } } diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 9728e2a2ad8..bb6ab53fbc5 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -43,10 +43,10 @@ fs_visitor::emit_nir_code() nir_emit_system_values(); /* get the main function and emit it */ - nir_foreach_overload(nir, overload) { - assert(strcmp(overload->function->name, "main") == 0); - assert(overload->impl); - nir_emit_impl(overload->impl); + nir_foreach_function(nir, function) { + assert(strcmp(function->name, "main") == 0); + assert(function->impl); + nir_emit_impl(function->impl); } } @@ -338,10 +338,10 @@ fs_visitor::nir_emit_system_values() nir_system_values[i] = fs_reg(); } - nir_foreach_overload(nir, overload) { - assert(strcmp(overload->function->name, "main") == 0); - assert(overload->impl); - nir_foreach_block(overload->impl, emit_system_values_block, this); + nir_foreach_function(nir, function) { + assert(strcmp(function->name, "main") == 0); + assert(function->impl); + nir_foreach_block(function->impl, emit_system_values_block, this); } } diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index eebd2a386b6..e031173036a 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -224,11 +224,11 @@ brw_nir_lower_inputs(nir_shader *nir, /* This pass needs actual constants */ nir_opt_constant_folding(nir); - nir_foreach_overload(nir, overload) { - if (overload->impl) { - nir_builder_init(¶ms.b, overload->impl); - nir_foreach_block(overload->impl, add_const_offset_to_base, ¶ms); - nir_foreach_block(overload->impl, remap_vs_attrs, &inputs_read); + nir_foreach_function(nir, function) { + if (function->impl) { + nir_builder_init(¶ms.b, function->impl); + nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms); + nir_foreach_block(function->impl, remap_vs_attrs, &inputs_read); } } } @@ -270,11 +270,11 @@ brw_nir_lower_inputs(nir_shader *nir, /* This pass needs actual constants */ nir_opt_constant_folding(nir); - nir_foreach_overload(nir, overload) { - if (overload->impl) { - nir_builder_init(¶ms.b, overload->impl); - nir_foreach_block(overload->impl, add_const_offset_to_base, ¶ms); - nir_foreach_block(overload->impl, remap_inputs_with_vue_map, + nir_foreach_function(nir, function) { + if (function->impl) { + nir_builder_init(¶ms.b, function->impl); + nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms); + nir_foreach_block(function->impl, remap_inputs_with_vue_map, &input_vue_map); } } @@ -296,12 +296,12 @@ brw_nir_lower_inputs(nir_shader *nir, /* This pass needs actual constants */ nir_opt_constant_folding(nir); - nir_foreach_overload(nir, overload) { - if (overload->impl) { - nir_builder_init(¶ms.b, overload->impl); - nir_foreach_block(overload->impl, add_const_offset_to_base, ¶ms); - nir_builder_init(&state.b, overload->impl); - nir_foreach_block(overload->impl, remap_patch_urb_offsets, &state); + nir_foreach_function(nir, function) { + if (function->impl) { + nir_builder_init(¶ms.b, function->impl); + nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms); + nir_builder_init(&state.b, function->impl); + nir_foreach_block(function->impl, remap_patch_urb_offsets, &state); } } break; @@ -356,12 +356,12 @@ brw_nir_lower_outputs(nir_shader *nir, /* This pass needs actual constants */ nir_opt_constant_folding(nir); - nir_foreach_overload(nir, overload) { - if (overload->impl) { - nir_builder_init(¶ms.b, overload->impl); - nir_foreach_block(overload->impl, add_const_offset_to_base, ¶ms); - nir_builder_init(&state.b, overload->impl); - nir_foreach_block(overload->impl, remap_patch_urb_offsets, &state); + nir_foreach_function(nir, function) { + if (function->impl) { + nir_builder_init(¶ms.b, function->impl); + nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms); + nir_builder_init(&state.b, function->impl); + nir_foreach_block(function->impl, remap_patch_urb_offsets, &state); } } break; @@ -565,9 +565,9 @@ brw_postprocess_nir(nir_shader *nir, if (unlikely(debug_enabled)) { /* Re-index SSA defs so we print more sensible numbers. */ - nir_foreach_overload(nir, overload) { - if (overload->impl) - nir_index_ssa_defs(overload->impl); + nir_foreach_function(nir, function) { + if (function->impl) + nir_index_ssa_defs(function->impl); } fprintf(stderr, "NIR (SSA form) for %s shader:\n", diff --git a/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c index f4d23d81260..56e15ef935f 100644 --- a/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c +++ b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c @@ -260,7 +260,8 @@ analyze_boolean_resolves_impl(nir_function_impl *impl) void brw_nir_analyze_boolean_resolves(nir_shader *shader) { - nir_foreach_overload(shader, overload) - if (overload->impl) - analyze_boolean_resolves_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + analyze_boolean_resolves_impl(function->impl); + } } diff --git a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c index 5603129bde7..5ff2cba0464 100644 --- a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c +++ b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c @@ -290,9 +290,9 @@ brw_nir_opt_peephole_ffma(nir_shader *shader) { bool progress = false; - nir_foreach_overload(shader, overload) { - if (overload->impl) - progress |= brw_nir_opt_peephole_ffma_impl(overload->impl); + nir_foreach_function(shader, function) { + if (function->impl) + progress |= brw_nir_opt_peephole_ffma_impl(function->impl); } return progress; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp index 25996281131..ab713047a8c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp @@ -41,10 +41,10 @@ vec4_visitor::emit_nir_code() nir_setup_system_values(); /* get the main function and emit it */ - nir_foreach_overload(nir, overload) { - assert(strcmp(overload->function->name, "main") == 0); - assert(overload->impl); - nir_emit_impl(overload->impl); + nir_foreach_function(nir, function) { + assert(strcmp(function->name, "main") == 0); + assert(function->impl); + nir_emit_impl(function->impl); } } @@ -107,10 +107,10 @@ vec4_visitor::nir_setup_system_values() nir_system_values[i] = dst_reg(); } - nir_foreach_overload(nir, overload) { - assert(strcmp(overload->function->name, "main") == 0); - assert(overload->impl); - nir_foreach_block(overload->impl, setup_system_values_block, this); + nir_foreach_function(nir, function) { + assert(strcmp(function->name, "main") == 0); + assert(function->impl); + nir_foreach_block(function->impl, setup_system_values_block, this); } } diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index 14a339cf96e..c5d4f273fc8 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -1098,8 +1098,7 @@ prog_to_nir(const struct gl_program *prog, } nir_function *func = nir_function_create(s, "main"); - nir_function_overload *overload = nir_function_overload_create(func); - nir_function_impl *impl = nir_function_impl_create(overload); + nir_function_impl *impl = nir_function_impl_create(func); c->build.shader = s; c->build.impl = impl; |