This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[ast-optimizer-branch] Print trees in C syntax
- From: POP Sebastian <m1sp at csc dot liv dot ac dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dnovillo at redhat dot com
- Date: Mon, 26 Nov 2001 16:45:23 +0000
- Subject: [ast-optimizer-branch] Print trees in C syntax
- References: <22136.1003775535@localhost.localdomain> <20011122225632.A30650@tornado.cygnus.com> <20011123135939.A12802@linux18.lxfarm.csc.liv.ac.uk> <1006552543.16583.0.camel@tornado>
Hi,
The following patch allows to print in C syntax a tree node.
There're some nodes that are not yet printed correctly.
They are printed as 'NIY' for 'Not Implemented Yet'.
But that can be fixed very easily. So this patch is not yet
ready for the main-line.
This function could be used to dump the results of a tree
optimisation in a human readable C source. By this a
programmer can see exactly the optimisations performed on
his code at AST level.
Sebastian.
2001-11-26 Sebastian Pop <s.pop@laposte.net>
* print-tree.c: Include c-tree.h and c-common.h
(print_c_declarations): Declare static function.
(print_c_tree): New function.
(print_c_node): New function.
(debug_chain): New function.
* tree.h (debug_chain): Declare.
(print_c_tree): Declare.
(print_c_node): Declare.
+++ tree.h 2001/11/26 15:53:56
@@ -2782,6 +2782,9 @@ extern void print_rtl PARAMS ((FILE *,
/* In print-tree.c */
extern void debug_tree PARAMS ((tree));
+extern void debug_chain PARAMS ((tree));
+extern void print_c_tree PARAMS ((FILE*, tree, HOST_WIDE_INT));
+extern int print_c_node PARAMS ((FILE*, tree, HOST_WIDE_INT));
#ifdef BUFSIZ
extern void print_node PARAMS ((FILE *, const char *, tree,
int));
Index: print-tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/print-tree.c,v
retrieving revision 1.46
diff -d -u -p -r1.46 print-tree.c
--- print-tree.c 2001/06/02 10:56:44 1.46
+++ print-tree.c 2001/11/26 15:53:57
@@ -24,6 +24,8 @@ Boston, MA 02111-1307, USA. */
#include "system.h"
#include "tree.h"
#include "ggc.h"
+#include "c-tree.h"
+#include "c-common.h"
/* Define the hash table of nodes already seen.
Such nodes are not repeated; brief cross-references are used. */
@@ -37,6 +39,7 @@ struct bucket
};
static struct bucket **table;
+static void print_c_declarations PARAMS ((FILE*, tree, HOST_WIDE_INT));
/* Print the node NODE on standard error, for debugging.
Most nodes referred to by this one are printed recursively
@@ -756,3 +759,601 @@ print_node (file, prefix, node, indent)
fprintf (file, ">");
}
+
+/* Print all nodes in the chain T. */
+
+void
+debug_chain (t)
+ tree t;
+{
+ HOST_WIDE_INT i = 0;
+ while (t)
+ {
+ fprintf (stderr, "NODE %d :\n", i);
+ debug_tree (t);
+ t = TREE_CHAIN (t);
+ i++;
+ }
+}
+
+/* Print the tree T in full, on file FILE, SPC spaces of indent. */
+
+void
+print_c_tree (file, t, spc)
+ FILE *file;
+ tree t;
+ HOST_WIDE_INT spc;
+{
+ tree node = t;
+ while (node && node != error_mark_node)
+ {
+ spc = print_c_node (file, node, spc);
+ switch (TREE_CODE (node))
+ {
+ case TYPE_DECL:
+ case FIELD_DECL:
+ case VAR_DECL:
+ case PARM_DECL:
+ /* Some nodes on which we need to stop the recursive printing,
+ otherwise we print all declared vars in the scope. */
+ return;
+ default:
+ break;
+ }
+ node = TREE_CHAIN (node);
+ }
+}
+
+/* Print a node NODE in full, on file FILE, SPC spaces of indent.
+ Returns the new value of SPC. */
+
+int
+print_c_node (file, node, spc)
+ FILE *file;
+ tree node;
+ HOST_WIDE_INT spc;
+{
+ HOST_WIDE_INT i;
+ tree type;
+
+#define INDENT_PRINT_C_NODE(SPACE) for (i = 0; i<SPACE; i++) fprintf (file, " ")
+ switch (TREE_CODE (node))
+ {
+ case DECL_STMT:
+ break;
+ case FIELD_DECL:
+ case VAR_DECL:
+ case PARM_DECL:
+ fprintf (file, "%s", (char*) IDENTIFIER_POINTER (DECL_NAME (node)));
+ break;
+ case INTEGER_CST:
+ if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
+ /* In the case of a pointer, divise by the size of the pointed type. */
+ fprintf (file, "%d",
+ TREE_INT_CST_LOW (node) /
+ TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (node)))) );
+ else
+ fprintf (file, "%d", TREE_INT_CST_LOW (node));
+ break;
+ case REAL_CST:
+ /* Code copied from print_node. */
+ {
+ REAL_VALUE_TYPE d;
+ if (TREE_OVERFLOW (node))
+ fprintf (file, " overflow");
+
+#if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
+ d = TREE_REAL_CST (node);
+ if (REAL_VALUE_ISINF (d))
+ fprintf (file, " Inf");
+ else if (REAL_VALUE_ISNAN (d))
+ fprintf (file, " Nan");
+ else
+ {
+ char string[100];
+ REAL_VALUE_TO_DECIMAL (d, "%e", string);
+ fprintf (file, "%s", string);
+ }
+#else
+ {
+ HOST_WIDE_INT i;
+ unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
+ fprintf (file, "0x");
+ for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
+ fprintf (file, "%02x", *p++);
+ fprintf (file, "");
+ }
+#endif
+ break;
+ }
+ case PLUS_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " + ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case MINUS_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " - ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case MULT_EXPR:
+ if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ else
+ {
+ if (TREE_CODE (TREE_OPERAND (node, 0)) == PLUS_EXPR ||
+ TREE_CODE (TREE_OPERAND (node, 0)) == MINUS_EXPR )
+ {
+ /* When the operands are expressions with less priority,
+ keep semantics of the tree representation. */
+ fprintf (file, "(");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, ")");
+ }
+ else
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " * ");
+ if (TREE_CODE (TREE_OPERAND (node, 1)) == PLUS_EXPR ||
+ TREE_CODE (TREE_OPERAND (node, 1)) == MINUS_EXPR )
+ {
+ /* When the operands are expressions with less priority,
+ keep semantics of the tree representation. */
+ fprintf (file, "(");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ fprintf (file, ")");
+ }
+ else
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ }
+ break;
+ case TRUNC_DIV_EXPR:
+ if (TREE_CODE (TREE_OPERAND (node, 0)) == PLUS_EXPR ||
+ TREE_CODE (TREE_OPERAND (node, 0)) == MINUS_EXPR )
+ {
+ /* When the operands are expressions with less priority,
+ keep semantics of the tree representation. */
+ fprintf (file, "(");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, ")");
+ }
+ else
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " / ");
+ if (TREE_CODE (TREE_OPERAND (node, 1)) == PLUS_EXPR ||
+ TREE_CODE (TREE_OPERAND (node, 1)) == MINUS_EXPR )
+ {
+ /* When the operands are expressions with less priority,
+ keep semantics of the tree representation. */
+ fprintf (file, "(");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ fprintf (file, ")");
+ }
+ else
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case EXPR_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ print_c_tree (file, EXPR_STMT_EXPR (node), spc);
+ fprintf (file, ";\n");
+ break;
+ case STMT_EXPR:
+ fprintf (file, "(\n");
+ print_c_tree (file, STMT_EXPR_STMT (node), spc);
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, ")");
+ break;
+ case RETURN_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "return ");
+ if (RETURN_EXPR (node))
+ print_c_tree (file, TREE_OPERAND (RETURN_EXPR (node), 1), spc);
+ fprintf (file, ";\n");
+ break;
+ case FOR_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "for (");
+ if (FOR_INIT_STMT (node))
+ print_c_tree (file, EXPR_STMT_EXPR (FOR_INIT_STMT (node)), 0);
+ fprintf (file, "; ");
+ print_c_tree (file, FOR_COND (node), 0);
+ fprintf (file, "; ");
+ print_c_tree (file, FOR_EXPR (node), 0);
+ fprintf (file, ")\n");
+ print_c_tree (file, FOR_BODY (node), spc+2);
+ break;
+ case WHILE_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "while (");
+ print_c_tree (file, WHILE_COND (node), spc);
+ fprintf (file, ")\n");
+ print_c_tree (file, WHILE_BODY (node), spc+2);
+ break;
+ case DO_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "do\n");
+ print_c_tree (file, DO_BODY (node), spc+2);
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "while (");
+ print_c_tree (file, DO_COND (node), spc);
+ fprintf (file, ");\n");
+ break;
+ case IF_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "if (");
+ print_c_tree (file, IF_COND (node), spc);
+ fprintf (file, ")\n");
+ print_c_tree (file, THEN_CLAUSE (node), spc+2);
+ if (ELSE_CLAUSE (node))
+ {
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "else\n");
+ print_c_tree (file, ELSE_CLAUSE (node), spc+2);
+ }
+ break;
+ case SWITCH_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "switch (");
+ print_c_tree (file, SWITCH_COND (node), spc);
+ fprintf (file, ")\n");
+ print_c_tree (file, SWITCH_BODY (node), spc+2);
+ break;
+ case CASE_LABEL:
+ INDENT_PRINT_C_NODE (spc-2);
+ if (CASE_LOW (node) && CASE_HIGH (node))
+ {
+ fprintf (file, "case ");
+ print_c_tree (file, CASE_LOW (node), spc);
+ fprintf (file, " ... ");
+ print_c_tree (file, CASE_HIGH (node), spc);
+ }
+ else if (CASE_LOW (node))
+ {
+ fprintf (file, "case ");
+ print_c_tree (file, CASE_LOW (node), spc);
+ }
+ else
+ fprintf (file, "default ");
+ fprintf (file, ":\n");
+ break;
+ case MODIFY_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " = ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case SCOPE_STMT:
+ if (SCOPE_BEGIN_P (node))
+ {
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "{\n");
+ spc += 2;
+ if (SCOPE_STMT_BLOCK (node))
+ print_c_declarations (file, BLOCK_VARS (SCOPE_STMT_BLOCK (node)), spc);
+ }
+ else
+ {
+ spc -= 2;
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "}\n");
+ }
+ break;
+ case CALL_EXPR:
+ fprintf (file, "%s (", IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (TREE_OPERAND (node, 0), 0))));
+ if (TREE_OPERAND (node, 1))
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ fprintf (file, ")");
+ break;
+ case ARRAY_REF:
+ if (TREE_CODE (TREE_OPERAND (node, 0)) == ARRAY_REF)
+ {
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, "[");
+ }
+ else
+ fprintf (file, "%s[", IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (node, 0))));
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ fprintf (file, "]");
+ break;
+ case BREAK_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "break;\n");
+ break;
+ case CONTINUE_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "continue;\n");
+ break;
+ case TREE_LIST:
+ print_c_tree (file, TREE_VALUE (node), spc);
+ if (TREE_CHAIN (node) && TREE_CODE (TREE_CHAIN (node)) == TREE_LIST)
+ fprintf (file, ", ");
+ break;
+ case COMPOUND_STMT:
+ print_c_tree (file, COMPOUND_BODY (node), spc);
+ break;
+ case COMPOUND_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, ", ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case NOP_EXPR:
+ type = TREE_TYPE (node);
+ if (type == ptr_type_node)
+ {
+ type = TREE_TYPE (node);
+ if (type == integer_type_node)
+ {
+ fprintf (file, "(int*)");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ }
+ }
+ else
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ break;
+ case ADDR_EXPR:
+ if (TREE_CODE (TREE_TYPE (TREE_OPERAND (node, 0))) != ARRAY_TYPE)
+ fprintf (file, "&");
+ fprintf (file, "%s", (char*) IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (node, 0))));
+ break;
+ case LSHIFT_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " << ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case RSHIFT_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " >> ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ /*
+ case LROTATE_EXPR:
+ case RROTATE_EXPR:
+ */
+ case BIT_IOR_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " | ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case BIT_XOR_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " ^ ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case BIT_AND_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " & ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ /*
+ case BIT_ANDTC_EXPR:
+ case BIT_NOT_EXPR:
+ */
+ case TRUTH_ANDIF_EXPR:
+ case TRUTH_AND_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " && ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case TRUTH_ORIF_EXPR:
+ case TRUTH_OR_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " || ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ /*
+ case TRUTH_XOR_EXPR:
+ */
+ case TRUTH_NOT_EXPR:
+ fprintf (file, " !");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ break;
+ case LT_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " < ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case LE_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " <= ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case GT_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " > ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case GE_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " >= ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case EQ_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " == ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case NE_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " != ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case PREDECREMENT_EXPR:
+ fprintf (file, " --");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ break;
+ case PREINCREMENT_EXPR:
+ fprintf (file, " ++");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ break;
+ case POSTDECREMENT_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, "-- ");
+ break;
+ case POSTINCREMENT_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, "++ ");
+ break;
+ case LABEL_DECL:
+ fprintf (file, "%s", (char*) IDENTIFIER_POINTER (DECL_NAME (node)));
+ break;
+ case LABEL_STMT:
+ case LABEL_EXPR:
+ INDENT_PRINT_C_NODE (spc);
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, ":;\n");
+ break;
+ case GOTO_STMT:
+ INDENT_PRINT_C_NODE (spc);
+ fprintf (file, "goto ");
+ print_c_tree (file, GOTO_DESTINATION (node), spc);
+ fprintf (file, ";\n");
+ break;
+ case FIX_TRUNC_EXPR:
+ case FIX_CEIL_EXPR:
+ case FIX_FLOOR_EXPR:
+ case FIX_ROUND_EXPR:
+ case FLOAT_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ break;
+ case NEGATE_EXPR:
+ fprintf (file, "-(");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, ")");
+ break;
+ case COND_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, " ? ");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ fprintf (file, " : ");
+ print_c_tree (file, TREE_OPERAND (node, 2), spc);
+ break;
+ case CONSTRUCTOR:
+ fprintf (file, "{");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ fprintf (file, "}");
+ break;
+ case COMPONENT_REF:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, ".");
+ print_c_tree (file, TREE_OPERAND (node, 1), spc);
+ break;
+ case INDIRECT_REF:
+ fprintf (file, "(*");
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ fprintf (file, ")");
+ break;
+ case NON_LVALUE_EXPR:
+ print_c_tree (file, TREE_OPERAND (node, 0), spc);
+ break;
+ case CONVERT_EXPR:
+ if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
+ print_c_tree (file, TREE_OPERAND (TREE_OPERAND (node, 0), 0), spc);
+ else
+ fprintf (file, "NIY ");
+ break;
+ case ARRAY_RANGE_REF:
+ fprintf (file, "array_range_ref:NIY");
+ break;
+ case TYPE_DECL:
+ fprintf (file, "typedef:NIY");
+ break;
+ default:
+ /* Not Implemented Yet ... */
+ fprintf (file, "NIY ");
+ break;
+ }
+ return spc;
+}
+
+static void
+print_c_declarations (file, t, spc)
+ FILE *file;
+ tree t;
+ HOST_WIDE_INT spc;
+{
+ HOST_WIDE_INT i;
+ tree node = t, type, type1, type1_tmp;
+ while (node && (TREE_CODE (node) == VAR_DECL ||
+ TREE_CODE (node) == TYPE_DECL))
+ {
+ if (TREE_CODE (node) == TYPE_DECL)
+ {
+ print_c_tree (file, node, spc);
+ node = TREE_CHAIN (node);
+ continue;
+ }
+ for (i = 0; i<spc; i++) fprintf (file, " ");
+ type = TREE_TYPE (node);
+ switch (TREE_CODE (type))
+ {
+ case ARRAY_TYPE:
+ /* Look for the last type-attribute of the ARRAY node :
+ that attribute is the type of the array. */
+ type1 = TREE_TYPE (type);
+ while (TREE_CODE (type1) == ARRAY_TYPE)
+ {
+ type1 = TREE_TYPE (type1);
+ }
+ if (TREE_CODE (type1) == POINTER_TYPE)
+ {
+ type1 = TREE_TYPE (type1);
+ type1_tmp = type1;
+ while (TREE_CODE (type1) == POINTER_TYPE)
+ {
+ type1 = TREE_TYPE (type1);
+ }
+ fprintf (file, "%s *", (char*) IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type1))));
+ type1 = type1_tmp;
+ while (TREE_CODE (type1) == POINTER_TYPE)
+ {
+ fprintf (file, "*");
+ type1 = TREE_TYPE (type1);
+ }
+ }
+ else
+ fprintf (file, "%s ", (char*) IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type1))));
+ fprintf (file, "%s", (char*) IDENTIFIER_POINTER (DECL_NAME (node)));
+
+ /* Print the array subscripts. */
+ while (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ type1 = TREE_TYPE (type);
+ /* int A[1234][233] works, but A[var+3] is a save_expr ... §§ */
+ fprintf (file, "[%d]",
+ TREE_INT_CST_LOW (TYPE_SIZE (type)) /
+ TREE_INT_CST_LOW (TYPE_SIZE (type1)));
+ type = TREE_TYPE (type);
+ }
+ break;
+ case POINTER_TYPE:
+ type1 = TREE_TYPE (type);
+ while (TREE_CODE (type1) == POINTER_TYPE)
+ {
+ type1 = TREE_TYPE (type1);
+ }
+ fprintf (file, "%s *", (char*) IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type1))));
+ type = TREE_TYPE (type);
+ while (TREE_CODE (type) == POINTER_TYPE)
+ {
+ fprintf (file, "*");
+ type = TREE_TYPE (type);
+ }
+ fprintf (file, "%s", (char*) IDENTIFIER_POINTER (DECL_NAME (node)));
+ break;
+ case RECORD_TYPE:
+ fprintf (file, "struct {...}:NIY ");
+ fprintf (file, "%s", (char*) IDENTIFIER_POINTER (DECL_NAME (node)));
+ break;
+ default:
+ fprintf (file, "%s ", (char*) IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
+ fprintf (file, "%s", (char*) IDENTIFIER_POINTER (DECL_NAME (node)));
+ break;
+ }
+ if (DECL_INITIAL (node))
+ {
+ fprintf (file, " = ");
+ print_c_tree (file, DECL_INITIAL (node), spc);
+ }
+ fprintf (file, ";\n");
+ node = TREE_CHAIN (node);
+ }
+}
+