gallivm: use LLVM opaque pointers in lp_bld_flow.c
authorMihai Preda <mhpreda@gmail.com>
Mon, 2 May 2022 12:54:57 +0000 (15:54 +0300)
committerMihai Preda <42345-preda@users.noreply.gitlab.freedesktop.org>
Wed, 4 May 2022 20:00:33 +0000 (20:00 +0000)
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15893>

src/gallium/auxiliary/gallivm/lp_bld_flow.c
src/gallium/auxiliary/gallivm/lp_bld_flow.h

index d5d903f..8858aac 100644 (file)
@@ -168,8 +168,9 @@ lp_build_mask_begin(struct lp_build_mask_context *mask,
    memset(mask, 0, sizeof *mask);
 
    mask->reg_type = LLVMIntTypeInContext(gallivm->context, type.width * type.length);
+   mask->var_type = lp_build_int_vec_type(gallivm, type);
    mask->var = lp_build_alloca(gallivm,
-                               lp_build_int_vec_type(gallivm, type),
+                               mask->var_type,
                                "execution_mask");
 
    LLVMBuildStore(gallivm->builder, value, mask->var);
@@ -181,7 +182,7 @@ lp_build_mask_begin(struct lp_build_mask_context *mask,
 LLVMValueRef
 lp_build_mask_value(struct lp_build_mask_context *mask)
 {
-   return LLVMBuildLoad(mask->skip.gallivm->builder, mask->var, "");
+   return LLVMBuildLoad2(mask->skip.gallivm->builder, mask->var_type, mask->var, "");
 }
 
 
@@ -233,7 +234,8 @@ lp_build_loop_begin(struct lp_build_loop_state *state,
 
    state->block = lp_build_insert_new_block(gallivm, "loop_begin");
 
-   state->counter_var = lp_build_alloca(gallivm, LLVMTypeOf(start), "loop_counter");
+   state->counter_type = LLVMTypeOf(start);
+   state->counter_var = lp_build_alloca(gallivm, state->counter_type, "loop_counter");
    state->gallivm = gallivm;
 
    LLVMBuildStore(builder, start, state->counter_var);
@@ -242,7 +244,7 @@ lp_build_loop_begin(struct lp_build_loop_state *state,
 
    LLVMPositionBuilderAtEnd(builder, state->block);
 
-   state->counter = LLVMBuildLoad(builder, state->counter_var, "");
+   state->counter = LLVMBuildLoad2(builder, state->counter_type, state->counter_var, "");
 }
 
 
@@ -272,7 +274,7 @@ lp_build_loop_end_cond(struct lp_build_loop_state *state,
 
    LLVMPositionBuilderAtEnd(builder, after_block);
 
-   state->counter = LLVMBuildLoad(builder, state->counter_var, "");
+   state->counter = LLVMBuildLoad2(builder, state->counter_type, state->counter_var, "");
 }
 
 void
@@ -287,7 +289,7 @@ 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, "");
+   state->counter = LLVMBuildLoad2(builder, state->counter_type, state->counter_var, "");
 }
 
 void
@@ -324,7 +326,8 @@ lp_build_for_loop_begin(struct lp_build_for_loop_state *state,
 
    state->begin = lp_build_insert_new_block(gallivm, "loop_begin");
    state->step  = step;
-   state->counter_var = lp_build_alloca(gallivm, LLVMTypeOf(start), "loop_counter");
+   state->counter_type = LLVMTypeOf(start);
+   state->counter_var = lp_build_alloca(gallivm, state->counter_type, "loop_counter");
    state->gallivm = gallivm;
    state->cond = cmp_op;
    state->end = end;
@@ -333,7 +336,7 @@ lp_build_for_loop_begin(struct lp_build_for_loop_state *state,
    LLVMBuildBr(builder, state->begin);
 
    LLVMPositionBuilderAtEnd(builder, state->begin);
-   state->counter = LLVMBuildLoad(builder, state->counter_var, "");
+   state->counter = LLVMBuildLoad2(builder, state->counter_type, state->counter_var, "");
 
    state->body = lp_build_insert_new_block(gallivm, "loop_body");
    LLVMPositionBuilderAtEnd(builder, state->body);
index c4ffa83..c79502a 100644 (file)
@@ -73,7 +73,8 @@ struct lp_build_mask_context
    struct lp_build_skip_context skip;
 
    LLVMTypeRef reg_type;
-
+   LLVMTypeRef var_type;
+   /* 'var' is a pointer (alloca) pointing to 'var_type' */
    LLVMValueRef var;
 };
 
@@ -107,7 +108,7 @@ lp_build_mask_end(struct lp_build_mask_context *mask);
 
 /**
  * LLVM's IR doesn't represent for-loops directly. Furthermore it
- * it requires creating code blocks, branches, phi variables, so it
+ * requires creating code blocks, branches, phi variables, so it
  * requires a fair amount of code.
  *
  * @sa http://www.llvm.org/docs/tutorial/LangImpl5.html#for
@@ -117,6 +118,7 @@ struct lp_build_loop_state
    LLVMBasicBlockRef block;
    LLVMValueRef counter_var;
    LLVMValueRef counter;
+   LLVMTypeRef counter_type;
    struct gallivm_state *gallivm;
 };
 
@@ -154,6 +156,7 @@ struct lp_build_for_loop_state
    LLVMBasicBlockRef exit;
    LLVMValueRef counter_var;
    LLVMValueRef counter;
+   LLVMTypeRef counter_type;
    LLVMValueRef step;
    LLVMIntPredicate cond;
    LLVMValueRef end;