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