Re: [llvm-commits] llvm-gcc4: display the LLVM type when printing type trees

2007-02-19 Thread Duncan Sands
 Very cool.  However, it doesn't apply to CVS right.  GET_TYPE_LLVM  
 needs to go through the LTypes vector now, can you plz update the patch?

Here you go.  I put GET_TYPE_LLVM back into tree.h (it was moved into
llvm-types.cpp recently) so that print-tree.c can get at it.  I only
made a C version available, to discourage use outside of llvm-types.cpp.

Ciao,

Duncan.
Index: gcc.llvm.master/gcc/print-tree.c
===
--- gcc.llvm.master.orig/gcc/print-tree.c	2007-02-19 12:19:15.0 +0100
+++ gcc.llvm.master/gcc/print-tree.c	2007-02-19 12:51:11.0 +0100
@@ -603,6 +603,16 @@
 
   lang_hooks.print_type (file, node, indent);
 
+  /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+  if (GET_TYPE_LLVM (node))
+	{
+	  indent_to (file, indent + 4);
+	  print_llvm_type (file, GET_TYPE_LLVM (node));
+	}
+#endif
+  /* APPLE LOCAL end LLVM */
+
   if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
 	indent_to (file, indent + 3);
 
Index: gcc.llvm.master/gcc/llvm-backend.cpp
===
--- gcc.llvm.master.orig/gcc/llvm-backend.cpp	2007-02-19 12:37:23.0 +0100
+++ gcc.llvm.master/gcc/llvm-backend.cpp	2007-02-19 12:51:11.0 +0100
@@ -917,4 +917,13 @@
   WriteAsOperand(FS, (Value*)LLVM, true, TheModule);
 }
 
+// print_llvm_type - Print the specified LLVM type symbolically, called by
+// print-tree.c for tree dumps.
+//
+void print_llvm_type(FILE *file, void *LLVM) {
+  oFILEstream FS(file);
+  FS  LLVM: ;
+  WriteTypeSymbolic(FS, (const Type*)LLVM, TheModule);
+}
+
 /* APPLE LOCAL end LLVM (ENTIRE FILE!)  */
Index: gcc.llvm.master/gcc/llvm.h
===
--- gcc.llvm.master.orig/gcc/llvm.h	2007-02-19 12:50:55.0 +0100
+++ gcc.llvm.master/gcc/llvm.h	2007-02-19 12:51:11.0 +0100
@@ -80,6 +80,11 @@
  */
 void print_llvm(FILE *file, void *LLVM);
 
+/* print_llvm_type - Print the specified LLVM type symbolically, called by
+ * print-tree.c for tree dumps.
+ */
+void print_llvm_type(FILE *file, void *LLVM);
+
 /* Init pch writing. */
 void llvm_pch_write_init(void);
 
Index: gcc.llvm.master/gcc/tree.h
===
--- gcc.llvm.master.orig/gcc/tree.h	2007-02-19 12:37:23.0 +0100
+++ gcc.llvm.master/gcc/tree.h	2007-02-19 14:20:41.0 +0100
@@ -2095,6 +2095,14 @@
 /* The DECL_LLVM for NODE, if it is set, or NULL, if it is not set.  */
 #define DECL_LLVM_IF_SET(NODE) \
   (DECL_LLVM_SET_P (NODE) ? DECL_LLVM (NODE) : NULL)
+
+#ifndef __cplusplus
+/* C version, for debugging */
+extern void *llvm_get_type(unsigned);
+#define GET_TYPE_LLVM(NODE) \
+  (void *)llvm_get_type( TYPE_CHECK (NODE)-type.symtab.llvm)
+#endif
+
 #endif
 /* APPLE LOCAL end LLVM */
 
Index: gcc.llvm.master/gcc/llvm-types.cpp
===
--- gcc.llvm.master.orig/gcc/llvm-types.cpp	2007-02-19 13:02:58.0 +0100
+++ gcc.llvm.master/gcc/llvm-types.cpp	2007-02-19 15:16:46.0 +0100
@@ -64,8 +64,7 @@
 static LTypesMapTy LTypesMap;
 
 // GET_TYPE_LLVM/SET_TYPE_LLVM - Associate an LLVM type with each TREE type.
-// These are lazily computed by ConvertType, accessors available only to C++
-// code.
+// These are lazily computed by ConvertType.
 
 #define SET_TYPE_SYMTAB_LLVM(NODE, index) (TYPE_CHECK (NODE)-type.symtab.llvm = index)
 
@@ -92,7 +91,7 @@
 // Get LLVM Type for the GCC tree node based on LTypes vector index.
 // When GCC tree node is initialized, it has 0 as the index value. This is
 // why all recorded indexes are offset by 1. 
-static inline const Type *llvm_get_type(unsigned Index) {
+extern C inline const Type *llvm_get_type(unsigned Index) {
 
   if (Index == 0)
 return NULL;
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc4: display the LLVM type when printing type trees

2007-02-16 Thread Chris Lattner
Very cool.  However, it doesn't apply to CVS right.  GET_TYPE_LLVM  
needs to go through the LTypes vector now, can you plz update the patch?

Thanks,

-Chris

On Feb 15, 2007, at 1:45 PM, Duncan Sands wrote:

 For example:

 (gdb) call debug_tree(type)
  void_type 0xb7bd6ac8 void sizes-gimplified visited VOID
 align 8 symtab 152957560 alias set -1
 LLVM:  void
 pointer_to_this pointer_type 0xb7bd6b40

 Enjoy!

 Duncan.
 print_type.diff
 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] llvm-gcc4: display the LLVM type when printing type trees

2007-02-15 Thread Duncan Sands
For example:

(gdb) call debug_tree(type)
 void_type 0xb7bd6ac8 void sizes-gimplified visited VOID
align 8 symtab 152957560 alias set -1
LLVM:  void
pointer_to_this pointer_type 0xb7bd6b40

Enjoy!

Duncan.
Index: gcc.llvm.master/gcc/print-tree.c
===
--- gcc.llvm.master.orig/gcc/print-tree.c	2007-02-15 20:31:54.0 +0100
+++ gcc.llvm.master/gcc/print-tree.c	2007-02-15 22:33:46.0 +0100
@@ -603,6 +603,16 @@
 
   lang_hooks.print_type (file, node, indent);
 
+  /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+  if (GET_TYPE_LLVM (node))
+	{
+	  indent_to (file, indent + 4);
+	  print_llvm_type (file, GET_TYPE_LLVM (node));
+	}
+#endif
+  /* APPLE LOCAL end LLVM */
+
   if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
 	indent_to (file, indent + 3);
 
Index: gcc.llvm.master/gcc/llvm-backend.cpp
===
--- gcc.llvm.master.orig/gcc/llvm-backend.cpp	2007-02-15 20:34:11.0 +0100
+++ gcc.llvm.master/gcc/llvm-backend.cpp	2007-02-15 20:41:41.0 +0100
@@ -892,4 +892,13 @@
   WriteAsOperand(FS, (Value*)LLVM, true, TheModule);
 }
 
+// print_llvm_type - Print the specified LLVM type symbolically, called by
+// print-tree.c for tree dumps.
+//
+void print_llvm_type(FILE *file, void *LLVM) {
+  oFILEstream FS(file);
+  FS  LLVM: ;
+  WriteTypeSymbolic(FS, (const Type*)LLVM, TheModule);
+}
+
 /* APPLE LOCAL end LLVM (ENTIRE FILE!)  */
Index: gcc.llvm.master/gcc/llvm.h
===
--- gcc.llvm.master.orig/gcc/llvm.h	2007-02-15 20:32:52.0 +0100
+++ gcc.llvm.master/gcc/llvm.h	2007-02-15 20:41:24.0 +0100
@@ -80,6 +80,11 @@
  */
 void print_llvm(FILE *file, void *LLVM);
 
+/* print_llvm_type - Print the specified LLVM type symbolically, called by
+ * print-tree.c for tree dumps.
+ */
+void print_llvm_type(FILE *file, void *LLVM);
+
 /* Init pch writing. */
 void llvm_pch_write_init(void);
 
Index: gcc.llvm.master/gcc/tree.h
===
--- gcc.llvm.master.orig/gcc/tree.h	2007-02-15 20:39:44.0 +0100
+++ gcc.llvm.master/gcc/tree.h	2007-02-15 20:40:24.0 +0100
@@ -2092,6 +2092,7 @@
  ? (void*)(NODE)-decl.llvm		\
  : (make_decl_llvm (NODE), (void*)(NODE)-decl.llvm)))
 #define SET_DECL_LLVM(NODE, LLVM) (DECL_CHECK (NODE)-decl.llvm = (long)LLVM)
+#define GET_TYPE_LLVM(NODE) (void *)(TYPE_CHECK (NODE)-type.symtab.llvm)
 #endif
 /* Returns nonzero if the DECL_LLVM for NODE has already been set.  */
 #define DECL_LLVM_SET_P(NODE) (DECL_CHECK (NODE)-decl.llvm != 0)
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits