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

Tobias Droste tdroste at gmx.de
Sat Jan 28 14:04:49 UTC 2017


Only define HAVE_LLVM if --enable-gallium-llvm is provided.
If radv is built add HAVE_LLVM_RADV define with the same value
as HAVE_LLVM.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99010

Signed-off-by: Tobias Droste <tdroste at gmx.de>
---
 configure.ac                      |  3 ++-
 src/amd/common/ac_llvm_helper.cpp | 10 +++++++++-
 src/amd/common/ac_llvm_util.c     | 21 +++++++++++++++------
 src/amd/common/ac_nir_to_llvm.c   | 14 +++++++++++---
 4 files changed, 37 insertions(+), 11 deletions(-)

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..ff7ceb367c 100644
--- a/src/amd/common/ac_llvm_helper.cpp
+++ b/src/amd/common/ac_llvm_helper.cpp
@@ -23,10 +23,18 @@
  *
  */
 
+#if defined(HAVE_LLVM)
+  #define MESA_LLVM_VERSION HAVE_LLVM
+#elif defined(HAVE_LLVM_RADV)
+  #define MESA_LLVM_VERSION HAVE_LLVM_RADV
+#else
+  #error "HAVE_LLVM or HAVE_LLVM_RADV should be set with LLVM's version number, e.g. (0x0309 for 3.9)"
+#endif
+
 /* 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 770e3bd13c..8c3287aa94 100644
--- a/src/amd/common/ac_llvm_util.c
+++ b/src/amd/common/ac_llvm_util.c
@@ -22,6 +22,15 @@
  * of the Software.
  *
  */
+
+#if defined(HAVE_LLVM)
+  #define MESA_LLVM_VERSION HAVE_LLVM
+#elif defined(HAVE_LLVM_RADV)
+  #define MESA_LLVM_VERSION HAVE_LLVM_RADV
+#else
+  #error "HAVE_LLVM or HAVE_LLVM_RADV should be set with LLVM's version number, e.g. (0x0309 for 3.9)"
+#endif
+
 /* based on pieces from si_pipe.c and radeon_llvm_emit.c */
 #include "ac_llvm_util.h"
 
@@ -37,7 +46,7 @@
 
 static void ac_init_llvm_target()
 {
-#if HAVE_LLVM < 0x0307
+#if MESA_LLVM_VERSION < 0x0307
 	LLVMInitializeR600TargetInfo();
 	LLVMInitializeR600Target();
 	LLVMInitializeR600TargetMC();
@@ -99,7 +108,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 +119,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 +175,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 +218,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 +338,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_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 72ae6eb073..b4727aa858 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -21,6 +21,14 @@
  * IN THE SOFTWARE.
  */
 
+#if defined(HAVE_LLVM)
+  #define MESA_LLVM_VERSION HAVE_LLVM
+#elif defined(HAVE_LLVM_RADV)
+  #define MESA_LLVM_VERSION HAVE_LLVM_RADV
+#else
+  #error "HAVE_LLVM or HAVE_LLVM_RADV should be set with LLVM's version number, e.g. (0x0309 for 3.9)"
+#endif
+
 #include "ac_nir_to_llvm.h"
 #include "ac_llvm_util.h"
 #include "ac_binary.h"
@@ -2339,7 +2347,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];
@@ -2389,7 +2397,7 @@ static LLVMValueRef visit_image_load(struct nir_to_llvm_context *ctx,
 		params[0] = get_image_coords(ctx, instr, add_frag_pos);
 		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;
@@ -2448,7 +2456,7 @@ static void visit_image_store(struct nir_to_llvm_context *ctx,
 		params[1] = get_image_coords(ctx, instr, false); /* 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;
-- 
2.11.0



More information about the mesa-dev mailing list