Mesa (master): gallivm: added lp_dump_llvmtype() debug helper

Brian Paul brianp at kemper.freedesktop.org
Thu May 13 20:17:13 UTC 2010


Module: Mesa
Branch: master
Commit: 45d6289fab1aa012f265e5b51a10c2a07c85679b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=45d6289fab1aa012f265e5b51a10c2a07c85679b

Author: Brian Paul <brianp at vmware.com>
Date:   Thu May 13 10:24:10 2010 -0600

gallivm: added lp_dump_llvmtype() debug helper

---

 src/gallium/auxiliary/gallivm/lp_bld_type.c |   36 +++++++++++++++++++++++++++
 src/gallium/auxiliary/gallivm/lp_bld_type.h |    4 +++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c
index 9028963..37d278d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_type.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c
@@ -285,6 +285,42 @@ lp_typekind_name(LLVMTypeKind t)
 }
 
 
+/**
+ * Print an LLVMTypeRef.  Like LLVMDumpValue().  For debugging.
+ */
+void
+lp_dump_llvmtype(LLVMTypeRef t)
+{
+   LLVMTypeKind k = LLVMGetTypeKind(t);
+
+   if (k == LLVMVectorTypeKind) {
+      LLVMTypeRef te = LLVMGetElementType(t);
+      LLVMTypeKind ke = LLVMGetTypeKind(te);
+      unsigned len = LLVMGetVectorSize(t);
+      if (ke == LLVMIntegerTypeKind) {
+         unsigned b = LLVMGetIntTypeWidth(te);
+         debug_printf("Vector [%u] of %u-bit Integer\n", len, b);
+      }
+      else {
+         debug_printf("Vector [%u] of %s\n", len, lp_typekind_name(ke));
+      }
+   }
+   else if (k == LLVMArrayTypeKind) {
+      LLVMTypeRef te = LLVMGetElementType(t);
+      LLVMTypeKind ke = LLVMGetTypeKind(te);
+      unsigned len = LLVMGetArrayLength(t);
+      debug_printf("Array [%u] of %s\n", len, lp_typekind_name(ke));
+   }
+   else if (k == LLVMIntegerTypeKind) {
+      unsigned b = LLVMGetIntTypeWidth(t);
+      debug_printf("%u-bit Integer\n", b);
+   }
+   else {
+      debug_printf("%s\n", lp_typekind_name(k));
+   }
+}
+
+
 void
 lp_build_context_init(struct lp_build_context *bld,
                       LLVMBuilderRef builder,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h
index f1922ef..b3f9e91 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_type.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h
@@ -321,6 +321,10 @@ lp_typekind_name(LLVMTypeKind t);
 
 
 void
+lp_dump_llvmtype(LLVMTypeRef t);
+
+
+void
 lp_build_context_init(struct lp_build_context *bld,
                       LLVMBuilderRef builder,
                       struct lp_type type);




More information about the mesa-commit mailing list