<div dir="ltr"><div>The new intrinsic is supported since LLVM 5.0. With that fixed:</div><div><br></div><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div><div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 15, 2018 at 8:24 PM, Dave Airlie <span dir="ltr"><<a href="mailto:airlied@gmail.com" target="_blank">airlied@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
<br>
Drop the use of the old intrinsic.<br>
---<br>
 src/amd/common/ac_llvm_build.c | 92 +++++++++++++++++++++++++++---<wbr>------------<br>
 1 file changed, 60 insertions(+), 32 deletions(-)<br>
<br>
diff --git a/src/amd/common/ac_llvm_<wbr>build.c b/src/amd/common/ac_llvm_<wbr>build.c<br>
index c9b2e36b632..18a624a0dae 100644<br>
--- a/src/amd/common/ac_llvm_<wbr>build.c<br>
+++ b/src/amd/common/ac_llvm_<wbr>build.c<br>
@@ -888,11 +888,18 @@ ac_build_buffer_store_dword(<wbr>struct ac_llvm_context *ctx,<br>
                            bool writeonly_memory,<br>
                            bool swizzle_enable_hint)<br>
 {<br>
+       static unsigned dfmt[] = {<br>
+               V_008F0C_BUF_DATA_FORMAT_32,<br>
+               V_008F0C_BUF_DATA_FORMAT_32_<wbr>32,<br>
+               V_008F0C_BUF_DATA_FORMAT_32_<wbr>32_32,<br>
+               V_008F0C_BUF_DATA_FORMAT_32_<wbr>32_32_32<br>
+       };<br>
+<br>
        /* SWIZZLE_ENABLE requires that soffset isn't folded into voffset<br>
         * (voffset is swizzled, but soffset isn't swizzled).<br>
         * llvm.amdgcn.buffer.store doesn't have a separate soffset parameter.<br>
         */<br>
-       if (!swizzle_enable_hint) {<br>
+       if (!swizzle_enable_hint || HAVE_LLVM >= 0x0700) {<br>
                /* Split 3 channel stores, becase LLVM doesn't support 3-channel<br>
                 * intrinsics. */<br>
                if (num_channels == 3) {<br>
@@ -915,42 +922,63 @@ ac_build_buffer_store_dword(<wbr>struct ac_llvm_context *ctx,<br>
                }<br>
<br>
                unsigned func = CLAMP(num_channels, 1, 3) - 1;<br>
-               static const char *types[] = {"f32", "v2f32", "v4f32"};<br>
                char name[256];<br>
-               LLVMValueRef offset = soffset;<br>
-<br>
-               if (inst_offset)<br>
-                       offset = LLVMBuildAdd(ctx->builder, offset,<br>
-                                             LLVMConstInt(ctx->i32, inst_offset, 0), "");<br>
-               if (voffset)<br>
-                       offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");<br>
-<br>
-               LLVMValueRef args[] = {<br>
-                       ac_to_float(ctx, vdata),<br>
-                       LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),<br>
-                       LLVMConstInt(ctx->i32, 0, 0),<br>
-                       offset,<br>
-                       LLVMConstInt(ctx->i1, glc, 0),<br>
-                       LLVMConstInt(ctx->i1, slc, 0),<br>
-               };<br>
-<br>
-               snprintf(name, sizeof(name), "llvm.amdgcn.buffer.store.%s",<br>
-                        types[func]);<br>
-<br>
-               ac_build_intrinsic(ctx, name, ctx->voidt,<br>
-                                  args, ARRAY_SIZE(args),<br>
-                                  writeonly_memory ?<br>
+<br>
+               if (!swizzle_enable_hint) {<br>
+                       LLVMValueRef offset = soffset;<br>
+<br>
+                       static const char *types[] = {"f32", "v2f32", "v4f32"};<br>
+<br>
+                       if (inst_offset)<br>
+                               offset = LLVMBuildAdd(ctx->builder, offset,<br>
+                                                     LLVMConstInt(ctx->i32, inst_offset, 0), "");<br>
+                       if (voffset)<br>
+                               offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");<br>
+<br>
+                       LLVMValueRef args[] = {<br>
+                               ac_to_float(ctx, vdata),<br>
+                               LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),<br>
+                               LLVMConstInt(ctx->i32, 0, 0),<br>
+                               offset,<br>
+                               LLVMConstInt(ctx->i1, glc, 0),<br>
+                               LLVMConstInt(ctx->i1, slc, 0),<br>
+                       };<br>
+<br>
+                       snprintf(name, sizeof(name), "llvm.amdgcn.buffer.store.%s",<br>
+                                types[func]);<br>
+<br>
+                       ac_build_intrinsic(ctx, name, ctx->voidt,<br>
+                                          args, ARRAY_SIZE(args),<br>
+                                          writeonly_memory ?<br>
                                           AC_FUNC_ATTR_INACCESSIBLE_MEM_<wbr>ONLY :<br>
                                           AC_FUNC_ATTR_WRITEONLY);<br>
-               return;<br>
+                       return;<br>
+               } else {<br>
+                       static const char *types[] = {"i32", "v2i32", "v4i32"};<br>
+                       LLVMValueRef args[] = {<br>
+                               vdata,<br>
+                               LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),<br>
+                               LLVMConstInt(ctx->i32, 0, 0),<br>
+                               voffset ? voffset : LLVMConstInt(ctx->i32, 0, 0),<br>
+                               soffset,<br>
+                               LLVMConstInt(ctx->i32, inst_offset, 0),<br>
+                               LLVMConstInt(ctx->i32, dfmt[num_channels - 1], 0),<br>
+                               LLVMConstInt(ctx->i32, V_008F0C_BUF_NUM_FORMAT_UINT, 0),<br>
+                               LLVMConstInt(ctx->i1, glc, 0),<br>
+                               LLVMConstInt(ctx->i1, slc, 0),<br>
+                       };<br>
+                       snprintf(name, sizeof(name), "llvm.amdgcn.tbuffer.store.%s"<wbr>,<br>
+                                types[func]);<br>
+<br>
+                       ac_build_intrinsic(ctx, name, ctx->voidt,<br>
+                                          args, ARRAY_SIZE(args),<br>
+                                          writeonly_memory ?<br>
+                                          AC_FUNC_ATTR_INACCESSIBLE_MEM_<wbr>ONLY :<br>
+                                          AC_FUNC_ATTR_WRITEONLY);<br>
+                       return;<br>
+               }<br>
        }<br>
<br>
-       static unsigned dfmt[] = {<br>
-               V_008F0C_BUF_DATA_FORMAT_32,<br>
-               V_008F0C_BUF_DATA_FORMAT_32_<wbr>32,<br>
-               V_008F0C_BUF_DATA_FORMAT_32_<wbr>32_32,<br>
-               V_008F0C_BUF_DATA_FORMAT_32_<wbr>32_32_32<br>
-       };<br>
        assert(num_channels >= 1 && num_channels <= 4);<br>
<br>
        LLVMValueRef args[] = {<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.14.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>