summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-03-26 15:38:49 -0700
committerJason Ekstrand <[email protected]>2018-04-11 11:03:22 -0700
commitbc2b170d6849d31fc88df4ece635ff789e4ad0c2 (patch)
treed3d342653cc5d9928c7da9a7adcae4b9dc12263d /src
parentbd95397d651f89e1f485716b228e18bacbd7d486 (diff)
nir: Use nir_builder in lower_io_to_temporaries
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_lower_io_to_temporaries.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c
index bff04b97687..3dae52220dc 100644
--- a/src/compiler/nir/nir_lower_io_to_temporaries.c
+++ b/src/compiler/nir/nir_lower_io_to_temporaries.c
@@ -31,6 +31,7 @@
*/
#include "nir.h"
+#include "nir_builder.h"
struct lower_io_state {
nir_shader *shader;
@@ -40,7 +41,7 @@ struct lower_io_state {
};
static void
-emit_copies(nir_cursor cursor, nir_shader *shader, struct exec_list *dest_vars,
+emit_copies(nir_builder *b, struct exec_list *dest_vars,
struct exec_list *src_vars)
{
assert(exec_list_length(dest_vars) == exec_list_length(src_vars));
@@ -64,18 +65,16 @@ emit_copies(nir_cursor cursor, nir_shader *shader, struct exec_list *dest_vars,
if (dest->data.read_only)
continue;
- nir_intrinsic_instr *copy =
- nir_intrinsic_instr_create(shader, nir_intrinsic_copy_var);
- copy->variables[0] = nir_deref_var_create(copy, dest);
- copy->variables[1] = nir_deref_var_create(copy, src);
-
- nir_instr_insert(cursor, &copy->instr);
+ nir_copy_var(b, dest, src);
}
}
static void
emit_output_copies_impl(struct lower_io_state *state, nir_function_impl *impl)
{
+ nir_builder b;
+ nir_builder_init(&b, impl);
+
if (state->shader->info.stage == MESA_SHADER_GEOMETRY) {
/* For geometry shaders, we have to emit the output copies right
* before each EmitVertex call.
@@ -87,16 +86,14 @@ emit_output_copies_impl(struct lower_io_state *state, nir_function_impl *impl)
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
if (intrin->intrinsic == nir_intrinsic_emit_vertex) {
- nir_cursor cursor = nir_before_instr(&intrin->instr);
- emit_copies(cursor, state->shader, &state->shader->outputs,
- &state->old_outputs);
+ b.cursor = nir_before_instr(&intrin->instr);
+ emit_copies(&b, &state->shader->outputs, &state->old_outputs);
}
}
}
} else if (impl == state->entrypoint) {
- nir_cursor cursor = nir_before_block(nir_start_block(impl));
- emit_copies(cursor, state->shader, &state->old_outputs,
- &state->shader->outputs);
+ b.cursor = nir_before_block(nir_start_block(impl));
+ emit_copies(&b, &state->old_outputs, &state->shader->outputs);
/* For all other shader types, we need to do the copies right before
* the jumps to the end block.
@@ -104,9 +101,8 @@ emit_output_copies_impl(struct lower_io_state *state, nir_function_impl *impl)
struct set_entry *block_entry;
set_foreach(impl->end_block->predecessors, block_entry) {
struct nir_block *block = (void *)block_entry->key;
- nir_cursor cursor = nir_after_block_before_jump(block);
- emit_copies(cursor, state->shader, &state->shader->outputs,
- &state->old_outputs);
+ b.cursor = nir_after_block_before_jump(block);
+ emit_copies(&b, &state->shader->outputs, &state->old_outputs);
}
}
}
@@ -115,9 +111,10 @@ static void
emit_input_copies_impl(struct lower_io_state *state, nir_function_impl *impl)
{
if (impl == state->entrypoint) {
- nir_cursor cursor = nir_before_block(nir_start_block(impl));
- emit_copies(cursor, state->shader, &state->old_inputs,
- &state->shader->inputs);
+ nir_builder b;
+ nir_builder_init(&b, impl);
+ b.cursor = nir_before_block(nir_start_block(impl));
+ emit_copies(&b, &state->old_inputs, &state->shader->inputs);
}
}