summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-08-16 11:50:17 +0100
committerJosé Fonseca <[email protected]>2009-08-29 09:21:32 +0100
commit818d444e12bb57568fbf3bf5f06ee24c6c73a61a (patch)
tree4abd55212b63a898e8e5d56d77f0a9959ce2ff84 /src/gallium/drivers
parenta7f9b915aeade96d8ca58d70a1f1d42cd6a16e3d (diff)
llvmpipe: Disassemble generated x86 code.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/llvmpipe/README10
-rw-r--r--src/gallium/drivers/llvmpipe/SConscript2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_debug.c70
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_debug.h37
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_blend.c7
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c5
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_blend.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_conv.c4
8 files changed, 137 insertions, 2 deletions
diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README
index afa9cbaf3ee..af0ef2b317c 100644
--- a/src/gallium/drivers/llvmpipe/README
+++ b/src/gallium/drivers/llvmpipe/README
@@ -6,11 +6,19 @@ Requirements
- Linux
+ - udis86, http://udis86.sourceforge.net/
+
+ git clone git://udis86.git.sourceforge.net/gitroot/udis86
+ cd udis86
+ ./configure --with-pic
+ make
+ sudo make install
+
- LLVM. On Debian based distributions do:
aptitude install llvm-dev
- There is a type in one of the llvm-dev 2.5 headers, that causes compilation
+ There is a typo in one of the llvm-dev 2.5 headers, that causes compilation
errors in the debug build:
--- /usr/include/llvm-c/Core.h.orig 2009-08-10 15:38:54.000000000 +0100
diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript
index 154964bf7ac..cdd301b0291 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -12,6 +12,7 @@ llvmpipe = env.ConvenienceLibrary(
'lp_bld_blend_soa.c',
'lp_bld_const.c',
'lp_bld_conv.c',
+ 'lp_bld_debug.c',
'lp_bld_intr.c',
'lp_bld_pack.c',
'lp_bld_unpack.c',
@@ -55,6 +56,7 @@ llvmpipe = env.ConvenienceLibrary(
env = env.Clone()
+env.Prepend(LIBS = 'udis86')
env['LINK'] = env['CXX']
env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
env.Prepend(LIBS = [llvmpipe] + auxiliaries)
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_debug.c b/src/gallium/drivers/llvmpipe/lp_bld_debug.c
new file mode 100644
index 00000000000..49a6065a8cd
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_bld_debug.c
@@ -0,0 +1,70 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <udis86.h>
+
+#include "util/u_debug.h"
+#include "lp_bld_debug.h"
+
+
+void
+lp_disassemble(const void* func)
+{
+ ud_t ud_obj;
+
+ ud_init(&ud_obj);
+
+ ud_set_input_buffer(&ud_obj, (void*)func, 0xffff);
+ ud_set_pc(&ud_obj, (uint64_t) (uintptr_t) func);
+
+#ifdef PIPE_ARCH_X86
+ ud_set_mode(&ud_obj, 32);
+#endif
+#ifdef PIPE_ARCH_X86_64
+ ud_set_mode(&ud_obj, 64);
+#endif
+
+ ud_set_syntax(&ud_obj, UD_SYN_ATT);
+
+ while (ud_disassemble(&ud_obj)) {
+#ifdef PIPE_ARCH_X86
+ debug_printf("%08lx:\t%s\n",
+ (unsigned long)ud_insn_off(&ud_obj),
+ ud_insn_asm(&ud_obj));
+#endif
+#ifdef PIPE_ARCH_X86_64
+ debug_printf("%016llx:\t%s\n",
+ (unsigned long long)ud_insn_off(&ud_obj),
+ ud_insn_asm(&ud_obj));
+#endif
+
+ if (ud_obj.mnemonic == UD_Iret)
+ break;
+ }
+ debug_printf("\n");
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_debug.h b/src/gallium/drivers/llvmpipe/lp_bld_debug.h
new file mode 100644
index 00000000000..d83652504bb
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_bld_debug.h
@@ -0,0 +1,37 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef LP_BLD_DEBUG_H
+#define LP_BLD_DEBUG_H
+
+
+void
+lp_disassemble(const void* func);
+
+
+#endif /* !LP_BLD_DEBUG_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c
index be3e7b16291..d31fc6c5fa6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c
@@ -41,6 +41,7 @@
#include "lp_bld_type.h"
#include "lp_bld_arit.h"
#include "lp_bld_blend.h"
+#include "lp_bld_debug.h"
static void
@@ -127,7 +128,7 @@ llvmpipe_create_blend_state(struct pipe_context *pipe,
LLVMRunFunctionPassManager(screen->pass, blend->function);
-#if 1
+#ifdef DEBUG
debug_printf("%s=%s %s=%s %s=%s %s=%s %s=%s %s=%s\n",
"rgb_func", debug_dump_blend_func (blend->base.rgb_func, TRUE),
"rgb_src_factor", debug_dump_blend_factor(blend->base.rgb_src_factor, TRUE),
@@ -146,6 +147,10 @@ llvmpipe_create_blend_state(struct pipe_context *pipe,
blend->jit_function = (lp_blend_func)LLVMGetPointerToGlobal(screen->engine, blend->function);
+#ifdef DEBUG
+ lp_disassemble(blend->jit_function);
+#endif
+
return blend;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index b9bb7abb0b0..157f4eb59c9 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -36,6 +36,7 @@
#include "tgsi/tgsi_parse.h"
#include "lp_bld_type.h"
#include "lp_bld_tgsi.h"
+#include "lp_bld_debug.h"
#include "lp_screen.h"
#include "lp_context.h"
#include "lp_state.h"
@@ -188,6 +189,10 @@ llvmpipe_create_fs_state(struct pipe_context *pipe,
shader->jit_function = (lp_shader_fs_func)LLVMGetPointerToGlobal(screen->engine, shader->function);
+#ifdef DEBUG
+ lp_disassemble(shader->jit_function);
+#endif
+
return shader;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index 645d3880b90..0b6d2da590a 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -40,6 +40,7 @@
#include "lp_bld_type.h"
#include "lp_bld_arit.h"
#include "lp_bld_blend.h"
+#include "lp_bld_debug.h"
#include "lp_test.h"
@@ -526,6 +527,9 @@ test_one(unsigned verbose,
blend_test_ptr = (blend_test_ptr_t)LLVMGetPointerToGlobal(engine, func);
+ if(verbose >= 2)
+ lp_disassemble(blend_test_ptr);
+
success = TRUE;
for(i = 0; i < n && success; ++i) {
if(mode == AoS) {
diff --git a/src/gallium/drivers/llvmpipe/lp_test_conv.c b/src/gallium/drivers/llvmpipe/lp_test_conv.c
index 7e8b9347c22..91815509b79 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_conv.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_conv.c
@@ -36,6 +36,7 @@
#include "lp_bld_type.h"
#include "lp_bld_conv.h"
+#include "lp_bld_debug.h"
#include "lp_test.h"
@@ -217,6 +218,9 @@ test_one(unsigned verbose,
conv_test_ptr = (conv_test_ptr_t)LLVMGetPointerToGlobal(engine, func);
+ if(verbose >= 2)
+ lp_disassemble(conv_test_ptr);
+
success = TRUE;
for(i = 0; i < n && success; ++i) {
unsigned src_stride = src_type.length*src_type.width/8;