From f3f0cbf4f4481341ddf257a9228c7e8bdabd38a0 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 26 Jun 2019 07:35:36 +1000 Subject: [PATCH] gallivm/flow: add counter reset for loops This allows the counter value to be forced to a certain value Reviewed-by: Roland Scheidegger --- src/gallium/auxiliary/gallivm/lp_bld_flow.c | 14 ++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_flow.h | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c b/src/gallium/auxiliary/gallivm/lp_bld_flow.c index c522bc4f4ab..3bd24b4ba87 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c @@ -265,6 +265,20 @@ lp_build_loop_end_cond(struct lp_build_loop_state *state, state->counter = LLVMBuildLoad(builder, state->counter_var, ""); } +void +lp_build_loop_force_set_counter(struct lp_build_loop_state *state, + LLVMValueRef end) +{ + LLVMBuilderRef builder = state->gallivm->builder; + LLVMBuildStore(builder, end, state->counter_var); +} + +void +lp_build_loop_force_reload_counter(struct lp_build_loop_state *state) +{ + LLVMBuilderRef builder = state->gallivm->builder; + state->counter = LLVMBuildLoad(builder, state->counter_var, ""); +} void lp_build_loop_end(struct lp_build_loop_state *state, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h b/src/gallium/auxiliary/gallivm/lp_bld_flow.h index 674fc189f1a..ddb3fdfd7b7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h @@ -127,6 +127,12 @@ lp_build_loop_end(struct lp_build_loop_state *state, LLVMValueRef end, LLVMValueRef step); +void +lp_build_loop_force_set_counter(struct lp_build_loop_state *state, + LLVMValueRef end); + +void +lp_build_loop_force_reload_counter(struct lp_build_loop_state *state); void lp_build_loop_end_cond(struct lp_build_loop_state *state, LLVMValueRef end, -- 2.30.2