From: Tim Rowley Date: Mon, 31 Oct 2016 15:29:07 +0000 (-0500) Subject: gallivm: use getHostCPUFeatures on x86/llvm-4.0+. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b035d9cab5a483f0ceee2d8fad578f64aca1888a;p=mesa.git gallivm: use getHostCPUFeatures on x86/llvm-4.0+. Use llvm provided API based on cpuid rather than our own manually mantained list of mattr enabling/disabling. Reviewed-by: Roland Scheidegger --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index a68428d5d3b..21d9e15f1a9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -542,6 +542,20 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, llvm::SmallVector MAttrs; #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) +#if HAVE_LLVM >= 0x0400 + /* llvm-3.7+ implements sys::getHostCPUFeatures for x86, + * which allows us to enable/disable code generation based + * on the results of cpuid. + */ + llvm::StringMap features; + llvm::sys::getHostCPUFeatures(features); + + for (StringMapIterator f = features.begin(); + f != features.end(); + ++f) { + MAttrs.push_back(((*f).second ? "+" : "-") + (*f).first().str()); + } +#else /* * We need to unset attributes because sometimes LLVM mistakenly assumes * certain features are present given the processor name. @@ -596,6 +610,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, MAttrs.push_back("-avx512vl"); #endif #endif +#endif #if defined(PIPE_ARCH_PPC) MAttrs.push_back(util_cpu_caps.has_altivec ? "+altivec" : "-altivec");