From d00e7d42f5a6bad04c60e399c7ca0b062d3b5dea Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Wed, 25 Apr 2018 18:22:02 +0200 Subject: [PATCH] ac/nir: Add shared atomic deref instr support. Acked-by: Rob Clark Acked-by: Bas Nieuwenhuizen Acked-by: Dave Airlie Reviewed-by: Kenneth Graunke --- src/amd/common/ac_nir_to_llvm.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 467d1dd19ab..8aee933b2d8 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -2806,7 +2806,8 @@ static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx, LLVMValueRef src = get_src(ctx, instr->src[src_idx]); if (instr->intrinsic == nir_intrinsic_var_atomic_comp_swap || - instr->intrinsic == nir_intrinsic_shared_atomic_comp_swap) { + instr->intrinsic == nir_intrinsic_shared_atomic_comp_swap || + instr->intrinsic == nir_intrinsic_deref_atomic_comp_swap) { LLVMValueRef src1 = get_src(ctx, instr->src[src_idx + 1]); result = LLVMBuildAtomicCmpXchg(ctx->ac.builder, ptr, src, src1, @@ -2819,38 +2820,47 @@ static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx, switch (instr->intrinsic) { case nir_intrinsic_var_atomic_add: case nir_intrinsic_shared_atomic_add: + case nir_intrinsic_deref_atomic_add: op = LLVMAtomicRMWBinOpAdd; break; case nir_intrinsic_var_atomic_umin: case nir_intrinsic_shared_atomic_umin: + case nir_intrinsic_deref_atomic_umin: op = LLVMAtomicRMWBinOpUMin; break; case nir_intrinsic_var_atomic_umax: case nir_intrinsic_shared_atomic_umax: + case nir_intrinsic_deref_atomic_umax: op = LLVMAtomicRMWBinOpUMax; break; case nir_intrinsic_var_atomic_imin: case nir_intrinsic_shared_atomic_imin: + case nir_intrinsic_deref_atomic_imin: op = LLVMAtomicRMWBinOpMin; break; case nir_intrinsic_var_atomic_imax: case nir_intrinsic_shared_atomic_imax: + case nir_intrinsic_deref_atomic_imax: op = LLVMAtomicRMWBinOpMax; break; case nir_intrinsic_var_atomic_and: case nir_intrinsic_shared_atomic_and: + case nir_intrinsic_deref_atomic_and: op = LLVMAtomicRMWBinOpAnd; break; case nir_intrinsic_var_atomic_or: case nir_intrinsic_shared_atomic_or: + case nir_intrinsic_deref_atomic_or: op = LLVMAtomicRMWBinOpOr; break; case nir_intrinsic_var_atomic_xor: case nir_intrinsic_shared_atomic_xor: + case nir_intrinsic_deref_atomic_xor: op = LLVMAtomicRMWBinOpXor; break; case nir_intrinsic_var_atomic_exchange: case nir_intrinsic_shared_atomic_exchange: + case nir_intrinsic_deref_atomic_exchange: op = LLVMAtomicRMWBinOpXchg; break; default: @@ -3233,6 +3243,20 @@ static void visit_intrinsic(struct ac_nir_context *ctx, result = visit_var_atomic(ctx, instr, ptr, 0); break; } + case nir_intrinsic_deref_atomic_add: + case nir_intrinsic_deref_atomic_imin: + case nir_intrinsic_deref_atomic_umin: + case nir_intrinsic_deref_atomic_imax: + case nir_intrinsic_deref_atomic_umax: + case nir_intrinsic_deref_atomic_and: + 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: { + LLVMValueRef ptr = get_src(ctx, instr->src[0]); + result = visit_var_atomic(ctx, instr, ptr, 1); + break; + } case nir_intrinsic_interp_var_at_centroid: case nir_intrinsic_interp_var_at_sample: case nir_intrinsic_interp_var_at_offset: -- 2.30.2