Mesa (master): gallivm: replace major llvm version checks with LLVM_VERSION_MAJOR

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Sep 6 21:41:59 UTC 2019


Module: Mesa
Branch: master
Commit: 08890068c5c2c923ad85ced58c479ffbe4f84fc5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=08890068c5c2c923ad85ced58c479ffbe4f84fc5

Author: Eric Engestrom <eric.engestrom at intel.com>
Date:   Wed Aug 28 00:06:21 2019 +0100

gallivm: replace major llvm version checks with LLVM_VERSION_MAJOR

Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Acked-by: Michel Dänzer <mdaenzer at redhat.com>

---

 src/gallium/auxiliary/gallivm/lp_bld.h             |  2 +-
 src/gallium/auxiliary/gallivm/lp_bld_arit.c        | 28 ++++++++++++----------
 src/gallium/auxiliary/gallivm/lp_bld_coro.c        |  2 +-
 src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c |  4 +++-
 src/gallium/auxiliary/gallivm/lp_bld_init.c        |  3 ++-
 src/gallium/auxiliary/gallivm/lp_bld_intr.c        |  7 +++---
 src/gallium/auxiliary/gallivm/lp_bld_intr.h        |  7 +++---
 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp      |  7 +++---
 8 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h
index a6a6c1add0a..af40a661b95 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld.h
@@ -95,7 +95,7 @@ typedef void *LLVMMCJITMemoryManagerRef;
 #define LLVMInsertBasicBlock ILLEGAL_LLVM_FUNCTION
 #define LLVMCreateBuilder ILLEGAL_LLVM_FUNCTION
 
-#if HAVE_LLVM >= 0x0800
+#if LLVM_VERSION_MAJOR >= 8
 #define GALLIVM_HAVE_CORO 1
 #else
 #define GALLIVM_HAVE_CORO 0
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index f1866c6625f..8a912ac5753 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -47,6 +47,8 @@
 
 #include <float.h>
 
+#include <llvm/Config/llvm-config.h>
+
 #include "util/u_memory.h"
 #include "util/u_debug.h"
 #include "util/u_math.h"
@@ -555,7 +557,7 @@ lp_build_add(struct lp_build_context *bld,
         return bld->one;
 
       if (!type.floating && !type.fixed) {
-         if (HAVE_LLVM >= 0x0900) {
+         if (LLVM_VERSION_MAJOR >= 9) {
             char intrin[32];
             intrinsic = type.sign ? "llvm.sadd.sat" : "llvm.uadd.sat";
             lp_format_intrinsic(intrin, sizeof intrin, intrinsic, bld->vec_type);
@@ -565,10 +567,10 @@ lp_build_add(struct lp_build_context *bld,
             if (util_cpu_caps.has_sse2) {
                if (type.width == 8)
                  intrinsic = type.sign ? "llvm.x86.sse2.padds.b" :
-                                         HAVE_LLVM < 0x0800 ? "llvm.x86.sse2.paddus.b" : NULL;
+                                         LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.paddus.b" : NULL;
                if (type.width == 16)
                  intrinsic = type.sign ? "llvm.x86.sse2.padds.w" :
-                                         HAVE_LLVM < 0x0800 ? "llvm.x86.sse2.paddus.w" : NULL;
+                                         LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.paddus.w" : NULL;
             } else if (util_cpu_caps.has_altivec) {
                if (type.width == 8)
                   intrinsic = type.sign ? "llvm.ppc.altivec.vaddsbs" : "llvm.ppc.altivec.vaddubs";
@@ -580,10 +582,10 @@ lp_build_add(struct lp_build_context *bld,
             if (util_cpu_caps.has_avx2) {
                if (type.width == 8)
                   intrinsic = type.sign ? "llvm.x86.avx2.padds.b" :
-                                          HAVE_LLVM < 0x0800 ? "llvm.x86.avx2.paddus.b" : NULL;
+                                          LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.paddus.b" : NULL;
                if (type.width == 16)
                   intrinsic = type.sign ? "llvm.x86.avx2.padds.w" :
-                                          HAVE_LLVM < 0x0800 ? "llvm.x86.avx2.paddus.w" : NULL;
+                                          LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.paddus.w" : NULL;
             }
          }
       }
@@ -883,7 +885,7 @@ lp_build_sub(struct lp_build_context *bld,
         return bld->zero;
 
       if (!type.floating && !type.fixed) {
-         if (HAVE_LLVM >= 0x0900) {
+         if (LLVM_VERSION_MAJOR >= 9) {
             char intrin[32];
             intrinsic = type.sign ? "llvm.ssub.sat" : "llvm.usub.sat";
             lp_format_intrinsic(intrin, sizeof intrin, intrinsic, bld->vec_type);
@@ -893,10 +895,10 @@ lp_build_sub(struct lp_build_context *bld,
             if (util_cpu_caps.has_sse2) {
                if (type.width == 8)
                   intrinsic = type.sign ? "llvm.x86.sse2.psubs.b" :
-                                          HAVE_LLVM < 0x0800 ? "llvm.x86.sse2.psubus.b" : NULL;
+                                          LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.psubus.b" : NULL;
                if (type.width == 16)
                   intrinsic = type.sign ? "llvm.x86.sse2.psubs.w" :
-                                          HAVE_LLVM < 0x0800 ? "llvm.x86.sse2.psubus.w" : NULL;
+                                          LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.psubus.w" : NULL;
             } else if (util_cpu_caps.has_altivec) {
                if (type.width == 8)
                   intrinsic = type.sign ? "llvm.ppc.altivec.vsubsbs" : "llvm.ppc.altivec.vsububs";
@@ -908,10 +910,10 @@ lp_build_sub(struct lp_build_context *bld,
             if (util_cpu_caps.has_avx2) {
                if (type.width == 8)
                   intrinsic = type.sign ? "llvm.x86.avx2.psubs.b" :
-                                          HAVE_LLVM < 0x0800 ? "llvm.x86.avx2.psubus.b" : NULL;
+                                          LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.psubus.b" : NULL;
                if (type.width == 16)
                   intrinsic = type.sign ? "llvm.x86.avx2.psubs.w" :
-                                          HAVE_LLVM < 0x0800 ? "llvm.x86.avx2.psubus.w" : NULL;
+                                          LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.psubus.w" : NULL;
             }
          }
       }
@@ -1174,7 +1176,7 @@ lp_build_mul_32_lohi_cpu(struct lp_build_context *bld,
     * for signed), which the fallback code does not, without this llvm
     * will likely still produce atrocious code.
     */
-   if (HAVE_LLVM < 0x0700 &&
+   if (LLVM_VERSION_MAJOR < 7 &&
        (bld->type.length == 4 || bld->type.length == 8) &&
        ((util_cpu_caps.has_sse2 && (bld->type.sign == 0)) ||
         util_cpu_caps.has_sse4_1)) {
@@ -1851,7 +1853,7 @@ lp_build_abs(struct lp_build_context *bld,
       }
    }
 
-   if(type.width*type.length == 128 && util_cpu_caps.has_ssse3 && HAVE_LLVM < 0x0600) {
+   if(type.width*type.length == 128 && util_cpu_caps.has_ssse3 && LLVM_VERSION_MAJOR < 6) {
       switch(type.width) {
       case 8:
          return lp_build_intrinsic_unary(builder, "llvm.x86.ssse3.pabs.b.128", vec_type, a);
@@ -1861,7 +1863,7 @@ lp_build_abs(struct lp_build_context *bld,
          return lp_build_intrinsic_unary(builder, "llvm.x86.ssse3.pabs.d.128", vec_type, a);
       }
    }
-   else if (type.width*type.length == 256 && util_cpu_caps.has_avx2 && HAVE_LLVM < 0x0600) {
+   else if (type.width*type.length == 256 && util_cpu_caps.has_avx2 && LLVM_VERSION_MAJOR < 6) {
       switch(type.width) {
       case 8:
          return lp_build_intrinsic_unary(builder, "llvm.x86.avx2.pabs.b", vec_type, a);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_coro.c b/src/gallium/auxiliary/gallivm/lp_bld_coro.c
index 971d715c04b..8f3db6f481f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_coro.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_coro.c
@@ -31,7 +31,7 @@
 #include "lp_bld_intr.h"
 #include "lp_bld_flow.h"
 
-#if HAVE_LLVM < 0x0600
+#if LLVM_VERSION_MAJOR < 6
 /* not a wrapper, just lets it compile */
 static LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C)
 {
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c
index 6d934891ce5..2949494c1cc 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c
@@ -34,6 +34,8 @@
  */
 
 
+#include <llvm/Config/llvm-config.h>
+
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_string.h"
@@ -465,7 +467,7 @@ lp_build_pavgb(struct lp_build_context *bld8,
    LLVMBuilderRef builder = gallivm->builder;
    assert(bld8->type.width == 8);
    assert(bld8->type.length == 16 || bld8->type.length == 32);
-   if (HAVE_LLVM < 0x0600) {
+   if (LLVM_VERSION_MAJOR < 6) {
       LLVMValueRef intrargs[2];
       char *intr_name = bld8->type.length == 32 ? "llvm.x86.avx2.pavg.b" :
                                                   "llvm.x86.sse2.pavg.b";
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index b0781eb97c2..0e81df357a8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -38,9 +38,10 @@
 #include "lp_bld_misc.h"
 #include "lp_bld_init.h"
 
+#include <llvm/Config/llvm-config.h>
 #include <llvm-c/Analysis.h>
 #include <llvm-c/Transforms/Scalar.h>
-#if HAVE_LLVM >= 0x0700
+#if LLVM_VERSION_MAJOR >= 7
 #include <llvm-c/Transforms/Utils.h>
 #endif
 #include <llvm-c/BitWriter.h>
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
index b7fab4fc123..5e9cc70ef3d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
@@ -43,6 +43,7 @@
  * @author Jose Fonseca <jfonseca at vmware.com>
  */
 
+#include <llvm/Config/llvm-config.h>
 
 #include "util/u_debug.h"
 #include "util/u_string.h"
@@ -121,7 +122,7 @@ lp_declare_intrinsic(LLVMModuleRef module,
 }
 
 
-#if HAVE_LLVM < 0x0400
+#if LLVM_VERSION_MAJOR < 4
 static LLVMAttribute lp_attr_to_llvm_attr(enum lp_func_attr attr)
 {
    switch (attr) {
@@ -164,7 +165,7 @@ lp_add_function_attr(LLVMValueRef function_or_call,
                      int attr_idx, enum lp_func_attr attr)
 {
 
-#if HAVE_LLVM < 0x0400
+#if LLVM_VERSION_MAJOR < 4
    LLVMAttribute llvm_attr = lp_attr_to_llvm_attr(attr);
    if (LLVMIsAFunction(function_or_call)) {
       if (attr_idx == -1) {
@@ -224,7 +225,7 @@ lp_build_intrinsic(LLVMBuilderRef builder,
 {
    LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
    LLVMValueRef function, call;
-   bool set_callsite_attrs = HAVE_LLVM >= 0x0400 &&
+   bool set_callsite_attrs = LLVM_VERSION_MAJOR >= 4 &&
                              !(attr_mask & LP_FUNC_ATTR_LEGACY);
 
    function = LLVMGetNamedFunction(module, name);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.h b/src/gallium/auxiliary/gallivm/lp_bld_intr.h
index bf8143df87d..ed90979f16f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_intr.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.h
@@ -36,6 +36,7 @@
 #ifndef LP_BLD_INTR_H
 #define LP_BLD_INTR_H
 
+#include <llvm/Config/llvm-config.h>
 
 #include "gallivm/lp_bld.h"
 #include "gallivm/lp_bld_init.h"
@@ -53,9 +54,9 @@ enum lp_func_attr {
    LP_FUNC_ATTR_NOUNWIND     = (1 << 4),
    LP_FUNC_ATTR_READNONE     = (1 << 5),
    LP_FUNC_ATTR_READONLY     = (1 << 6),
-   LP_FUNC_ATTR_WRITEONLY    = HAVE_LLVM >= 0x0400 ? (1 << 7) : 0,
-   LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = HAVE_LLVM >= 0x0400 ? (1 << 8) : 0,
-   LP_FUNC_ATTR_CONVERGENT   = HAVE_LLVM >= 0x0400 ? (1 << 9) : 0,
+   LP_FUNC_ATTR_WRITEONLY    = LLVM_VERSION_MAJOR >= 4 ? (1 << 7) : 0,
+   LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = LLVM_VERSION_MAJOR >= 4 ? (1 << 8) : 0,
+   LP_FUNC_ATTR_CONVERGENT   = LLVM_VERSION_MAJOR >= 4 ? (1 << 9) : 0,
 
    /* Legacy intrinsic that needs attributes on function declarations
     * and they must match the internal LLVM definition exactly, otherwise
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 347381f9b32..26d9667393e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -48,6 +48,7 @@
 #  undef DEBUG
 #endif
 
+#include <llvm/Config/llvm-config.h>
 #include <llvm-c/Core.h>
 #if HAVE_LLVM >= 0x0306
 #include <llvm-c/Support.h>
@@ -363,7 +364,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
          mgr()->registerEHFrames(SectionData);
       }
 #endif
-#if HAVE_LLVM >= 0x0500
+#if LLVM_VERSION_MAJOR >= 5
       virtual void deregisterEHFrames() {
          mgr()->deregisterEHFrames();
       }
@@ -556,7 +557,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
 
    llvm::SmallVector<std::string, 16> MAttrs;
 
-#if HAVE_LLVM >= 0x0400 && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM))
+#if LLVM_VERSION_MAJOR >= 4 && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM))
    /* llvm-3.3+ implements sys::getHostCPUFeatures for Arm
     * and llvm-3.7+ for x86, which allows us to enable/disable
     * code generation based on the results of cpuid on these
@@ -636,7 +637,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
 #if defined(PIPE_ARCH_PPC)
    MAttrs.push_back(util_cpu_caps.has_altivec ? "+altivec" : "-altivec");
 #if (HAVE_LLVM >= 0x0304)
-#if (HAVE_LLVM < 0x0400)
+#if (LLVM_VERSION_MAJOR < 4)
    /*
     * Make sure VSX instructions are disabled
     * See LLVM bugs:




More information about the mesa-commit mailing list