Merge remote-tracking branch 'mesa-public/master' into vulkan

This pulls in the removal of nir_function_overload
This commit is contained in:
Jason Ekstrand 2015-12-28 10:56:31 -08:00
commit d5fa51bdee
67 changed files with 366 additions and 447 deletions

View 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);

View 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;
}

View 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;

View 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);
}

View 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);
}
}

View 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);
}
}

View 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;
}

View 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);
@ -434,60 +433,50 @@ nir_visitor::visit(ir_variable *ir)
ir_visitor_status
nir_function_visitor::visit_enter(ir_function *ir)
{
visitor->create_function(ir);
foreach_in_list(ir_function_signature, sig, &ir->signatures) {
visitor->create_function(sig);
}
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);
}
}
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
@ -507,13 +496,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;
@ -523,13 +512,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;
@ -540,7 +529,7 @@ nir_visitor::visit(ir_function_signature *ir)
this->is_global = true;
} else {
overload->impl = NULL;
func->impl = NULL;
}
}
@ -1086,7 +1075,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);

View 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;
@ -272,7 +258,7 @@ nir_function_impl_create_bare(nir_shader *shader)
{
nir_function_impl *impl = ralloc(shader, nir_function_impl);
impl->overload = NULL;
impl->function = NULL;
cf_init(&impl->cf_node, nir_cf_node_function);
@ -301,18 +287,17 @@ nir_function_impl_create_bare(nir_shader *shader)
}
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);
nir_function_impl *impl =
nir_function_impl_create_bare(overload->function->shader);
nir_function_impl *impl = nir_function_impl_create_bare(function->shader);
overload->impl = impl;
impl->overload = overload;
function->impl = impl;
impl->function = function;
impl->num_params = overload->num_params;
impl->params = ralloc_array(overload->function->shader,
impl->num_params = function->num_params;
impl->params = ralloc_array(function->shader,
nir_variable *, impl->num_params);
return impl;
@ -487,7 +472,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);

View 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;
@ -826,7 +825,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, \
@ -1400,8 +1399,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 */
@ -1486,31 +1485,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_fdiv;
@ -1672,10 +1663,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,
@ -1711,11 +1700,8 @@ 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);
/** creates a function_impl that isn't tied to any particular overload */
nir_function_impl *nir_function_impl_create(nir_function *func);
/** creates a function_impl that isn't tied to any particular function */
nir_function_impl *nir_function_impl_create_bare(nir_shader *shader);
nir_block *nir_block_create(nir_shader *shader);
@ -1741,7 +1727,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);

View 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;

View 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

View File

@ -454,7 +454,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 = remap_global(state, call->callee);
nir_function *ncallee = remap_global(state, call->callee);
nir_call_instr *ncall = nir_call_instr_create(state->ns, ncallee);
for (unsigned i = 0; i < ncall->num_params; i++)
@ -628,7 +628,7 @@ nir_function_impl_clone(const nir_function_impl *fi)
init_clone_state(&state, false);
/* We use the same shader */
state.ns = fi->overload->function->shader;
state.ns = fi->function->shader;
nir_function_impl *nfi = clone_function_impl(&state, fi);
@ -637,38 +637,26 @@ nir_function_impl_clone(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)
{
nir_function_overload *nfo = nir_function_overload_create(nfxn);
/* Needed for call instructions */
add_remap(state, nfo, fo);
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);
nfo->return_type = fo->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.
* 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);
/* Needed for call instructions */
add_remap(state, nfxn, fxn);
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);
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
* 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 nfxn;
}
@ -688,19 +676,19 @@ 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 = remap_global(&state, fo);
nfo->impl = clone_function_impl(&state, fo->impl);
nfo->impl->overload = nfo;
nir_foreach_function(s, fxn) {
nir_function *nfxn = remap_global(&state, fxn);
nfxn->impl = clone_function_impl(&state, fxn->impl);
nfxn->impl->function = nfxn;
}
clone_reg_list(&state, &ns->registers, &s->registers);

View 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);
}
}

View 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);
}
}

View 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) {

View File

@ -129,9 +129,9 @@ nir_inline_functions(nir_shader *shader)
{
bool progress = false;
nir_foreach_overload(shader, overload) {
if (overload->impl)
progress = nir_inline_functions_impl(overload->impl) || progress;
nir_foreach_function(shader, function) {
if (function->impl)
progress = nir_inline_functions_impl(function->impl) || progress;
}
return progress;

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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;

View 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);
}

View 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);
}
}

View File

@ -236,9 +236,9 @@ nir_lower_returns(nir_shader *shader)
{
bool progress = false;
nir_foreach_overload(shader, overload) {
if (overload->impl)
progress = nir_lower_returns_impl(overload->impl) || progress;
nir_foreach_function(shader, function) {
if (function->impl)
progress = nir_lower_returns_impl(function->impl) || progress;
}
return progress;

View File

@ -191,8 +191,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);
}
}

View File

@ -139,9 +139,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);

View 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;

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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;

View 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));
}
}

View 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);
}
}

View 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;

View 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;

View 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;
}

View 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;

View 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;
}

View 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;
}

View 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);
}
}

View 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;

View 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;
}

View 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);
}

View File

@ -653,7 +653,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)
@ -919,7 +919,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)
@ -957,18 +957,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;
@ -982,32 +981,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)
{

View 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;

View 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;

View 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

View 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);
}
}

View 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);
}
}

View File

@ -1879,10 +1879,10 @@ static void
vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count)
{
struct nir_function_overload *overload =
vtn_value(b, w[3], vtn_value_type_function)->func->impl->overload;
struct nir_function *callee =
vtn_value(b, w[3], vtn_value_type_function)->func->impl->function;
nir_call_instr *call = nir_call_instr_create(b->nb.shader, overload);
nir_call_instr *call = nir_call_instr_create(b->nb.shader, callee);
for (unsigned i = 0; i < call->num_params; i++) {
unsigned arg_id = w[4 + i];
struct vtn_value *arg = vtn_untyped_value(b, arg_id);
@ -1902,15 +1902,15 @@ vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
}
nir_variable *out_tmp = NULL;
if (!glsl_type_is_void(overload->return_type)) {
out_tmp = nir_local_variable_create(b->impl, overload->return_type,
if (!glsl_type_is_void(callee->return_type)) {
out_tmp = nir_local_variable_create(b->impl, callee->return_type,
"out_tmp");
call->return_deref = nir_deref_var_create(call, out_tmp);
}
nir_builder_instr_insert(&b->nb, &call->instr);
if (glsl_type_is_void(overload->return_type)) {
if (glsl_type_is_void(callee->return_type)) {
vtn_push_value(b, w[2], vtn_value_type_undef);
} else {
struct vtn_type *rettype = vtn_value(b, w[1], vtn_value_type_type)->type;
@ -3381,36 +3381,33 @@ vtn_handle_first_cfg_pass_instruction(struct vtn_builder *b, SpvOp opcode,
nir_function *func =
nir_function_create(b->shader, ralloc_strdup(b->shader, val->name));
nir_function_overload *overload = nir_function_overload_create(func);
overload->num_params = glsl_get_length(func_type);
overload->params = ralloc_array(overload, nir_parameter,
overload->num_params);
for (unsigned i = 0; i < overload->num_params; i++) {
func->num_params = glsl_get_length(func_type);
func->params = ralloc_array(b->shader, nir_parameter, func->num_params);
for (unsigned i = 0; i < func->num_params; i++) {
const struct glsl_function_param *param =
glsl_get_function_param(func_type, i);
overload->params[i].type = param->type;
func->params[i].type = param->type;
if (param->in) {
if (param->out) {
overload->params[i].param_type = nir_parameter_inout;
func->params[i].param_type = nir_parameter_inout;
} else {
overload->params[i].param_type = nir_parameter_in;
func->params[i].param_type = nir_parameter_in;
}
} else {
if (param->out) {
overload->params[i].param_type = nir_parameter_out;
func->params[i].param_type = nir_parameter_out;
} else {
assert(!"Parameter is neither in nor out");
}
}
}
overload->return_type = glsl_get_function_return_type(func_type);
func->return_type = glsl_get_function_return_type(func_type);
b->func->impl = nir_function_impl_create(overload);
if (!glsl_type_is_void(overload->return_type)) {
b->func->impl = nir_function_impl_create(func);
if (!glsl_type_is_void(func->return_type)) {
b->func->impl->return_var =
nir_local_variable_create(b->func->impl,
overload->return_type, "retval");
nir_local_variable_create(b->func->impl, func->return_type, "ret");
}
b->func_param_idx = 0;
@ -3430,7 +3427,7 @@ vtn_handle_first_cfg_pass_instruction(struct vtn_builder *b, SpvOp opcode,
nir_variable *param =
nir_local_variable_create(b->func->impl,
b->func->impl->overload->params[idx].type,
b->func->impl->function->params[idx].type,
val->name);
b->func->impl->params[idx] = param;

View 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);
}
}

View 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",

View 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);
}
}

View 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;

View 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);
}
}

View File

@ -1099,8 +1099,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;

View File

@ -150,11 +150,11 @@ anv_nir_apply_dynamic_offsets(struct anv_pipeline *pipeline,
if (!state.layout || !state.layout->stage[shader->stage].has_dynamic_offsets)
return;
nir_foreach_overload(shader, overload) {
if (overload->impl) {
nir_builder_init(&state.builder, overload->impl);
nir_foreach_block(overload->impl, apply_dynamic_offsets_block, &state);
nir_metadata_preserve(overload->impl, nir_metadata_block_index |
nir_foreach_function(shader, function) {
if (function->impl) {
nir_builder_init(&state.builder, function->impl);
nir_foreach_block(function->impl, apply_dynamic_offsets_block, &state);
nir_metadata_preserve(function->impl, nir_metadata_block_index |
nir_metadata_dominance);
}
}

View File

@ -262,11 +262,11 @@ anv_nir_apply_pipeline_layout(nir_shader *shader,
.layout = layout,
};
nir_foreach_overload(shader, overload) {
if (overload->impl) {
nir_builder_init(&state.builder, overload->impl);
nir_foreach_block(overload->impl, apply_pipeline_layout_block, &state);
nir_metadata_preserve(overload->impl, nir_metadata_block_index |
nir_foreach_function(shader, function) {
if (function->impl) {
nir_builder_init(&state.builder, function->impl);
nir_foreach_block(function->impl, apply_pipeline_layout_block, &state);
nir_metadata_preserve(function->impl, nir_metadata_block_index |
nir_metadata_dominance);
}
}

View File

@ -36,11 +36,9 @@ nir_builder_init_simple_shader(nir_builder *b, gl_shader_stage stage)
{
b->shader = nir_shader_create(NULL, stage, NULL);
nir_function *func = nir_function_create(b->shader,
ralloc_strdup(b->shader, "main"));
nir_function_overload *overload = nir_function_overload_create(func);
overload->num_params = 0;
nir_function *func =
nir_function_create(b->shader, ralloc_strdup(b->shader, "main"));
b->impl = nir_function_impl_create(overload);
b->impl = nir_function_impl_create(func);
b->cursor = nir_after_cf_list(&b->impl->body);
}

View File

@ -95,9 +95,9 @@ anv_nir_lower_push_constants(nir_shader *shader, bool is_scalar)
.is_scalar = is_scalar,
};
nir_foreach_overload(shader, overload) {
if (overload->impl)
nir_foreach_block(overload->impl, lower_push_constants_block, &state);
nir_foreach_function(shader, function) {
if (function->impl)
nir_foreach_block(function->impl, lower_push_constants_block, &state);
}
assert(shader->num_uniforms % 4 == 0);

View File

@ -133,13 +133,11 @@ anv_shader_compile_to_nir(struct anv_device *device,
continue;
}
assert(exec_list_length(&func->overload_list) == 1);
foreach_list_typed(nir_function_overload, overload, node,
&func->overload_list) {
assert(overload->impl);
entrypoint = overload->impl;
}
assert(entrypoint == NULL);
assert(func->impl);
entrypoint = func->impl;
}
assert(exec_list_length(&nir->functions) == 1);
assert(entrypoint != NULL);
nir = brw_preprocess_nir(nir, compiler->scalar_stage[stage]);