From: Eric Engestrom Date: Tue, 3 Sep 2019 21:40:32 +0000 (+0100) Subject: gallivm: drop LLVM<3.3 code paths as no build system allows that X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba73564b520d6a6b48f00d68702f20fca8a2ce4e;p=mesa.git gallivm: drop LLVM<3.3 code paths as no build system allows that Suggested-by: Michel Dänzer Signed-off-by: Eric Engestrom --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h index f99414c54f9..2fb638ceda4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -51,12 +51,7 @@ #include -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 3) -#error "LLVM 3.3 or newer required" -#endif - - -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 3) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 3 /* We won't actually use LLVMMCJITMemoryManagerRef, just create a dummy * typedef to simplify things elsewhere. */ @@ -103,7 +98,7 @@ typedef void *LLVMMCJITMemoryManagerRef; * Before LLVM 3.4 LLVMSetAlignment only supported GlobalValue, not * LoadInst/StoreInst as we need. */ -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 # ifdef __cplusplus extern "C" # endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index a1655ca5b61..ede15cf75c5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -144,7 +144,7 @@ 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_MAJOR == 3 && LLVM_VERSION_MINOR < 9)) && + } else if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 && util_cpu_caps.has_avx2 && type.length > 4) { intr_size = 256; switch (type.width) { @@ -158,7 +158,7 @@ lp_build_min_simple(struct lp_build_context *bld, intrinsic = type.sign ? "llvm.x86.avx2.pmins.d" : "llvm.x86.avx2.pminu.d"; break; } - } else if ((LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9)) && + } 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) && @@ -287,7 +287,7 @@ lp_build_fmuladd(LLVMBuilderRef builder, LLVMTypeRef type = LLVMTypeOf(a); assert(type == LLVMTypeOf(b)); assert(type == LLVMTypeOf(c)); - if (LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4)) { + if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) { /* XXX: LLVM 3.3 does not breakdown llvm.fmuladd into mul+add when FMA is * not supported, and instead it falls-back to a C function. */ @@ -362,7 +362,7 @@ 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_MAJOR == 3 && LLVM_VERSION_MINOR < 9)) && + } else if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 && util_cpu_caps.has_avx2 && type.length > 4) { intr_size = 256; switch (type.width) { @@ -376,7 +376,7 @@ lp_build_max_simple(struct lp_build_context *bld, intrinsic = type.sign ? "llvm.x86.avx2.pmaxs.d" : "llvm.x86.avx2.pmaxu.d"; break; } - } else if ((LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9)) && + } 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) && @@ -1837,7 +1837,7 @@ lp_build_abs(struct lp_build_context *bld, return a; if(type.floating) { - if ((LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 6)) && (LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9))) { + if ((LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 6)) && (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)); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 3a970148b6f..ed919c48838 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -138,7 +138,7 @@ create_pass_manager(struct gallivm_state *gallivm) * simple, or constant propagation into them, etc. */ -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) +#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 @@ -505,7 +505,7 @@ lp_build_init(void) util_cpu_caps.has_f16c = 0; util_cpu_caps.has_fma = 0; } - if ((LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4)) || !use_mcjit) { + if ((LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) || !use_mcjit) { /* AVX2 support has only been tested with LLVM 3.4, and it requires * MCJIT. */ util_cpu_caps.has_avx2 = 0; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index a75be648898..deffe207e04 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -64,7 +64,7 @@ #else #include #endif -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 #include #else #include @@ -153,7 +153,7 @@ static void init_native_targets() extern "C" void lp_set_target_options(void) { -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 /* * By default LLVM adds a signal handler to output a pretty stack trace. * This signal handler is never removed, causing problems when unloading the @@ -177,7 +177,7 @@ LLVMTargetLibraryInfoRef gallivm_create_target_library_info(const char *triple) { return reinterpret_cast( -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7 new llvm::TargetLibraryInfo( #else new llvm::TargetLibraryInfoImpl( @@ -190,7 +190,7 @@ void gallivm_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info) { delete reinterpret_cast< -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7 llvm::TargetLibraryInfo #else llvm::TargetLibraryInfoImpl @@ -199,7 +199,7 @@ gallivm_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info) } -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 extern "C" void @@ -222,7 +222,7 @@ LLVMSetAlignmentBackport(LLVMValueRef V, #endif -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 typedef llvm::JITMemoryManager BaseMemoryManager; #else typedef llvm::RTDyldMemoryManager BaseMemoryManager; @@ -240,7 +240,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { virtual BaseMemoryManager *mgr() const = 0; public: -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 /* * From JITMemoryManager */ @@ -287,7 +287,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { virtual void deallocateFunctionBody(void *Body) { mgr()->deallocateFunctionBody(Body); } -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 virtual uint8_t *startExceptionTable(const llvm::Function *F, uintptr_t &ActualSize) { return mgr()->startExceptionTable(F, ActualSize); @@ -379,7 +379,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { bool AbortOnFailure=true) { return mgr()->getPointerToNamedFunction(Name, AbortOnFailure); } -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 3) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 3 virtual bool applyPermissions(std::string *ErrMsg = 0) { return mgr()->applyPermissions(ErrMsg); } @@ -420,17 +420,17 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager { * Deallocate things as previously requested and * free shared manager when no longer used. */ -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 Vec::iterator i; assert(TheMM); for ( i = FunctionBody.begin(); i != FunctionBody.end(); ++i ) TheMM->deallocateFunctionBody(*i); -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 for ( i = ExceptionTable.begin(); i != ExceptionTable.end(); ++i ) TheMM->deallocateExceptionTable(*i); -#endif /* LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) */ -#endif /* LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) */ +#endif /* LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 */ +#endif /* LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 */ } }; @@ -462,7 +462,7 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager { delete (GeneratedCode *) code; } -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 virtual void deallocateExceptionTable(void *ET) { // remember for later deallocation code->ExceptionTable.push_back(ET); @@ -512,22 +512,21 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, TargetOptions options; #if defined(PIPE_ARCH_X86) options.StackAlignmentOverride = 4; -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 options.RealignStack = true; #endif #endif -#if defined(DEBUG) && (LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7)) +#if defined(DEBUG) && (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7) options.JITEmitDebugInfo = true; #endif /* XXX: Workaround http://llvm.org/PR21435 */ -#if defined(DEBUG) || defined(PROFILE) || \ - ((LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 3)) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))) -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) +#if defined(DEBUG) || defined(PROFILE) || defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 options.NoFramePointerElimNonLeaf = true; #endif -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7 options.NoFramePointerElim = true; #endif #endif @@ -538,7 +537,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, .setOptLevel((CodeGenOpt::Level)OptLevel); if (useMCJIT) { -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 builder.setUseMCJIT(true); #endif #ifdef _WIN32 @@ -729,7 +728,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, builder.setJITMemoryManager(MM); #endif } else { -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 BaseMemoryManager* JMM = reinterpret_cast(CMM); MM = new ShaderMemoryManager(JMM); *OutCode = MM->getGeneratedCode(); @@ -771,7 +770,7 @@ LLVMMCJITMemoryManagerRef lp_get_default_memory_manager() { BaseMemoryManager *mm; -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 mm = llvm::JITMemoryManager::CreateDefaultMemManager(); #else mm = new llvm::SectionMemoryManager(); @@ -808,7 +807,7 @@ lp_is_function(LLVMValueRef v) #endif } -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 static llvm::AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) { switch (Ordering) { case LLVMAtomicOrderingNotAtomic: return llvm::AtomicOrdering::NotAtomic; @@ -840,7 +839,7 @@ LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, } #endif -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering, LLVMBool singleThread, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h index 7d2e9ca07ca..e52eb7de8a7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.h @@ -78,7 +78,7 @@ extern bool lp_is_function(LLVMValueRef v); /* LLVM 3.9 introduces this, provide our own for earlier */ -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, @@ -86,7 +86,7 @@ LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMBool SingleThread); #endif -#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering, LLVMBool singleThread, const char *Name);