gallivm,llvmpipe,clover: Bump required LLVM version to 3.3.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 22 Oct 2014 12:09:59 +0000 (13:09 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 23 Oct 2014 09:18:56 +0000 (10:18 +0100)
We'll need to update gallivm for the interface changes in LLVM 3.6, and
the fewer the number of older LLVM versions we support the less hairy that
will be.

As consequence HAVE_AVX define can disappear.  (Note HAVE_AVX meant
whether LLVM version supports AVX or not.  Runtime support for AVX is
always checked and enforced independently.)

Verified llvmpipe builds and runs with with LLVM 3.3, 3.4, and 3.5.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
configure.ac
scons/llvm.py
src/gallium/auxiliary/gallivm/lp_bld.h
src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
src/gallium/auxiliary/gallivm/lp_bld_init.c
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/state_trackers/clover/llvm/invocation.cpp

index 0ed9325449051b800b11000399e72669a4458217..09a71b7e9459c0e1a7b08a2cc99e9a392115b903 100644 (file)
@@ -1714,7 +1714,7 @@ if test "x$enable_gallium_llvm" = xyes; then
         fi
 
         LLVM_REQUIRED_VERSION_MAJOR="3"
-        LLVM_REQUIRED_VERSION_MINOR="1"
+        LLVM_REQUIRED_VERSION_MINOR="3"
         if test "$LLVM_VERSION_INT" -lt "${LLVM_REQUIRED_VERSION_MAJOR}0${LLVM_REQUIRED_VERSION_MINOR}"; then
             AC_MSG_ERROR([LLVM $LLVM_REQUIRED_VERSION_MAJOR.$LLVM_REQUIRED_VERSION_MINOR or newer is required])
         fi
index 288a0806f2a7f25cdbb860f51b5fa7da1aff5db6..1e312f94de3237b20b54b99865dcc2e523c1e5e8 100644 (file)
@@ -37,7 +37,7 @@ import SCons.Errors
 import SCons.Util
 
 
-required_llvm_version = '3.1'
+required_llvm_version = '3.3'
 
 
 def generate(env):
@@ -98,7 +98,7 @@ def generate(env):
             'HAVE_STDINT_H',
         ])
         env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
-        if llvm_version >= distutils.version.LooseVersion('3.2'):
+        if True:
             # 3.2
             env.Prepend(LIBS = [
                 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
@@ -110,18 +110,6 @@ def generate(env):
                 'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore',
                 'LLVMSupport', 'LLVMRuntimeDyld', 'LLVMObject'
             ])
-        else:
-            # 3.1
-            env.Prepend(LIBS = [
-                'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
-                'LLVMX86CodeGen', 'LLVMX86Desc', 'LLVMSelectionDAG',
-                'LLVMAsmPrinter', 'LLVMMCParser', 'LLVMX86AsmPrinter',
-                'LLVMX86Utils', 'LLVMX86Info', 'LLVMMCJIT', 'LLVMJIT',
-                'LLVMExecutionEngine', 'LLVMCodeGen', 'LLVMScalarOpts',
-                'LLVMInstCombine', 'LLVMTransformUtils', 'LLVMipa',
-                'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore',
-                'LLVMSupport'
-            ])
         env.Append(LIBS = [
             'imagehlp',
             'psapi',
index a01c216cfabdbc48e7789bf6f39575f8d27fd38d..7ba925c480350d15b4aaa607149618fb2c3459f9 100644 (file)
@@ -53,8 +53,8 @@
 #ifndef HAVE_LLVM
 #error "HAVE_LLVM should be set with LLVM's version number, e.g. (0x0207 for 2.7)"
 #endif
-#if HAVE_LLVM < 0x301
-#error "LLVM 3.1 or newer required"
+#if HAVE_LLVM < 0x303
+#error "LLVM 3.3 or newer required"
 #endif
 
 
index b6b52c80efcab2fdb07c68116ff6d910bb9c16ca..bad65c2c0ed38018782c4d40085a1b528e4ed30a 100644 (file)
 
 #include <llvm/Support/Host.h>
 
-#if HAVE_LLVM >= 0x0303
 #include <llvm/IR/Module.h>
-#else
-#include <llvm/Module.h>
-#endif
 
 #include <llvm/MC/MCDisassembler.h>
 #include <llvm/MC/MCAsmInfo.h>
@@ -57,7 +53,7 @@
 
 #if HAVE_LLVM >= 0x0305
 #define OwningPtr std::unique_ptr
-#elif HAVE_LLVM >= 0x0303
+#else
 #include <llvm/ADT/OwningPtr.h>
 #endif
 
index 8d7a0b658627305073c4747e896fec91ec1b34d8..b82cb77a07a0b54fecae2bb2a8b437dbf5df9421 100644 (file)
 
 /* Only MCJIT is available as of LLVM SVN r216982 */
 #if HAVE_LLVM >= 0x0306
-
-#define USE_MCJIT 1
-#define HAVE_AVX 1
-
-#else
-
-/**
- * AVX is supported in:
- * - standard JIT from LLVM 3.2 onwards
- * - MC-JIT from LLVM 3.1
- *   - MC-JIT supports limited OSes (MacOSX and Linux)
- * - standard JIT in LLVM 3.1, with backports
- */
-#if defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
 #  define USE_MCJIT 1
-#  define HAVE_AVX 0
-#elif HAVE_LLVM >= 0x0302 || (HAVE_LLVM == 0x0301 && defined(HAVE_JIT_AVX_SUPPORT))
-#  define USE_MCJIT 0
-#  define HAVE_AVX 1
-#elif HAVE_LLVM == 0x0301 && (defined(PIPE_OS_LINUX) || defined(PIPE_OS_APPLE))
+#elif defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
 #  define USE_MCJIT 1
-#  define HAVE_AVX 1
 #else
 #  define USE_MCJIT 0
-#  define HAVE_AVX 0
 #endif
 
-#endif /* HAVE_LLVM >= 0x0306 */
-
 #if USE_MCJIT
 void LLVMLinkInMCJIT();
 #endif
@@ -414,8 +392,7 @@ lp_build_init(void)
     * See also:
     * - http://www.anandtech.com/show/4955/the-bulldozer-review-amd-fx8150-tested/2
     */
-   if (HAVE_AVX &&
-       util_cpu_caps.has_avx &&
+   if (util_cpu_caps.has_avx &&
        util_cpu_caps.has_intel) {
       lp_native_vector_width = 256;
    } else {
@@ -440,16 +417,6 @@ lp_build_init(void)
       util_cpu_caps.has_avx2 = 0;
    }
 
-   if (!HAVE_AVX) {
-      /*
-       * note these instructions are VEX-only, so can only emit if we use
-       * avx (don't want to base it on has_avx & has_f16c later as that would
-       * omit it unnecessarily on amd cpus, see above).
-       */
-      util_cpu_caps.has_f16c = 0;
-      util_cpu_caps.has_xop = 0;
-   }
-
 #ifdef PIPE_ARCH_PPC_64
    /* Set the NJ bit in VSCR to 0 so denormalized values are handled as
     * specified by IEEE standard (PowerISA 2.06 - Section 6.3). This guarantees
index 9c2de2ccbe6fdc27eac89cc8ddefb2b54ab7749e..ab3b3c9fbdfb1582051a823030f2ad1354e9154d 100644 (file)
 
 #include <llvm/Support/TargetSelect.h>
 
-#if HAVE_LLVM >= 0x0303
 #include <llvm/IR/IRBuilder.h>
 #include <llvm/IR/Module.h>
 #include <llvm/Support/CBindingWrapping.h>
-#endif
 
 #include "pipe/p_config.h"
 #include "util/u_debug.h"
@@ -82,15 +80,9 @@ class LLVMEnsureMultithreaded {
 public:
    LLVMEnsureMultithreaded()
    {
-#if HAVE_LLVM < 0x0303
-      if (!llvm::llvm_is_multithreaded()) {
-         llvm::llvm_start_multithreaded();
-      }
-#else
       if (!LLVMIsMultithreaded()) {
          LLVMStartMultithreaded();
       }
-#endif
    }
 };
 
@@ -260,7 +252,6 @@ class DelegatingJITMemoryManager : public llvm::JITMemoryManager {
          return mgr()->allocateCodeSection(Size, Alignment, SectionID);
       }
 #endif
-#if HAVE_LLVM >= 0x0303
       virtual uint8_t *allocateDataSection(uintptr_t Size,
                                            unsigned Alignment,
                                            unsigned SectionID,
@@ -285,23 +276,16 @@ class DelegatingJITMemoryManager : public llvm::JITMemoryManager {
       virtual void registerEHFrames(llvm::StringRef SectionData) {
          mgr()->registerEHFrames(SectionData);
       }
-#endif
-#else
-      virtual uint8_t *allocateDataSection(uintptr_t Size,
-                                           unsigned Alignment,
-                                           unsigned SectionID) {
-         return mgr()->allocateDataSection(Size, Alignment, SectionID);
-      }
 #endif
       virtual void *getPointerToNamedFunction(const std::string &Name,
                                               bool AbortOnFailure=true) {
          return mgr()->getPointerToNamedFunction(Name, AbortOnFailure);
       }
-#if HAVE_LLVM == 0x0303
+#if HAVE_LLVM <= 0x0303
       virtual bool applyPermissions(std::string *ErrMsg = 0) {
          return mgr()->applyPermissions(ErrMsg);
       }
-#elif HAVE_LLVM > 0x0303
+#else
       virtual bool finalizeMemory(std::string *ErrMsg = 0) {
          return mgr()->finalizeMemory(ErrMsg);
       }
@@ -509,17 +493,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
 
    ExecutionEngine *JIT;
 
-#if HAVE_LLVM >= 0x0302
    JIT = builder.create();
-#else
-   /*
-    * Workaround http://llvm.org/PR12833
-    */
-   StringRef MArch = "";
-   StringRef MCPU = "";
-   Triple TT(unwrap(M)->getTargetTriple());
-   JIT = builder.create(builder.selectTarget(TT, MArch, MCPU, MAttrs));
-#endif
    if (JIT) {
       *OutJIT = wrap(JIT);
       return 0;
index a264f990d02baf1381e7f9d42841dab7886d7d7d..ad716b70ca57265a9958a34f23f691a8e8fa0857 100644 (file)
@@ -551,12 +551,6 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
 
    util_cpu_detect();
 
-#if defined(PIPE_ARCH_X86) && HAVE_LLVM < 0x0302
-   /* require SSE2 due to LLVM PR6960. */
-   if (!util_cpu_caps.has_sse2)
-       return NULL;
-#endif
-
 #ifdef DEBUG
    LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 );
 #endif
index a7a55f8301cae431c2913d0a3652467a29cad2bb..0fc3686ba13f1dbe3de13e93591768adeb33c746 100644 (file)
@@ -1666,15 +1666,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
    partial_mask |= !variant->opaque;
    i32_zero = lp_build_const_int32(gallivm, 0);
 
-#if HAVE_LLVM < 0x0302
-   /*
-    * undef triggers a crash in LLVMBuildTrunc in convert_from_blend_type in some
-    * cases (seen with r10g10b10a2, 128bit wide vectors) (only used for 1d case).
-    */
-   undef_src_val = lp_build_zero(gallivm, fs_type);
-#else
    undef_src_val = lp_build_undef(gallivm, fs_type);
-#endif
 
    row_type.length = fs_type.length;
    vector_width    = dst_type.floating ? lp_native_vector_width : lp_integer_vector_width;
index 7c31008f52e8500a17bd427f4137a8490a944ab4..e9538224bf6730d276aefac4499f8d4624a9b8d3 100644 (file)
 #include <llvm/IR/DiagnosticInfo.h>
 #include <llvm/IR/DiagnosticPrinter.h>
 #endif
-#if HAVE_LLVM < 0x0303
-#include <llvm/DerivedTypes.h>
-#include <llvm/LLVMContext.h>
-#include <llvm/Module.h>
-#else
 #include <llvm/IR/DerivedTypes.h>
 #include <llvm/IR/LLVMContext.h>
 #include <llvm/IR/Module.h>
 #include <llvm/Support/SourceMgr.h>
 #include <llvm/IRReader/IRReader.h>
-#endif
 #if HAVE_LLVM < 0x0305
 #include <llvm/ADT/OwningPtr.h>
 #endif
@@ -54,9 +48,6 @@
 #include <llvm/Support/CodeGen.h>
 #include <llvm/Support/TargetSelect.h>
 #include <llvm/Support/MemoryBuffer.h>
-#if HAVE_LLVM < 0x0303
-#include <llvm/Support/PathV1.h>
-#endif
 #include <llvm/Support/FormattedStream.h>
 #include <llvm/Support/TargetRegistry.h>
 #include <llvm/Transforms/IPO.h>
 #include <llvm/Transforms/Utils/Cloning.h>
 
 
-#if HAVE_LLVM < 0x0302
-#include <llvm/Target/TargetData.h>
-#elif HAVE_LLVM < 0x0303
-#include <llvm/DataLayout.h>
-#else
 #include <llvm/IR/DataLayout.h>
-#endif
 #include <llvm/Target/TargetLibraryInfo.h>
 #include <llvm/Target/TargetMachine.h>
 #include <llvm/Target/TargetOptions.h>
@@ -203,9 +188,6 @@ namespace {
       c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,
                                       clang::frontend::Angled,
                                       false, false
-#if HAVE_LLVM < 0x0303
-                                      , false
-#endif
                                       );
 
       // Add libclc include
@@ -223,23 +205,12 @@ namespace {
       // of warnings and errors to be printed to stderr.
       // http://www.llvm.org/bugs/show_bug.cgi?id=19735
       c.getDiagnosticOpts().ShowCarets = false;
-#if HAVE_LLVM <= 0x0301
-      c.getInvocation().setLangDefaults(clang::IK_OpenCL);
-#else
       c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL,
                                         clang::LangStandard::lang_opencl11);
-#endif
       c.createDiagnostics(
-#if HAVE_LLVM < 0x0303
-                          0, NULL,
-#endif
                           new clang::TextDiagnosticPrinter(
                                  s_log,
-#if HAVE_LLVM <= 0x0301
-                                 c.getDiagnosticOpts()));
-#else
                                  &c.getDiagnosticOpts()));
-#endif
 
 #if HAVE_LLVM >= 0x0306
       c.getPreprocessorOpts().addRemappedFile(name,
@@ -255,9 +226,6 @@ namespace {
          c.getHeaderSearchOpts().AddPath(tmp_header_path,
                                          clang::frontend::Angled,
                                          false, false
-#if HAVE_LLVM < 0x0303
-                                         , false
-#endif
                                          );
 
          for (header_map::const_iterator it = headers.begin();
@@ -368,9 +336,7 @@ namespace {
       compat::vector<module::argument> args;
       llvm::Function *kernel_func = mod->getFunction(kernel_name);
 
-#if HAVE_LLVM < 0x0302
-         llvm::TargetData TD(kernel_func->getParent());
-#elif HAVE_LLVM < 0x0305
+#if HAVE_LLVM < 0x0305
          llvm::DataLayout TD(kernel_func->getParent()->getDataLayout());
 #else
          llvm::DataLayout TD(mod);