#endif
#include <llvm-c/BitWriter.h>
#if GALLIVM_HAVE_CORO
+#if LLVM_VERSION_MAJOR <= 8 && (defined(PIPE_ARCH_AARCH64) || defined (PIPE_ARCH_ARM) || defined(PIPE_ARCH_S390))
+#include <llvm-c/Transforms/IPO.h>
+#endif
#include <llvm-c/Transforms/Coroutines.h>
#endif
}
#if GALLIVM_HAVE_CORO
+#if LLVM_VERSION_MAJOR <= 8 && (defined(PIPE_ARCH_AARCH64) || defined (PIPE_ARCH_ARM) || defined(PIPE_ARCH_S390))
+ LLVMAddArgumentPromotionPass(gallivm->cgpassmgr);
+ LLVMAddFunctionAttrsPass(gallivm->cgpassmgr);
+#endif
LLVMAddCoroEarlyPass(gallivm->cgpassmgr);
LLVMAddCoroSplitPass(gallivm->cgpassmgr);
LLVMAddCoroElidePass(gallivm->cgpassmgr);
*/
LLVMAddReassociatePass(gallivm->passmgr);
LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
+#if LLVM_VERSION_MAJOR <= 11
LLVMAddConstantPropagationPass(gallivm->passmgr);
+#endif
LLVMAddInstructionCombiningPass(gallivm->passmgr);
LLVMAddGVNPass(gallivm->passmgr);
-#if GALLIVM_HAVE_CORO
- LLVMAddCoroCleanupPass(gallivm->passmgr);
-#endif
}
else {
/* We need at least this pass to prevent the backends to fail in
*/
LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
}
+#if GALLIVM_HAVE_CORO
+ LLVMAddCoroCleanupPass(gallivm->passmgr);
+#endif
return TRUE;
}
LLVMDisposeModule(gallivm->module);
}
+ if (gallivm->cache) {
+ lp_free_objcache(gallivm->cache->jit_obj_cache);
+ free(gallivm->cache->data);
+ }
FREE(gallivm->module_name);
if (gallivm->target) {
gallivm->passmgr = NULL;
gallivm->context = NULL;
gallivm->builder = NULL;
+ gallivm->cache = NULL;
}
ret = lp_build_create_jit_compiler_for_module(&gallivm->engine,
&gallivm->code,
+ gallivm->cache,
gallivm->module,
gallivm->memorymgr,
(unsigned) optlevel,
*/
static boolean
init_gallivm_state(struct gallivm_state *gallivm, const char *name,
- LLVMContextRef context)
+ LLVMContextRef context, struct lp_cached_code *cache)
{
assert(!gallivm->context);
assert(!gallivm->module);
return FALSE;
gallivm->context = context;
-
+ gallivm->cache = cache;
if (!gallivm->context)
goto fail;
const unsigned pointer_size = 8 * sizeof(void *);
char layout[512];
snprintf(layout, sizeof layout, "%c-p:%u:%u:%u-i64:64:64-a0:0:%u-s0:%u:%u",
-#ifdef PIPE_ARCH_LITTLE_ENDIAN
+#if UTIL_ARCH_LITTLE_ENDIAN
'e', // little endian
#else
'E', // big endian
}
#endif
- /* AMD Bulldozer AVX's throughput is the same as SSE2; and because using
- * 8-wide vector needs more floating ops than 4-wide (due to padding), it is
- * actually more efficient to use 4-wide vectors on this processor.
- *
- * See also:
- * - http://www.anandtech.com/show/4955/the-bulldozer-review-amd-fx8150-tested/2
- */
- if (util_cpu_caps.has_avx &&
- util_cpu_caps.has_intel) {
+ if (util_cpu_caps.has_avx2 || util_cpu_caps.has_avx) {
lp_native_vector_width = 256;
} else {
/* Leave it at 128, even when no SIMD extensions are available.
*/
lp_native_vector_width = 128;
}
-
+
lp_native_vector_width = debug_get_num_option("LP_NATIVE_VECTOR_WIDTH",
lp_native_vector_width);
+#if LLVM_VERSION_MAJOR < 4
if (lp_native_vector_width <= 128) {
/* Hide AVX support, as often LLVM AVX intrinsics are only guarded by
* "util_cpu_caps.has_avx" predicate, and lack the
util_cpu_caps.has_f16c = 0;
util_cpu_caps.has_fma = 0;
}
+#endif
#ifdef PIPE_ARCH_PPC_64
/* Set the NJ bit in VSCR to 0 so denormalized values are handled as
* Create a new gallivm_state object.
*/
struct gallivm_state *
-gallivm_create(const char *name, LLVMContextRef context)
+gallivm_create(const char *name, LLVMContextRef context,
+ struct lp_cached_code *cache)
{
struct gallivm_state *gallivm;
gallivm = CALLOC_STRUCT(gallivm_state);
if (gallivm) {
- if (!init_gallivm_state(gallivm, name, context)) {
+ if (!init_gallivm_state(gallivm, name, context, cache)) {
FREE(gallivm);
gallivm = NULL;
}
}
+ assert(gallivm != NULL);
return gallivm;
}
gallivm->builder = NULL;
}
+ if (gallivm->cache && gallivm->cache->data_size) {
+ goto skip_cached;
+ }
+
/* Dump bitcode to a file */
if (gallivm_debug & GALLIVM_DEBUG_DUMP_BC) {
char filename[256];
* implicitly created by the EngineBuilder in
* lp_build_create_jit_compiler_for_module()
*/
+ skip_cached:
LLVMSetDataLayout(gallivm->module, "");
assert(!gallivm->engine);
if (!init_gallivm_engine(gallivm)) {
++gallivm->compiled;
+ if (gallivm->debug_printf_hook)
+ LLVMAddGlobalMapping(gallivm->engine, gallivm->debug_printf_hook, debug_printf);
+
if (gallivm_debug & GALLIVM_DEBUG_ASM) {
LLVMValueRef llvm_func = LLVMGetFirstFunction(gallivm->module);