> 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.000000000 +0100
+++ gcc.llvm.master/gcc/print-tree.c	2007-02-19 12:51:11.000000000 +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.000000000 +0100
+++ gcc.llvm.master/gcc/llvm-backend.cpp	2007-02-19 12:51:11.000000000 +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.000000000 +0100
+++ gcc.llvm.master/gcc/llvm.h	2007-02-19 12:51:11.000000000 +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.000000000 +0100
+++ gcc.llvm.master/gcc/tree.h	2007-02-19 14:20:41.000000000 +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.000000000 +0100
+++ gcc.llvm.master/gcc/llvm-types.cpp	2007-02-19 15:16:46.000000000 +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

Reply via email to