gallium: Require LLVM >= 3.9
authorAdam Jackson <ajax@redhat.com>
Fri, 6 Sep 2019 07:50:32 +0000 (09:50 +0200)
committerAdam Jackson <ajax@nwnk.net>
Wed, 11 Sep 2019 17:00:43 +0000 (17:00 +0000)
To go any further than this would be to break the current version of
Android.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Android.mk
meson.build
scons/llvm.py
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_init.c
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
src/gallium/auxiliary/gallivm/lp_bld_misc.h
src/gallium/state_trackers/clover/llvm/metadata.hpp

index c7c2888599566aa6a2aba4d41ceed09d74834a5f..df379a4052821a66bf123d1f6f1c7c43e11c715d 100644 (file)
@@ -95,14 +95,9 @@ MESA_ENABLE_LLVM := true
 endif
 
 define mesa-build-with-llvm
-  $(if $(filter $(MESA_ANDROID_MAJOR_VERSION), 4 5 6), \
+  $(if $(filter $(MESA_ANDROID_MAJOR_VERSION), 4 5 6 7), \
     $(warning Unsupported LLVM version in Android $(MESA_ANDROID_MAJOR_VERSION)),) \
-  $(if $(filter 7,$(MESA_ANDROID_MAJOR_VERSION)), \
-    $(eval LOCAL_CFLAGS += -DLLVM_AVAILABLE -DMESA_LLVM_VERSION_STRING=\"3.8\")) \
-  $(if $(filter 8,$(MESA_ANDROID_MAJOR_VERSION)), \
-    $(eval LOCAL_CFLAGS += -DLLVM_AVAILABLE -DMESA_LLVM_VERSION_STRING=\"3.9\")) \
-  $(if $(filter P,$(MESA_ANDROID_MAJOR_VERSION)), \
-    $(eval LOCAL_CFLAGS += -DLLVM_AVAILABLE -DMESA_LLVM_VERSION_STRING=\"3.9\")) \
+  $(eval LOCAL_CFLAGS += -DLLVM_AVAILABLE -DMESA_LLVM_VERSION_STRING=\"3.9\")
   $(eval LOCAL_SHARED_LIBRARIES += libLLVM)
 endef
 
index 400427ee554497abe2572ad2382ee830a9929554..b8c19999f019e7e8cf02707cbac978eeedcde0ca 100644 (file)
@@ -1261,10 +1261,8 @@ if with_amd_vk or with_gallium_radeonsi
   _llvm_version = '>= 8.0.0'
 elif with_gallium_swr
   _llvm_version = '>= 6.0.0'
-elif with_gallium_opencl or with_gallium_r600
-  _llvm_version = '>= 3.9.0'
 else
-  _llvm_version = '>= 3.8.0'
+  _llvm_version = '>= 3.9.0'
 endif
 
 _shared_llvm = get_option('shared-llvm')
index 8d03d7ace067d02330f1d9b3dc9cfd0f43b8964a..4464b665751e8b54ddb8af41e7e10067345a19c5 100644 (file)
@@ -37,7 +37,7 @@ import SCons.Errors
 import SCons.Util
 
 
-required_llvm_version = '3.8'
+required_llvm_version = '3.9'
 
 
 def generate(env):
@@ -142,7 +142,7 @@ def generate(env):
                 'LLVMIRReader', 'LLVMAsmParser',
                 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF',
             ])
-        elif llvm_version >= distutils.version.LooseVersion('3.9'):
+        else:
             env.Prepend(LIBS = [
                 'LLVMX86Disassembler', 'LLVMX86AsmParser',
                 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter',
@@ -159,18 +159,6 @@ def generate(env):
                 'LLVMSupport',
                 'LLVMIRReader', 'LLVMASMParser'
             ])
-        else:
-            env.Prepend(LIBS = [
-                'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
-                'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter',
-                'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMProfileData',
-                'LLVMInstCombine', 'LLVMInstrumentation', 'LLVMTransformUtils', 'LLVMipa',
-                'LLVMAnalysis', 'LLVMX86Desc', 'LLVMMCDisassembler',
-                'LLVMX86Info', 'LLVMX86AsmPrinter', 'LLVMX86Utils',
-                'LLVMMCJIT', 'LLVMTarget', 'LLVMExecutionEngine',
-                'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser',
-                'LLVMBitReader', 'LLVMMC', 'LLVMCore', 'LLVMSupport'
-            ])
         env.Append(LIBS = [
             'imagehlp',
             'psapi',
index 9bf74f0a15be5a09b119cd5f44f8975deb54ef3a..6b7ce9aacf9fdc14f70dc9803d1e10572513e3b8 100644 (file)
@@ -144,49 +144,6 @@ lp_build_min_simple(struct lp_build_context *bld,
          intrinsic = "llvm.ppc.altivec.vminfp";
          intr_size = 128;
       }
-   } else if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 &&
-              util_cpu_caps.has_avx2 && type.length > 4) {
-      intr_size = 256;
-      switch (type.width) {
-      case 8:
-         intrinsic = type.sign ? "llvm.x86.avx2.pmins.b" : "llvm.x86.avx2.pminu.b";
-         break;
-      case 16:
-         intrinsic = type.sign ? "llvm.x86.avx2.pmins.w" : "llvm.x86.avx2.pminu.w";
-         break;
-      case 32:
-         intrinsic = type.sign ? "llvm.x86.avx2.pmins.d" : "llvm.x86.avx2.pminu.d";
-         break;
-      }
-   } else if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 &&
-              util_cpu_caps.has_sse2 && type.length >= 2) {
-      intr_size = 128;
-      if ((type.width == 8 || type.width == 16) &&
-          (type.width * type.length <= 64) &&
-          (gallivm_debug & GALLIVM_DEBUG_PERF)) {
-         debug_printf("%s: inefficient code, bogus shuffle due to packing\n",
-                      __FUNCTION__);
-      }
-      if (type.width == 8 && !type.sign) {
-         intrinsic = "llvm.x86.sse2.pminu.b";
-      }
-      else if (type.width == 16 && type.sign) {
-         intrinsic = "llvm.x86.sse2.pmins.w";
-      }
-      if (util_cpu_caps.has_sse4_1) {
-         if (type.width == 8 && type.sign) {
-            intrinsic = "llvm.x86.sse41.pminsb";
-         }
-         if (type.width == 16 && !type.sign) {
-            intrinsic = "llvm.x86.sse41.pminuw";
-         }
-         if (type.width == 32 && !type.sign) {
-            intrinsic = "llvm.x86.sse41.pminud";
-         }
-         if (type.width == 32 && type.sign) {
-            intrinsic = "llvm.x86.sse41.pminsd";
-         }
-      }
    } else if (util_cpu_caps.has_altivec) {
       intr_size = 128;
       if (type.width == 8) {
@@ -357,50 +314,6 @@ lp_build_max_simple(struct lp_build_context *bld,
          intrinsic = "llvm.ppc.altivec.vmaxfp";
          intr_size = 128;
       }
-   } else if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 &&
-              util_cpu_caps.has_avx2 && type.length > 4) {
-      intr_size = 256;
-      switch (type.width) {
-      case 8:
-         intrinsic = type.sign ? "llvm.x86.avx2.pmaxs.b" : "llvm.x86.avx2.pmaxu.b";
-         break;
-      case 16:
-         intrinsic = type.sign ? "llvm.x86.avx2.pmaxs.w" : "llvm.x86.avx2.pmaxu.w";
-         break;
-      case 32:
-         intrinsic = type.sign ? "llvm.x86.avx2.pmaxs.d" : "llvm.x86.avx2.pmaxu.d";
-         break;
-      }
-   } else if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 &&
-              util_cpu_caps.has_sse2 && type.length >= 2) {
-      intr_size = 128;
-      if ((type.width == 8 || type.width == 16) &&
-          (type.width * type.length <= 64) &&
-          (gallivm_debug & GALLIVM_DEBUG_PERF)) {
-         debug_printf("%s: inefficient code, bogus shuffle due to packing\n",
-                      __FUNCTION__);
-         }
-      if (type.width == 8 && !type.sign) {
-         intrinsic = "llvm.x86.sse2.pmaxu.b";
-         intr_size = 128;
-      }
-      else if (type.width == 16 && type.sign) {
-         intrinsic = "llvm.x86.sse2.pmaxs.w";
-      }
-      if (util_cpu_caps.has_sse4_1) {
-         if (type.width == 8 && type.sign) {
-            intrinsic = "llvm.x86.sse41.pmaxsb";
-         }
-         if (type.width == 16 && !type.sign) {
-            intrinsic = "llvm.x86.sse41.pmaxuw";
-         }
-         if (type.width == 32 && !type.sign) {
-            intrinsic = "llvm.x86.sse41.pmaxud";
-        }
-         if (type.width == 32 && type.sign) {
-            intrinsic = "llvm.x86.sse41.pmaxsd";
-         }
-      }
    } else if (util_cpu_caps.has_altivec) {
      intr_size = 128;
      if (type.width == 8) {
@@ -1832,20 +1745,9 @@ lp_build_abs(struct lp_build_context *bld,
       return a;
 
    if(type.floating) {
-      if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) {
-         /* Workaround llvm.org/PR27332 */
-         LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
-         unsigned long long absMask = ~(1ULL << (type.width - 1));
-         LLVMValueRef mask = lp_build_const_int_vec(bld->gallivm, type, ((unsigned long long) absMask));
-         a = LLVMBuildBitCast(builder, a, int_vec_type, "");
-         a = LLVMBuildAnd(builder, a, mask, "");
-         a = LLVMBuildBitCast(builder, a, vec_type, "");
-         return a;
-      } else {
-         char intrinsic[32];
-         lp_format_intrinsic(intrinsic, sizeof intrinsic, "llvm.fabs", vec_type);
-         return lp_build_intrinsic_unary(builder, intrinsic, vec_type, a);
-      }
+      char intrinsic[32];
+      lp_format_intrinsic(intrinsic, sizeof intrinsic, "llvm.fabs", vec_type);
+      return lp_build_intrinsic_unary(builder, intrinsic, vec_type, a);
    }
 
    if(type.width*type.length == 128 && util_cpu_caps.has_ssse3 && LLVM_VERSION_MAJOR < 6) {
index 46355e0277c3229d55fefac2ab3a0a9ec98d7713..19d0d5ab0318f5d7fbf9d8a1d0304029b08b5df2 100644 (file)
@@ -125,11 +125,6 @@ create_pass_manager(struct gallivm_state *gallivm)
     * simple, or constant propagation into them, etc.
     */
 
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9
-   // Old versions of LLVM get the DataLayout from the pass manager.
-   LLVMAddTargetData(gallivm->target, gallivm->passmgr);
-#endif
-
    {
       char *td_str;
       // New ones from the Module.
index cf18d6d14f970946c637404b8112c9cd26666ae8..3580ea6dd4bc20840f6d32a78166e9f0d6dc9f99 100644 (file)
@@ -509,49 +509,11 @@ lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr)
 extern "C" LLVMValueRef
 lp_get_called_value(LLVMValueRef call)
 {
-#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
        return LLVMGetCalledValue(call);
-#else
-       return llvm::wrap(llvm::CallSite(llvm::unwrap<llvm::Instruction>(call)).getCalledValue());
-#endif
 }
 
 extern "C" bool
 lp_is_function(LLVMValueRef v)
 {
-#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
        return LLVMGetValueKind(v) == LLVMFunctionValueKind;
-#else
-       return llvm::isa<llvm::Function>(llvm::unwrap(v));
-#endif
-}
-
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9
-static llvm::AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
-   switch (Ordering) {
-   case LLVMAtomicOrderingNotAtomic: return llvm::AtomicOrdering::NotAtomic;
-   case LLVMAtomicOrderingUnordered: return llvm::AtomicOrdering::Unordered;
-   case LLVMAtomicOrderingMonotonic: return llvm::AtomicOrdering::Monotonic;
-   case LLVMAtomicOrderingAcquire: return llvm::AtomicOrdering::Acquire;
-   case LLVMAtomicOrderingRelease: return llvm::AtomicOrdering::Release;
-   case LLVMAtomicOrderingAcquireRelease:
-      return llvm::AtomicOrdering::AcquireRelease;
-   case LLVMAtomicOrderingSequentiallyConsistent:
-      return llvm::AtomicOrdering::SequentiallyConsistent;
-   }
-
-   llvm_unreachable("Invalid LLVMAtomicOrdering value!");
-}
-
-LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
-                                    LLVMValueRef Cmp, LLVMValueRef New,
-                                    LLVMAtomicOrdering SuccessOrdering,
-                                    LLVMAtomicOrdering FailureOrdering,
-                                    LLVMBool SingleThread)
-{
-   return llvm::wrap(llvm::unwrap(B)->CreateAtomicCmpXchg(llvm::unwrap(Ptr), llvm::unwrap(Cmp),
-                                                          llvm::unwrap(New), mapFromLLVMOrdering(SuccessOrdering),
-                                                          mapFromLLVMOrdering(FailureOrdering),
-                                                          SingleThread ? llvm::SynchronizationScope::SingleThread : llvm::SynchronizationScope::CrossThread));
 }
-#endif
index eb1eac045fd2313c1306a4f2699ceaf1a5afc255..363fbded728be51cfe44841b8f2fadd1236f9859 100644 (file)
@@ -76,15 +76,6 @@ lp_get_called_value(LLVMValueRef call);
 extern bool
 lp_is_function(LLVMValueRef v);
 
-/* LLVM 3.9 introduces this, provide our own for earlier */
-#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9
-LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
-                                    LLVMValueRef Cmp, LLVMValueRef New,
-                                    LLVMAtomicOrdering SuccessOrdering,
-                                    LLVMAtomicOrdering FailureOrdering,
-                                    LLVMBool SingleThread);
-#endif
-
 #ifdef __cplusplus
 }
 #endif
index 4a6f37d8f5d9f5eac2a3c25ac3953702d6b0f2ad..d23f317c0a59d2c7cf7a07ab1145bf104e937d5c 100644 (file)
@@ -58,44 +58,14 @@ namespace clover {
 
          inline bool
          is_kernel(const ::llvm::Function &f) {
-#if (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9))
             return f.getMetadata("kernel_arg_type");
-#else
-            return clover::any_of(is_kernel_node_for(f),
-                                  get_kernel_nodes(*f.getParent()));
-#endif
          }
 
          inline iterator_range< ::llvm::MDNode::op_iterator>
          get_kernel_metadata_operands(const ::llvm::Function &f,
                                       const std::string &name) {
-#if (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9))
-            // On LLVM v3.9+ kernel argument attributes are stored as
-            // function metadata.
             const auto data_node = f.getMetadata(name);
             return range(data_node->op_begin(), data_node->op_end());
-#else
-            using ::llvm::cast;
-            using ::llvm::dyn_cast;
-            const auto kernel_node = find(is_kernel_node_for(f),
-                                          get_kernel_nodes(*f.getParent()));
-
-            const auto data_node = cast< ::llvm::MDNode>(
-               find([&](const ::llvm::MDOperand &op) {
-                     if (auto m = dyn_cast< ::llvm::MDNode>(op))
-                        if (m->getNumOperands())
-                           if (auto m_name = dyn_cast< ::llvm::MDString>(
-                                  m->getOperand(0).get()))
-                              return m_name->getString() == name;
-
-                     return false;
-                  },
-                  kernel_node->operands()));
-
-            // Skip the first operand node which is just the metadata
-            // attribute name.
-            return range(data_node->op_begin() + 1, data_node->op_end());
-#endif
          }
       }