summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2019-03-12 09:21:59 +0100
committerSamuel Pitoiset <[email protected]>2019-03-20 22:18:56 +0100
commit29132af2347ede46a6d02422295a5fadbe5fe788 (patch)
treeee37cf33f0607ef36b5244d16960df716ac2084d /src
parentb39844457fd1fcbdcab6960bba32d083672e1f2c (diff)
ac/nir: use new LLVM 8 intrinsics for SSBO atomic operations
Use the raw version (ie. IDXEN=0) because vindex is unused. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/amd/common/ac_nir_to_llvm.c66
1 files changed, 42 insertions, 24 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index e0ca6a5a548..ca198775f51 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1628,57 +1628,75 @@ static void visit_store_ssbo(struct ac_nir_context *ctx,
static LLVMValueRef visit_atomic_ssbo(struct ac_nir_context *ctx,
const nir_intrinsic_instr *instr)
{
- const char *name;
- LLVMValueRef params[6];
+ const char *atomic_name;
+ char intrinsic_name[64];
+ LLVMValueRef params[7];
int arg_count = 0;
-
- if (instr->intrinsic == nir_intrinsic_ssbo_atomic_comp_swap) {
- params[arg_count++] = ac_llvm_extract_elem(&ctx->ac, get_src(ctx, instr->src[3]), 0);
- }
- params[arg_count++] = ac_llvm_extract_elem(&ctx->ac, get_src(ctx, instr->src[2]), 0);
- params[arg_count++] = ctx->abi->load_ssbo(ctx->abi,
- get_src(ctx, instr->src[0]),
- true);
- params[arg_count++] = ctx->ac.i32_0; /* vindex */
- params[arg_count++] = get_src(ctx, instr->src[1]); /* voffset */
- params[arg_count++] = ctx->ac.i1false; /* slc */
+ int length;
switch (instr->intrinsic) {
case nir_intrinsic_ssbo_atomic_add:
- name = "llvm.amdgcn.buffer.atomic.add";
+ atomic_name = "add";
break;
case nir_intrinsic_ssbo_atomic_imin:
- name = "llvm.amdgcn.buffer.atomic.smin";
+ atomic_name = "smin";
break;
case nir_intrinsic_ssbo_atomic_umin:
- name = "llvm.amdgcn.buffer.atomic.umin";
+ atomic_name = "umin";
break;
case nir_intrinsic_ssbo_atomic_imax:
- name = "llvm.amdgcn.buffer.atomic.smax";
+ atomic_name = "smax";
break;
case nir_intrinsic_ssbo_atomic_umax:
- name = "llvm.amdgcn.buffer.atomic.umax";
+ atomic_name = "umax";
break;
case nir_intrinsic_ssbo_atomic_and:
- name = "llvm.amdgcn.buffer.atomic.and";
+ atomic_name = "and";
break;
case nir_intrinsic_ssbo_atomic_or:
- name = "llvm.amdgcn.buffer.atomic.or";
+ atomic_name = "or";
break;
case nir_intrinsic_ssbo_atomic_xor:
- name = "llvm.amdgcn.buffer.atomic.xor";
+ atomic_name = "xor";
break;
case nir_intrinsic_ssbo_atomic_exchange:
- name = "llvm.amdgcn.buffer.atomic.swap";
+ atomic_name = "swap";
break;
case nir_intrinsic_ssbo_atomic_comp_swap:
- name = "llvm.amdgcn.buffer.atomic.cmpswap";
+ atomic_name = "cmpswap";
break;
default:
abort();
}
- return ac_build_intrinsic(&ctx->ac, name, ctx->ac.i32, params, arg_count, 0);
+ if (instr->intrinsic == nir_intrinsic_ssbo_atomic_comp_swap) {
+ params[arg_count++] = ac_llvm_extract_elem(&ctx->ac, get_src(ctx, instr->src[3]), 0);
+ }
+ params[arg_count++] = ac_llvm_extract_elem(&ctx->ac, get_src(ctx, instr->src[2]), 0);
+ params[arg_count++] = ctx->abi->load_ssbo(ctx->abi,
+ get_src(ctx, instr->src[0]),
+ true);
+
+ if (HAVE_LLVM >= 0x0800) {
+ params[arg_count++] = get_src(ctx, instr->src[1]); /* voffset */
+ params[arg_count++] = ctx->ac.i32_0; /* soffset */
+ params[arg_count++] = ctx->ac.i32_0; /* slc */
+
+ length = snprintf(intrinsic_name, sizeof(intrinsic_name),
+ "llvm.amdgcn.raw.buffer.atomic.%s.i32",
+ atomic_name);
+ } else {
+ params[arg_count++] = ctx->ac.i32_0; /* vindex */
+ params[arg_count++] = get_src(ctx, instr->src[1]); /* voffset */
+ params[arg_count++] = ctx->ac.i1false; /* slc */
+
+ length = snprintf(intrinsic_name, sizeof(intrinsic_name),
+ "llvm.amdgcn.buffer.atomic.%s", atomic_name);
+ }
+
+ assert(length < sizeof(intrinsic_name));
+ return ac_build_intrinsic(&ctx->ac, intrinsic_name, ctx->ac.i32,
+ params, arg_count, 0);
}
static LLVMValueRef visit_load_buffer(struct ac_nir_context *ctx,