Merge branch 'glsl2-head' into glsl2
[mesa.git] / src / gallium / drivers / llvmpipe / lp_jit.c
index 8690941a507d4ccc5749c32cbb9288c2577811b1..23aa34ddec1c65d89aa0471816cb1ddcdd5a5346 100644 (file)
@@ -38,7 +38,7 @@
 #include "util/u_memory.h"
 #include "util/u_cpu_detect.h"
 #include "gallivm/lp_bld_init.h"
-#include "lp_debug.h"
+#include "gallivm/lp_bld_debug.h"
 #include "lp_screen.h"
 #include "gallivm/lp_bld_intr.h"
 #include "lp_jit.h"
@@ -151,9 +151,9 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
       screen->context_ptr_type = LLVMPointerType(context_type, 0);
    }
 
-#ifdef DEBUG
-   LLVMDumpModule(screen->module);
-#endif
+   if (gallivm_debug & GALLIVM_DEBUG_IR) {
+      LLVMDumpModule(screen->module);
+   }
 }
 
 
@@ -171,15 +171,6 @@ lp_jit_screen_cleanup(struct llvmpipe_screen *screen)
 void
 lp_jit_screen_init(struct llvmpipe_screen *screen)
 {
-   util_cpu_detect();
-
-#if 0
-   /* For simulating less capable machines */
-   util_cpu_caps.has_sse3 = 0;
-   util_cpu_caps.has_ssse3 = 0;
-   util_cpu_caps.has_sse4_1 = 0;
-#endif
-
    lp_build_init();
 
    screen->module = lp_build_module;
@@ -190,10 +181,12 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
    screen->pass = LLVMCreateFunctionPassManager(screen->provider);
    LLVMAddTargetData(screen->target, screen->pass);
 
-   if ((LP_DEBUG & DEBUG_NO_LLVM_OPT) == 0) {
+   if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) {
       /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
        * but there are more on SVN. */
       /* TODO: Add more passes */
+      LLVMAddCFGSimplificationPass(screen->pass);
+      LLVMAddPromoteMemoryToRegisterPass(screen->pass);
       LLVMAddConstantPropagationPass(screen->pass);
       if(util_cpu_caps.has_sse4_1) {
          /* FIXME: There is a bug in this pass, whereby the combination of fptosi
@@ -202,9 +195,12 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
           */
          LLVMAddInstructionCombiningPass(screen->pass);
       }
-      LLVMAddPromoteMemoryToRegisterPass(screen->pass);
       LLVMAddGVNPass(screen->pass);
-      LLVMAddCFGSimplificationPass(screen->pass);
+   } else {
+      /* We need at least this pass to prevent the backends to fail in
+       * unexpected ways.
+       */
+      LLVMAddPromoteMemoryToRegisterPass(screen->pass);
    }
 
    lp_jit_init_globals(screen);