gallivm: Centralize initialization. Fix stack alignment issues on Windows.

This commit is contained in:
José Fonseca 2010-03-03 12:00:08 +00:00
parent f58ca9b02b
commit a9e6da7b4c
2 changed files with 21 additions and 36 deletions

View File

@ -26,41 +26,36 @@
**************************************************************************/ **************************************************************************/
#include <llvm/Config/config.h>
#include <llvm/Target/TargetSelect.h>
#include <llvm/Target/TargetOptions.h>
#include "pipe/p_config.h" #include "pipe/p_config.h"
#include "lp_bld_init.h" #include "lp_bld_init.h"
#ifndef LLVM_NATIVE_ARCH extern "C" void LLVMLinkInJIT();
namespace llvm {
extern void LinkInJIT();
}
void extern "C" void
LLVMLinkInJIT(void) lp_build_init(void)
{ {
llvm::LinkInJIT(); #if defined(PIPE_OS_WINDOWS) && defined(PIPE_ARCH_X86)
} /*
* This is mis-detected on some hardware / software combinations.
*/
extern "C" int X86TargetMachineModule; llvm::StackAlignment = 4;
llvm::RealignStack = true;
int
LLVMInitializeNativeTarget(void)
{
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
X86TargetMachineModule = 1;
#endif #endif
return 0;
/* Same as LLVMInitializeNativeTarget(); */
llvm::InitializeNativeTarget();
LLVMLinkInJIT();
} }
#endif
/* /*
* Hack to allow the linking of release LLVM static libraries on a debug build. * Hack to allow the linking of release LLVM static libraries on a debug build.
* *
@ -69,7 +64,6 @@ LLVMInitializeNativeTarget(void)
*/ */
#if defined(_MSC_VER) && defined(_DEBUG) #if defined(_MSC_VER) && defined(_DEBUG)
#include <crtdefs.h> #include <crtdefs.h>
extern "C" { extern "C" _CRTIMP void __cdecl
_CRTIMP void __cdecl _invalid_parameter_noinfo(void) {} _invalid_parameter_noinfo(void) {}
}
#endif #endif

View File

@ -30,22 +30,13 @@
#define LP_BLD_INIT_H #define LP_BLD_INIT_H
#include "llvm/Config/config.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef LLVM_NATIVE_ARCH
void void
LLVMLinkInJIT(void); lp_build_init(void);
int
LLVMInitializeNativeTarget(void);
#endif /* !LLVM_NATIVE_ARCH */
#ifdef __cplusplus #ifdef __cplusplus