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);
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, "");
}
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);
LLVMPositionBuilderAtEnd(builder, state->block);
- state->counter = LLVMBuildLoad(builder, state->counter_var, "");
+ state->counter = LLVMBuildLoad2(builder, state->counter_type, state->counter_var, "");
}
LLVMPositionBuilderAtEnd(builder, after_block);
- state->counter = LLVMBuildLoad(builder, state->counter_var, "");
+ state->counter = LLVMBuildLoad2(builder, state->counter_type, 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, "");
+ state->counter = LLVMBuildLoad2(builder, state->counter_type, state->counter_var, "");
}
void
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;
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);
struct lp_build_skip_context skip;
LLVMTypeRef reg_type;
-
+ LLVMTypeRef var_type;
+ /* 'var' is a pointer (alloca) pointing to 'var_type' */
LLVMValueRef var;
};
/**
* 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
LLVMBasicBlockRef block;
LLVMValueRef counter_var;
LLVMValueRef counter;
+ LLVMTypeRef counter_type;
struct gallivm_state *gallivm;
};
LLVMBasicBlockRef exit;
LLVMValueRef counter_var;
LLVMValueRef counter;
+ LLVMTypeRef counter_type;
LLVMValueRef step;
LLVMIntPredicate cond;
LLVMValueRef end;