[llvm-commits] [124304] Make debug_tree(type) print the LLVM type if it exists.
clattner at apple.com
clattner at apple.com
Sun Feb 25 14:58:45 PST 2007
Revision: 124304
Author: clattner
Date: 2007-02-25 14:58:44 -0800 (Sun, 25 Feb 2007)
Log Message:
-----------
Make debug_tree(type) print the LLVM type if it exists. Patch
contributed by Duncan Sands!
Modified Paths:
--------------
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm-types.cpp
apple-local/branches/llvm/gcc/llvm.h
apple-local/branches/llvm/gcc/print-tree.c
apple-local/branches/llvm/gcc/tree.h
Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-25 22:01:13 UTC (rev 124303)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-25 22:58:44 UTC (rev 124304)
@@ -920,4 +920,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!) */
Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-25 22:01:13 UTC (rev 124303)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-25 22:58:44 UTC (rev 124304)
@@ -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;
Modified: apple-local/branches/llvm/gcc/llvm.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm.h 2007-02-25 22:01:13 UTC (rev 124303)
+++ apple-local/branches/llvm/gcc/llvm.h 2007-02-25 22:58:44 UTC (rev 124304)
@@ -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);
Modified: apple-local/branches/llvm/gcc/print-tree.c
===================================================================
--- apple-local/branches/llvm/gcc/print-tree.c 2007-02-25 22:01:13 UTC (rev 124303)
+++ apple-local/branches/llvm/gcc/print-tree.c 2007-02-25 22:58:44 UTC (rev 124304)
@@ -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);
Modified: apple-local/branches/llvm/gcc/tree.h
===================================================================
--- apple-local/branches/llvm/gcc/tree.h 2007-02-25 22:01:13 UTC (rev 124303)
+++ apple-local/branches/llvm/gcc/tree.h 2007-02-25 22:58:44 UTC (rev 124304)
@@ -2095,7 +2095,15 @@
/* 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 */
/* For PARM_DECL, holds an RTL for the stack slot or register
More information about the llvm-commits
mailing list