nir: Get rid of function overloads

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

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>

ir3 bits are

Reviewed-by: Rob Clark <robclark@gmail.com>
This commit is contained in:
Jason Ekstrand
2015-12-26 10:00:47 -08:00
parent 109c348284
commit 237f2f2d8b
59 changed files with 318 additions and 391 deletions
+1 -2
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);
@@ -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;
}
@@ -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;
@@ -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);
}
+3 -3
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);
}
}
@@ -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);
}
}
+7 -7
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;
}
+21 -32
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);
@@ -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);
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
@@ -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);
+12 -26
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;
@@ -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);
+16 -30
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;
@@ -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);
+3 -3
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;
+1 -1
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
+23 -35
View 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,38 +588,26 @@ 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)
{
nir_function_overload *nfo = nir_function_overload_create(nfxn);
/* Needed for call instructions */
store_ptr(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 */
store_ptr(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;
}
@@ -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);
+14 -14
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);
}
}
+3 -3
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);
}
}
+3 -3
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) {
+3 -3
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);
}
}
+4 -4
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);
}
}
+9 -9
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);
}
}
@@ -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);
}
}
+6 -6
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);
}
}
+3 -3
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);
}
}
+3 -3
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);
}
}
@@ -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);
}
}
+4 -4
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;
@@ -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);
}
+3 -3
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);
}
}
+3 -3
View 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);
}
}
+3 -3
View 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);
+3 -3
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;
+3 -3
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);
}
}
+3 -3
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);
}
}
+3 -3
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);
}
}
+4 -4
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);
}
}
+4 -4
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;
+6 -6
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));
}
}
+3 -3
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);
}
}
+3 -3
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;
+3 -3
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;
+2 -2
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;
}
+3 -3
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;
+2 -2
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;
}
+3 -3
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;
}
+3 -3
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);
}
}
+3 -3
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;
+3 -3
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;
}
+4 -4
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);
}
+12 -21
View 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)
{
+7 -7
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;
+3 -3
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;
+3 -6
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
+3 -3
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);
}
}
+8 -17
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);
}
}
+8 -8
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);
}
}
+25 -25
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",
@@ -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);
}
}
@@ -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;
+8 -8
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);
}
}
+1 -2
View 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;