amd/common: import get_{load,store}_intr_attribs() from RadeonSI
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 10 Jan 2018 11:57:19 +0000 (12:57 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 10 Jan 2018 18:02:23 +0000 (19:02 +0100)
v2: move those helpers to the header and use static inline

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> (v1)
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_util.h
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index efc6fa12e561b043b26d49193aa5bfc54a2999d3..07044142b0b91ad4f6ed693f06179d4b090d9dab 100644 (file)
@@ -983,11 +983,7 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
 
        return ac_build_intrinsic(ctx, name, types[func], args,
                                  ARRAY_SIZE(args),
-                                 /* READNONE means writes can't affect it, while
-                                  * READONLY means that writes can affect it. */
-                                 can_speculate && HAVE_LLVM >= 0x0400 ?
-                                         AC_FUNC_ATTR_READNONE :
-                                         AC_FUNC_ATTR_READONLY);
+                                 ac_get_load_intr_attribs(can_speculate));
 }
 
 LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx,
@@ -1007,11 +1003,7 @@ LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx,
        return ac_build_intrinsic(ctx,
                                  "llvm.amdgcn.buffer.load.format.v4f32",
                                  ctx->v4f32, args, ARRAY_SIZE(args),
-                                 /* READNONE means writes can't affect it, while
-                                  * READONLY means that writes can affect it. */
-                                 can_speculate && HAVE_LLVM >= 0x0400 ?
-                                         AC_FUNC_ATTR_READNONE :
-                                         AC_FUNC_ATTR_READONLY);
+                                 ac_get_load_intr_attribs(can_speculate));
 }
 
 /**
index 7c8b6b0a13065ad66b9e5b7e3b19c9b58a384186..61bcc4e54edf99b04fc2cf62a81ee647cadf2404 100644 (file)
@@ -81,6 +81,24 @@ void
 ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
                                     const char *name, int value);
 
+static inline unsigned
+ac_get_load_intr_attribs(bool can_speculate)
+{
+       /* READNONE means writes can't affect it, while READONLY means that
+        * writes can affect it. */
+       return can_speculate && HAVE_LLVM >= 0x0400 ?
+                                AC_FUNC_ATTR_READNONE :
+                                AC_FUNC_ATTR_READONLY;
+}
+
+static inline unsigned
+ac_get_store_intr_attribs(bool writeonly_memory)
+{
+       return writeonly_memory && HAVE_LLVM >= 0x0400 ?
+                                 AC_FUNC_ATTR_INACCESSIBLE_MEM_ONLY :
+                                 AC_FUNC_ATTR_WRITEONLY;
+}
+
 #ifdef __cplusplus
 }
 #endif
index fe0cfcef9974573c0e15f778673fa7df6e143904..d5c9470974aed688e3d02b737d80f1e94b16aa0f 100644 (file)
@@ -390,22 +390,6 @@ static void load_fetch_args(
        }
 }
 
-static unsigned get_load_intr_attribs(bool can_speculate)
-{
-       /* READNONE means writes can't affect it, while READONLY means that
-        * writes can affect it. */
-       return can_speculate && HAVE_LLVM >= 0x0400 ?
-                                LP_FUNC_ATTR_READNONE :
-                                LP_FUNC_ATTR_READONLY;
-}
-
-static unsigned get_store_intr_attribs(bool writeonly_memory)
-{
-       return writeonly_memory && HAVE_LLVM >= 0x0400 ?
-                                 LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY :
-                                 LP_FUNC_ATTR_WRITEONLY;
-}
-
 static void load_emit_buffer(struct si_shader_context *ctx,
                             struct lp_build_emit_data *emit_data,
                             bool can_speculate, bool allow_smem)
@@ -586,7 +570,7 @@ static void load_emit(
                        lp_build_intrinsic(
                                builder, "llvm.amdgcn.buffer.load.format.v4f32", emit_data->dst_type,
                                emit_data->args, emit_data->arg_count,
-                               get_load_intr_attribs(can_speculate));
+                               ac_get_load_intr_attribs(can_speculate));
        } else {
                ac_get_image_intr_name("llvm.amdgcn.image.load",
                                       emit_data->dst_type,             /* vdata */
@@ -598,7 +582,7 @@ static void load_emit(
                        lp_build_intrinsic(
                                builder, intrinsic_name, emit_data->dst_type,
                                emit_data->args, emit_data->arg_count,
-                               get_load_intr_attribs(can_speculate));
+                               ac_get_load_intr_attribs(can_speculate));
        }
 }
 
@@ -734,7 +718,7 @@ static void store_emit_buffer(
                lp_build_intrinsic(
                        builder, intrinsic_name, emit_data->dst_type,
                        emit_data->args, emit_data->arg_count,
-                       get_store_intr_attribs(writeonly_memory));
+                       ac_get_store_intr_attribs(writeonly_memory));
        }
 }
 
@@ -798,7 +782,7 @@ static void store_emit(
                        builder, "llvm.amdgcn.buffer.store.format.v4f32",
                        emit_data->dst_type, emit_data->args,
                        emit_data->arg_count,
-                       get_store_intr_attribs(writeonly_memory));
+                       ac_get_store_intr_attribs(writeonly_memory));
        } else {
                ac_get_image_intr_name("llvm.amdgcn.image.store",
                                       LLVMTypeOf(emit_data->args[0]), /* vdata */
@@ -810,7 +794,7 @@ static void store_emit(
                        lp_build_intrinsic(
                                builder, intrinsic_name, emit_data->dst_type,
                                emit_data->args, emit_data->arg_count,
-                               get_store_intr_attribs(writeonly_memory));
+                               ac_get_store_intr_attribs(writeonly_memory));
        }
 }