nir: Get rid of function overloads
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 26 Dec 2015 18:00:47 +0000 (10:00 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 28 Dec 2015 17:59:53 +0000 (09:59 -0800)
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 <cwabbott0@gmail.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
ir3 bits are

Reviewed-by: Rob Clark <robclark@gmail.com>
59 files changed:
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c
src/gallium/drivers/vc4/vc4_nir_lower_blend.c
src/gallium/drivers/vc4/vc4_nir_lower_io.c
src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c
src/gallium/drivers/vc4/vc4_program.c
src/glsl/nir/glsl_to_nir.cpp
src/glsl/nir/nir.c
src/glsl/nir/nir.h
src/glsl/nir/nir_algebraic.py
src/glsl/nir/nir_builder.h
src/glsl/nir/nir_clone.c
src/glsl/nir/nir_dominance.c
src/glsl/nir/nir_from_ssa.c
src/glsl/nir/nir_gs_count_vertices.c
src/glsl/nir/nir_lower_alu_to_scalar.c
src/glsl/nir/nir_lower_atomics.c
src/glsl/nir/nir_lower_clip.c
src/glsl/nir/nir_lower_global_vars_to_local.c
src/glsl/nir/nir_lower_gs_intrinsics.c
src/glsl/nir/nir_lower_idiv.c
src/glsl/nir/nir_lower_io.c
src/glsl/nir/nir_lower_load_const_to_scalar.c
src/glsl/nir/nir_lower_locals_to_regs.c
src/glsl/nir/nir_lower_outputs_to_temporaries.c
src/glsl/nir/nir_lower_phis_to_scalar.c
src/glsl/nir/nir_lower_samplers.c
src/glsl/nir/nir_lower_system_values.c
src/glsl/nir/nir_lower_tex.c
src/glsl/nir/nir_lower_to_source_mods.c
src/glsl/nir/nir_lower_two_sided_color.c
src/glsl/nir/nir_lower_var_copies.c
src/glsl/nir/nir_lower_vars_to_ssa.c
src/glsl/nir/nir_lower_vec_to_movs.c
src/glsl/nir/nir_metadata.c
src/glsl/nir/nir_move_vec_src_uses_to_dest.c
src/glsl/nir/nir_normalize_cubemap_coords.c
src/glsl/nir/nir_opt_constant_folding.c
src/glsl/nir/nir_opt_copy_propagate.c
src/glsl/nir/nir_opt_cse.c
src/glsl/nir/nir_opt_dce.c
src/glsl/nir/nir_opt_dead_cf.c
src/glsl/nir/nir_opt_gcm.c
src/glsl/nir/nir_opt_peephole_select.c
src/glsl/nir/nir_opt_remove_phis.c
src/glsl/nir/nir_opt_undef.c
src/glsl/nir/nir_print.c
src/glsl/nir/nir_remove_dead_variables.c
src/glsl/nir/nir_split_var_copies.c
src/glsl/nir/nir_sweep.c
src/glsl/nir/nir_to_ssa.c
src/glsl/nir/nir_validate.c
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_nir.c
src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c
src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c
src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
src/mesa/program/prog_to_nir.c

index 2cb723c5793757ca8c336ebb35c704a1c3cdb182..01426e86e61dead306dff60cd8c6b8c99ce0e3ba 100644 (file)
@@ -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);
index 44c74b84e34e90eaded3ed4edbc4e76ebd7d2730..224f7806b3cbe6b2313928f0184cecc511101c64 100644 (file)
@@ -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;
        }
 
index 4ec0e2bd2ac2babd15ff7a95bdf352d9c5423133..6eee2ebbab67aaa7239c897293189359950e9ab1 100644 (file)
@@ -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;
index a1ec4c70918ffe40a62bd0e05130133b3767737c..6d9a624c9b001512f5f85456e9b32b8c5547ccf7 100644 (file)
@@ -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);
                 }
index 465b28840b473d63d436da56a228531180f51273..bf6631e944e2743b8c74937675df705af1a404bf 100644 (file)
@@ -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);
         }
 }
index 54873e6186a9980e3ddb11479ea9b0b870f905d4..2490819c297962703fd2e92f90a92f596e351083 100644 (file)
@@ -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);
         }
 }
index d11c4e3b7ca83b66c1fbdbc2e9cc66489e36d506..da0d21111a0ef82449722240765aaffff4bbd391 100644 (file)
@@ -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;
 }
index 0f0f4a133e0839483801e533bb48d75ee8dab5d0..0d1d0f4e2822561e1a2dccfa95844c073e722b74 100644 (file)
@@ -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);
 
index 35fc1de2e01c1f91a40b1b5b7c5870dedd272125..60395ae3ab0361d9db00a04c7a67d9bfad43f6fe 100644 (file)
@@ -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);
index 9dbda448dd61ec58f5bed5bb046bae1c6cf13078..562c5c5cc8c7466e71848b1146f83da6e0c235a2 100644 (file)
@@ -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);
 
index bbf4f08ef92856531c343fa67a692c34a06cf2cb..a30652f2afdb8d16309614c7437fe8514c7e07be 100644 (file)
@@ -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;
index 5883d86e907f02ddb94a8340b2e5fefacfe43cf0..ee6131a089f5d6fc96a0de57b4b6ffbba2c5543e 100644 (file)
@@ -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
index 33ff5261b218f0a1d82ade4dc19c0b7f6880712b..5eff743d835d6f69cdfd83036a72fa113a7bde81 100644 (file)
@@ -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);
index af4caae0055913d184a7de096d5a3ceddc64e757..b345b85e8a0f94ff1b7e33f5457f643e11cfc442 100644 (file)
@@ -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);
    }
 }
index f2797f72c8e6028398c9f260b92aa20920d062ae..8bc9f24e4066755932c18cfd5dc1c989aed3f151 100644 (file)
@@ -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);
    }
 }
index 1c360673ddcd81c9d4cafde4fbe7e4692718ddb8..db15d160ee77389f0b899237283ddf732b83f14a 100644 (file)
@@ -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) {
index d267ca383ab2b68e940fcd480701a77acfc307c0..0a27e66cf0f596b24714172b60799eaf6e59895e 100644 (file)
@@ -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);
    }
 }
index 40ca3de96cfdb7054ee81353f54a890a1671e9b2..259c154149bf557e09d936d2dd95b1a37bdda787 100644 (file)
@@ -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);
       }
    }
index 46301351c96584aaee89d00900b5e5552f97942e..f84a02410a839522613da02a09d49eb43e912a97 100644 (file)
@@ -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);
    }
 }
index d549ee79bb4bfada96462f92f9344ea685be5f3a..7b4cd4ee8dc8d77ea0fceeb4f57f5f3e5389fddb 100644 (file)
@@ -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);
       }
    }
 
index 13254599088cdacdcacbd3465e97a94ce3925256..fdff1656b4dbae84527b9a1b404550f4e4dca2c9 100644 (file)
@@ -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);
       }
    }
 
index f64b3eac8a07e90384c48f072e7060ae749d5fe5..a084ad9c0e5ea2f2ac7697b7182ca01b6027eba7 100644 (file)
@@ -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);
    }
 }
index a3565cc52ea5d0359b6404a95719c8214c50df7e..80c5151f0ea03f7850e1e88a196bae1b0603d3af 100644 (file)
@@ -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);
    }
 }
 
index 84d0c1453cbb98a1d53e0775412f81cc2fb93c0d..1eeed13cbacc4bbf2c464c44b0cedc06d0385ee0 100644 (file)
@@ -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);
    }
 }
index 3e21ac0cdd5e17a2cc94ec44b4e0a4eee41f7a25..51b0fa733f29fd9464b6408fc62112254ccb20dc 100644 (file)
@@ -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;
index 9441f4762b673aac34f512e1ae781db061cb7277..71b06b81fcceace1712108a45f1eb540ef44f47d 100644 (file)
@@ -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);
    }
 
index 2f5927f6406896265779cf34bc1aed714a4e066e..dd2abcf72f82bc65907c7ee6dcd0d4ce82b39f40 100644 (file)
@@ -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);
    }
 }
index 2aab305e6cc9d2c65024f76d49e6619a519489fb..95ea072bdfd1a613d5d91263daebd2481d784209 100644 (file)
@@ -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);
    }
 }
index 402f98e319c6f8f9cc435a46266f663936aa815b..2bd787d3574bada0d20e5bbb426b655aeee46f65 100644 (file)
@@ -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);
index 93ebf8e78a9a32db279b5c7a32185c2c9c467066..ae24fb2e16a7bd37b58e07b34532964de5065213 100644 (file)
@@ -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;
index 94c7e36d4d803f22fc84000b67c1f62266ed67f9..6c4e1f0d3f349e838c5470c6716a9066ec91483a 100644 (file)
@@ -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);
    }
 }
index 7df12e070f1128acb0ae03a387ae604e7e05584d..1294cb89004f6d440740d575f869d4934ab4c8a5 100644 (file)
@@ -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);
    }
 
 }
index a9017de5449284e7b8785ef759e1ade991cc7b7b..350e99c3423ab84cfcc9ab6b1b098fa42864c2ca 100644 (file)
@@ -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);
    }
 }
index 3ec0e1d99601d9aaacc6291db78d42361b31058c..75d31ff60afb1e6d51f3fd152c1410b41dcebe87 100644 (file)
@@ -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);
    }
 }
index 736a66c863993c3aa2203dbc0d8f62fcd96c013d..06d627900c6441ae953328ffde609f7dba7529c0 100644 (file)
@@ -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;
index d5324b35a78718d587f81613e87005cd1bbc630b..61aae73221eb2bf79d4422fa23abe0127c9d2a75 100644 (file)
@@ -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));
       }
    }
index 4c9032dfaf37ca48155711f67b5361fef6a526e7..b5186e6e944d9924fe8826d49a6c785aa230246a 100644 (file)
@@ -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);
    }
 }
index 7385576a223eb181143f8896e88d2cff0d0e544f..9c15eb8c15ccfe774834913dde952026f916ca5c 100644 (file)
@@ -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;
index 007b81cfd4165fb2d8ab3d84eaf520a7ea6b8c38..28a73f86f95565918ddb199c452f3064037777db 100644 (file)
@@ -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;
index cfc8e3311286a76a8832652ba733bedc084d452c..d99f78ddb36af3f1640fe41ad8b7a362a9567413 100644 (file)
@@ -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;
    }
 
index 93a6635337a0033556ba8f63483f02ec469ad0fa..364fb023dce70bd0fe67b5306205158dcf82f68a 100644 (file)
@@ -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;
index 603252825c3a0bfc051ccb63526ee75d8e162641..32436c18b60f6098ea528668178ce4c87b2f30a2 100644 (file)
@@ -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;
    }
 
index 356e926ffe38656d3abd1f446269f74813f417c0..4cc6798702b3647e113db6c34d58cbdd8af6ea5d 100644 (file)
@@ -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;
 }
index 5b412eebc32df9fba71658f6fce100db386efbd3..a8779ce5b84db5b48d9a364ad8130dd8dc45e5c2 100644 (file)
@@ -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);
    }
 }
index 90902b97ffcdf73f157e59212b2214b087c5e8ef..0fc658df8619fb4a2ed6e79f54b8334e704c2128 100644 (file)
@@ -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;
index 66d3754411507b66b0797631e258be3854bdd456..646183707bd29a8f0b2390545c188373989d81fe 100644 (file)
@@ -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;
 }
index 4ab27a8c9d556f792a59327a9949528eb4a90d60..374564d34c5898283a9f3e66387a6de3cb90a0e2 100644 (file)
@@ -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);
       }
index 56e570504d7f42a711b9350f741193a722f32048..80638ed58f2be1bcf122b372b8cf878c1b60c6d0 100644 (file)
@@ -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,32 +972,24 @@ 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)
 {
index 8f0833c7e2474dc47453fec09ba8ef85130a5bdc..db754e56b1c08a68917a8c6ef6793ac2d925835c 100644 (file)
@@ -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;
index bfbef72c1ab63b5932f1362f2020a5ddef70ceef..6fdaefa32c8407e6742c3ca50146c9b3d13ce4ab 100644 (file)
@@ -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;
index 5a22f509f5048a7067a8861e7f114b8cdf03e118..0710bdba7c7c950aa8346738c3aa1daf92e2cce7 100644 (file)
@@ -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
index b089df79fcf2ee53f3449a4b1c32ad47096d5b7a..44a505477380d923cf4e1f7c9e4c9fe543533cf0 100644 (file)
@@ -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);
    }
 }
index da920557d204c3824a15514c6a07c190d4790e78..e4db68db3c0102fb8bb3a6fb64b7c15ddc72bb51 100644 (file)
@@ -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);
@@ -980,21 +980,12 @@ validate_function_impl(nir_function_impl *impl, validate_state *state)
    nir_foreach_block(impl, postvalidate_ssa_defs_block, 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);
    }
 }
 
index 9728e2a2ad8f85e5420b5edac07252c5a6d6652a..bb6ab53fbc5e81a327c399da73b5a4f3e662fbf9 100644 (file)
@@ -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);
    }
 }
 
index eebd2a386b61cae60e14450a0d7c1256c3525d4d..e031173036a4dd7d4fd7dcfce1f2b21da7257b1a 100644 (file)
@@ -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(&params.b, overload->impl);
-               nir_foreach_block(overload->impl, add_const_offset_to_base, &params);
-               nir_foreach_block(overload->impl, remap_vs_attrs, &inputs_read);
+         nir_foreach_function(nir, function) {
+            if (function->impl) {
+               nir_builder_init(&params.b, function->impl);
+               nir_foreach_block(function->impl, add_const_offset_to_base, &params);
+               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(&params.b, overload->impl);
-               nir_foreach_block(overload->impl, add_const_offset_to_base, &params);
-               nir_foreach_block(overload->impl, remap_inputs_with_vue_map,
+         nir_foreach_function(nir, function) {
+            if (function->impl) {
+               nir_builder_init(&params.b, function->impl);
+               nir_foreach_block(function->impl, add_const_offset_to_base, &params);
+               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(&params.b, overload->impl);
-            nir_foreach_block(overload->impl, add_const_offset_to_base, &params);
-            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(&params.b, function->impl);
+            nir_foreach_block(function->impl, add_const_offset_to_base, &params);
+            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(&params.b, overload->impl);
-            nir_foreach_block(overload->impl, add_const_offset_to_base, &params);
-            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(&params.b, function->impl);
+            nir_foreach_block(function->impl, add_const_offset_to_base, &params);
+            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",
index f4d23d81260d931eb7608ee10d49051c164f87f1..56e15ef935f1f608db00dfa8c651a52a613bba80 100644 (file)
@@ -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);
+   }
 }
index 5603129bde7485be81bc5d35311535c5c9d5ccb4..5ff2cba0464eae64f2421dba310309d958fabecc 100644 (file)
@@ -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;
index 25996281131b128467342533f126a8a2ccaa5646..ab713047a8cf248e2e347ed7e6d022482e03ecfc 100644 (file)
@@ -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);
    }
 }
 
index 14a339cf96ea950cde8e69b318f50cd294cdfaa9..c5d4f273fc82b7ac31cea3e58e1c9d03d1627dc1 100644 (file)
@@ -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;