]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-dump.c
/cp
[thirdparty/gcc.git] / gcc / tree-dump.c
CommitLineData
74338ff6 1/* Tree-dumping functionality for intermediate representation.
d353bf18 2 Copyright (C) 1999-2015 Free Software Foundation, Inc.
74338ff6 3 Written by Mark Mitchell <mark@codesourcery.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
8c4c00c1 9Software Foundation; either version 3, or (at your option) any later
74338ff6 10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
8c4c00c1 18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
74338ff6 20
21#include "config.h"
22#include "system.h"
805e22b2 23#include "coretypes.h"
24#include "tm.h"
b20a8bb4 25#include "alias.h"
74338ff6 26#include "tree.h"
74338ff6 27#include "splay-tree.h"
82715bcd 28#include "filenames.h"
3119c950 29#include "tree-dump.h"
74338ff6 30#include "langhooks.h"
e8c5dd3c 31#include "tree-iterator.h"
c7d89805 32#include "tree-pretty-print.h"
dd9784d4 33#include "tree-cfg.h"
e913b5cd 34#include "wide-int-print.h"
74338ff6 35
9f627b1a 36static unsigned int queue (dump_info_p, const_tree, int);
d598ad0d 37static void dump_index (dump_info_p, unsigned int);
38static void dequeue_and_dump (dump_info_p);
39static void dump_new_line (dump_info_p);
40static void dump_maybe_newline (dump_info_p);
74338ff6 41
42/* Add T to the end of the queue of nodes to dump. Returns the index
43 assigned to T. */
44
45static unsigned int
9f627b1a 46queue (dump_info_p di, const_tree t, int flags)
74338ff6 47{
48 dump_queue_p dq;
49 dump_node_info_p dni;
50 unsigned int index;
51
52 /* Assign the next available index to T. */
53 index = ++di->index;
54
55 /* Obtain a new queue node. */
56 if (di->free_list)
57 {
58 dq = di->free_list;
59 di->free_list = dq->next;
60 }
61 else
4c36ffe6 62 dq = XNEW (struct dump_queue);
74338ff6 63
64 /* Create a new entry in the splay-tree. */
4c36ffe6 65 dni = XNEW (struct dump_node_info);
74338ff6 66 dni->index = index;
67 dni->binfo_p = ((flags & DUMP_BINFO) != 0);
40570cc2 68 dq->node = splay_tree_insert (di->nodes, (splay_tree_key) t,
74338ff6 69 (splay_tree_value) dni);
70
71 /* Add it to the end of the queue. */
72 dq->next = 0;
73 if (!di->queue_end)
74 di->queue = dq;
75 else
76 di->queue_end->next = dq;
77 di->queue_end = dq;
78
79 /* Return the index. */
80 return index;
81}
82
83static void
d598ad0d 84dump_index (dump_info_p di, unsigned int index)
74338ff6 85{
86 fprintf (di->stream, "@%-6u ", index);
87 di->column += 8;
88}
89
90/* If T has not already been output, queue it for subsequent output.
91 FIELD is a string to print before printing the index. Then, the
92 index of T is printed. */
93
94void
9f627b1a 95queue_and_dump_index (dump_info_p di, const char *field, const_tree t, int flags)
74338ff6 96{
97 unsigned int index;
98 splay_tree_node n;
99
100 /* If there's no node, just return. This makes for fewer checks in
101 our callers. */
102 if (!t)
103 return;
104
105 /* See if we've already queued or dumped this node. */
106 n = splay_tree_lookup (di->nodes, (splay_tree_key) t);
107 if (n)
108 index = ((dump_node_info_p) n->value)->index;
109 else
110 /* If we haven't, add it to the queue. */
111 index = queue (di, t, flags);
112
113 /* Print the index of the node. */
114 dump_maybe_newline (di);
115 fprintf (di->stream, "%-4s: ", field);
116 di->column += 6;
117 dump_index (di, index);
118}
119
120/* Dump the type of T. */
121
122void
9f627b1a 123queue_and_dump_type (dump_info_p di, const_tree t)
74338ff6 124{
125 queue_and_dump_index (di, "type", TREE_TYPE (t), DUMP_NONE);
126}
127
128/* Dump column control */
129#define SOL_COLUMN 25 /* Start of line column. */
130#define EOL_COLUMN 55 /* End of line column. */
131#define COLUMN_ALIGNMENT 15 /* Alignment. */
132
133/* Insert a new line in the dump output, and indent to an appropriate
134 place to start printing more fields. */
135
136static void
d598ad0d 137dump_new_line (dump_info_p di)
74338ff6 138{
139 fprintf (di->stream, "\n%*s", SOL_COLUMN, "");
140 di->column = SOL_COLUMN;
141}
142
143/* If necessary, insert a new line. */
144
145static void
d598ad0d 146dump_maybe_newline (dump_info_p di)
74338ff6 147{
148 int extra;
40570cc2 149
74338ff6 150 /* See if we need a new line. */
151 if (di->column > EOL_COLUMN)
152 dump_new_line (di);
153 /* See if we need any padding. */
154 else if ((extra = (di->column - SOL_COLUMN) % COLUMN_ALIGNMENT) != 0)
155 {
156 fprintf (di->stream, "%*s", COLUMN_ALIGNMENT - extra, "");
157 di->column += COLUMN_ALIGNMENT - extra;
158 }
159}
160
7bd765d4 161/* Dump FUNCTION_DECL FN as tree dump PHASE. */
162
163void
164dump_function (int phase, tree fn)
165{
166 FILE *stream;
167 int flags;
168
169 stream = dump_begin (phase, &flags);
170 if (stream)
171 {
172 dump_function_to_file (fn, stream, flags);
173 dump_end (phase, stream);
174 }
175}
176
74338ff6 177/* Dump pointer PTR using FIELD to identify it. */
178
179void
d598ad0d 180dump_pointer (dump_info_p di, const char *field, void *ptr)
74338ff6 181{
182 dump_maybe_newline (di);
fb2893a7 183 fprintf (di->stream, "%-4s: %-8" HOST_WIDE_INT_PRINT "x ", field,
184 (unsigned HOST_WIDE_INT) (uintptr_t) ptr);
74338ff6 185 di->column += 15;
186}
187
188/* Dump integer I using FIELD to identify it. */
189
190void
d598ad0d 191dump_int (dump_info_p di, const char *field, int i)
74338ff6 192{
193 dump_maybe_newline (di);
194 fprintf (di->stream, "%-4s: %-7d ", field, i);
195 di->column += 14;
196}
197
905582c1 198/* Dump the floating point value R, using FIELD to identify it. */
199
200static void
201dump_real (dump_info_p di, const char *field, const REAL_VALUE_TYPE *r)
202{
203 char buf[32];
204 real_to_decimal (buf, r, sizeof (buf), 0, true);
205 dump_maybe_newline (di);
206 fprintf (di->stream, "%-4s: %s ", field, buf);
207 di->column += strlen (buf) + 7;
208}
209
06f0b99c 210/* Dump the fixed-point value F, using FIELD to identify it. */
211
212static void
213dump_fixed (dump_info_p di, const char *field, const FIXED_VALUE_TYPE *f)
214{
215 char buf[32];
216 fixed_to_decimal (buf, f, sizeof (buf));
217 dump_maybe_newline (di);
218 fprintf (di->stream, "%-4s: %s ", field, buf);
219 di->column += strlen (buf) + 7;
220}
221
905582c1 222
74338ff6 223/* Dump the string S. */
224
225void
d598ad0d 226dump_string (dump_info_p di, const char *string)
74338ff6 227{
228 dump_maybe_newline (di);
229 fprintf (di->stream, "%-13s ", string);
230 if (strlen (string) > 13)
231 di->column += strlen (string) + 1;
232 else
233 di->column += 14;
234}
235
236/* Dump the string field S. */
237
5a471c32 238void
d598ad0d 239dump_string_field (dump_info_p di, const char *field, const char *string)
74338ff6 240{
241 dump_maybe_newline (di);
242 fprintf (di->stream, "%-4s: %-7s ", field, string);
243 if (strlen (string) > 7)
244 di->column += 6 + strlen (string) + 1;
245 else
246 di->column += 14;
247}
248
74338ff6 249/* Dump the next node in the queue. */
250
40570cc2 251static void
d598ad0d 252dequeue_and_dump (dump_info_p di)
74338ff6 253{
254 dump_queue_p dq;
255 splay_tree_node stn;
256 dump_node_info_p dni;
257 tree t;
258 unsigned int index;
259 enum tree_code code;
ce45a448 260 enum tree_code_class code_class;
74338ff6 261 const char* code_name;
262
263 /* Get the next node from the queue. */
264 dq = di->queue;
265 stn = dq->node;
266 t = (tree) stn->key;
267 dni = (dump_node_info_p) stn->value;
268 index = dni->index;
269
270 /* Remove the node from the queue, and put it on the free list. */
271 di->queue = dq->next;
272 if (!di->queue)
273 di->queue_end = 0;
274 dq->next = di->free_list;
275 di->free_list = dq;
276
277 /* Print the node index. */
278 dump_index (di, index);
279 /* And the type of node this is. */
280 if (dni->binfo_p)
281 code_name = "binfo";
282 else
f3d35d4d 283 code_name = get_tree_code_name (TREE_CODE (t));
74338ff6 284 fprintf (di->stream, "%-16s ", code_name);
285 di->column = 25;
286
287 /* Figure out what kind of node this is. */
288 code = TREE_CODE (t);
289 code_class = TREE_CODE_CLASS (code);
290
291 /* Although BINFOs are TREE_VECs, we dump them specially so as to be
292 more informative. */
293 if (dni->binfo_p)
294 {
95f3173a 295 unsigned ix;
f6cc6a08 296 tree base;
f1f41a6c 297 vec<tree, va_gc> *accesses = BINFO_BASE_ACCESSES (t);
d598ad0d 298
95f3173a 299 dump_child ("type", BINFO_TYPE (t));
300
57c28194 301 if (BINFO_VIRTUAL_P (t))
5a471c32 302 dump_string_field (di, "spec", "virt");
40570cc2 303
f6cc6a08 304 dump_int (di, "bases", BINFO_N_BASE_BINFOS (t));
305 for (ix = 0; BINFO_BASE_ITERATE (t, ix, base); ix++)
95f3173a 306 {
f1f41a6c 307 tree access = (accesses ? (*accesses)[ix] : access_public_node);
95f3173a 308 const char *string = NULL;
309
310 if (access == access_public_node)
311 string = "pub";
312 else if (access == access_protected_node)
313 string = "prot";
314 else if (access == access_private_node)
315 string = "priv";
316 else
8c0963c4 317 gcc_unreachable ();
d598ad0d 318
5a471c32 319 dump_string_field (di, "accs", string);
95f3173a 320 queue_and_dump_index (di, "binf", base, DUMP_BINFO);
321 }
d598ad0d 322
74338ff6 323 goto done;
324 }
325
326 /* We can knock off a bunch of expression nodes in exactly the same
327 way. */
328 if (IS_EXPR_CODE_CLASS (code_class))
329 {
330 /* If we're dumping children, dump them now. */
331 queue_and_dump_type (di, t);
332
333 switch (code_class)
334 {
ce45a448 335 case tcc_unary:
74338ff6 336 dump_child ("op 0", TREE_OPERAND (t, 0));
337 break;
40570cc2 338
ce45a448 339 case tcc_binary:
340 case tcc_comparison:
74338ff6 341 dump_child ("op 0", TREE_OPERAND (t, 0));
342 dump_child ("op 1", TREE_OPERAND (t, 1));
343 break;
40570cc2 344
ce45a448 345 case tcc_expression:
346 case tcc_reference:
347 case tcc_statement:
f43a1a60 348 case tcc_vl_exp:
74338ff6 349 /* These nodes are handled explicitly below. */
350 break;
40570cc2 351
74338ff6 352 default:
8c0963c4 353 gcc_unreachable ();
74338ff6 354 }
355 }
356 else if (DECL_P (t))
357 {
2ed8b5d0 358 expanded_location xloc;
74338ff6 359 /* All declarations have names. */
360 if (DECL_NAME (t))
361 dump_child ("name", DECL_NAME (t));
40570cc2 362 if (DECL_ASSEMBLER_NAME_SET_P (t)
74338ff6 363 && DECL_ASSEMBLER_NAME (t) != DECL_NAME (t))
364 dump_child ("mngl", DECL_ASSEMBLER_NAME (t));
9021d2da 365 if (DECL_ABSTRACT_ORIGIN (t))
366 dump_child ("orig", DECL_ABSTRACT_ORIGIN (t));
74338ff6 367 /* And types. */
368 queue_and_dump_type (di, t);
369 dump_child ("scpe", DECL_CONTEXT (t));
370 /* And a source position. */
2ed8b5d0 371 xloc = expand_location (DECL_SOURCE_LOCATION (t));
372 if (xloc.file)
74338ff6 373 {
82715bcd 374 const char *filename = lbasename (xloc.file);
74338ff6 375
376 dump_maybe_newline (di);
40570cc2 377 fprintf (di->stream, "srcp: %s:%-6d ", filename,
2ed8b5d0 378 xloc.line);
74338ff6 379 di->column += 6 + strlen (filename) + 8;
380 }
381 /* And any declaration can be compiler-generated. */
437f5d6b 382 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_COMMON)
383 && DECL_ARTIFICIAL (t))
5a471c32 384 dump_string_field (di, "note", "artificial");
1767a056 385 if (DECL_CHAIN (t) && !dump_flag (di, TDF_SLIM, NULL))
386 dump_child ("chain", DECL_CHAIN (t));
74338ff6 387 }
ce45a448 388 else if (code_class == tcc_type)
74338ff6 389 {
390 /* All types have qualifiers. */
dc24ddbd 391 int quals = lang_hooks.tree_dump.type_quals (t);
40570cc2 392
74338ff6 393 if (quals != TYPE_UNQUALIFIED)
394 {
395 fprintf (di->stream, "qual: %c%c%c ",
396 (quals & TYPE_QUAL_CONST) ? 'c' : ' ',
397 (quals & TYPE_QUAL_VOLATILE) ? 'v' : ' ',
398 (quals & TYPE_QUAL_RESTRICT) ? 'r' : ' ');
399 di->column += 14;
400 }
401
402 /* All types have associated declarations. */
403 dump_child ("name", TYPE_NAME (t));
404
405 /* All types have a main variant. */
406 if (TYPE_MAIN_VARIANT (t) != t)
407 dump_child ("unql", TYPE_MAIN_VARIANT (t));
40570cc2 408
74338ff6 409 /* And sizes. */
410 dump_child ("size", TYPE_SIZE (t));
411
412 /* All types have alignments. */
413 dump_int (di, "algn", TYPE_ALIGN (t));
414 }
ce45a448 415 else if (code_class == tcc_constant)
74338ff6 416 /* All constants can have types. */
417 queue_and_dump_type (di, t);
418
419 /* Give the language-specific code a chance to print something. If
420 it's completely taken care of things, don't bother printing
421 anything more ourselves. */
dc24ddbd 422 if (lang_hooks.tree_dump.dump_tree (di, t))
74338ff6 423 goto done;
424
425 /* Now handle the various kinds of nodes. */
426 switch (code)
427 {
428 int i;
429
430 case IDENTIFIER_NODE:
431 dump_string_field (di, "strg", IDENTIFIER_POINTER (t));
432 dump_int (di, "lngt", IDENTIFIER_LENGTH (t));
433 break;
434
435 case TREE_LIST:
436 dump_child ("purp", TREE_PURPOSE (t));
437 dump_child ("valu", TREE_VALUE (t));
438 dump_child ("chan", TREE_CHAIN (t));
439 break;
440
e8c5dd3c 441 case STATEMENT_LIST:
442 {
443 tree_stmt_iterator it;
444 for (i = 0, it = tsi_start (t); !tsi_end_p (it); tsi_next (&it), i++)
445 {
446 char buffer[32];
447 sprintf (buffer, "%u", i);
448 dump_child (buffer, tsi_stmt (it));
449 }
450 }
451 break;
452
74338ff6 453 case TREE_VEC:
454 dump_int (di, "lngt", TREE_VEC_LENGTH (t));
455 for (i = 0; i < TREE_VEC_LENGTH (t); ++i)
456 {
457 char buffer[32];
458 sprintf (buffer, "%u", i);
459 dump_child (buffer, TREE_VEC_ELT (t, i));
460 }
461 break;
462
463 case INTEGER_TYPE:
464 case ENUMERAL_TYPE:
465 dump_int (di, "prec", TYPE_PRECISION (t));
5a471c32 466 dump_string_field (di, "sign", TYPE_UNSIGNED (t) ? "unsigned": "signed");
74338ff6 467 dump_child ("min", TYPE_MIN_VALUE (t));
468 dump_child ("max", TYPE_MAX_VALUE (t));
469
470 if (code == ENUMERAL_TYPE)
471 dump_child ("csts", TYPE_VALUES (t));
472 break;
473
474 case REAL_TYPE:
475 dump_int (di, "prec", TYPE_PRECISION (t));
476 break;
477
06f0b99c 478 case FIXED_POINT_TYPE:
479 dump_int (di, "prec", TYPE_PRECISION (t));
480 dump_string_field (di, "sign", TYPE_UNSIGNED (t) ? "unsigned": "signed");
481 dump_string_field (di, "saturating",
482 TYPE_SATURATING (t) ? "saturating": "non-saturating");
483 break;
484
74338ff6 485 case POINTER_TYPE:
486 dump_child ("ptd", TREE_TYPE (t));
487 break;
488
489 case REFERENCE_TYPE:
490 dump_child ("refd", TREE_TYPE (t));
491 break;
492
493 case METHOD_TYPE:
494 dump_child ("clas", TYPE_METHOD_BASETYPE (t));
495 /* Fall through. */
496
497 case FUNCTION_TYPE:
498 dump_child ("retn", TREE_TYPE (t));
499 dump_child ("prms", TYPE_ARG_TYPES (t));
500 break;
501
502 case ARRAY_TYPE:
503 dump_child ("elts", TREE_TYPE (t));
504 dump_child ("domn", TYPE_DOMAIN (t));
505 break;
506
507 case RECORD_TYPE:
508 case UNION_TYPE:
509 if (TREE_CODE (t) == RECORD_TYPE)
5a471c32 510 dump_string_field (di, "tag", "struct");
74338ff6 511 else
5a471c32 512 dump_string_field (di, "tag", "union");
40570cc2 513
74338ff6 514 dump_child ("flds", TYPE_FIELDS (t));
515 dump_child ("fncs", TYPE_METHODS (t));
40570cc2 516 queue_and_dump_index (di, "binf", TYPE_BINFO (t),
74338ff6 517 DUMP_BINFO);
518 break;
519
520 case CONST_DECL:
521 dump_child ("cnst", DECL_INITIAL (t));
522 break;
523
688ff29b 524 case DEBUG_EXPR_DECL:
525 dump_int (di, "-uid", DEBUG_TEMP_UID (t));
526 /* Fall through. */
527
74338ff6 528 case VAR_DECL:
529 case PARM_DECL:
530 case FIELD_DECL:
531 case RESULT_DECL:
532 if (TREE_CODE (t) == PARM_DECL)
533 dump_child ("argt", DECL_ARG_TYPE (t));
534 else
535 dump_child ("init", DECL_INITIAL (t));
536 dump_child ("size", DECL_SIZE (t));
537 dump_int (di, "algn", DECL_ALIGN (t));
538
539 if (TREE_CODE (t) == FIELD_DECL)
540 {
74338ff6 541 if (DECL_FIELD_OFFSET (t))
542 dump_child ("bpos", bit_position (t));
543 }
40570cc2 544 else if (TREE_CODE (t) == VAR_DECL
74338ff6 545 || TREE_CODE (t) == PARM_DECL)
546 {
547 dump_int (di, "used", TREE_USED (t));
548 if (DECL_REGISTER (t))
5a471c32 549 dump_string_field (di, "spec", "register");
74338ff6 550 }
551 break;
552
553 case FUNCTION_DECL:
554 dump_child ("args", DECL_ARGUMENTS (t));
555 if (DECL_EXTERNAL (t))
5a471c32 556 dump_string_field (di, "body", "undefined");
74338ff6 557 if (TREE_PUBLIC (t))
5a471c32 558 dump_string_field (di, "link", "extern");
74338ff6 559 else
5a471c32 560 dump_string_field (di, "link", "static");
de9ebaea 561 if (DECL_SAVED_TREE (t) && !dump_flag (di, TDF_SLIM, t))
74338ff6 562 dump_child ("body", DECL_SAVED_TREE (t));
563 break;
564
74338ff6 565 case INTEGER_CST:
e913b5cd 566 fprintf (di->stream, "int: ");
6da74b21 567 print_decs (t, di->stream);
74338ff6 568 break;
569
570 case STRING_CST:
571 fprintf (di->stream, "strg: %-7s ", TREE_STRING_POINTER (t));
572 dump_int (di, "lngt", TREE_STRING_LENGTH (t));
573 break;
574
905582c1 575 case REAL_CST:
576 dump_real (di, "valu", TREE_REAL_CST_PTR (t));
577 break;
578
06f0b99c 579 case FIXED_CST:
580 dump_fixed (di, "valu", TREE_FIXED_CST_PTR (t));
581 break;
582
74338ff6 583 case TRUTH_NOT_EXPR:
584 case ADDR_EXPR:
585 case INDIRECT_REF:
586 case CLEANUP_POINT_EXPR:
587 case SAVE_EXPR:
b25de375 588 case REALPART_EXPR:
589 case IMAGPART_EXPR:
74338ff6 590 /* These nodes are unary, but do not have code class `1'. */
591 dump_child ("op 0", TREE_OPERAND (t, 0));
592 break;
593
594 case TRUTH_ANDIF_EXPR:
595 case TRUTH_ORIF_EXPR:
596 case INIT_EXPR:
597 case MODIFY_EXPR:
74338ff6 598 case COMPOUND_EXPR:
74338ff6 599 case PREDECREMENT_EXPR:
600 case PREINCREMENT_EXPR:
601 case POSTDECREMENT_EXPR:
602 case POSTINCREMENT_EXPR:
603 /* These nodes are binary, but do not have code class `2'. */
604 dump_child ("op 0", TREE_OPERAND (t, 0));
605 dump_child ("op 1", TREE_OPERAND (t, 1));
606 break;
607
6374121b 608 case COMPONENT_REF:
7f85203b 609 case BIT_FIELD_REF:
6374121b 610 dump_child ("op 0", TREE_OPERAND (t, 0));
611 dump_child ("op 1", TREE_OPERAND (t, 1));
612 dump_child ("op 2", TREE_OPERAND (t, 2));
613 break;
614
615 case ARRAY_REF:
616 case ARRAY_RANGE_REF:
617 dump_child ("op 0", TREE_OPERAND (t, 0));
618 dump_child ("op 1", TREE_OPERAND (t, 1));
619 dump_child ("op 2", TREE_OPERAND (t, 2));
620 dump_child ("op 3", TREE_OPERAND (t, 3));
621 break;
622
74338ff6 623 case COND_EXPR:
624 dump_child ("op 0", TREE_OPERAND (t, 0));
625 dump_child ("op 1", TREE_OPERAND (t, 1));
626 dump_child ("op 2", TREE_OPERAND (t, 2));
627 break;
628
9021d2da 629 case TRY_FINALLY_EXPR:
630 dump_child ("op 0", TREE_OPERAND (t, 0));
631 dump_child ("op 1", TREE_OPERAND (t, 1));
632 break;
633
74338ff6 634 case CALL_EXPR:
c2f47e15 635 {
636 int i = 0;
637 tree arg;
638 call_expr_arg_iterator iter;
639 dump_child ("fn", CALL_EXPR_FN (t));
640 FOR_EACH_CALL_EXPR_ARG (arg, iter, t)
641 {
642 char buffer[32];
643 sprintf (buffer, "%u", i);
644 dump_child (buffer, arg);
645 i++;
646 }
647 }
74338ff6 648 break;
649
650 case CONSTRUCTOR:
c75b4594 651 {
652 unsigned HOST_WIDE_INT cnt;
653 tree index, value;
f1f41a6c 654 dump_int (di, "lngt", vec_safe_length (CONSTRUCTOR_ELTS (t)));
c75b4594 655 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), cnt, index, value)
656 {
657 dump_child ("idx", index);
658 dump_child ("val", value);
659 }
660 }
74338ff6 661 break;
662
74338ff6 663 case BIND_EXPR:
664 dump_child ("vars", TREE_OPERAND (t, 0));
665 dump_child ("body", TREE_OPERAND (t, 1));
666 break;
667
668 case LOOP_EXPR:
669 dump_child ("body", TREE_OPERAND (t, 0));
670 break;
671
672 case EXIT_EXPR:
673 dump_child ("cond", TREE_OPERAND (t, 0));
674 break;
675
9021d2da 676 case RETURN_EXPR:
677 dump_child ("expr", TREE_OPERAND (t, 0));
678 break;
679
74338ff6 680 case TARGET_EXPR:
681 dump_child ("decl", TREE_OPERAND (t, 0));
682 dump_child ("init", TREE_OPERAND (t, 1));
683 dump_child ("clnp", TREE_OPERAND (t, 2));
684 /* There really are two possible places the initializer can be.
685 After RTL expansion, the second operand is moved to the
686 position of the fourth operand, and the second operand
687 becomes NULL. */
688 dump_child ("init", TREE_OPERAND (t, 3));
689 break;
40570cc2 690
9021d2da 691 case CASE_LABEL_EXPR:
692 dump_child ("name", CASE_LABEL (t));
7d4c98bc 693 if (CASE_LOW (t))
694 {
695 dump_child ("low ", CASE_LOW (t));
696 if (CASE_HIGH (t))
697 dump_child ("high", CASE_HIGH (t));
9021d2da 698 }
9021d2da 699 break;
700 case LABEL_EXPR:
701 dump_child ("name", TREE_OPERAND (t,0));
702 break;
703 case GOTO_EXPR:
704 dump_child ("labl", TREE_OPERAND (t, 0));
705 break;
706 case SWITCH_EXPR:
707 dump_child ("cond", TREE_OPERAND (t, 0));
708 dump_child ("body", TREE_OPERAND (t, 1));
709 if (TREE_OPERAND (t, 2))
710 {
711 dump_child ("labl", TREE_OPERAND (t,2));
712 }
713 break;
55d6e7cd 714 case OMP_CLAUSE:
715 {
716 int i;
717 fprintf (di->stream, "%s\n", omp_clause_code_name[OMP_CLAUSE_CODE (t)]);
718 for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (t)]; i++)
719 dump_child ("op: ", OMP_CLAUSE_OPERAND (t, i));
720 }
721 break;
74338ff6 722 default:
723 /* There are no additional fields to print. */
724 break;
725 }
726
727 done:
728 if (dump_flag (di, TDF_ADDRESS, NULL))
729 dump_pointer (di, "addr", (void *)t);
40570cc2 730
74338ff6 731 /* Terminate the line. */
732 fprintf (di->stream, "\n");
733}
734
f712a0dc 735/* Return nonzero if FLAG has been specified for the dump, and NODE
74338ff6 736 is not the root node of the dump. */
737
9f627b1a 738int dump_flag (dump_info_p di, int flag, const_tree node)
74338ff6 739{
740 return (di->flags & flag) && (node != di->node);
741}
742
743/* Dump T, and all its children, on STREAM. */
744
745void
9f627b1a 746dump_node (const_tree t, int flags, FILE *stream)
74338ff6 747{
748 struct dump_info di;
749 dump_queue_p dq;
750 dump_queue_p next_dq;
751
752 /* Initialize the dump-information structure. */
753 di.stream = stream;
754 di.index = 0;
755 di.column = 0;
756 di.queue = 0;
757 di.queue_end = 0;
758 di.free_list = 0;
759 di.flags = flags;
760 di.node = t;
40570cc2 761 di.nodes = splay_tree_new (splay_tree_compare_pointers, 0,
74338ff6 762 (splay_tree_delete_value_fn) &free);
763
764 /* Queue up the first node. */
765 queue (&di, t, DUMP_NONE);
766
767 /* Until the queue is empty, keep dumping nodes. */
768 while (di.queue)
769 dequeue_and_dump (&di);
770
771 /* Now, clean up. */
772 for (dq = di.free_list; dq; dq = next_dq)
773 {
774 next_dq = dq->next;
775 free (dq);
776 }
777 splay_tree_delete (di.nodes);
778}