Merge trunk version 193672 into gupc branch.
[official-gcc.git] / gcc / print-tree.c
blob726081f02f56a8c0e9a932543ee0f1f8e12c289f
1 /* Prints out tree in human readable form - GCC
2 Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "tree.h"
28 #include "ggc.h"
29 #include "langhooks.h"
30 #include "tree-iterator.h"
31 #include "diagnostic.h"
32 #include "gimple-pretty-print.h" /* FIXME */
33 #include "tree-flow.h"
34 #include "dumpfile.h"
36 /* Define the hash table of nodes already seen.
37 Such nodes are not repeated; brief cross-references are used. */
39 #define HASH_SIZE 37
41 struct bucket
43 tree node;
44 struct bucket *next;
47 static struct bucket **table;
49 /* Print the node NODE on standard error, for debugging.
50 Most nodes referred to by this one are printed recursively
51 down to a depth of six. */
53 DEBUG_FUNCTION void
54 debug_tree (tree node)
56 table = XCNEWVEC (struct bucket *, HASH_SIZE);
57 print_node (stderr, "", node, 0);
58 free (table);
59 table = 0;
60 putc ('\n', stderr);
63 /* Print the vector of trees VEC on standard error, for debugging.
64 Most nodes referred to by this one are printed recursively
65 down to a depth of six. */
67 DEBUG_FUNCTION void
68 debug_vec_tree (vec<tree, va_gc> *vec)
70 table = XCNEWVEC (struct bucket *, HASH_SIZE);
71 print_vec_tree (stderr, "", vec, 0);
72 free (table);
73 table = 0;
74 putc ('\n', stderr);
77 /* Print PREFIX and ADDR to FILE. */
78 void
79 dump_addr (FILE *file, const char *prefix, const void *addr)
81 if (flag_dump_noaddr || flag_dump_unnumbered)
82 fprintf (file, "%s#", prefix);
83 else
84 fprintf (file, "%s" HOST_PTR_PRINTF, prefix, addr);
87 /* Print a node in brief fashion, with just the code, address and name. */
89 void
90 print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
92 enum tree_code_class tclass;
94 if (node == 0)
95 return;
97 tclass = TREE_CODE_CLASS (TREE_CODE (node));
99 /* Always print the slot this node is in, and its code, address and
100 name if any. */
101 if (indent > 0)
102 fprintf (file, " ");
103 fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]);
104 dump_addr (file, " ", node);
106 if (tclass == tcc_declaration)
108 if (DECL_NAME (node))
109 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
110 else if (TREE_CODE (node) == LABEL_DECL
111 && LABEL_DECL_UID (node) != -1)
113 if (dump_flags & TDF_NOUID)
114 fprintf (file, " L.xxxx");
115 else
116 fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
118 else
120 if (dump_flags & TDF_NOUID)
121 fprintf (file, " %c.xxxx",
122 TREE_CODE (node) == CONST_DECL ? 'C' : 'D');
123 else
124 fprintf (file, " %c.%u",
125 TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
126 DECL_UID (node));
129 else if (tclass == tcc_type)
131 if (TYPE_NAME (node))
133 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
134 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
135 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
136 && DECL_NAME (TYPE_NAME (node)))
137 fprintf (file, " %s",
138 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
140 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
141 fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
143 if (TREE_CODE (node) == IDENTIFIER_NODE)
144 fprintf (file, " %s", IDENTIFIER_POINTER (node));
146 /* We might as well always print the value of an integer or real. */
147 if (TREE_CODE (node) == INTEGER_CST)
149 if (TREE_OVERFLOW (node))
150 fprintf (file, " overflow");
152 fprintf (file, " ");
153 if (TREE_INT_CST_HIGH (node) == 0)
154 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
155 else if (TREE_INT_CST_HIGH (node) == -1
156 && TREE_INT_CST_LOW (node) != 0)
157 fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
158 -TREE_INT_CST_LOW (node));
159 else
160 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
161 (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
162 (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
164 if (TREE_CODE (node) == REAL_CST)
166 REAL_VALUE_TYPE d;
168 if (TREE_OVERFLOW (node))
169 fprintf (file, " overflow");
171 d = TREE_REAL_CST (node);
172 if (REAL_VALUE_ISINF (d))
173 fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
174 else if (REAL_VALUE_ISNAN (d))
175 fprintf (file, " Nan");
176 else
178 char string[60];
179 real_to_decimal (string, &d, sizeof (string), 0, 1);
180 fprintf (file, " %s", string);
183 if (TREE_CODE (node) == FIXED_CST)
185 FIXED_VALUE_TYPE f;
186 char string[60];
188 if (TREE_OVERFLOW (node))
189 fprintf (file, " overflow");
191 f = TREE_FIXED_CST (node);
192 fixed_to_decimal (string, &f, sizeof (string));
193 fprintf (file, " %s", string);
196 fprintf (file, ">");
199 void
200 indent_to (FILE *file, int column)
202 int i;
204 /* Since this is the long way, indent to desired column. */
205 if (column > 0)
206 fprintf (file, "\n");
207 for (i = 0; i < column; i++)
208 fprintf (file, " ");
211 /* Print the node NODE in full on file FILE, preceded by PREFIX,
212 starting in column INDENT. */
214 void
215 print_node (FILE *file, const char *prefix, tree node, int indent)
217 int hash;
218 struct bucket *b;
219 enum machine_mode mode;
220 enum tree_code_class tclass;
221 int len;
222 int i;
223 expanded_location xloc;
224 enum tree_code code;
226 if (node == 0)
227 return;
229 code = TREE_CODE (node);
230 tclass = TREE_CODE_CLASS (code);
232 /* Don't get too deep in nesting. If the user wants to see deeper,
233 it is easy to use the address of a lowest-level node
234 as an argument in another call to debug_tree. */
236 if (indent > 24)
238 print_node_brief (file, prefix, node, indent);
239 return;
242 if (indent > 8 && (tclass == tcc_type || tclass == tcc_declaration))
244 print_node_brief (file, prefix, node, indent);
245 return;
248 /* It is unsafe to look at any other fields of an ERROR_MARK node. */
249 if (code == ERROR_MARK)
251 print_node_brief (file, prefix, node, indent);
252 return;
255 /* Allow this function to be called if the table is not there. */
256 if (table)
258 hash = ((unsigned long) node) % HASH_SIZE;
260 /* If node is in the table, just mention its address. */
261 for (b = table[hash]; b; b = b->next)
262 if (b->node == node)
264 print_node_brief (file, prefix, node, indent);
265 return;
268 /* Add this node to the table. */
269 b = XNEW (struct bucket);
270 b->node = node;
271 b->next = table[hash];
272 table[hash] = b;
275 /* Indent to the specified column, since this is the long form. */
276 indent_to (file, indent);
278 /* Print the slot this node is in, and its code, and address. */
279 fprintf (file, "%s <%s", prefix, tree_code_name[(int) code]);
280 dump_addr (file, " ", node);
282 /* Print the name, if any. */
283 if (tclass == tcc_declaration)
285 if (DECL_NAME (node))
286 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
287 else if (code == LABEL_DECL
288 && LABEL_DECL_UID (node) != -1)
290 if (dump_flags & TDF_NOUID)
291 fprintf (file, " L.xxxx");
292 else
293 fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
295 else
297 if (dump_flags & TDF_NOUID)
298 fprintf (file, " %c.xxxx", code == CONST_DECL ? 'C' : 'D');
299 else
300 fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D',
301 DECL_UID (node));
304 else if (tclass == tcc_type)
306 if (TYPE_NAME (node))
308 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
309 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
310 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
311 && DECL_NAME (TYPE_NAME (node)))
312 fprintf (file, " %s",
313 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
316 if (code == IDENTIFIER_NODE)
317 fprintf (file, " %s", IDENTIFIER_POINTER (node));
319 if (code == INTEGER_CST)
321 if (indent <= 4)
322 print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
324 else if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
326 print_node (file, "type", TREE_TYPE (node), indent + 4);
327 if (TREE_TYPE (node))
328 indent_to (file, indent + 3);
331 if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node))
332 fputs (" side-effects", file);
334 if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
335 fputs (" readonly", file);
336 if (TREE_SHARED (node))
337 fputs (" shared", file);
338 if (!TYPE_P (node) && TREE_CONSTANT (node))
339 fputs (" constant", file);
340 else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
341 fputs (" sizes-gimplified", file);
343 if (TYPE_P (node) && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
344 fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
346 if (TREE_ADDRESSABLE (node))
347 fputs (" addressable", file);
348 if (TREE_THIS_VOLATILE (node))
349 fputs (" volatile", file);
350 if (TREE_ASM_WRITTEN (node))
351 fputs (" asm_written", file);
352 if (TREE_USED (node))
353 fputs (" used", file);
354 if (TREE_NOTHROW (node))
355 fputs (TYPE_P (node) ? " align-ok" : " nothrow", file);
356 if (TREE_PUBLIC (node))
357 fputs (" public", file);
358 if (TREE_PRIVATE (node))
359 fputs (" private", file);
360 if (TREE_PROTECTED (node))
361 fputs (" protected", file);
362 if (TREE_STATIC (node))
363 fputs (" static", file);
364 if (TREE_CODE (node) == FUNCTION_DECL && DECL_STATIC_CONSTRUCTOR (node))
365 fputs (" constructor", file);
366 if (TREE_CODE (node) == FUNCTION_DECL && DECL_STATIC_DESTRUCTOR (node))
367 fputs (" destructor", file);
368 if (TREE_DEPRECATED (node))
369 fputs (" deprecated", file);
370 if (TREE_VISITED (node))
371 fputs (" visited", file);
373 if (code != TREE_VEC && code != SSA_NAME)
375 if (TREE_LANG_FLAG_0 (node))
376 fputs (" tree_0", file);
377 if (TREE_LANG_FLAG_1 (node))
378 fputs (" tree_1", file);
379 if (TREE_LANG_FLAG_2 (node))
380 fputs (" tree_2", file);
381 if (TREE_LANG_FLAG_3 (node))
382 fputs (" tree_3", file);
383 if (TREE_LANG_FLAG_4 (node))
384 fputs (" tree_4", file);
385 if (TREE_LANG_FLAG_5 (node))
386 fputs (" tree_5", file);
387 if (TREE_LANG_FLAG_6 (node))
388 fputs (" tree_6", file);
391 /* DECL_ nodes have additional attributes. */
393 switch (TREE_CODE_CLASS (code))
395 case tcc_declaration:
396 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
398 if (DECL_UNSIGNED (node))
399 fputs (" unsigned", file);
400 if (DECL_IGNORED_P (node))
401 fputs (" ignored", file);
402 if (DECL_ABSTRACT (node))
403 fputs (" abstract", file);
404 if (DECL_EXTERNAL (node))
405 fputs (" external", file);
406 if (DECL_NONLOCAL (node))
407 fputs (" nonlocal", file);
409 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
411 if (DECL_WEAK (node))
412 fputs (" weak", file);
413 if (DECL_IN_SYSTEM_HEADER (node))
414 fputs (" in_system_header", file);
416 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL)
417 && code != LABEL_DECL
418 && code != FUNCTION_DECL
419 && DECL_REGISTER (node))
420 fputs (" regdecl", file);
422 if (code == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
423 fputs (" suppress-debug", file);
425 if (code == FUNCTION_DECL
426 && DECL_FUNCTION_SPECIFIC_TARGET (node))
427 fputs (" function-specific-target", file);
428 if (code == FUNCTION_DECL
429 && DECL_FUNCTION_SPECIFIC_OPTIMIZATION (node))
430 fputs (" function-specific-opt", file);
431 if (code == FUNCTION_DECL && DECL_DECLARED_INLINE_P (node))
432 fputs (" autoinline", file);
433 if (code == FUNCTION_DECL && DECL_BUILT_IN (node))
434 fputs (" built-in", file);
435 if (code == FUNCTION_DECL && DECL_STATIC_CHAIN (node))
436 fputs (" static-chain", file);
437 if (TREE_CODE (node) == FUNCTION_DECL && decl_is_tm_clone (node))
438 fputs (" tm-clone", file);
440 if (code == FIELD_DECL && DECL_PACKED (node))
441 fputs (" packed", file);
442 if (code == FIELD_DECL && DECL_BIT_FIELD (node))
443 fputs (" bit-field", file);
444 if (code == FIELD_DECL && DECL_NONADDRESSABLE_P (node))
445 fputs (" nonaddressable", file);
447 if (code == LABEL_DECL && DECL_ERROR_ISSUED (node))
448 fputs (" error-issued", file);
449 if (code == LABEL_DECL && EH_LANDING_PAD_NR (node))
450 fprintf (file, " landing-pad:%d", EH_LANDING_PAD_NR (node));
452 if (code == VAR_DECL && DECL_IN_TEXT_SECTION (node))
453 fputs (" in-text-section", file);
454 if (code == VAR_DECL && DECL_IN_CONSTANT_POOL (node))
455 fputs (" in-constant-pool", file);
456 if (code == VAR_DECL && DECL_COMMON (node))
457 fputs (" common", file);
458 if (code == VAR_DECL && DECL_THREAD_LOCAL_P (node))
460 enum tls_model kind = DECL_TLS_MODEL (node);
461 switch (kind)
463 case TLS_MODEL_GLOBAL_DYNAMIC:
464 fputs (" tls-global-dynamic", file);
465 break;
466 case TLS_MODEL_LOCAL_DYNAMIC:
467 fputs (" tls-local-dynamic", file);
468 break;
469 case TLS_MODEL_INITIAL_EXEC:
470 fputs (" tls-initial-exec", file);
471 break;
472 case TLS_MODEL_LOCAL_EXEC:
473 fputs (" tls-local-exec", file);
474 break;
475 default:
476 gcc_unreachable ();
480 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
482 if (DECL_VIRTUAL_P (node))
483 fputs (" virtual", file);
484 if (DECL_PRESERVE_P (node))
485 fputs (" preserve", file);
486 if (DECL_LANG_FLAG_0 (node))
487 fputs (" decl_0", file);
488 if (DECL_LANG_FLAG_1 (node))
489 fputs (" decl_1", file);
490 if (DECL_LANG_FLAG_2 (node))
491 fputs (" decl_2", file);
492 if (DECL_LANG_FLAG_3 (node))
493 fputs (" decl_3", file);
494 if (DECL_LANG_FLAG_4 (node))
495 fputs (" decl_4", file);
496 if (DECL_LANG_FLAG_5 (node))
497 fputs (" decl_5", file);
498 if (DECL_LANG_FLAG_6 (node))
499 fputs (" decl_6", file);
500 if (DECL_LANG_FLAG_7 (node))
501 fputs (" decl_7", file);
503 mode = DECL_MODE (node);
504 fprintf (file, " %s", GET_MODE_NAME (mode));
507 if ((code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
508 && DECL_BY_REFERENCE (node))
509 fputs (" passed-by-reference", file);
511 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node))
512 fputs (" defer-output", file);
515 xloc = expand_location (DECL_SOURCE_LOCATION (node));
516 fprintf (file, " file %s line %d col %d", xloc.file, xloc.line,
517 xloc.column);
519 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
521 print_node (file, "size", DECL_SIZE (node), indent + 4);
522 print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
524 if (code != FUNCTION_DECL || DECL_BUILT_IN (node))
525 indent_to (file, indent + 3);
527 if (DECL_USER_ALIGN (node))
528 fprintf (file, " user");
530 fprintf (file, " align %d", DECL_ALIGN (node));
531 if (code == FIELD_DECL)
532 fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
533 DECL_OFFSET_ALIGN (node));
535 if (code == FUNCTION_DECL && DECL_BUILT_IN (node))
537 if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
538 fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));
539 else
540 fprintf (file, " built-in %s:%s",
541 built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)],
542 built_in_names[(int) DECL_FUNCTION_CODE (node)]);
545 if (code == FIELD_DECL)
547 print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4);
548 print_node (file, "bit offset", DECL_FIELD_BIT_OFFSET (node),
549 indent + 4);
550 if (DECL_BIT_FIELD_TYPE (node))
551 print_node (file, "bit_field_type", DECL_BIT_FIELD_TYPE (node),
552 indent + 4);
555 print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
557 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
559 print_node_brief (file, "attributes",
560 DECL_ATTRIBUTES (node), indent + 4);
561 if (code != PARM_DECL)
562 print_node_brief (file, "initial", DECL_INITIAL (node),
563 indent + 4);
565 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
567 print_node_brief (file, "abstract_origin",
568 DECL_ABSTRACT_ORIGIN (node), indent + 4);
570 if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
572 print_node (file, "arguments", DECL_ARGUMENT_FLD (node), indent + 4);
573 print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
576 lang_hooks.print_decl (file, node, indent);
578 if (DECL_RTL_SET_P (node))
580 indent_to (file, indent + 4);
581 print_rtl (file, DECL_RTL (node));
584 if (code == PARM_DECL)
586 print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4);
588 if (DECL_INCOMING_RTL (node) != 0)
590 indent_to (file, indent + 4);
591 fprintf (file, "incoming-rtl ");
592 print_rtl (file, DECL_INCOMING_RTL (node));
595 else if (code == FUNCTION_DECL
596 && DECL_STRUCT_FUNCTION (node) != 0)
598 indent_to (file, indent + 4);
599 dump_addr (file, "struct-function ", DECL_STRUCT_FUNCTION (node));
602 if ((code == VAR_DECL || code == PARM_DECL)
603 && DECL_HAS_VALUE_EXPR_P (node))
604 print_node (file, "value-expr", DECL_VALUE_EXPR (node), indent + 4);
606 /* Print the decl chain only if decl is at second level. */
607 if (indent == 4)
608 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
609 else
610 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
611 break;
613 case tcc_type:
614 if (TYPE_UNSIGNED (node))
615 fputs (" unsigned", file);
617 /* The no-force-blk flag is used for different things in
618 different types. */
619 if ((code == RECORD_TYPE
620 || code == UNION_TYPE
621 || code == QUAL_UNION_TYPE)
622 && TYPE_NO_FORCE_BLK (node))
623 fputs (" no-force-blk", file);
625 if (TYPE_STRING_FLAG (node))
626 fputs (" string-flag", file);
627 if (TYPE_NEEDS_CONSTRUCTING (node))
628 fputs (" needs-constructing", file);
630 /* The transparent-union flag is used for different things in
631 different nodes. */
632 if ((code == UNION_TYPE || code == RECORD_TYPE)
633 && TYPE_TRANSPARENT_AGGR (node))
634 fputs (" transparent-aggr", file);
635 else if (code == ARRAY_TYPE
636 && TYPE_NONALIASED_COMPONENT (node))
637 fputs (" nonaliased-component", file);
639 if (TYPE_PACKED (node))
640 fputs (" packed", file);
642 if (TYPE_RESTRICT (node))
643 fputs (" restrict", file);
645 if (TYPE_LANG_FLAG_0 (node))
646 fputs (" type_0", file);
647 if (TYPE_LANG_FLAG_1 (node))
648 fputs (" type_1", file);
649 if (TYPE_LANG_FLAG_2 (node))
650 fputs (" type_2", file);
651 if (!TYPE_SHARED (node))
653 if (TYPE_LANG_FLAG_3 (node))
654 fputs (" type_3", file);
655 if (TYPE_LANG_FLAG_4 (node))
656 fputs (" type_4", file);
657 if (TYPE_LANG_FLAG_5 (node))
658 fputs (" type_5", file);
660 if (TYPE_LANG_FLAG_6 (node))
661 fputs (" type_6", file);
663 mode = TYPE_MODE (node);
664 fprintf (file, " %s", GET_MODE_NAME (mode));
666 print_node (file, "size", TYPE_SIZE (node), indent + 4);
667 print_node (file, "unit size", TYPE_SIZE_UNIT (node), indent + 4);
668 if (TYPE_SHARED (node))
670 if (TYPE_HAS_THREADS_FACTOR(node))
671 fputs (" THREADS factor", file);
672 if (TYPE_HAS_BLOCK_FACTOR (node))
673 print_node (file, "block factor",
674 TYPE_BLOCK_FACTOR (node), indent + 4);
676 indent_to (file, indent + 3);
678 if (TYPE_USER_ALIGN (node))
679 fprintf (file, " user");
681 fprintf (file, " align %d symtab %d alias set " HOST_WIDE_INT_PRINT_DEC,
682 TYPE_ALIGN (node), TYPE_SYMTAB_ADDRESS (node),
683 (HOST_WIDE_INT) TYPE_ALIAS_SET (node));
685 if (TYPE_STRUCTURAL_EQUALITY_P (node))
686 fprintf (file, " structural equality");
687 else
688 dump_addr (file, " canonical type ", TYPE_CANONICAL (node));
690 print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
692 if (INTEGRAL_TYPE_P (node) || code == REAL_TYPE
693 || code == FIXED_POINT_TYPE)
695 fprintf (file, " precision %d", TYPE_PRECISION (node));
696 print_node_brief (file, "min", TYPE_MIN_VALUE (node), indent + 4);
697 print_node_brief (file, "max", TYPE_MAX_VALUE (node), indent + 4);
700 if (code == ENUMERAL_TYPE)
701 print_node (file, "values", TYPE_VALUES (node), indent + 4);
702 else if (code == ARRAY_TYPE)
703 print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
704 else if (code == VECTOR_TYPE)
705 fprintf (file, " nunits %d", (int) TYPE_VECTOR_SUBPARTS (node));
706 else if (code == RECORD_TYPE
707 || code == UNION_TYPE
708 || code == QUAL_UNION_TYPE)
709 print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
710 else if (code == FUNCTION_TYPE
711 || code == METHOD_TYPE)
713 if (TYPE_METHOD_BASETYPE (node))
714 print_node_brief (file, "method basetype",
715 TYPE_METHOD_BASETYPE (node), indent + 4);
716 print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
718 else if (code == OFFSET_TYPE)
719 print_node_brief (file, "basetype", TYPE_OFFSET_BASETYPE (node),
720 indent + 4);
722 if (TYPE_CONTEXT (node))
723 print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
725 lang_hooks.print_type (file, node, indent);
727 if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
728 indent_to (file, indent + 3);
730 print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node),
731 indent + 4);
732 print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node),
733 indent + 4);
734 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
735 break;
737 case tcc_expression:
738 case tcc_comparison:
739 case tcc_unary:
740 case tcc_binary:
741 case tcc_reference:
742 case tcc_statement:
743 case tcc_vl_exp:
744 if (code == BIND_EXPR)
746 print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
747 print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
748 print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
749 break;
751 if (code == CALL_EXPR)
753 call_expr_arg_iterator iter;
754 tree arg;
755 print_node (file, "fn", CALL_EXPR_FN (node), indent + 4);
756 print_node (file, "static_chain", CALL_EXPR_STATIC_CHAIN (node),
757 indent + 4);
758 i = 0;
759 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
761 char temp[10];
762 sprintf (temp, "arg %d", i);
763 print_node (file, temp, arg, indent + 4);
764 i++;
767 else
769 len = TREE_OPERAND_LENGTH (node);
771 for (i = 0; i < len; i++)
773 char temp[10];
775 sprintf (temp, "arg %d", i);
776 print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
779 if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
780 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
781 break;
783 case tcc_constant:
784 case tcc_exceptional:
785 switch (code)
787 case INTEGER_CST:
788 if (TREE_OVERFLOW (node))
789 fprintf (file, " overflow");
791 fprintf (file, " ");
792 if (TREE_INT_CST_HIGH (node) == 0)
793 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
794 TREE_INT_CST_LOW (node));
795 else if (TREE_INT_CST_HIGH (node) == -1
796 && TREE_INT_CST_LOW (node) != 0)
797 fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
798 -TREE_INT_CST_LOW (node));
799 else
800 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
801 (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
802 (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
803 break;
805 case REAL_CST:
807 REAL_VALUE_TYPE d;
809 if (TREE_OVERFLOW (node))
810 fprintf (file, " overflow");
812 d = TREE_REAL_CST (node);
813 if (REAL_VALUE_ISINF (d))
814 fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
815 else if (REAL_VALUE_ISNAN (d))
816 fprintf (file, " Nan");
817 else
819 char string[64];
820 real_to_decimal (string, &d, sizeof (string), 0, 1);
821 fprintf (file, " %s", string);
824 break;
826 case FIXED_CST:
828 FIXED_VALUE_TYPE f;
829 char string[64];
831 if (TREE_OVERFLOW (node))
832 fprintf (file, " overflow");
834 f = TREE_FIXED_CST (node);
835 fixed_to_decimal (string, &f, sizeof (string));
836 fprintf (file, " %s", string);
838 break;
840 case VECTOR_CST:
842 char buf[10];
843 unsigned i;
845 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
847 sprintf (buf, "elt%u: ", i);
848 print_node (file, buf, VECTOR_CST_ELT (node, i), indent + 4);
851 break;
853 case COMPLEX_CST:
854 print_node (file, "real", TREE_REALPART (node), indent + 4);
855 print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
856 break;
858 case STRING_CST:
860 const char *p = TREE_STRING_POINTER (node);
861 int i = TREE_STRING_LENGTH (node);
862 fputs (" \"", file);
863 while (--i >= 0)
865 char ch = *p++;
866 if (ch >= ' ' && ch < 127)
867 putc (ch, file);
868 else
869 fprintf(file, "\\%03o", ch & 0xFF);
871 fputc ('\"', file);
873 break;
875 case IDENTIFIER_NODE:
876 lang_hooks.print_identifier (file, node, indent);
877 break;
879 case TREE_LIST:
880 print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
881 print_node (file, "value", TREE_VALUE (node), indent + 4);
882 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
883 break;
885 case TREE_VEC:
886 len = TREE_VEC_LENGTH (node);
887 for (i = 0; i < len; i++)
888 if (TREE_VEC_ELT (node, i))
890 char temp[10];
891 sprintf (temp, "elt %d", i);
892 print_node (file, temp, TREE_VEC_ELT (node, i), indent + 4);
894 break;
896 case CONSTRUCTOR:
898 unsigned HOST_WIDE_INT cnt;
899 tree index, value;
900 len = vec_safe_length (CONSTRUCTOR_ELTS (node));
901 fprintf (file, " lngt %d", len);
902 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),
903 cnt, index, value)
905 print_node (file, "idx", index, indent + 4);
906 print_node (file, "val", value, indent + 4);
909 break;
911 case STATEMENT_LIST:
912 dump_addr (file, " head ", node->stmt_list.head);
913 dump_addr (file, " tail ", node->stmt_list.tail);
914 fprintf (file, " stmts");
916 tree_stmt_iterator i;
917 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
919 /* Not printing the addresses of the (not-a-tree)
920 'struct tree_stmt_list_node's. */
921 dump_addr (file, " ", tsi_stmt (i));
923 fprintf (file, "\n");
924 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
926 /* Not printing the addresses of the (not-a-tree)
927 'struct tree_stmt_list_node's. */
928 print_node (file, "stmt", tsi_stmt (i), indent + 4);
931 break;
933 case BLOCK:
934 print_node (file, "vars", BLOCK_VARS (node), indent + 4);
935 print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node),
936 indent + 4);
937 print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
938 print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
939 print_node (file, "abstract_origin",
940 BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
941 break;
943 case SSA_NAME:
944 print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
945 fprintf (file, "def_stmt ");
946 print_gimple_stmt (file, SSA_NAME_DEF_STMT (node), indent + 4, 0);
948 indent_to (file, indent + 4);
949 fprintf (file, "version %u", SSA_NAME_VERSION (node));
950 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
951 fprintf (file, " in-abnormal-phi");
952 if (SSA_NAME_IN_FREE_LIST (node))
953 fprintf (file, " in-free-list");
955 if (SSA_NAME_PTR_INFO (node))
957 indent_to (file, indent + 3);
958 if (SSA_NAME_PTR_INFO (node))
959 dump_addr (file, " ptr-info ", SSA_NAME_PTR_INFO (node));
961 break;
963 case OMP_CLAUSE:
965 int i;
966 fprintf (file, " %s",
967 omp_clause_code_name[OMP_CLAUSE_CODE (node)]);
968 for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (node)]; i++)
970 indent_to (file, indent + 4);
971 fprintf (file, "op %d:", i);
972 print_node_brief (file, "", OMP_CLAUSE_OPERAND (node, i), 0);
975 break;
977 case OPTIMIZATION_NODE:
978 cl_optimization_print (file, indent + 4, TREE_OPTIMIZATION (node));
979 break;
981 case TARGET_OPTION_NODE:
982 cl_target_option_print (file, indent + 4, TREE_TARGET_OPTION (node));
983 break;
984 case IMPORTED_DECL:
985 fprintf (file, " imported declaration");
986 print_node_brief (file, "associated declaration",
987 IMPORTED_DECL_ASSOCIATED_DECL (node),
988 indent + 4);
989 break;
991 default:
992 if (EXCEPTIONAL_CLASS_P (node))
993 lang_hooks.print_xnode (file, node, indent);
994 break;
997 break;
1000 if (EXPR_HAS_LOCATION (node))
1002 expanded_location xloc = expand_location (EXPR_LOCATION (node));
1003 indent_to (file, indent+4);
1004 fprintf (file, "%s:%d:%d", xloc.file, xloc.line, xloc.column);
1007 fprintf (file, ">");
1010 /* Print the tree vector VEC in full on file FILE, preceded by PREFIX,
1011 starting in column INDENT. */
1013 void
1014 print_vec_tree (FILE *file, const char *prefix, vec<tree, va_gc> *vec, int indent)
1016 tree elt;
1017 unsigned ix;
1019 /* Indent to the specified column, since this is the long form. */
1020 indent_to (file, indent);
1022 /* Print the slot this node is in, and its code, and address. */
1023 fprintf (file, "%s <VEC", prefix);
1024 dump_addr (file, " ", vec->address ());
1026 FOR_EACH_VEC_ELT (*vec, ix, elt)
1028 char temp[10];
1029 sprintf (temp, "elt %d", ix);
1030 print_node (file, temp, elt, indent + 4);