translate_atomic_opcode(nir_intrinsic_atomic_op(instr));
agx_index base =
local ? agx_local_base(instr->src[0]) : agx_src_index(&instr->src[0]);
- agx_index value = agx_src_index(&instr->src[1]);
- agx_index index = agx_zero(); /* TODO: optimize address arithmetic? */
+ agx_index value = agx_src_index(&instr->src[local ? 1 : 2]);
+ agx_index index = local ? agx_zero() : agx_src_index(&instr->src[1]);
/* cmpxchg (only) takes 2 sources, passed in consecutive registers */
if (op == AGX_ATOMIC_OPC_CMPXCHG) {
- agx_index value2 = agx_src_index(&instr->src[2]);
+ agx_index value2 = agx_src_index(&instr->src[local ? 2 : 3]);
value = agx_vec2(b, value2, value);
}
agx_emit_local_load(b, dst, instr);
return NULL;
- case nir_intrinsic_global_atomic:
- case nir_intrinsic_global_atomic_swap:
+ case nir_intrinsic_global_atomic_agx:
+ case nir_intrinsic_global_atomic_swap_agx:
agx_emit_atomic(b, dst, instr, false);
return NULL;
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
if (intr->intrinsic != nir_intrinsic_load_global &&
intr->intrinsic != nir_intrinsic_load_global_constant &&
+ intr->intrinsic != nir_intrinsic_global_atomic &&
+ intr->intrinsic != nir_intrinsic_global_atomic_swap &&
intr->intrinsic != nir_intrinsic_store_global)
return false;
offset, .access = nir_intrinsic_access(intr),
.base = match.shift, .format = format,
.sign_extend = match.sign_extend);
+ } else if (intr->intrinsic == nir_intrinsic_global_atomic) {
+ offset = nir_ishl_imm(b, offset, match.shift);
+ repl =
+ nir_global_atomic_agx(b, bit_size, new_base, offset, intr->src[1].ssa,
+ .atomic_op = nir_intrinsic_atomic_op(intr),
+ .sign_extend = match.sign_extend);
+ } else if (intr->intrinsic == nir_intrinsic_global_atomic_swap) {
+ offset = nir_ishl_imm(b, offset, match.shift);
+ repl = nir_global_atomic_swap_agx(
+ b, bit_size, new_base, offset, intr->src[1].ssa, intr->src[2].ssa,
+ .atomic_op = nir_intrinsic_atomic_op(intr),
+ .sign_extend = match.sign_extend);
} else {
nir_store_agx(b, intr->src[0].ssa, new_base, offset,
.access = nir_intrinsic_access(intr), .base = match.shift,