From b8517e5ef9b935adc15ff441bc697805243730c9 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 21 Jul 2020 10:49:36 +0200 Subject: [PATCH] ac/nir: add support for nir_intrinsic_shared_atomic_fadd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Only LLVM 10+ has support. Signed-off-by: Samuel Pitoiset Reviewed-by: Daniel Schürmann Part-of: --- src/amd/llvm/ac_nir_to_llvm.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 862ae5c30ff..47539cfb56a 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -3404,11 +3404,26 @@ static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx, case nir_intrinsic_deref_atomic_exchange: op = LLVMAtomicRMWBinOpXchg; break; +#if LLVM_VERSION_MAJOR >= 10 + case nir_intrinsic_shared_atomic_fadd: + case nir_intrinsic_deref_atomic_fadd: + op = LLVMAtomicRMWBinOpFAdd; + break; +#endif default: return NULL; } - result = ac_build_atomic_rmw(&ctx->ac, op, ptr, ac_to_integer(&ctx->ac, src), sync_scope); + LLVMValueRef val; + + if (instr->intrinsic == nir_intrinsic_shared_atomic_fadd || + instr->intrinsic == nir_intrinsic_deref_atomic_fadd) { + val = ac_to_float(&ctx->ac, src); + } else { + val = ac_to_integer(&ctx->ac, src); + } + + result = ac_build_atomic_rmw(&ctx->ac, op, ptr, val, sync_scope); } if (ctx->ac.postponed_kill) @@ -3944,7 +3959,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx, case nir_intrinsic_shared_atomic_or: case nir_intrinsic_shared_atomic_xor: case nir_intrinsic_shared_atomic_exchange: - case nir_intrinsic_shared_atomic_comp_swap: { + case nir_intrinsic_shared_atomic_comp_swap: + case nir_intrinsic_shared_atomic_fadd: { LLVMValueRef ptr = get_memory_ptr(ctx, instr->src[0], instr->src[1].ssa->bit_size); result = visit_var_atomic(ctx, instr, ptr, 1); @@ -3959,7 +3975,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx, case nir_intrinsic_deref_atomic_or: case nir_intrinsic_deref_atomic_xor: case nir_intrinsic_deref_atomic_exchange: - case nir_intrinsic_deref_atomic_comp_swap: { + case nir_intrinsic_deref_atomic_comp_swap: + case nir_intrinsic_deref_atomic_fadd: { LLVMValueRef ptr = get_src(ctx, instr->src[0]); result = visit_var_atomic(ctx, instr, ptr, 1); break; -- 2.30.2