[Mesa-dev] [PATCH 2/8] glsl/nir: Use nir_builder's new control-flow helpers
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Fri Feb 24 14:07:09 UTC 2017
Patches 2-5 and 7-8 are:
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
On 24/02/17 02:14, Jason Ekstrand wrote:
> ---
> src/compiler/glsl/glsl_to_nir.cpp | 38 +++++++++++---------------------------
> 1 file changed, 11 insertions(+), 27 deletions(-)
>
> diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
> index 00f20da..fc2a2c4 100644
> --- a/src/compiler/glsl/glsl_to_nir.cpp
> +++ b/src/compiler/glsl/glsl_to_nir.cpp
> @@ -520,31 +520,19 @@ nir_visitor::visit(ir_function_signature *ir)
> void
> nir_visitor::visit(ir_loop *ir)
> {
> - nir_loop *loop = nir_loop_create(this->shader);
> - nir_builder_cf_insert(&b, &loop->cf_node);
> -
> - b.cursor = nir_after_cf_list(&loop->body);
> + nir_push_loop(&b);
> visit_exec_list(&ir->body_instructions, this);
> - b.cursor = nir_after_cf_node(&loop->cf_node);
> + nir_pop_loop(&b, NULL);
> }
>
> void
> nir_visitor::visit(ir_if *ir)
> {
> - nir_src condition =
> - nir_src_for_ssa(evaluate_rvalue(ir->condition));
> -
> - nir_if *if_stmt = nir_if_create(this->shader);
> - if_stmt->condition = condition;
> - nir_builder_cf_insert(&b, &if_stmt->cf_node);
> -
> - b.cursor = nir_after_cf_list(&if_stmt->then_list);
> + nir_push_if(&b, evaluate_rvalue(ir->condition));
> visit_exec_list(&ir->then_instructions, this);
> -
> - b.cursor = nir_after_cf_list(&if_stmt->else_list);
> + nir_push_else(&b, NULL);
> visit_exec_list(&ir->else_instructions, this);
> -
> - b.cursor = nir_after_cf_node(&if_stmt->cf_node);
> + nir_pop_if(&b, NULL);
> }
>
> void
> @@ -1193,11 +1181,9 @@ nir_visitor::visit(ir_assignment *ir)
> copy->variables[1] = evaluate_deref(©->instr, ir->rhs);
>
> if (ir->condition) {
> - nir_if *if_stmt = nir_if_create(this->shader);
> - if_stmt->condition = nir_src_for_ssa(evaluate_rvalue(ir->condition));
> - nir_builder_cf_insert(&b, &if_stmt->cf_node);
> - nir_instr_insert_after_cf_list(&if_stmt->then_list, ©->instr);
> - b.cursor = nir_after_cf_node(&if_stmt->cf_node);
> + nir_push_if(&b, evaluate_rvalue(ir->condition));
> + nir_builder_instr_insert(&b, ©->instr);
> + nir_pop_if(&b, NULL);
> } else {
> nir_builder_instr_insert(&b, ©->instr);
> }
> @@ -1232,11 +1218,9 @@ nir_visitor::visit(ir_assignment *ir)
> store->src[0] = nir_src_for_ssa(src);
>
> if (ir->condition) {
> - nir_if *if_stmt = nir_if_create(this->shader);
> - if_stmt->condition = nir_src_for_ssa(evaluate_rvalue(ir->condition));
> - nir_builder_cf_insert(&b, &if_stmt->cf_node);
> - nir_instr_insert_after_cf_list(&if_stmt->then_list, &store->instr);
> - b.cursor = nir_after_cf_node(&if_stmt->cf_node);
> + nir_push_if(&b, evaluate_rvalue(ir->condition));
> + nir_builder_instr_insert(&b, &store->instr);
> + nir_pop_if(&b, NULL);
> } else {
> nir_builder_instr_insert(&b, &store->instr);
> }
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 862 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170224/bf470b90/attachment.sig>
More information about the mesa-dev
mailing list