gallivm: Centralize some of the LLVM debugging options.
authorJosé Fonseca <jfonseca@vmware.com>
Sat, 15 May 2010 10:42:02 +0000 (11:42 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Sat, 15 May 2010 10:42:02 +0000 (11:42 +0100)
src/gallium/auxiliary/gallivm/lp_bld_debug.h
src/gallium/auxiliary/gallivm/lp_bld_init.c

index 1897acce795403e35d1fb37d559cb4ec60298015..858002b34feda33fb79b838242f9c067e4083504 100644 (file)
 #include "util/u_string.h"
 
 
+#define GALLIVM_DEBUG_TGSI      0x1
+#define GALLIVM_DEBUG_IR        0x2
+#define GALLIVM_DEBUG_ASM       0x4
+#define GALLIVM_DEBUG_NO_OPT    0x8
+
+
+#ifdef DEBUG
+extern unsigned gallivm_debug;
+#else
+#define gallivm_debug 0
+#endif
+
+
 static INLINE void
 lp_build_name(LLVMValueRef val, const char *format, ...)
 {
index 5067d0a164f4cf7b9d3ee5c3483ad59ec6054c58..bd080f397aa0f73907a4ae67a8f7c3d7773a9629 100644 (file)
 #include "pipe/p_compiler.h"
 #include "util/u_cpu_detect.h"
 #include "util/u_debug.h"
+#include "lp_bld_debug.h"
 #include "lp_bld_init.h"
 
 
+#ifdef DEBUG
+unsigned gallivm_debug = 0;
+
+static const struct debug_named_value lp_bld_debug_flags[] = {
+   { "tgsi",   GALLIVM_DEBUG_TGSI },
+   { "ir",     GALLIVM_DEBUG_IR },
+   { "asm",    GALLIVM_DEBUG_ASM },
+   { "nopt",   GALLIVM_DEBUG_NO_OPT },
+   {NULL, 0}
+};
+#endif
+
+
 LLVMModuleRef lp_build_module = NULL;
 LLVMExecutionEngineRef lp_build_engine = NULL;
 LLVMModuleProviderRef lp_build_provider = NULL;
@@ -41,6 +55,10 @@ LLVMTargetDataRef lp_build_target = NULL;
 void
 lp_build_init(void)
 {
+#ifdef DEBUG
+   gallivm_debug = debug_get_flags_option("GALLIVM_DEBUG", lp_bld_debug_flags, 0 );
+#endif
+
    LLVMInitializeNativeTarget();
 
    LLVMLinkInJIT();