diff options
author | Eric Anholt <[email protected]> | 2019-12-16 20:53:59 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2020-02-18 15:40:04 -0800 |
commit | d8d34238a6dc61f6c522e2807bc83d434d27e74f (patch) | |
tree | 0309bb85d9057283a6dfb2ce2e86ce3918687762 /src/gallium/auxiliary/gallivm | |
parent | b32bd704c0a22b6eb691f93158acbbdd4c5d370a (diff) |
llvmpipe: Fix warning about uninitialized "op" in the NIR path.
Similar to TGSI, move the switch statement and use more unreachable().
Reviewed-by: Roland Scheidegger <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3867>
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 149 |
1 files changed, 75 insertions, 74 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index e1e476e35ce..05f16d81e56 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -641,38 +641,6 @@ static void emit_atomic_global(struct lp_build_nir_context *bld_base, struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; struct lp_build_context *uint_bld = &bld_base->uint_bld; - LLVMAtomicRMWBinOp op; - switch (nir_op) { - case nir_intrinsic_global_atomic_add: - op = LLVMAtomicRMWBinOpAdd; - break; - case nir_intrinsic_global_atomic_exchange: - op = LLVMAtomicRMWBinOpXchg; - break; - case nir_intrinsic_global_atomic_and: - op = LLVMAtomicRMWBinOpAnd; - break; - case nir_intrinsic_global_atomic_or: - op = LLVMAtomicRMWBinOpOr; - break; - case nir_intrinsic_global_atomic_xor: - op = LLVMAtomicRMWBinOpXor; - break; - case nir_intrinsic_global_atomic_umin: - op = LLVMAtomicRMWBinOpUMin; - break; - case nir_intrinsic_global_atomic_umax: - op = LLVMAtomicRMWBinOpUMax; - break; - case nir_intrinsic_global_atomic_imin: - op = LLVMAtomicRMWBinOpMin; - break; - case nir_intrinsic_global_atomic_imax: - op = LLVMAtomicRMWBinOpMax; - break; - default: - break; - } LLVMValueRef atom_res = lp_build_alloca(gallivm, uint_bld->vec_type, ""); @@ -704,6 +672,39 @@ static void emit_atomic_global(struct lp_build_nir_context *bld_base, false); scalar = LLVMBuildExtractValue(gallivm->builder, scalar, 0, ""); } else { + LLVMAtomicRMWBinOp op; + switch (nir_op) { + case nir_intrinsic_global_atomic_add: + op = LLVMAtomicRMWBinOpAdd; + break; + case nir_intrinsic_global_atomic_exchange: + op = LLVMAtomicRMWBinOpXchg; + break; + case nir_intrinsic_global_atomic_and: + op = LLVMAtomicRMWBinOpAnd; + break; + case nir_intrinsic_global_atomic_or: + op = LLVMAtomicRMWBinOpOr; + break; + case nir_intrinsic_global_atomic_xor: + op = LLVMAtomicRMWBinOpXor; + break; + case nir_intrinsic_global_atomic_umin: + op = LLVMAtomicRMWBinOpUMin; + break; + case nir_intrinsic_global_atomic_umax: + op = LLVMAtomicRMWBinOpUMax; + break; + case nir_intrinsic_global_atomic_imin: + op = LLVMAtomicRMWBinOpMin; + break; + case nir_intrinsic_global_atomic_imax: + op = LLVMAtomicRMWBinOpMax; + break; + default: + unreachable("unknown atomic op"); + } + scalar = LLVMBuildAtomicRMW(builder, op, addr_ptr, value_ptr, LLVMAtomicOrderingSequentiallyConsistent, @@ -922,7 +923,6 @@ static void emit_atomic_mem(struct lp_build_nir_context *bld_base, LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder; LLVMValueRef ssbo_ptr; struct lp_build_context *uint_bld = &bld_base->uint_bld; - LLVMAtomicRMWBinOp op; LLVMValueRef ssbo_limit = NULL; if (index) { @@ -933,47 +933,6 @@ static void emit_atomic_mem(struct lp_build_nir_context *bld_base, } else ssbo_ptr = bld->shared_ptr; - switch (nir_op) { - case nir_intrinsic_shared_atomic_add: - case nir_intrinsic_ssbo_atomic_add: - op = LLVMAtomicRMWBinOpAdd; - break; - case nir_intrinsic_shared_atomic_exchange: - case nir_intrinsic_ssbo_atomic_exchange: - op = LLVMAtomicRMWBinOpXchg; - break; - case nir_intrinsic_shared_atomic_and: - case nir_intrinsic_ssbo_atomic_and: - op = LLVMAtomicRMWBinOpAnd; - break; - case nir_intrinsic_shared_atomic_or: - case nir_intrinsic_ssbo_atomic_or: - op = LLVMAtomicRMWBinOpOr; - break; - case nir_intrinsic_shared_atomic_xor: - case nir_intrinsic_ssbo_atomic_xor: - op = LLVMAtomicRMWBinOpXor; - break; - case nir_intrinsic_shared_atomic_umin: - case nir_intrinsic_ssbo_atomic_umin: - op = LLVMAtomicRMWBinOpUMin; - break; - case nir_intrinsic_shared_atomic_umax: - case nir_intrinsic_ssbo_atomic_umax: - op = LLVMAtomicRMWBinOpUMax; - break; - case nir_intrinsic_ssbo_atomic_imin: - case nir_intrinsic_shared_atomic_imin: - op = LLVMAtomicRMWBinOpMin; - break; - case nir_intrinsic_ssbo_atomic_imax: - case nir_intrinsic_shared_atomic_imax: - op = LLVMAtomicRMWBinOpMax; - break; - default: - break; - } - offset = lp_build_shr_imm(uint_bld, offset, 2); LLVMValueRef atom_res = lp_build_alloca(gallivm, uint_bld->vec_type, ""); @@ -1015,6 +974,48 @@ static void emit_atomic_mem(struct lp_build_nir_context *bld_base, false); scalar = LLVMBuildExtractValue(gallivm->builder, scalar, 0, ""); } else { + LLVMAtomicRMWBinOp op; + + switch (nir_op) { + case nir_intrinsic_shared_atomic_add: + case nir_intrinsic_ssbo_atomic_add: + op = LLVMAtomicRMWBinOpAdd; + break; + case nir_intrinsic_shared_atomic_exchange: + case nir_intrinsic_ssbo_atomic_exchange: + op = LLVMAtomicRMWBinOpXchg; + break; + case nir_intrinsic_shared_atomic_and: + case nir_intrinsic_ssbo_atomic_and: + op = LLVMAtomicRMWBinOpAnd; + break; + case nir_intrinsic_shared_atomic_or: + case nir_intrinsic_ssbo_atomic_or: + op = LLVMAtomicRMWBinOpOr; + break; + case nir_intrinsic_shared_atomic_xor: + case nir_intrinsic_ssbo_atomic_xor: + op = LLVMAtomicRMWBinOpXor; + break; + case nir_intrinsic_shared_atomic_umin: + case nir_intrinsic_ssbo_atomic_umin: + op = LLVMAtomicRMWBinOpUMin; + break; + case nir_intrinsic_shared_atomic_umax: + case nir_intrinsic_ssbo_atomic_umax: + op = LLVMAtomicRMWBinOpUMax; + break; + case nir_intrinsic_ssbo_atomic_imin: + case nir_intrinsic_shared_atomic_imin: + op = LLVMAtomicRMWBinOpMin; + break; + case nir_intrinsic_ssbo_atomic_imax: + case nir_intrinsic_shared_atomic_imax: + op = LLVMAtomicRMWBinOpMax; + break; + default: + unreachable("unknown atomic op"); + } scalar = LLVMBuildAtomicRMW(builder, op, scalar_ptr, value_ptr, LLVMAtomicOrderingSequentiallyConsistent, |