mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
gallivm/nir: Refactor out some repeated code to generate 0 values.
Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14999>
This commit is contained in:
parent
4fad4c1d79
commit
d74606d440
1 changed files with 16 additions and 19 deletions
|
|
@ -91,6 +91,19 @@ invocation_0_must_be_active(struct lp_build_nir_context *bld_base)
|
|||
return true;
|
||||
}
|
||||
|
||||
static LLVMValueRef
|
||||
lp_build_zero_bits(struct gallivm_state *gallivm, int bit_size)
|
||||
{
|
||||
if (bit_size == 64)
|
||||
return LLVMConstInt(LLVMInt64TypeInContext(gallivm->context), 0, 0);
|
||||
else if (bit_size == 16)
|
||||
return LLVMConstInt(LLVMInt16TypeInContext(gallivm->context), 0, 0);
|
||||
else if (bit_size == 8)
|
||||
return LLVMConstInt(LLVMInt8TypeInContext(gallivm->context), 0, 0);
|
||||
else
|
||||
return lp_build_const_int32(gallivm, 0);
|
||||
}
|
||||
|
||||
static LLVMValueRef
|
||||
emit_fetch_64bit(
|
||||
struct lp_build_nir_context * bld_base,
|
||||
|
|
@ -1170,15 +1183,7 @@ static void emit_load_mem(struct lp_build_nir_context *bld_base,
|
|||
LLVMBuildStore(builder, temp_res, result[c]);
|
||||
lp_build_else(&ifthen);
|
||||
temp_res = LLVMBuildLoad(builder, result[c], "");
|
||||
LLVMValueRef zero;
|
||||
if (bit_size == 64)
|
||||
zero = LLVMConstInt(LLVMInt64TypeInContext(gallivm->context), 0, 0);
|
||||
else if (bit_size == 16)
|
||||
zero = LLVMConstInt(LLVMInt16TypeInContext(gallivm->context), 0, 0);
|
||||
else if (bit_size == 8)
|
||||
zero = LLVMConstInt(LLVMInt8TypeInContext(gallivm->context), 0, 0);
|
||||
else
|
||||
zero = lp_build_const_int32(gallivm, 0);
|
||||
LLVMValueRef zero = lp_build_zero_bits(gallivm, bit_size);
|
||||
temp_res = LLVMBuildInsertElement(builder, temp_res, zero, loop_state.counter, "");
|
||||
LLVMBuildStore(builder, temp_res, result[c]);
|
||||
lp_build_endif(&ifthen);
|
||||
|
|
@ -1368,7 +1373,7 @@ static void emit_atomic_mem(struct lp_build_nir_context *bld_base,
|
|||
LLVMBuildStore(builder, temp_res, atom_res);
|
||||
lp_build_else(&ifthen);
|
||||
temp_res = LLVMBuildLoad(builder, atom_res, "");
|
||||
LLVMValueRef zero = bit_size == 64 ? lp_build_const_int64(gallivm, 0) : lp_build_const_int32(gallivm, 0);
|
||||
LLVMValueRef zero = lp_build_zero_bits(gallivm, bit_size);
|
||||
temp_res = LLVMBuildInsertElement(builder, temp_res, zero, loop_state.counter, "");
|
||||
LLVMBuildStore(builder, temp_res, atom_res);
|
||||
lp_build_endif(&ifthen);
|
||||
|
|
@ -2390,15 +2395,7 @@ emit_load_scratch(struct lp_build_nir_context *bld_base,
|
|||
LLVMBuildStore(builder, temp_res, result);
|
||||
lp_build_else(&ifthen);
|
||||
temp_res = LLVMBuildLoad(builder, result, "");
|
||||
LLVMValueRef zero;
|
||||
if (bit_size == 64)
|
||||
zero = LLVMConstInt(LLVMInt64TypeInContext(gallivm->context), 0, 0);
|
||||
else if (bit_size == 16)
|
||||
zero = LLVMConstInt(LLVMInt16TypeInContext(gallivm->context), 0, 0);
|
||||
else if (bit_size == 8)
|
||||
zero = LLVMConstInt(LLVMInt8TypeInContext(gallivm->context), 0, 0);
|
||||
else
|
||||
zero = lp_build_const_int32(gallivm, 0);
|
||||
LLVMValueRef zero = lp_build_zero_bits(gallivm, bit_size);
|
||||
temp_res = LLVMBuildInsertElement(builder, temp_res, zero, loop_state.counter, "");
|
||||
LLVMBuildStore(builder, temp_res, result);
|
||||
lp_build_endif(&ifthen);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue