summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Engestrom <[email protected]>2019-08-28 00:36:25 +0100
committerEric Engestrom <[email protected]>2019-09-06 22:26:29 +0100
commit1c1c477470697a65b85bed1fa52b3b37861dd530 (patch)
tree956a692d7e142e5307ac371dc9f63b09e5eae76f /src
parent75271443830c4a2d89b32b6cd73d7900a2985477 (diff)
gallivm: replace more complex 3.x version check with LLVM_VERSION_MAJOR/MINOR
Signed-off-by: Eric Engestrom <[email protected]> Acked-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld.h12
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit.c12
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_debug.cpp3
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_init.c10
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_logic.c3
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_misc.cpp100
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_misc.h5
7 files changed, 74 insertions, 71 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h
index af40a661b95..f99414c54f9 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld.h
@@ -46,19 +46,17 @@
* for a standalone example.
*/
+#include <llvm/Config/llvm-config.h>
+
#include <llvm-c/Core.h>
-/** Ensure HAVE_LLVM is set to avoid #ifdef HAVE_LLVM everywhere */
-#ifndef HAVE_LLVM
-#error "HAVE_LLVM should be set with LLVM's version number, e.g. (0x0207 for 2.7)"
-#endif
-#if HAVE_LLVM < 0x303
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 3)
#error "LLVM 3.3 or newer required"
#endif
-#if HAVE_LLVM <= 0x0303
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 3)
/* We won't actually use LLVMMCJITMemoryManagerRef, just create a dummy
* typedef to simplify things elsewhere.
*/
@@ -105,7 +103,7 @@ typedef void *LLVMMCJITMemoryManagerRef;
* Before LLVM 3.4 LLVMSetAlignment only supported GlobalValue, not
* LoadInst/StoreInst as we need.
*/
-#if HAVE_LLVM < 0x0304
+#if LLVM_VERSION_MAJOR < 3 || (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 8a912ac5753..a1655ca5b61 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 (HAVE_LLVM < 0x0309 &&
+ } else if ((LLVM_VERSION_MAJOR < 3 || (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 (HAVE_LLVM < 0x0309 &&
+ } else if ((LLVM_VERSION_MAJOR < 3 || (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 (HAVE_LLVM < 0x0304) {
+ if (LLVM_VERSION_MAJOR < 3 || (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 (HAVE_LLVM < 0x0309 &&
+ } else if ((LLVM_VERSION_MAJOR < 3 || (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 (HAVE_LLVM < 0x0309 &&
+ } else if ((LLVM_VERSION_MAJOR < 3 || (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 (0x0306 <= HAVE_LLVM && HAVE_LLVM < 0x0309) {
+ 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))) {
/* 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_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index 1bada6ff394..67b10093e8a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -30,6 +30,7 @@
#include <sstream>
#include <iomanip>
+#include <llvm/Config/llvm-config.h>
#include <llvm-c/Core.h>
#include <llvm-c/Disassembler.h>
#include <llvm/Support/raw_ostream.h>
@@ -71,7 +72,7 @@ lp_check_alignment(const void *ptr, unsigned alignment)
extern "C" void
lp_debug_dump_value(LLVMValueRef value)
{
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
char *str = LLVMPrintValueToString(value);
if (str) {
os_log_message(str);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 0e81df357a8..3a970148b6f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -50,7 +50,7 @@
#endif
/* Only MCJIT is available as of LLVM SVN r216982 */
-#if HAVE_LLVM >= 0x0306
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6)
# define USE_MCJIT 1
#elif defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
# define USE_MCJIT 1
@@ -138,7 +138,7 @@ create_pass_manager(struct gallivm_state *gallivm)
* simple, or constant propagation into them, etc.
*/
-#if HAVE_LLVM < 0x0309
+#if LLVM_VERSION_MAJOR < 3 || (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 (HAVE_LLVM < 0x0304 || !use_mcjit) {
+ if ((LLVM_VERSION_MAJOR < 3 || (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;
@@ -626,7 +626,7 @@ gallivm_compile_module(struct gallivm_state *gallivm)
"-sroa -early-cse -simplifycfg -reassociate "
"-mem2reg -constprop -instcombine -gvn",
filename, gallivm_debug & GALLIVM_PERF_NO_OPT ? 0 : 2,
- (HAVE_LLVM >= 0x0305) ? "[-mcpu=<-mcpu option>] " : "",
+ (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)) ? "[-mcpu=<-mcpu option>] " : "",
"[-mattr=<-mattr option(s)>]");
}
@@ -646,7 +646,7 @@ gallivm_compile_module(struct gallivm_state *gallivm)
/* Disable frame pointer omission on debug/profile builds */
/* XXX: And workaround http://llvm.org/PR21435 */
-#if HAVE_LLVM >= 0x0307 && \
+#if (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7)) && \
(defined(DEBUG) || defined(PROFILE) || \
defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
LLVMAddTargetDependentFunctionAttr(func, "no-frame-pointer-elim", "true");
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
index 524917abe27..740a83e2e36 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
@@ -32,6 +32,7 @@
* @author Jose Fonseca <[email protected]>
*/
+#include <llvm/Config/llvm-config.h>
#include "util/u_cpu_detect.h"
#include "util/u_memory.h"
@@ -317,7 +318,7 @@ lp_build_select(struct lp_build_context *bld,
mask = LLVMBuildTrunc(builder, mask, LLVMInt1TypeInContext(lc), "");
res = LLVMBuildSelect(builder, mask, a, b, "");
}
- else if (!(HAVE_LLVM == 0x0307) &&
+ else if (!(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 7) &&
(LLVMIsConstant(mask) ||
LLVMGetInstructionOpcode(mask) == LLVMSExt)) {
/* Generate a vector select.
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 26d9667393e..a75be648898 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -42,27 +42,29 @@
#include <stddef.h>
+#include <llvm/Config/llvm-config.h>
+
// Workaround http://llvm.org/PR23628
-#if HAVE_LLVM >= 0x0307
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7)
# pragma push_macro("DEBUG")
# undef DEBUG
#endif
#include <llvm/Config/llvm-config.h>
#include <llvm-c/Core.h>
-#if HAVE_LLVM >= 0x0306
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6)
#include <llvm-c/Support.h>
#endif
#include <llvm-c/ExecutionEngine.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/ADT/Triple.h>
-#if HAVE_LLVM >= 0x0307
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7)
#include <llvm/Analysis/TargetLibraryInfo.h>
#else
#include <llvm/Target/TargetLibraryInfo.h>
#endif
-#if HAVE_LLVM < 0x0306
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6)
#include <llvm/ExecutionEngine/JITMemoryManager.h>
#else
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
@@ -73,7 +75,7 @@
#include <llvm/Support/TargetSelect.h>
-#if HAVE_LLVM >= 0x0305
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
#include <llvm/IR/CallSite.h>
#endif
#include <llvm/IR/IRBuilder.h>
@@ -86,7 +88,7 @@
#endif
// Workaround http://llvm.org/PR23628
-#if HAVE_LLVM >= 0x0307
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7)
# pragma pop_macro("DEBUG")
#endif
@@ -126,7 +128,7 @@ static void init_native_targets()
llvm::InitializeNativeTargetAsmPrinter();
llvm::InitializeNativeTargetDisassembler();
-#if DEBUG && HAVE_LLVM >= 0x0306
+#if DEBUG && (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6))
{
char *env_llc_options = getenv("GALLIVM_LLC_OPTIONS");
if (env_llc_options) {
@@ -151,7 +153,7 @@ static void init_native_targets()
extern "C" void
lp_set_target_options(void)
{
-#if HAVE_LLVM < 0x0304
+#if LLVM_VERSION_MAJOR < 3 || (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
@@ -175,7 +177,7 @@ LLVMTargetLibraryInfoRef
gallivm_create_target_library_info(const char *triple)
{
return reinterpret_cast<LLVMTargetLibraryInfoRef>(
-#if HAVE_LLVM < 0x0307
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7)
new llvm::TargetLibraryInfo(
#else
new llvm::TargetLibraryInfoImpl(
@@ -188,7 +190,7 @@ void
gallivm_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info)
{
delete reinterpret_cast<
-#if HAVE_LLVM < 0x0307
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7)
llvm::TargetLibraryInfo
#else
llvm::TargetLibraryInfoImpl
@@ -197,7 +199,7 @@ gallivm_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info)
}
-#if HAVE_LLVM < 0x0304
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4)
extern "C"
void
@@ -220,7 +222,7 @@ LLVMSetAlignmentBackport(LLVMValueRef V,
#endif
-#if HAVE_LLVM < 0x0306
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6)
typedef llvm::JITMemoryManager BaseMemoryManager;
#else
typedef llvm::RTDyldMemoryManager BaseMemoryManager;
@@ -238,7 +240,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
virtual BaseMemoryManager *mgr() const = 0;
public:
-#if HAVE_LLVM < 0x0306
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6)
/*
* From JITMemoryManager
*/
@@ -285,7 +287,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
virtual void deallocateFunctionBody(void *Body) {
mgr()->deallocateFunctionBody(Body);
}
-#if HAVE_LLVM < 0x0304
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4)
virtual uint8_t *startExceptionTable(const llvm::Function *F,
uintptr_t &ActualSize) {
return mgr()->startExceptionTable(F, ActualSize);
@@ -327,7 +329,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
/*
* From RTDyldMemoryManager
*/
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
virtual uint8_t *allocateCodeSection(uintptr_t Size,
unsigned Alignment,
unsigned SectionID,
@@ -345,17 +347,17 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
virtual uint8_t *allocateDataSection(uintptr_t Size,
unsigned Alignment,
unsigned SectionID,
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
llvm::StringRef SectionName,
#endif
bool IsReadOnly) {
return mgr()->allocateDataSection(Size, Alignment, SectionID,
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
SectionName,
#endif
IsReadOnly);
}
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
mgr()->registerEHFrames(Addr, LoadAddr, Size);
}
@@ -368,7 +370,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
virtual void deregisterEHFrames() {
mgr()->deregisterEHFrames();
}
-#elif HAVE_LLVM >= 0x0304
+#elif LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
mgr()->deregisterEHFrames(Addr, LoadAddr, Size);
}
@@ -377,7 +379,7 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
bool AbortOnFailure=true) {
return mgr()->getPointerToNamedFunction(Name, AbortOnFailure);
}
-#if HAVE_LLVM <= 0x0303
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 3)
virtual bool applyPermissions(std::string *ErrMsg = 0) {
return mgr()->applyPermissions(ErrMsg);
}
@@ -418,17 +420,17 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager {
* Deallocate things as previously requested and
* free shared manager when no longer used.
*/
-#if HAVE_LLVM < 0x0306
+#if LLVM_VERSION_MAJOR < 3 || (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 HAVE_LLVM < 0x0304
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4)
for ( i = ExceptionTable.begin(); i != ExceptionTable.end(); ++i )
TheMM->deallocateExceptionTable(*i);
-#endif /* HAVE_LLVM < 0x0304 */
-#endif /* HAVE_LLVM < 0x0306 */
+#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) */
}
};
@@ -460,7 +462,7 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager {
delete (GeneratedCode *) code;
}
-#if HAVE_LLVM < 0x0304
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4)
virtual void deallocateExceptionTable(void *ET) {
// remember for later deallocation
code->ExceptionTable.push_back(ET);
@@ -497,7 +499,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
using namespace llvm;
std::string Error;
-#if HAVE_LLVM >= 0x0306
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6)
EngineBuilder builder(std::unique_ptr<Module>(unwrap(M)));
#else
EngineBuilder builder(unwrap(M));
@@ -510,22 +512,22 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
TargetOptions options;
#if defined(PIPE_ARCH_X86)
options.StackAlignmentOverride = 4;
-#if HAVE_LLVM < 0x0304
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4)
options.RealignStack = true;
#endif
#endif
-#if defined(DEBUG) && HAVE_LLVM < 0x0307
+#if defined(DEBUG) && (LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7))
options.JITEmitDebugInfo = true;
#endif
/* XXX: Workaround http://llvm.org/PR21435 */
#if defined(DEBUG) || defined(PROFILE) || \
- (HAVE_LLVM >= 0x0303 && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)))
-#if HAVE_LLVM < 0x0304
+ ((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)
options.NoFramePointerElimNonLeaf = true;
#endif
-#if HAVE_LLVM < 0x0307
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7)
options.NoFramePointerElim = true;
#endif
#endif
@@ -536,7 +538,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
.setOptLevel((CodeGenOpt::Level)OptLevel);
if (useMCJIT) {
-#if HAVE_LLVM < 0x0306
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6)
builder.setUseMCJIT(true);
#endif
#ifdef _WIN32
@@ -585,12 +587,12 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
MAttrs.push_back(util_cpu_caps.has_sse2 ? "+sse2" : "-sse2" );
MAttrs.push_back(util_cpu_caps.has_sse3 ? "+sse3" : "-sse3" );
MAttrs.push_back(util_cpu_caps.has_ssse3 ? "+ssse3" : "-ssse3" );
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
MAttrs.push_back(util_cpu_caps.has_sse4_1 ? "+sse4.1" : "-sse4.1");
#else
MAttrs.push_back(util_cpu_caps.has_sse4_1 ? "+sse41" : "-sse41" );
#endif
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
MAttrs.push_back(util_cpu_caps.has_sse4_2 ? "+sse4.2" : "-sse4.2");
#else
MAttrs.push_back(util_cpu_caps.has_sse4_2 ? "+sse42" : "-sse42" );
@@ -603,7 +605,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
*/
MAttrs.push_back(util_cpu_caps.has_avx ? "+avx" : "-avx");
MAttrs.push_back(util_cpu_caps.has_f16c ? "+f16c" : "-f16c");
- if (HAVE_LLVM >= 0x0304) {
+ if (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)) {
MAttrs.push_back(util_cpu_caps.has_fma ? "+fma" : "-fma");
} else {
/*
@@ -614,13 +616,13 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
}
MAttrs.push_back(util_cpu_caps.has_avx2 ? "+avx2" : "-avx2");
/* disable avx512 and all subvariants */
-#if HAVE_LLVM >= 0x0304
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)
MAttrs.push_back("-avx512cd");
MAttrs.push_back("-avx512er");
MAttrs.push_back("-avx512f");
MAttrs.push_back("-avx512pf");
#endif
-#if HAVE_LLVM >= 0x0305
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
MAttrs.push_back("-avx512bw");
MAttrs.push_back("-avx512dq");
MAttrs.push_back("-avx512vl");
@@ -636,7 +638,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 (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4))
#if (LLVM_VERSION_MAJOR < 4)
/*
* Make sure VSX instructions are disabled
@@ -679,7 +681,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
}
}
-#if HAVE_LLVM >= 0x0305
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
StringRef MCPU = llvm::sys::getHostCPUName();
/*
* The cpu bits are no longer set automatically, so need to set mcpu manually.
@@ -718,16 +720,16 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
MM = new ShaderMemoryManager(JMM);
*OutCode = MM->getGeneratedCode();
-#if HAVE_LLVM >= 0x0306
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6)
builder.setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager>(MM));
MM = NULL; // ownership taken by std::unique_ptr
-#elif HAVE_LLVM > 0x0303
+#elif LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 3)
builder.setMCJITMemoryManager(MM);
#else
builder.setJITMemoryManager(MM);
#endif
} else {
-#if HAVE_LLVM < 0x0306
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6)
BaseMemoryManager* JMM = reinterpret_cast<BaseMemoryManager*>(CMM);
MM = new ShaderMemoryManager(JMM);
*OutCode = MM->getGeneratedCode();
@@ -769,7 +771,7 @@ LLVMMCJITMemoryManagerRef
lp_get_default_memory_manager()
{
BaseMemoryManager *mm;
-#if HAVE_LLVM < 0x0306
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6)
mm = llvm::JITMemoryManager::CreateDefaultMemManager();
#else
mm = new llvm::SectionMemoryManager();
@@ -787,9 +789,9 @@ lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr)
extern "C" LLVMValueRef
lp_get_called_value(LLVMValueRef call)
{
-#if HAVE_LLVM >= 0x0309
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
return LLVMGetCalledValue(call);
-#elif HAVE_LLVM >= 0x0305
+#elif LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
return llvm::wrap(llvm::CallSite(llvm::unwrap<llvm::Instruction>(call)).getCalledValue());
#else
return NULL; /* radeonsi doesn't support so old LLVM. */
@@ -799,14 +801,14 @@ lp_get_called_value(LLVMValueRef call)
extern "C" bool
lp_is_function(LLVMValueRef v)
{
-#if HAVE_LLVM >= 0x0309
+#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 HAVE_LLVM < 0x309
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9)
static llvm::AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
switch (Ordering) {
case LLVMAtomicOrderingNotAtomic: return llvm::AtomicOrdering::NotAtomic;
@@ -831,14 +833,14 @@ LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
{
return llvm::wrap(llvm::unwrap(B)->CreateAtomicCmpXchg(llvm::unwrap(Ptr), llvm::unwrap(Cmp),
llvm::unwrap(New), mapFromLLVMOrdering(SuccessOrdering),
-#if HAVE_LLVM >= 0x305
+#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
mapFromLLVMOrdering(FailureOrdering),
#endif
SingleThread ? llvm::SynchronizationScope::SingleThread : llvm::SynchronizationScope::CrossThread));
}
#endif
-#if HAVE_LLVM < 0x305
+#if LLVM_VERSION_MAJOR < 3 || (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 67c2cfd3fc4..7d2e9ca07ca 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.h
@@ -31,6 +31,7 @@
#include "lp_bld.h"
+#include <llvm/Config/llvm-config.h>
#include <llvm-c/ExecutionEngine.h>
#include <llvm-c/Target.h>
@@ -77,7 +78,7 @@ extern bool
lp_is_function(LLVMValueRef v);
/* LLVM 3.9 introduces this, provide our own for earlier */
-#if HAVE_LLVM < 0x309
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 9)
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
LLVMValueRef Cmp, LLVMValueRef New,
LLVMAtomicOrdering SuccessOrdering,
@@ -85,7 +86,7 @@ LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
LLVMBool SingleThread);
#endif
-#if HAVE_LLVM < 0x305
+#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5)
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B,
LLVMAtomicOrdering ordering,
LLVMBool singleThread, const char *Name);