[Mesa-dev] [PATCH 5/6] radeonsi/ac: move get_image_intr_name to common

Marek Olšák maraeo at gmail.com
Mon Mar 6 21:27:55 UTC 2017


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Mon, Mar 6, 2017 at 12:29 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> This code is used in radv, so move to common build code.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/amd/common/ac_llvm_build.c           | 26 ++++++++++++++++++
>  src/amd/common/ac_llvm_build.h           |  5 ++++
>  src/gallium/drivers/radeonsi/si_shader.c | 46 +++++++-------------------------
>  3 files changed, 41 insertions(+), 36 deletions(-)
>
> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> index acda5e2..9e02190 100644
> --- a/src/amd/common/ac_llvm_build.c
> +++ b/src/amd/common/ac_llvm_build.c
> @@ -1220,3 +1220,29 @@ LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input,
>                                   AC_FUNC_ATTR_READNONE |
>                                   AC_FUNC_ATTR_LEGACY);
>  }
> +
> +void ac_get_image_intr_name(const char *base_name,
> +                           LLVMTypeRef data_type,
> +                           LLVMTypeRef coords_type,
> +                           LLVMTypeRef rsrc_type,
> +                           char *out_name, unsigned out_len)
> +{
> +        char coords_type_name[8];
> +
> +        ac_build_type_name_for_intr(coords_type, coords_type_name,
> +                            sizeof(coords_type_name));
> +
> +        if (HAVE_LLVM <= 0x0309) {
> +                snprintf(out_name, out_len, "%s.%s", base_name, coords_type_name);
> +        } else {
> +                char data_type_name[8];
> +                char rsrc_type_name[8];
> +
> +                ac_build_type_name_for_intr(data_type, data_type_name,
> +                                        sizeof(data_type_name));
> +                ac_build_type_name_for_intr(rsrc_type, rsrc_type_name,
> +                                        sizeof(rsrc_type_name));
> +                snprintf(out_name, out_len, "%s.%s.%s.%s", base_name,
> +                         data_type_name, coords_type_name, rsrc_type_name);
> +        }
> +}
> diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
> index d3c537b..d6edcde 100644
> --- a/src/amd/common/ac_llvm_build.h
> +++ b/src/amd/common/ac_llvm_build.h
> @@ -234,6 +234,11 @@ LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input,
>                           LLVMValueRef offset, LLVMValueRef width,
>                           bool is_signed);
>
> +void ac_get_image_intr_name(const char *base_name,
> +                           LLVMTypeRef data_type,
> +                           LLVMTypeRef coords_type,
> +                           LLVMTypeRef rsrc_type,
> +                           char *out_name, unsigned out_len);
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
> index 319c0c8..3e827c1 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -3532,32 +3532,6 @@ static void load_emit_memory(
>         emit_data->output[emit_data->chan] = lp_build_gather_values(gallivm, channels, 4);
>  }
>
> -static void get_image_intr_name(const char *base_name,
> -                               LLVMTypeRef data_type,
> -                               LLVMTypeRef coords_type,
> -                               LLVMTypeRef rsrc_type,
> -                               char *out_name, unsigned out_len)
> -{
> -       char coords_type_name[8];
> -
> -       ac_build_type_name_for_intr(coords_type, coords_type_name,
> -                           sizeof(coords_type_name));
> -
> -       if (HAVE_LLVM <= 0x0309) {
> -               snprintf(out_name, out_len, "%s.%s", base_name, coords_type_name);
> -       } else {
> -               char data_type_name[8];
> -               char rsrc_type_name[8];
> -
> -               ac_build_type_name_for_intr(data_type, data_type_name,
> -                                       sizeof(data_type_name));
> -               ac_build_type_name_for_intr(rsrc_type, rsrc_type_name,
> -                                       sizeof(rsrc_type_name));
> -               snprintf(out_name, out_len, "%s.%s.%s.%s", base_name,
> -                        data_type_name, coords_type_name, rsrc_type_name);
> -       }
> -}
> -
>  /**
>   * Return true if the memory accessed by a LOAD or STORE instruction is
>   * read-only or write-only, respectively.
> @@ -3660,11 +3634,11 @@ static void load_emit(
>                                 emit_data->args, emit_data->arg_count,
>                                 get_load_intr_attribs(readonly_memory));
>         } else {
> -               get_image_intr_name("llvm.amdgcn.image.load",
> -                               emit_data->dst_type,            /* vdata */
> -                               LLVMTypeOf(emit_data->args[0]), /* coords */
> -                               LLVMTypeOf(emit_data->args[1]), /* rsrc */
> -                               intrinsic_name, sizeof(intrinsic_name));
> +               ac_get_image_intr_name("llvm.amdgcn.image.load",
> +                                      emit_data->dst_type,             /* vdata */
> +                                      LLVMTypeOf(emit_data->args[0]), /* coords */
> +                                      LLVMTypeOf(emit_data->args[1]), /* rsrc */
> +                                      intrinsic_name, sizeof(intrinsic_name));
>
>                 emit_data->output[emit_data->chan] =
>                         lp_build_intrinsic(
> @@ -3879,11 +3853,11 @@ static void store_emit(
>                         emit_data->arg_count,
>                         get_store_intr_attribs(writeonly_memory));
>         } else {
> -               get_image_intr_name("llvm.amdgcn.image.store",
> -                               LLVMTypeOf(emit_data->args[0]), /* vdata */
> -                               LLVMTypeOf(emit_data->args[1]), /* coords */
> -                               LLVMTypeOf(emit_data->args[2]), /* rsrc */
> -                               intrinsic_name, sizeof(intrinsic_name));
> +               ac_get_image_intr_name("llvm.amdgcn.image.store",
> +                                      LLVMTypeOf(emit_data->args[0]), /* vdata */
> +                                      LLVMTypeOf(emit_data->args[1]), /* coords */
> +                                      LLVMTypeOf(emit_data->args[2]), /* rsrc */
> +                                      intrinsic_name, sizeof(intrinsic_name));
>
>                 emit_data->output[emit_data->chan] =
>                         lp_build_intrinsic(
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list