[Mesa-dev] [PATCHv2 3/4] configure.ac: Separate HAVE_LLVM defines for gallium and radv

Dave Airlie airlied at gmail.com
Wed Feb 1 22:19:42 UTC 2017


Just make radv depend on enable-gallium-llvm.

I really don't want to make the #defines into the spaghetti this introduces.

Dave.

> diff --git a/configure.ac b/configure.ac
> index f956df5120..5101e3bb0b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1001,7 +1001,6 @@ llvm_set_environment_variables() {
>              LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}"
>          fi
>
> -        DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
>          FOUND_LLVM=yes
>          USE_LLVM=no
>      else
> @@ -1775,6 +1774,7 @@ if test -n "$with_vulkan_drivers"; then
>              PKG_CHECK_MODULES([AMDGPU], [libdrm_amdgpu >= $LIBDRM_AMDGPU_REQUIRED])
>              radeon_llvm_check $LLVM_REQUIRED_RADV "radv"
>              HAVE_RADEON_VULKAN=yes;
> +            DEFINES="${DEFINES} -DHAVE_LLVM_RADV=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
>              ;;
>          *)
>              AC_MSG_ERROR([Vulkan driver '$driver' does not exist])
> @@ -2407,6 +2407,7 @@ if test "x$enable_gallium_llvm" == "xyes"; then
>      llvm_add_default_components "gallium"
>
>      USE_LLVM_GALLIUM=yes
> +    DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
>  else
>      USE_LLVM_GALLIUM=no
>  fi
> diff --git a/src/amd/common/ac_llvm_helper.cpp b/src/amd/common/ac_llvm_helper.cpp
> index 594339ee8c..154156b8a3 100644
> --- a/src/amd/common/ac_llvm_helper.cpp
> +++ b/src/amd/common/ac_llvm_helper.cpp
> @@ -26,7 +26,7 @@
>  /* based on Marek's patch to lp_bld_misc.cpp */
>
>  // Workaround http://llvm.org/PR23628
> -#if HAVE_LLVM >= 0x0307
> +#if MESA_LLVM_VERSION >= 0x0307
>  #  pragma push_macro("DEBUG")
>  #  undef DEBUG
>  #endif
> diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c
> index f3cab921ba..7060a2f003 100644
> --- a/src/amd/common/ac_llvm_util.c
> +++ b/src/amd/common/ac_llvm_util.c
> @@ -22,6 +22,7 @@
>   * of the Software.
>   *
>   */
> +
>  /* based on pieces from si_pipe.c and radeon_llvm_emit.c */
>  #include "ac_llvm_util.h"
>
> @@ -37,7 +38,7 @@
>
>  static void ac_init_llvm_target()
>  {
> -#if HAVE_LLVM < 0x0307
> +#if MESA_LLVM_VERSION < 0x0307
>         LLVMInitializeR600TargetInfo();
>         LLVMInitializeR600Target();
>         LLVMInitializeR600TargetMC();
> @@ -99,7 +100,7 @@ static const char *ac_get_llvm_processor_name(enum radeon_family family)
>                 return "iceland";
>         case CHIP_CARRIZO:
>                 return "carrizo";
> -#if HAVE_LLVM <= 0x0307
> +#if MESA_LLVM_VERSION <= 0x0307
>         case CHIP_FIJI:
>                 return "tonga";
>         case CHIP_STONEY:
> @@ -110,7 +111,7 @@ static const char *ac_get_llvm_processor_name(enum radeon_family family)
>         case CHIP_STONEY:
>                 return "stoney";
>  #endif
> -#if HAVE_LLVM <= 0x0308
> +#if MESA_LLVM_VERSION <= 0x0308
>         case CHIP_POLARIS10:
>                 return "tonga";
>         case CHIP_POLARIS11:
> @@ -166,7 +167,7 @@ ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context)
>         ctx->fpmath_md_2p5_ulp = LLVMMDNodeInContext(ctx->context, args, 1);
>  }
>
> -#if HAVE_LLVM < 0x0400
> +#if MESA_LLVM_VERSION < 0x0400
>  static LLVMAttribute ac_attr_to_llvm_attr(enum ac_func_attr attr)
>  {
>     switch (attr) {
> @@ -209,7 +210,7 @@ ac_add_function_attr(LLVMValueRef function,
>                       enum ac_func_attr attr)
>  {
>
> -#if HAVE_LLVM < 0x0400
> +#if MESA_LLVM_VERSION < 0x0400
>     LLVMAttribute llvm_attr = ac_attr_to_llvm_attr(attr);
>     if (attr_idx == -1) {
>        LLVMAddFunctionAttr(function, llvm_attr);
> @@ -329,7 +330,7 @@ build_cube_intrinsic(struct ac_llvm_context *ctx,
>  {
>         LLVMBuilderRef builder = ctx->builder;
>
> -       if (HAVE_LLVM >= 0x0309) {
> +       if (MESA_LLVM_VERSION >= 0x0309) {
>                 LLVMTypeRef f32 = ctx->f32;
>
>                 out->stc[1] = ac_emit_llvm_intrinsic(ctx, "llvm.amdgcn.cubetc",
> diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h
> index c07f67ab8b..64af30228d 100644
> --- a/src/amd/common/ac_llvm_util.h
> +++ b/src/amd/common/ac_llvm_util.h
> @@ -24,6 +24,20 @@
>   */
>  #pragma once
>
> +/*
> + * Since HAVE_LLVM means --enable-gallium-llvm and we cannot change that we
> + * need to indicate/track the LLVM version in a separate way (HAVE_LLVM_RADV).
> + *
> + * Strictly speaking we could get away with HAVE_LLVM_RADV alone, but things
> + * are quite fragile and on their way out since this work is mostly -stable
> + * fixes to get all the crazy permutations building again.
> + */
> +#if defined(HAVE_LLVM)
> +#  define MESA_LLVM_VERSION HAVE_LLVM
> +#elif defined(HAVE_LLVM_RADV)
> +#  define MESA_LLVM_VERSION HAVE_LLVM_RADV
> +#endif
> +
>  #include <stdbool.h>
>  #include <llvm-c/TargetMachine.h>
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 50ed4d4783..6af109cda7 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -2661,7 +2661,7 @@ static void get_image_intr_name(const char *base_name,
>          build_type_name_for_intr(coords_type, coords_type_name,
>                              sizeof(coords_type_name));
>
> -        if (HAVE_LLVM <= 0x0309) {
> +        if (MESA_LLVM_VERSION <= 0x0309) {
>                  snprintf(out_name, out_len, "%s.%s", base_name, coords_type_name);
>          } else {
>                  char data_type_name[8];
> @@ -2710,7 +2710,7 @@ static LLVMValueRef visit_image_load(struct nir_to_llvm_context *ctx,
>                 params[0] = get_image_coords(ctx, instr);
>                 params[1] = get_sampler_desc(ctx, instr->variables[0], DESC_IMAGE);
>                 params[2] = LLVMConstInt(ctx->i32, 15, false); /* dmask */
> -               if (HAVE_LLVM <= 0x0309) {
> +               if (MESA_LLVM_VERSION <= 0x0309) {
>                         params[3] = LLVMConstInt(ctx->i1, 0, false);  /* r128 */
>                         params[4] = da;
>                         params[5] = glc;
> @@ -2769,7 +2769,7 @@ static void visit_image_store(struct nir_to_llvm_context *ctx,
>                 params[1] = get_image_coords(ctx, instr); /* coords */
>                 params[2] = get_sampler_desc(ctx, instr->variables[0], DESC_IMAGE);
>                 params[3] = LLVMConstInt(ctx->i32, 15, false); /* dmask */
> -               if (HAVE_LLVM <= 0x0309) {
> +               if (MESA_LLVM_VERSION <= 0x0309) {
>                         params[4] = i1false;  /* r128 */
>                         params[5] = da;
>                         params[6] = glc;
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index 0026de5a0e..9c8675bef9 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -861,7 +861,7 @@ VkResult radv_CreateDevice(
>                 }
>         }
>
> -#if HAVE_LLVM < 0x0400
> +#if MESA_LLVM_VERSION < 0x0400
>         device->llvm_supports_spill = false;
>  #else
>         device->llvm_supports_spill = true;
> --
> 2.11.0
>
> _______________________________________________
> 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