Commit 96b59269 authored by Adam Jackson's avatar Adam Jackson 🥃 Committed by Adam Jackson

gallium: Require LLVM >= 3.9

To go any further than this would be to break the current version of
Android.
Reviewed-by: Timothy Arceri's avatarTimothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Jose Fonseca's avatarJose Fonseca <jfonseca@vmware.com>
parent 585d0956
Pipeline #62903 passed with stages
in 57 minutes and 42 seconds
......@@ -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
......
......@@ -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')
......
......@@ -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',
......
......@@ -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) {
......
......@@ -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.
......
......@@ -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
......@@ -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
......
......@@ -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
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment