gallivm: Move the global LLVM objects (module, engine, provider, target) into here.

This commit is contained in:
José Fonseca
2010-04-06 22:37:08 +01:00
parent 859642c655
commit 306835cc0f
5 changed files with 43 additions and 43 deletions
+2 -2
View File
@@ -152,6 +152,7 @@ GALLIVM_SOURCES = \
gallivm/lp_bld_depth.c \
gallivm/lp_bld_flow.c \
gallivm/lp_bld_format_soa.c \
gallivm/lp_bld_init.c \
gallivm/lp_bld_interp.c \
gallivm/lp_bld_intr.c \
gallivm/lp_bld_logic.c \
@@ -164,8 +165,7 @@ GALLIVM_SOURCES = \
gallivm/lp_bld_tgsi_soa.c \
gallivm/lp_bld_type.c
GALLIVM_CPP_SOURCES = \
gallivm/lp_bld_init.cpp
GALLIVM_CPP_SOURCES =
GENERATED_SOURCES = \
indices/u_indices_gen.c \
+1 -1
View File
@@ -204,7 +204,7 @@ if drawllvm:
'gallivm/lp_bld_interp.c',
'gallivm/lp_bld_intr.c',
'gallivm/lp_bld_logic.c',
'gallivm/lp_bld_init.cpp',
'gallivm/lp_bld_init.c',
'gallivm/lp_bld_pack.c',
'gallivm/lp_bld_printf.c',
'gallivm/lp_bld_sample.c',
@@ -26,33 +26,42 @@
**************************************************************************/
#include <llvm/Config/config.h>
#include <llvm/Target/TargetSelect.h>
#include <llvm/Target/TargetOptions.h>
#include "pipe/p_config.h"
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
#include "lp_bld_init.h"
extern "C" void LLVMLinkInJIT();
LLVMModuleRef lp_build_module = NULL;
LLVMExecutionEngineRef lp_build_engine = NULL;
LLVMModuleProviderRef lp_build_provider = NULL;
LLVMTargetDataRef lp_build_target = NULL;
extern "C" void
void
lp_build_init(void)
{
#if defined(PIPE_OS_WINDOWS) && defined(PIPE_ARCH_X86)
/*
* This is mis-detected on some hardware / software combinations.
*/
llvm::StackAlignment = 4;
llvm::RealignStack = true;
#endif
/* Same as LLVMInitializeNativeTarget(); */
llvm::InitializeNativeTarget();
LLVMInitializeNativeTarget();
LLVMLinkInJIT();
if (!lp_build_module)
lp_build_module = LLVMModuleCreateWithName("gallivm");
if (!lp_build_provider)
lp_build_provider = LLVMCreateModuleProviderForExistingModule(lp_build_module);
if (!lp_build_engine) {
char *error = NULL;
if (LLVMCreateJITCompiler(&lp_build_engine, lp_build_provider, 1, &error)) {
_debug_printf("%s\n", error);
LLVMDisposeMessage(error);
assert(0);
}
}
if (!lp_build_target)
lp_build_target = LLVMGetExecutionEngineTargetData(lp_build_engine);
}
@@ -64,6 +73,6 @@ lp_build_init(void)
*/
#if defined(_MSC_VER) && defined(_DEBUG)
#include <crtdefs.h>
extern "C" _CRTIMP void __cdecl
_CRTIMP void __cdecl
_invalid_parameter_noinfo(void) {}
#endif
+8 -8
View File
@@ -30,18 +30,18 @@
#define LP_BLD_INIT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "lp_bld.h"
#include <llvm-c/ExecutionEngine.h>
extern LLVMModuleRef lp_build_module;
extern LLVMExecutionEngineRef lp_build_engine;
extern LLVMModuleProviderRef lp_build_provider;
extern LLVMTargetDataRef lp_build_target;
void
lp_build_init(void);
#ifdef __cplusplus
}
#endif
#endif /* !LP_BLD_INIT_H */
+4 -13
View File
@@ -166,8 +166,6 @@ lp_jit_screen_cleanup(struct llvmpipe_screen *screen)
void
lp_jit_screen_init(struct llvmpipe_screen *screen)
{
char *error = NULL;
util_cpu_detect();
#if 0
@@ -179,17 +177,10 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
lp_build_init();
screen->module = LLVMModuleCreateWithName("llvmpipe");
screen->provider = LLVMCreateModuleProviderForExistingModule(screen->module);
if (LLVMCreateJITCompiler(&screen->engine, screen->provider, 1, &error)) {
_debug_printf("%s\n", error);
LLVMDisposeMessage(error);
assert(0);
}
screen->target = LLVMGetExecutionEngineTargetData(screen->engine);
screen->module = lp_build_module;
screen->provider = lp_build_provider;
screen->engine = lp_build_engine;
screen->target = lp_build_target;
screen->pass = LLVMCreateFunctionPassManager(screen->provider);
LLVMAddTargetData(screen->target, screen->pass);