gallivm: Override some of the default target options.
authorJosé Fonseca <jfonseca@vmware.com>
Sun, 13 Jun 2010 12:13:11 +0000 (13:13 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 14 Jun 2010 15:51:47 +0000 (16:51 +0100)
In particular:
- enable LLVM <-> GDB integration for JIT code
- disable frame-pointer elimination on debug/profile builds
- enable fast-math.

src/gallium/auxiliary/gallivm/lp_bld_init.c
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp

index 0a690ea7476953732073c842da76e7c6b060137a..44cfdc4d3fbea794a8770485e7a5497507921c3c 100644 (file)
@@ -78,6 +78,9 @@ enum LLVM_CodeGenOpt_Level {
 extern void
 lp_register_oprofile_jit_event_listener(LLVMExecutionEngineRef EE);
 
+extern void
+lp_set_target_options(void);
+
 
 void
 lp_build_init(void)
@@ -86,6 +89,8 @@ lp_build_init(void)
    gallivm_debug = debug_get_flags_option("GALLIVM_DEBUG", lp_bld_debug_flags, 0 );
 #endif
 
+   lp_set_target_options();
+
    LLVMInitializeNativeTarget();
 
    LLVMLinkInJIT();
index f004c0ae45141d5b56c116f611c8cb1960a57082..87e9f0048781a725d136ffbc28aa8b1a1bc46587 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <llvm-c/Core.h>
 #include <llvm-c/ExecutionEngine.h>
+#include <llvm/Target/TargetOptions.h>
 #include <llvm/ExecutionEngine/ExecutionEngine.h>
 #include <llvm/ExecutionEngine/JITEventListener.h>
 
@@ -119,3 +120,28 @@ lp_register_oprofile_jit_event_listener(LLVMExecutionEngineRef EE)
 {
    llvm::unwrap(EE)->RegisterJITEventListener(llvm::createOProfileJITEventListener());
 }
+
+
+extern "C" void
+lp_set_target_options(void)
+{
+#if defined(DEBUG)
+#if HAVE_LLVM >= 0x0207
+   llvm::JITEmitDebugInfo = true;
+#endif
+#endif
+
+#if defined(DEBUG) || defined(PROFILE)
+   llvm::NoFramePointerElim = true;
+#if HAVE_LLVM >= 0x0207
+   llvm::NoFramePointerElimNonLeaf = true;
+#endif
+#endif
+
+   llvm::NoExcessFPPrecision = false;
+
+   /* XXX: Investigate this */
+#if 0
+   llvm::UnsafeFPMath = true;
+#endif
+}