]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-pretty-print.c
Daily bump.
[thirdparty/gcc.git] / gcc / tree-pretty-print.c
CommitLineData
6de9cd9a 1/* Pretty formatting of GENERIC trees in C syntax.
3aecd443
JJ
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
3 2011 Free Software Foundation, Inc.
6de9cd9a
DN
4 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
9dcd6f09 10Software Foundation; either version 3, or (at your option) any later
6de9cd9a
DN
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
9dcd6f09
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
6de9cd9a
DN
21
22#include "config.h"
23#include "system.h"
24#include "coretypes.h"
25#include "tm.h"
6de9cd9a 26#include "tree.h"
cf835838 27#include "tree-pretty-print.h"
6de9cd9a
DN
28#include "hashtab.h"
29#include "tree-flow.h"
30#include "langhooks.h"
31#include "tree-iterator.h"
4619c701 32#include "tree-chrec.h"
7ee2468b 33#include "dumpfile.h"
6946b3f7 34#include "value-prof.h"
2e28e797 35#include "predict.h"
6de9cd9a
DN
36
37/* Local functions, macros and variables. */
ac545c64 38static const char *op_symbol (const_tree);
6de9cd9a 39static void pretty_print_string (pretty_printer *, const char*);
6de9cd9a
DN
40static void newline_and_indent (pretty_printer *, int);
41static void maybe_init_pretty_print (FILE *);
ac545c64
KG
42static void print_struct_decl (pretty_printer *, const_tree, int, int);
43static void do_niy (pretty_printer *, const_tree);
6de9cd9a
DN
44
45#define INDENT(SPACE) do { \
46 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
47
48#define NIY do_niy(buffer,node)
49
6de9cd9a
DN
50static pretty_printer buffer;
51static int initialized = 0;
6de9cd9a
DN
52
53/* Try to print something for an unknown tree code. */
54
55static void
ac545c64 56do_niy (pretty_printer *buffer, const_tree node)
6de9cd9a
DN
57{
58 int i, len;
59
60 pp_string (buffer, "<<< Unknown tree: ");
61 pp_string (buffer, tree_code_name[(int) TREE_CODE (node)]);
62
6615c446 63 if (EXPR_P (node))
6de9cd9a 64 {
5039610b 65 len = TREE_OPERAND_LENGTH (node);
6de9cd9a
DN
66 for (i = 0; i < len; ++i)
67 {
68 newline_and_indent (buffer, 2);
69 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
70 }
71 }
72
f051cb5d 73 pp_string (buffer, " >>>");
6de9cd9a
DN
74}
75
434548f6
AP
76/* Debugging function to print out a generic expression. */
77
24e47c76 78DEBUG_FUNCTION void
6de9cd9a
DN
79debug_generic_expr (tree t)
80{
38635499 81 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
6de9cd9a
DN
82 fprintf (stderr, "\n");
83}
84
434548f6
AP
85/* Debugging function to print out a generic statement. */
86
24e47c76 87DEBUG_FUNCTION void
6de9cd9a
DN
88debug_generic_stmt (tree t)
89{
38635499 90 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
6de9cd9a
DN
91 fprintf (stderr, "\n");
92}
93
434548f6
AP
94/* Debugging function to print out a chain of trees . */
95
24e47c76 96DEBUG_FUNCTION void
953ff289
DN
97debug_tree_chain (tree t)
98{
e923c8ea
DN
99 struct pointer_set_t *seen = pointer_set_create ();
100
406f9d5e 101 while (t)
e923c8ea
DN
102 {
103 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
104 fprintf (stderr, " ");
105 t = TREE_CHAIN (t);
106 if (pointer_set_insert (seen, t))
107 {
108 fprintf (stderr, "... [cycled back to ");
109 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
110 fprintf (stderr, "]");
111 break;
112 }
113 }
953ff289 114 fprintf (stderr, "\n");
e923c8ea
DN
115
116 pointer_set_destroy (seen);
953ff289
DN
117}
118
6de9cd9a
DN
119/* Prints declaration DECL to the FILE with details specified by FLAGS. */
120void
121print_generic_decl (FILE *file, tree decl, int flags)
122{
123 maybe_init_pretty_print (file);
6de9cd9a
DN
124 print_declaration (&buffer, decl, 2, flags);
125 pp_write_text_to_stream (&buffer);
126}
127
128/* Print tree T, and its successors, on file FILE. FLAGS specifies details
7ee2468b 129 to show in the dump. See TDF_* in dumpfile.h. */
6de9cd9a
DN
130
131void
132print_generic_stmt (FILE *file, tree t, int flags)
133{
134 maybe_init_pretty_print (file);
6de9cd9a 135 dump_generic_node (&buffer, t, 0, flags, true);
f8923f7e 136 pp_newline_and_flush (&buffer);
6de9cd9a
DN
137}
138
139/* Print tree T, and its successors, on file FILE. FLAGS specifies details
7ee2468b 140 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
6de9cd9a
DN
141 INDENT spaces. */
142
143void
144print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
145{
146 int i;
147
148 maybe_init_pretty_print (file);
6de9cd9a
DN
149
150 for (i = 0; i < indent; i++)
151 pp_space (&buffer);
152 dump_generic_node (&buffer, t, indent, flags, true);
f8923f7e 153 pp_newline_and_flush (&buffer);
6de9cd9a
DN
154}
155
156/* Print a single expression T on file FILE. FLAGS specifies details to show
7ee2468b 157 in the dump. See TDF_* in dumpfile.h. */
6de9cd9a
DN
158
159void
160print_generic_expr (FILE *file, tree t, int flags)
161{
162 maybe_init_pretty_print (file);
6de9cd9a
DN
163 dump_generic_node (&buffer, t, 0, flags, false);
164}
165
166/* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
167 in FLAGS. */
168
169static void
170dump_decl_name (pretty_printer *buffer, tree node, int flags)
171{
394bd84d
RH
172 if (DECL_NAME (node))
173 {
174 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
175 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
176 else
177 pp_tree_identifier (buffer, DECL_NAME (node));
178 }
179 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
6de9cd9a 180 {
394bd84d 181 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
831b9ef8 182 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
0ca5af51 183 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
831b9ef8
RG
184 {
185 if (flags & TDF_NOUID)
186 pp_string (buffer, "D#xxxx");
187 else
188 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
189 }
406f9d5e 190 else
0534fa56 191 {
394bd84d 192 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
831b9ef8
RG
193 if (flags & TDF_NOUID)
194 pp_printf (buffer, "%c.xxxx", c);
195 else
196 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
0534fa56 197 }
6de9cd9a 198 }
25a6a873
RG
199 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
200 {
201 if (flags & TDF_NOUID)
202 pp_printf (buffer, "ptD.xxxx");
203 else
204 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
205 }
6de9cd9a
DN
206}
207
05cf561d
SB
208/* Like the above, but used for pretty printing function calls. */
209
210static void
394bd84d 211dump_function_name (pretty_printer *buffer, tree node, int flags)
05cf561d 212{
394bd84d
RH
213 if (TREE_CODE (node) == NOP_EXPR)
214 node = TREE_OPERAND (node, 0);
215 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
216 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
05cf561d 217 else
394bd84d 218 dump_decl_name (buffer, node, flags);
05cf561d
SB
219}
220
5f2dcbe1
RK
221/* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
222 FLAGS are as in dump_generic_node. */
223
224static void
225dump_function_declaration (pretty_printer *buffer, tree node,
226 int spc, int flags)
227{
228 bool wrote_arg = false;
229 tree arg;
230
231 pp_space (buffer);
232 pp_character (buffer, '(');
233
930672ad 234 /* Print the argument types. */
5f2dcbe1 235 arg = TYPE_ARG_TYPES (node);
930672ad 236 while (arg && arg != void_list_node && arg != error_mark_node)
5f2dcbe1 237 {
930672ad 238 if (wrote_arg)
5f2dcbe1
RK
239 {
240 pp_character (buffer, ',');
241 pp_space (buffer);
242 }
930672ad
RG
243 wrote_arg = true;
244 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
245 arg = TREE_CHAIN (arg);
5f2dcbe1
RK
246 }
247
930672ad
RG
248 /* Drop the trailing void_type_node if we had any previous argument. */
249 if (arg == void_list_node && !wrote_arg)
5f2dcbe1 250 pp_string (buffer, "void");
930672ad
RG
251 /* Properly dump vararg function types. */
252 else if (!arg && wrote_arg)
253 pp_string (buffer, ", ...");
254 /* Avoid printing any arg for unprototyped functions. */
5f2dcbe1
RK
255
256 pp_character (buffer, ')');
257}
258
b16bcb17
RH
259/* Dump the domain associated with an array. */
260
261static void
262dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
263{
264 pp_character (buffer, '[');
265 if (domain)
266 {
267 tree min = TYPE_MIN_VALUE (domain);
268 tree max = TYPE_MAX_VALUE (domain);
269
270 if (min && max
271 && integer_zerop (min)
272 && host_integerp (max, 0))
273 pp_wide_integer (buffer, TREE_INT_CST_LOW (max) + 1);
274 else
275 {
276 if (min)
277 dump_generic_node (buffer, min, spc, flags, false);
278 pp_character (buffer, ':');
279 if (max)
280 dump_generic_node (buffer, max, spc, flags, false);
281 }
282 }
283 else
284 pp_string (buffer, "<unknown>");
285 pp_character (buffer, ']');
286}
287
aaf46ef9
DN
288
289/* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
290 dump_generic_node. */
953ff289
DN
291
292static void
aaf46ef9 293dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
953ff289
DN
294{
295 const char *name;
296
aaf46ef9 297 switch (OMP_CLAUSE_CODE (clause))
953ff289 298 {
aaf46ef9
DN
299 case OMP_CLAUSE_PRIVATE:
300 name = "private";
301 goto print_remap;
302 case OMP_CLAUSE_SHARED:
303 name = "shared";
304 goto print_remap;
305 case OMP_CLAUSE_FIRSTPRIVATE:
306 name = "firstprivate";
307 goto print_remap;
308 case OMP_CLAUSE_LASTPRIVATE:
309 name = "lastprivate";
310 goto print_remap;
311 case OMP_CLAUSE_COPYIN:
312 name = "copyin";
313 goto print_remap;
314 case OMP_CLAUSE_COPYPRIVATE:
315 name = "copyprivate";
316 goto print_remap;
317 print_remap:
318 pp_string (buffer, name);
319 pp_character (buffer, '(');
320 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
321 spc, flags, false);
322 pp_character (buffer, ')');
323 break;
953ff289 324
aaf46ef9
DN
325 case OMP_CLAUSE_REDUCTION:
326 pp_string (buffer, "reduction(");
bbc8a8dc 327 pp_string (buffer, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
aaf46ef9
DN
328 pp_character (buffer, ':');
329 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
330 spc, flags, false);
331 pp_character (buffer, ')');
332 break;
953ff289 333
aaf46ef9
DN
334 case OMP_CLAUSE_IF:
335 pp_string (buffer, "if(");
336 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
337 spc, flags, false);
338 pp_character (buffer, ')');
339 break;
953ff289 340
aaf46ef9
DN
341 case OMP_CLAUSE_NUM_THREADS:
342 pp_string (buffer, "num_threads(");
343 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
344 spc, flags, false);
345 pp_character (buffer, ')');
346 break;
953ff289 347
aaf46ef9
DN
348 case OMP_CLAUSE_NOWAIT:
349 pp_string (buffer, "nowait");
350 break;
351 case OMP_CLAUSE_ORDERED:
352 pp_string (buffer, "ordered");
353 break;
953ff289 354
aaf46ef9
DN
355 case OMP_CLAUSE_DEFAULT:
356 pp_string (buffer, "default(");
357 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
358 {
a68ab351
JJ
359 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
360 break;
361 case OMP_CLAUSE_DEFAULT_SHARED:
362 pp_string (buffer, "shared");
363 break;
364 case OMP_CLAUSE_DEFAULT_NONE:
365 pp_string (buffer, "none");
366 break;
367 case OMP_CLAUSE_DEFAULT_PRIVATE:
368 pp_string (buffer, "private");
369 break;
370 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
371 pp_string (buffer, "firstprivate");
372 break;
373 default:
374 gcc_unreachable ();
aaf46ef9
DN
375 }
376 pp_character (buffer, ')');
377 break;
953ff289 378
aaf46ef9
DN
379 case OMP_CLAUSE_SCHEDULE:
380 pp_string (buffer, "schedule(");
381 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
382 {
383 case OMP_CLAUSE_SCHEDULE_STATIC:
384 pp_string (buffer, "static");
385 break;
386 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
387 pp_string (buffer, "dynamic");
388 break;
389 case OMP_CLAUSE_SCHEDULE_GUIDED:
390 pp_string (buffer, "guided");
391 break;
392 case OMP_CLAUSE_SCHEDULE_RUNTIME:
393 pp_string (buffer, "runtime");
394 break;
a68ab351
JJ
395 case OMP_CLAUSE_SCHEDULE_AUTO:
396 pp_string (buffer, "auto");
397 break;
aaf46ef9
DN
398 default:
399 gcc_unreachable ();
953ff289 400 }
aaf46ef9
DN
401 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
402 {
403 pp_character (buffer, ',');
404 dump_generic_node (buffer,
405 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
406 spc, flags, false);
407 }
408 pp_character (buffer, ')');
409 break;
410
a68ab351
JJ
411 case OMP_CLAUSE_UNTIED:
412 pp_string (buffer, "untied");
413 break;
414
415 case OMP_CLAUSE_COLLAPSE:
416 pp_string (buffer, "collapse(");
417 dump_generic_node (buffer,
418 OMP_CLAUSE_COLLAPSE_EXPR (clause),
419 spc, flags, false);
420 pp_character (buffer, ')');
421 break;
422
20906c66
JJ
423 case OMP_CLAUSE_FINAL:
424 pp_string (buffer, "final(");
425 dump_generic_node (buffer, OMP_CLAUSE_FINAL_EXPR (clause),
426 spc, flags, false);
427 pp_character (buffer, ')');
428 break;
429
430 case OMP_CLAUSE_MERGEABLE:
431 pp_string (buffer, "mergeable");
432 break;
433
aaf46ef9
DN
434 default:
435 /* Should never happen. */
436 dump_generic_node (buffer, clause, spc, flags, false);
437 break;
438 }
439}
440
441
442/* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
443 dump_generic_node. */
444
726a989a 445void
aaf46ef9
DN
446dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
447{
448 if (clause == NULL)
449 return;
953ff289 450
aaf46ef9
DN
451 pp_space (buffer);
452 while (1)
453 {
454 dump_omp_clause (buffer, clause, spc, flags);
953ff289
DN
455 clause = OMP_CLAUSE_CHAIN (clause);
456 if (clause == NULL)
457 return;
458 pp_space (buffer);
459 }
460}
461
aaf46ef9 462
65332587
DN
463/* Dump location LOC to BUFFER. */
464
465static void
466dump_location (pretty_printer *buffer, location_t loc)
467{
468 expanded_location xloc = expand_location (loc);
469
470 pp_character (buffer, '[');
471 if (xloc.file)
472 {
473 pp_string (buffer, xloc.file);
474 pp_string (buffer, " : ");
475 }
476 pp_decimal_int (buffer, xloc.line);
477 pp_string (buffer, "] ");
478}
479
480
481/* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
482 dump_generic_node. */
483
484static void
485dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
486{
487 tree t;
488
489 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
490
491 if (flags & TDF_ADDRESS)
492 pp_printf (buffer, "[%p] ", (void *) block);
493
494 if (BLOCK_ABSTRACT (block))
495 pp_string (buffer, "[abstract] ");
496
497 if (TREE_ASM_WRITTEN (block))
498 pp_string (buffer, "[written] ");
499
500 if (flags & TDF_SLIM)
501 return;
502
503 if (BLOCK_SOURCE_LOCATION (block))
504 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
505
506 newline_and_indent (buffer, spc + 2);
507
508 if (BLOCK_SUPERCONTEXT (block))
509 {
510 pp_string (buffer, "SUPERCONTEXT: ");
511 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
512 flags | TDF_SLIM, false);
513 newline_and_indent (buffer, spc + 2);
514 }
515
516 if (BLOCK_SUBBLOCKS (block))
517 {
518 pp_string (buffer, "SUBBLOCKS: ");
519 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
520 {
521 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
522 pp_string (buffer, " ");
523 }
524 newline_and_indent (buffer, spc + 2);
525 }
526
527 if (BLOCK_CHAIN (block))
528 {
529 pp_string (buffer, "SIBLINGS: ");
530 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
531 {
532 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
533 pp_string (buffer, " ");
534 }
535 newline_and_indent (buffer, spc + 2);
536 }
537
538 if (BLOCK_VARS (block))
539 {
540 pp_string (buffer, "VARS: ");
541 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
542 {
543 dump_generic_node (buffer, t, 0, flags, false);
544 pp_string (buffer, " ");
545 }
546 newline_and_indent (buffer, spc + 2);
547 }
548
549 if (VEC_length (tree, BLOCK_NONLOCALIZED_VARS (block)) > 0)
550 {
551 unsigned i;
552 VEC(tree,gc) *nlv = BLOCK_NONLOCALIZED_VARS (block);
553
554 pp_string (buffer, "NONLOCALIZED_VARS: ");
ac47786e 555 FOR_EACH_VEC_ELT (tree, nlv, i, t)
65332587
DN
556 {
557 dump_generic_node (buffer, t, 0, flags, false);
558 pp_string (buffer, " ");
559 }
560 newline_and_indent (buffer, spc + 2);
561 }
562
563 if (BLOCK_ABSTRACT_ORIGIN (block))
564 {
565 pp_string (buffer, "ABSTRACT_ORIGIN: ");
566 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
567 flags | TDF_SLIM, false);
568 newline_and_indent (buffer, spc + 2);
569 }
570
571 if (BLOCK_FRAGMENT_ORIGIN (block))
572 {
573 pp_string (buffer, "FRAGMENT_ORIGIN: ");
574 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
575 flags | TDF_SLIM, false);
576 newline_and_indent (buffer, spc + 2);
577 }
578
579 if (BLOCK_FRAGMENT_CHAIN (block))
580 {
581 pp_string (buffer, "FRAGMENT_CHAIN: ");
582 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
583 {
584 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
585 pp_string (buffer, " ");
586 }
587 newline_and_indent (buffer, spc + 2);
588 }
589}
590
591
3e894af1
KZ
592/* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
593 indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 594 dumpfile.h). If IS_STMT is true, the object printed is considered
3e894af1 595 to be a statement and it is terminated by ';' if appropriate. */
6de9cd9a
DN
596
597int
598dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
599 bool is_stmt)
600{
601 tree type;
602 tree op0, op1;
5f2dcbe1 603 const char *str;
6de9cd9a 604 bool is_expr;
3f30a9a6 605 enum tree_code code;
6de9cd9a
DN
606
607 if (node == NULL_TREE)
608 return spc;
609
726a989a 610 is_expr = EXPR_P (node);
6de9cd9a 611
f430bae8 612 if (is_stmt && (flags & TDF_STMTADDR))
dbb9a00f 613 pp_printf (buffer, "<&%p> ", (void *)node);
f430bae8 614
953ff289 615 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
65332587 616 dump_location (buffer, EXPR_LOCATION (node));
6de9cd9a 617
3f30a9a6
RH
618 code = TREE_CODE (node);
619 switch (code)
6de9cd9a
DN
620 {
621 case ERROR_MARK:
622 pp_string (buffer, "<<< error >>>");
623 break;
624
625 case IDENTIFIER_NODE:
626 pp_tree_identifier (buffer, node);
627 break;
628
629 case TREE_LIST:
630 while (node && node != error_mark_node)
631 {
632 if (TREE_PURPOSE (node))
633 {
634 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
635 pp_space (buffer);
636 }
637 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
638 node = TREE_CHAIN (node);
639 if (node && TREE_CODE (node) == TREE_LIST)
640 {
641 pp_character (buffer, ',');
642 pp_space (buffer);
643 }
644 }
645 break;
646
55e9452e 647 case TREE_BINFO:
6de9cd9a 648 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
413d3aa8 649 break;
55e9452e
DB
650
651 case TREE_VEC:
652 {
653 size_t i;
654 if (TREE_VEC_LENGTH (node) > 0)
655 {
656 size_t len = TREE_VEC_LENGTH (node);
657 for (i = 0; i < len - 1; i++)
b8698a0f 658 {
55e9452e
DB
659 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
660 false);
661 pp_character (buffer, ',');
662 pp_space (buffer);
663 }
b8698a0f 664 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
55e9452e
DB
665 flags, false);
666 }
667 }
6de9cd9a
DN
668 break;
669
6de9cd9a
DN
670 case VOID_TYPE:
671 case INTEGER_TYPE:
672 case REAL_TYPE:
325217ed 673 case FIXED_POINT_TYPE:
6de9cd9a
DN
674 case COMPLEX_TYPE:
675 case VECTOR_TYPE:
676 case ENUMERAL_TYPE:
677 case BOOLEAN_TYPE:
6de9cd9a
DN
678 {
679 unsigned int quals = TYPE_QUALS (node);
82d6e6fc 680 enum tree_code_class tclass;
6de9cd9a
DN
681
682 if (quals & TYPE_QUAL_CONST)
683 pp_string (buffer, "const ");
684 else if (quals & TYPE_QUAL_VOLATILE)
685 pp_string (buffer, "volatile ");
686 else if (quals & TYPE_QUAL_RESTRICT)
687 pp_string (buffer, "restrict ");
688
09e881c9
BE
689 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
690 {
691 pp_string (buffer, "<address-space-");
692 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
693 pp_string (buffer, "> ");
694 }
695
82d6e6fc 696 tclass = TREE_CODE_CLASS (TREE_CODE (node));
6de9cd9a 697
82d6e6fc 698 if (tclass == tcc_declaration)
6de9cd9a
DN
699 {
700 if (DECL_NAME (node))
701 dump_decl_name (buffer, node, flags);
702 else
703 pp_string (buffer, "<unnamed type decl>");
704 }
82d6e6fc 705 else if (tclass == tcc_type)
6de9cd9a
DN
706 {
707 if (TYPE_NAME (node))
708 {
709 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
710 pp_tree_identifier (buffer, TYPE_NAME (node));
711 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
712 && DECL_NAME (TYPE_NAME (node)))
713 dump_decl_name (buffer, TYPE_NAME (node), flags);
714 else
56bac5af
DP
715 pp_string (buffer, "<unnamed type>");
716 }
717 else if (TREE_CODE (node) == VECTOR_TYPE)
718 {
74367220
RG
719 pp_string (buffer, "vector");
720 pp_character (buffer, '(');
721 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
722 pp_string (buffer, ") ");
413d3aa8 723 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
6de9cd9a 724 }
71175bf3
JM
725 else if (TREE_CODE (node) == INTEGER_TYPE)
726 {
7ee6fd68
RG
727 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
728 pp_string (buffer, (TYPE_UNSIGNED (node)
729 ? "unsigned char"
730 : "signed char"));
731 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
732 pp_string (buffer, (TYPE_UNSIGNED (node)
733 ? "unsigned short"
734 : "signed short"));
735 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
736 pp_string (buffer, (TYPE_UNSIGNED (node)
737 ? "unsigned int"
738 : "signed int"));
739 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
740 pp_string (buffer, (TYPE_UNSIGNED (node)
741 ? "unsigned long"
742 : "signed long"));
743 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
744 pp_string (buffer, (TYPE_UNSIGNED (node)
745 ? "unsigned long long"
746 : "signed long long"));
747 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
44b9837c 748 && exact_log2 (TYPE_PRECISION (node)) != -1)
7ee6fd68
RG
749 {
750 pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
751 pp_decimal_int (buffer, TYPE_PRECISION (node));
752 pp_string (buffer, "_t");
753 }
754 else
755 {
756 pp_string (buffer, (TYPE_UNSIGNED (node)
757 ? "<unnamed-unsigned:"
758 : "<unnamed-signed:"));
759 pp_decimal_int (buffer, TYPE_PRECISION (node));
760 pp_string (buffer, ">");
761 }
71175bf3 762 }
413d3aa8
DN
763 else if (TREE_CODE (node) == COMPLEX_TYPE)
764 {
765 pp_string (buffer, "__complex__ ");
766 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
767 }
768 else if (TREE_CODE (node) == REAL_TYPE)
769 {
770 pp_string (buffer, "<float:");
771 pp_decimal_int (buffer, TYPE_PRECISION (node));
772 pp_string (buffer, ">");
773 }
774 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
775 {
776 pp_string (buffer, "<fixed-point-");
777 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
778 pp_decimal_int (buffer, TYPE_PRECISION (node));
779 pp_string (buffer, ">");
780 }
d7806def
RG
781 else if (TREE_CODE (node) == VOID_TYPE)
782 pp_string (buffer, "void");
6de9cd9a
DN
783 else
784 pp_string (buffer, "<unnamed type>");
785 }
786 break;
787 }
788
789 case POINTER_TYPE:
790 case REFERENCE_TYPE:
791 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
792
413d3aa8
DN
793 if (TREE_TYPE (node) == NULL)
794 {
795 pp_string (buffer, str);
796 pp_string (buffer, "<null type>");
797 }
798 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
6de9cd9a
DN
799 {
800 tree fnode = TREE_TYPE (node);
5f2dcbe1 801
6de9cd9a
DN
802 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
803 pp_space (buffer);
804 pp_character (buffer, '(');
805 pp_string (buffer, str);
806 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
807 dump_decl_name (buffer, TYPE_NAME (node), flags);
c31c32f9
JR
808 else if (flags & TDF_NOUID)
809 pp_printf (buffer, "<Txxxx>");
6de9cd9a
DN
810 else
811 pp_printf (buffer, "<T%x>", TYPE_UID (node));
812
813 pp_character (buffer, ')');
5f2dcbe1 814 dump_function_declaration (buffer, fnode, spc, flags);
6de9cd9a
DN
815 }
816 else
817 {
818 unsigned int quals = TYPE_QUALS (node);
819
820 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
821 pp_space (buffer);
822 pp_string (buffer, str);
823
824 if (quals & TYPE_QUAL_CONST)
825 pp_string (buffer, " const");
04d86531
RG
826 if (quals & TYPE_QUAL_VOLATILE)
827 pp_string (buffer, " volatile");
828 if (quals & TYPE_QUAL_RESTRICT)
6de9cd9a 829 pp_string (buffer, " restrict");
39123624 830
09e881c9
BE
831 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
832 {
833 pp_string (buffer, " <address-space-");
834 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
835 pp_string (buffer, ">");
836 }
837
39123624
RK
838 if (TYPE_REF_CAN_ALIAS_ALL (node))
839 pp_string (buffer, " {ref-all}");
6de9cd9a
DN
840 }
841 break;
842
843 case OFFSET_TYPE:
844 NIY;
845 break;
846
70f34814
RG
847 case MEM_REF:
848 {
849 if (integer_zerop (TREE_OPERAND (node, 1))
7de9e0a1
AO
850 /* Dump the types of INTEGER_CSTs explicitly, for we can't
851 infer them and MEM_ATTR caching will share MEM_REFs
852 with differently-typed op0s. */
853 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
fd1777ca
TV
854 /* Released SSA_NAMES have no TREE_TYPE. */
855 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
70f34814
RG
856 /* Same pointer types, but ignoring POINTER_TYPE vs.
857 REFERENCE_TYPE. */
858 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
859 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
860 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
861 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
862 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
863 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
70f34814
RG
864 /* Same value types ignoring qualifiers. */
865 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
866 == TYPE_MAIN_VARIANT
867 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
868 {
869 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
870 {
871 pp_string (buffer, "*");
872 dump_generic_node (buffer, TREE_OPERAND (node, 0),
873 spc, flags, false);
874 }
875 else
876 dump_generic_node (buffer,
877 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
878 spc, flags, false);
879 }
880 else
881 {
359bea1d
AO
882 tree ptype;
883
70f34814
RG
884 pp_string (buffer, "MEM[");
885 pp_string (buffer, "(");
359bea1d
AO
886 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
887 dump_generic_node (buffer, ptype,
2eb0b984 888 spc, flags | TDF_SLIM, false);
70f34814
RG
889 pp_string (buffer, ")");
890 dump_generic_node (buffer, TREE_OPERAND (node, 0),
891 spc, flags, false);
892 if (!integer_zerop (TREE_OPERAND (node, 1)))
893 {
894 pp_string (buffer, " + ");
895 dump_generic_node (buffer, TREE_OPERAND (node, 1),
896 spc, flags, false);
897 }
898 pp_string (buffer, "]");
899 }
900 break;
901 }
902
ac182688
ZD
903 case TARGET_MEM_REF:
904 {
905 const char *sep = "";
906 tree tmp;
907
908 pp_string (buffer, "MEM[");
909
4d948885 910 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
ac182688
ZD
911 {
912 pp_string (buffer, sep);
913 sep = ", ";
914 pp_string (buffer, "symbol: ");
4d948885 915 dump_generic_node (buffer, TREE_OPERAND (TMR_BASE (node), 0),
23a534a1 916 spc, flags, false);
ac182688 917 }
4d948885
RG
918 else
919 {
920 pp_string (buffer, sep);
921 sep = ", ";
922 pp_string (buffer, "base: ");
923 dump_generic_node (buffer, TMR_BASE (node), spc, flags, false);
924 }
925 tmp = TMR_INDEX2 (node);
ac182688
ZD
926 if (tmp)
927 {
928 pp_string (buffer, sep);
929 sep = ", ";
930 pp_string (buffer, "base: ");
931 dump_generic_node (buffer, tmp, spc, flags, false);
932 }
933 tmp = TMR_INDEX (node);
934 if (tmp)
935 {
936 pp_string (buffer, sep);
937 sep = ", ";
938 pp_string (buffer, "index: ");
939 dump_generic_node (buffer, tmp, spc, flags, false);
940 }
941 tmp = TMR_STEP (node);
942 if (tmp)
943 {
944 pp_string (buffer, sep);
945 sep = ", ";
946 pp_string (buffer, "step: ");
947 dump_generic_node (buffer, tmp, spc, flags, false);
948 }
949 tmp = TMR_OFFSET (node);
950 if (tmp)
951 {
952 pp_string (buffer, sep);
953 sep = ", ";
954 pp_string (buffer, "offset: ");
955 dump_generic_node (buffer, tmp, spc, flags, false);
956 }
957 pp_string (buffer, "]");
ac182688
ZD
958 }
959 break;
960
6de9cd9a
DN
961 case ARRAY_TYPE:
962 {
963 tree tmp;
964
2709efd8
RK
965 /* Print the innermost component type. */
966 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
967 tmp = TREE_TYPE (tmp))
968 ;
969 dump_generic_node (buffer, tmp, spc, flags, false);
6de9cd9a
DN
970
971 /* Print the dimensions. */
b16bcb17
RH
972 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
973 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
6de9cd9a
DN
974 break;
975 }
976
6de9cd9a
DN
977 case RECORD_TYPE:
978 case UNION_TYPE:
44de5aeb 979 case QUAL_UNION_TYPE:
04d86531
RG
980 {
981 unsigned int quals = TYPE_QUALS (node);
982
983 if (quals & TYPE_QUAL_CONST)
984 pp_string (buffer, "const ");
985 if (quals & TYPE_QUAL_VOLATILE)
986 pp_string (buffer, "volatile ");
987
988 /* Print the name of the structure. */
989 if (TREE_CODE (node) == RECORD_TYPE)
990 pp_string (buffer, "struct ");
991 else if (TREE_CODE (node) == UNION_TYPE)
992 pp_string (buffer, "union ");
993
994 if (TYPE_NAME (node))
995 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
413d3aa8
DN
996 else if (!(flags & TDF_SLIM))
997 /* FIXME: If we eliminate the 'else' above and attempt
998 to show the fields for named types, we may get stuck
999 following a cycle of pointers to structs. The alleged
1000 self-reference check in print_struct_decl will not detect
1001 cycles involving more than one pointer or struct type. */
04d86531
RG
1002 print_struct_decl (buffer, node, spc, flags);
1003 break;
1004 }
6de9cd9a 1005
6de9cd9a
DN
1006 case LANG_TYPE:
1007 NIY;
1008 break;
1009
1010 case INTEGER_CST:
1011 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1012 {
1013 /* In the case of a pointer, one may want to divide by the
1014 size of the pointed-to type. Unfortunately, this not
1015 straightforward. The C front-end maps expressions
1016
1017 (int *) 5
1018 int *p; (p + 5)
1019
1020 in such a way that the two INTEGER_CST nodes for "5" have
1021 different values but identical types. In the latter
1022 case, the 5 is multiplied by sizeof (int) in c-common.c
1023 (pointer_int_sum) to convert it to a byte address, and
1024 yet the type of the node is left unchanged. Argh. What
1025 is consistent though is that the number value corresponds
1026 to bytes (UNITS) offset.
1027
1028 NB: Neither of the following divisors can be trivially
1029 used to recover the original literal:
1030
1031 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1032 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1033 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1034 pp_string (buffer, "B"); /* pseudo-unit */
1035 }
aa547a51
RG
1036 else if (host_integerp (node, 0))
1037 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1038 else if (host_integerp (node, 1))
1039 pp_unsigned_wide_integer (buffer, TREE_INT_CST_LOW (node));
1040 else
6de9cd9a
DN
1041 {
1042 tree val = node;
7fb41a42
RG
1043 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (val);
1044 HOST_WIDE_INT high = TREE_INT_CST_HIGH (val);
6de9cd9a
DN
1045
1046 if (tree_int_cst_sgn (val) < 0)
1047 {
1048 pp_character (buffer, '-');
7fb41a42
RG
1049 high = ~high + !low;
1050 low = -low;
6de9cd9a
DN
1051 }
1052 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1053 systems? */
7fb41a42 1054 sprintf (pp_buffer (buffer)->digit_buffer,
3d57d7ce
DK
1055 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
1056 (unsigned HOST_WIDE_INT) high, low);
7fb41a42 1057 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
6de9cd9a 1058 }
6de9cd9a
DN
1059 break;
1060
1061 case REAL_CST:
1062 /* Code copied from print_node. */
1063 {
1064 REAL_VALUE_TYPE d;
1065 if (TREE_OVERFLOW (node))
1066 pp_string (buffer, " overflow");
1067
1068#if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1069 d = TREE_REAL_CST (node);
1070 if (REAL_VALUE_ISINF (d))
89fa98d6 1071 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
6de9cd9a
DN
1072 else if (REAL_VALUE_ISNAN (d))
1073 pp_string (buffer, " Nan");
1074 else
1075 {
1076 char string[100];
1077 real_to_decimal (string, &d, sizeof (string), 0, 1);
1078 pp_string (buffer, string);
1079 }
1080#else
1081 {
1082 HOST_WIDE_INT i;
1083 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1084 pp_string (buffer, "0x");
1085 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1086 output_formatted_integer (buffer, "%02x", *p++);
1087 }
1088#endif
1089 break;
1090 }
1091
325217ed
CF
1092 case FIXED_CST:
1093 {
1094 char string[100];
1095 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1096 pp_string (buffer, string);
1097 break;
1098 }
1099
6de9cd9a
DN
1100 case COMPLEX_CST:
1101 pp_string (buffer, "__complex__ (");
1102 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
1103 pp_string (buffer, ", ");
1104 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
1105 pp_string (buffer, ")");
1106 break;
1107
1108 case STRING_CST:
1109 pp_string (buffer, "\"");
1110 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1111 pp_string (buffer, "\"");
1112 break;
1113
1114 case VECTOR_CST:
1115 {
d2a12ae7 1116 unsigned i;
6de9cd9a 1117 pp_string (buffer, "{ ");
d2a12ae7 1118 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
6de9cd9a 1119 {
d2a12ae7 1120 if (i != 0)
6de9cd9a 1121 pp_string (buffer, ", ");
d2a12ae7
RG
1122 dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
1123 spc, flags, false);
6de9cd9a
DN
1124 }
1125 pp_string (buffer, " }");
1126 }
1127 break;
1128
1129 case FUNCTION_TYPE:
413d3aa8
DN
1130 case METHOD_TYPE:
1131 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1132 pp_space (buffer);
1133 if (TREE_CODE (node) == METHOD_TYPE)
1134 {
1135 if (TYPE_METHOD_BASETYPE (node))
1136 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1137 flags);
1138 else
1139 pp_string (buffer, "<null method basetype>");
1140 pp_string (buffer, "::");
1141 }
1142 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1143 dump_decl_name (buffer, TYPE_NAME (node), flags);
c31c32f9
JR
1144 else if (flags & TDF_NOUID)
1145 pp_printf (buffer, "<Txxxx>");
413d3aa8
DN
1146 else
1147 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1148 dump_function_declaration (buffer, node, spc, flags);
6de9cd9a
DN
1149 break;
1150
1151 case FUNCTION_DECL:
1152 case CONST_DECL:
1153 dump_decl_name (buffer, node, flags);
1154 break;
1155
1156 case LABEL_DECL:
1157 if (DECL_NAME (node))
1158 dump_decl_name (buffer, node, flags);
1159 else if (LABEL_DECL_UID (node) != -1)
831b9ef8 1160 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
6de9cd9a 1161 else
831b9ef8
RG
1162 {
1163 if (flags & TDF_NOUID)
1164 pp_string (buffer, "<D.xxxx>");
1165 else
1166 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1167 }
6de9cd9a
DN
1168 break;
1169
1170 case TYPE_DECL:
6773e15f 1171 if (DECL_IS_BUILTIN (node))
6de9cd9a
DN
1172 {
1173 /* Don't print the declaration of built-in types. */
1174 break;
1175 }
1176 if (DECL_NAME (node))
5f2dcbe1 1177 dump_decl_name (buffer, node, flags);
2eb0b984 1178 else if (TYPE_NAME (TREE_TYPE (node)) != node)
6de9cd9a 1179 {
6e6e49b1
RK
1180 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1181 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1182 && TYPE_METHODS (TREE_TYPE (node)))
6de9cd9a
DN
1183 {
1184 /* The type is a c++ class: all structures have at least
9cf737f8 1185 4 methods. */
6de9cd9a
DN
1186 pp_string (buffer, "class ");
1187 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1188 }
1189 else
1190 {
5f2dcbe1
RK
1191 pp_string (buffer,
1192 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1193 ? "union" : "struct "));
6de9cd9a 1194 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
6de9cd9a
DN
1195 }
1196 }
2eb0b984
RG
1197 else
1198 pp_string (buffer, "<anon>");
6de9cd9a
DN
1199 break;
1200
1201 case VAR_DECL:
1202 case PARM_DECL:
1203 case FIELD_DECL:
0ca5af51 1204 case DEBUG_EXPR_DECL:
6de9cd9a
DN
1205 case NAMESPACE_DECL:
1206 dump_decl_name (buffer, node, flags);
1207 break;
1208
1209 case RESULT_DECL:
1210 pp_string (buffer, "<retval>");
1211 break;
1212
1213 case COMPONENT_REF:
1214 op0 = TREE_OPERAND (node, 0);
1215 str = ".";
70f34814
RG
1216 if (op0
1217 && (TREE_CODE (op0) == INDIRECT_REF
1218 || (TREE_CODE (op0) == MEM_REF
1219 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1220 && integer_zerop (TREE_OPERAND (op0, 1))
7de9e0a1
AO
1221 /* Dump the types of INTEGER_CSTs explicitly, for we
1222 can't infer them and MEM_ATTR caching will share
1223 MEM_REFs with differently-typed op0s. */
1224 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
fd1777ca
TV
1225 /* Released SSA_NAMES have no TREE_TYPE. */
1226 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
70f34814
RG
1227 /* Same pointer types, but ignoring POINTER_TYPE vs.
1228 REFERENCE_TYPE. */
1229 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1230 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1231 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1232 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1233 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1234 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
70f34814
RG
1235 /* Same value types ignoring qualifiers. */
1236 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1237 == TYPE_MAIN_VARIANT
1238 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
6de9cd9a
DN
1239 {
1240 op0 = TREE_OPERAND (op0, 0);
1241 str = "->";
1242 }
1243 if (op_prio (op0) < op_prio (node))
1244 pp_character (buffer, '(');
1245 dump_generic_node (buffer, op0, spc, flags, false);
1246 if (op_prio (op0) < op_prio (node))
1247 pp_character (buffer, ')');
1248 pp_string (buffer, str);
1249 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
c9145754
DB
1250 op0 = component_ref_field_offset (node);
1251 if (op0 && TREE_CODE (op0) != INTEGER_CST)
44de5aeb 1252 {
c9145754 1253 pp_string (buffer, "{off: ");
ef6379fd
DN
1254 dump_generic_node (buffer, op0, spc, flags, false);
1255 pp_character (buffer, '}');
44de5aeb 1256 }
6de9cd9a
DN
1257 break;
1258
1259 case BIT_FIELD_REF:
1260 pp_string (buffer, "BIT_FIELD_REF <");
1261 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1262 pp_string (buffer, ", ");
1263 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1264 pp_string (buffer, ", ");
1265 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1266 pp_string (buffer, ">");
1267 break;
1268
6de9cd9a 1269 case ARRAY_REF:
44de5aeb 1270 case ARRAY_RANGE_REF:
6de9cd9a
DN
1271 op0 = TREE_OPERAND (node, 0);
1272 if (op_prio (op0) < op_prio (node))
1273 pp_character (buffer, '(');
1274 dump_generic_node (buffer, op0, spc, flags, false);
1275 if (op_prio (op0) < op_prio (node))
1276 pp_character (buffer, ')');
1277 pp_character (buffer, '[');
1278 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
44de5aeb
RK
1279 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1280 pp_string (buffer, " ...");
6de9cd9a 1281 pp_character (buffer, ']');
6de9cd9a 1282
8e6b96d3
RK
1283 op0 = array_ref_low_bound (node);
1284 op1 = array_ref_element_size (node);
1285
1286 if (!integer_zerop (op0)
a670437d
RG
1287 || TREE_OPERAND (node, 2)
1288 || TREE_OPERAND (node, 3))
44de5aeb
RK
1289 {
1290 pp_string (buffer, "{lb: ");
8e6b96d3 1291 dump_generic_node (buffer, op0, spc, flags, false);
44de5aeb 1292 pp_string (buffer, " sz: ");
8e6b96d3 1293 dump_generic_node (buffer, op1, spc, flags, false);
44de5aeb
RK
1294 pp_character (buffer, '}');
1295 }
6de9cd9a
DN
1296 break;
1297
1298 case CONSTRUCTOR:
1299 {
4038c495
GB
1300 unsigned HOST_WIDE_INT ix;
1301 tree field, val;
3aecd443
JJ
1302 bool is_struct_init = false;
1303 bool is_array_init = false;
1304 double_int curidx = double_int_zero;
6de9cd9a 1305 pp_character (buffer, '{');
47598145
MM
1306 if (TREE_CLOBBER_P (node))
1307 pp_string (buffer, "CLOBBER");
1308 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1309 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
3aecd443
JJ
1310 is_struct_init = true;
1311 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1312 && TYPE_DOMAIN (TREE_TYPE (node))
1313 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1314 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1315 == INTEGER_CST)
1316 {
1317 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1318 is_array_init = true;
1319 curidx = tree_to_double_int (minv);
1320 }
4038c495 1321 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
6de9cd9a 1322 {
3aecd443 1323 if (field)
6de9cd9a 1324 {
3aecd443
JJ
1325 if (is_struct_init)
1326 {
1327 pp_character (buffer, '.');
1328 dump_generic_node (buffer, field, spc, flags, false);
1329 pp_character (buffer, '=');
1330 }
1331 else if (is_array_init
1332 && (TREE_CODE (field) != INTEGER_CST
27bcd47c 1333 || tree_to_double_int (field) != curidx))
3aecd443
JJ
1334 {
1335 pp_character (buffer, '[');
1336 if (TREE_CODE (field) == RANGE_EXPR)
1337 {
1338 dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
1339 flags, false);
1340 pp_string (buffer, " ... ");
1341 dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
1342 flags, false);
1343 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1344 curidx = tree_to_double_int (TREE_OPERAND (field, 1));
1345 }
1346 else
1347 dump_generic_node (buffer, field, spc, flags, false);
1348 if (TREE_CODE (field) == INTEGER_CST)
1349 curidx = tree_to_double_int (field);
1350 pp_string (buffer, "]=");
1351 }
6de9cd9a 1352 }
3aecd443 1353 if (is_array_init)
27bcd47c 1354 curidx += double_int_one;
6de9cd9a
DN
1355 if (val && TREE_CODE (val) == ADDR_EXPR)
1356 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1357 val = TREE_OPERAND (val, 0);
1358 if (val && TREE_CODE (val) == FUNCTION_DECL)
6de9cd9a 1359 dump_decl_name (buffer, val, flags);
6de9cd9a 1360 else
4038c495
GB
1361 dump_generic_node (buffer, val, spc, flags, false);
1362 if (ix != VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node)) - 1)
6de9cd9a
DN
1363 {
1364 pp_character (buffer, ',');
1365 pp_space (buffer);
1366 }
1367 }
1368 pp_character (buffer, '}');
1369 }
1370 break;
1371
1372 case COMPOUND_EXPR:
1373 {
1374 tree *tp;
1375 if (flags & TDF_SLIM)
1376 {
1377 pp_string (buffer, "<COMPOUND_EXPR>");
1378 break;
1379 }
1380
1381 dump_generic_node (buffer, TREE_OPERAND (node, 0),
953ff289
DN
1382 spc, flags, !(flags & TDF_SLIM));
1383 if (flags & TDF_SLIM)
6de9cd9a
DN
1384 newline_and_indent (buffer, spc);
1385 else
1386 {
1387 pp_character (buffer, ',');
1388 pp_space (buffer);
1389 }
1390
1391 for (tp = &TREE_OPERAND (node, 1);
1392 TREE_CODE (*tp) == COMPOUND_EXPR;
1393 tp = &TREE_OPERAND (*tp, 1))
1394 {
1395 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
953ff289
DN
1396 spc, flags, !(flags & TDF_SLIM));
1397 if (flags & TDF_SLIM)
6de9cd9a
DN
1398 newline_and_indent (buffer, spc);
1399 else
1400 {
1401 pp_character (buffer, ',');
1402 pp_space (buffer);
1403 }
1404 }
1405
953ff289 1406 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
6de9cd9a
DN
1407 }
1408 break;
1409
1410 case STATEMENT_LIST:
1411 {
1412 tree_stmt_iterator si;
1413 bool first = true;
9f63daea 1414
953ff289 1415 if (flags & TDF_SLIM)
6de9cd9a
DN
1416 {
1417 pp_string (buffer, "<STATEMENT_LIST>");
1418 break;
1419 }
1420
1421 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1422 {
1423 if (!first)
1424 newline_and_indent (buffer, spc);
1425 else
1426 first = false;
1427 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1428 }
1429 }
1430 break;
1431
1432 case MODIFY_EXPR:
1433 case INIT_EXPR:
726a989a 1434 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
07beea0d 1435 false);
6de9cd9a
DN
1436 pp_space (buffer);
1437 pp_character (buffer, '=');
1438 pp_space (buffer);
726a989a 1439 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
07beea0d 1440 false);
6de9cd9a
DN
1441 break;
1442
1443 case TARGET_EXPR:
325c3691
RH
1444 pp_string (buffer, "TARGET_EXPR <");
1445 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1446 pp_character (buffer, ',');
1447 pp_space (buffer);
6de9cd9a 1448 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
325c3691 1449 pp_character (buffer, '>');
6de9cd9a
DN
1450 break;
1451
5f2dcbe1
RK
1452 case DECL_EXPR:
1453 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1454 is_stmt = false;
1455 break;
1456
6de9cd9a 1457 case COND_EXPR:
506e2710 1458 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
6de9cd9a
DN
1459 {
1460 pp_string (buffer, "if (");
1461 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1462 pp_character (buffer, ')');
1463 /* The lowered cond_exprs should always be printed in full. */
1464 if (COND_EXPR_THEN (node)
b7211528
SB
1465 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1466 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
6de9cd9a 1467 && COND_EXPR_ELSE (node)
b7211528
SB
1468 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1469 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
6de9cd9a
DN
1470 {
1471 pp_space (buffer);
458e3389
RS
1472 dump_generic_node (buffer, COND_EXPR_THEN (node),
1473 0, flags, true);
1474 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1475 {
1476 pp_string (buffer, " else ");
1477 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1478 0, flags, true);
1479 }
6de9cd9a
DN
1480 }
1481 else if (!(flags & TDF_SLIM))
1482 {
1483 /* Output COND_EXPR_THEN. */
1484 if (COND_EXPR_THEN (node))
1485 {
1486 newline_and_indent (buffer, spc+2);
1487 pp_character (buffer, '{');
1488 newline_and_indent (buffer, spc+4);
1489 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1490 flags, true);
1491 newline_and_indent (buffer, spc+2);
1492 pp_character (buffer, '}');
1493 }
1494
1495 /* Output COND_EXPR_ELSE. */
458e3389
RS
1496 if (COND_EXPR_ELSE (node)
1497 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
6de9cd9a
DN
1498 {
1499 newline_and_indent (buffer, spc);
1500 pp_string (buffer, "else");
1501 newline_and_indent (buffer, spc+2);
1502 pp_character (buffer, '{');
1503 newline_and_indent (buffer, spc+4);
1504 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1505 flags, true);
1506 newline_and_indent (buffer, spc+2);
1507 pp_character (buffer, '}');
1508 }
1509 }
1510 is_expr = false;
1511 }
1512 else
1513 {
1514 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1515 pp_space (buffer);
1516 pp_character (buffer, '?');
1517 pp_space (buffer);
1518 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1519 pp_space (buffer);
1520 pp_character (buffer, ':');
1521 pp_space (buffer);
1522 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1523 }
1524 break;
1525
1526 case BIND_EXPR:
1527 pp_character (buffer, '{');
1528 if (!(flags & TDF_SLIM))
1529 {
1530 if (BIND_EXPR_VARS (node))
1531 {
1532 pp_newline (buffer);
1533
910ad8de 1534 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
6de9cd9a
DN
1535 {
1536 print_declaration (buffer, op0, spc+2, flags);
1537 pp_newline (buffer);
1538 }
1539 }
1540
1541 newline_and_indent (buffer, spc+2);
1542 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1543 newline_and_indent (buffer, spc);
1544 pp_character (buffer, '}');
1545 }
1546 is_expr = false;
1547 break;
1548
1549 case CALL_EXPR:
394bd84d 1550 print_call_name (buffer, CALL_EXPR_FN (node), flags);
6de9cd9a
DN
1551
1552 /* Print parameters. */
1553 pp_space (buffer);
1554 pp_character (buffer, '(');
5039610b
SL
1555 {
1556 tree arg;
1557 call_expr_arg_iterator iter;
1558 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1559 {
1560 dump_generic_node (buffer, arg, spc, flags, false);
1561 if (more_call_expr_args_p (&iter))
1562 {
1563 pp_character (buffer, ',');
1564 pp_space (buffer);
1565 }
1566 }
1567 }
6ef5231b
JJ
1568 if (CALL_EXPR_VA_ARG_PACK (node))
1569 {
1570 if (call_expr_nargs (node) > 0)
1571 {
1572 pp_character (buffer, ',');
1573 pp_space (buffer);
1574 }
1575 pp_string (buffer, "__builtin_va_arg_pack ()");
1576 }
6de9cd9a
DN
1577 pp_character (buffer, ')');
1578
5039610b 1579 op1 = CALL_EXPR_STATIC_CHAIN (node);
6de9cd9a
DN
1580 if (op1)
1581 {
1582 pp_string (buffer, " [static-chain: ");
1583 dump_generic_node (buffer, op1, spc, flags, false);
1584 pp_character (buffer, ']');
1585 }
1586
fa47911c
JM
1587 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1588 pp_string (buffer, " [return slot optimization]");
6de9cd9a
DN
1589 if (CALL_EXPR_TAILCALL (node))
1590 pp_string (buffer, " [tail call]");
1591 break;
1592
1593 case WITH_CLEANUP_EXPR:
1594 NIY;
1595 break;
1596
1597 case CLEANUP_POINT_EXPR:
1598 pp_string (buffer, "<<cleanup_point ");
1599 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1600 pp_string (buffer, ">>");
1601 break;
1602
1603 case PLACEHOLDER_EXPR:
5f2dcbe1
RK
1604 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1605 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1606 pp_character (buffer, '>');
6de9cd9a
DN
1607 break;
1608
1609 /* Binary arithmetic and logic expressions. */
20f06221
DN
1610 case WIDEN_SUM_EXPR:
1611 case WIDEN_MULT_EXPR:
6de9cd9a 1612 case MULT_EXPR:
98449720 1613 case MULT_HIGHPART_EXPR:
6de9cd9a 1614 case PLUS_EXPR:
5be014d5 1615 case POINTER_PLUS_EXPR:
6de9cd9a
DN
1616 case MINUS_EXPR:
1617 case TRUNC_DIV_EXPR:
1618 case CEIL_DIV_EXPR:
1619 case FLOOR_DIV_EXPR:
1620 case ROUND_DIV_EXPR:
1621 case TRUNC_MOD_EXPR:
1622 case CEIL_MOD_EXPR:
1623 case FLOOR_MOD_EXPR:
1624 case ROUND_MOD_EXPR:
1625 case RDIV_EXPR:
1626 case EXACT_DIV_EXPR:
1627 case LSHIFT_EXPR:
1628 case RSHIFT_EXPR:
1629 case LROTATE_EXPR:
1630 case RROTATE_EXPR:
a6b46ba2
DN
1631 case VEC_LSHIFT_EXPR:
1632 case VEC_RSHIFT_EXPR:
36ba4aae 1633 case WIDEN_LSHIFT_EXPR:
6de9cd9a
DN
1634 case BIT_IOR_EXPR:
1635 case BIT_XOR_EXPR:
1636 case BIT_AND_EXPR:
1637 case TRUTH_ANDIF_EXPR:
1638 case TRUTH_ORIF_EXPR:
1639 case TRUTH_AND_EXPR:
1640 case TRUTH_OR_EXPR:
1641 case TRUTH_XOR_EXPR:
1642 case LT_EXPR:
1643 case LE_EXPR:
1644 case GT_EXPR:
1645 case GE_EXPR:
1646 case EQ_EXPR:
1647 case NE_EXPR:
1648 case UNLT_EXPR:
1649 case UNLE_EXPR:
1650 case UNGT_EXPR:
1651 case UNGE_EXPR:
1652 case UNEQ_EXPR:
d1a7edaf
PB
1653 case LTGT_EXPR:
1654 case ORDERED_EXPR:
1655 case UNORDERED_EXPR:
6de9cd9a
DN
1656 {
1657 const char *op = op_symbol (node);
1658 op0 = TREE_OPERAND (node, 0);
1659 op1 = TREE_OPERAND (node, 1);
1660
1661 /* When the operands are expressions with less priority,
1662 keep semantics of the tree representation. */
ee3202e1 1663 if (op_prio (op0) <= op_prio (node))
6de9cd9a
DN
1664 {
1665 pp_character (buffer, '(');
1666 dump_generic_node (buffer, op0, spc, flags, false);
1667 pp_character (buffer, ')');
1668 }
1669 else
1670 dump_generic_node (buffer, op0, spc, flags, false);
1671
1672 pp_space (buffer);
1673 pp_string (buffer, op);
1674 pp_space (buffer);
1675
1676 /* When the operands are expressions with less priority,
1677 keep semantics of the tree representation. */
ee3202e1 1678 if (op_prio (op1) <= op_prio (node))
6de9cd9a
DN
1679 {
1680 pp_character (buffer, '(');
1681 dump_generic_node (buffer, op1, spc, flags, false);
1682 pp_character (buffer, ')');
1683 }
1684 else
1685 dump_generic_node (buffer, op1, spc, flags, false);
1686 }
1687 break;
1688
1689 /* Unary arithmetic and logic expressions. */
1690 case NEGATE_EXPR:
1691 case BIT_NOT_EXPR:
1692 case TRUTH_NOT_EXPR:
1693 case ADDR_EXPR:
6de9cd9a
DN
1694 case PREDECREMENT_EXPR:
1695 case PREINCREMENT_EXPR:
1696 case INDIRECT_REF:
1697 if (TREE_CODE (node) == ADDR_EXPR
1698 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1699 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1700 ; /* Do not output '&' for strings and function pointers. */
1701 else
1702 pp_string (buffer, op_symbol (node));
1703
1704 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1705 {
1706 pp_character (buffer, '(');
1707 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1708 pp_character (buffer, ')');
1709 }
1710 else
1711 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1712 break;
1713
1714 case POSTDECREMENT_EXPR:
1715 case POSTINCREMENT_EXPR:
1716 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1717 {
1718 pp_character (buffer, '(');
1719 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1720 pp_character (buffer, ')');
1721 }
1722 else
1723 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1724 pp_string (buffer, op_symbol (node));
1725 break;
1726
1727 case MIN_EXPR:
1728 pp_string (buffer, "MIN_EXPR <");
1729 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1730 pp_string (buffer, ", ");
1731 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1732 pp_character (buffer, '>');
1733 break;
1734
1735 case MAX_EXPR:
1736 pp_string (buffer, "MAX_EXPR <");
1737 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1738 pp_string (buffer, ", ");
1739 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1740 pp_character (buffer, '>');
1741 break;
1742
1743 case ABS_EXPR:
1744 pp_string (buffer, "ABS_EXPR <");
1745 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1746 pp_character (buffer, '>');
1747 break;
1748
6de9cd9a
DN
1749 case RANGE_EXPR:
1750 NIY;
1751 break;
1752
09e881c9 1753 case ADDR_SPACE_CONVERT_EXPR:
325217ed 1754 case FIXED_CONVERT_EXPR:
6de9cd9a 1755 case FIX_TRUNC_EXPR:
6de9cd9a 1756 case FLOAT_EXPR:
1043771b 1757 CASE_CONVERT:
6de9cd9a
DN
1758 type = TREE_TYPE (node);
1759 op0 = TREE_OPERAND (node, 0);
1760 if (type != TREE_TYPE (op0))
1761 {
1762 pp_character (buffer, '(');
1763 dump_generic_node (buffer, type, spc, flags, false);
a0ca8e0c 1764 pp_string (buffer, ") ");
6de9cd9a
DN
1765 }
1766 if (op_prio (op0) < op_prio (node))
1767 pp_character (buffer, '(');
1768 dump_generic_node (buffer, op0, spc, flags, false);
1769 if (op_prio (op0) < op_prio (node))
1770 pp_character (buffer, ')');
1771 break;
1772
1773 case VIEW_CONVERT_EXPR:
1774 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1775 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1776 pp_string (buffer, ">(");
1777 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1778 pp_character (buffer, ')');
1779 break;
1780
dedd42d5
RG
1781 case PAREN_EXPR:
1782 pp_string (buffer, "((");
1783 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1784 pp_string (buffer, "))");
1785 break;
1786
6de9cd9a
DN
1787 case NON_LVALUE_EXPR:
1788 pp_string (buffer, "NON_LVALUE_EXPR <");
1789 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1790 pp_character (buffer, '>');
1791 break;
1792
1793 case SAVE_EXPR:
1794 pp_string (buffer, "SAVE_EXPR <");
1795 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1796 pp_character (buffer, '>');
1797 break;
1798
6de9cd9a
DN
1799 case COMPLEX_EXPR:
1800 pp_string (buffer, "COMPLEX_EXPR <");
1801 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1802 pp_string (buffer, ", ");
1803 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1804 pp_string (buffer, ">");
1805 break;
1806
1807 case CONJ_EXPR:
1808 pp_string (buffer, "CONJ_EXPR <");
1809 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1810 pp_string (buffer, ">");
1811 break;
1812
1813 case REALPART_EXPR:
1814 pp_string (buffer, "REALPART_EXPR <");
1815 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1816 pp_string (buffer, ">");
1817 break;
1818
1819 case IMAGPART_EXPR:
1820 pp_string (buffer, "IMAGPART_EXPR <");
1821 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1822 pp_string (buffer, ">");
1823 break;
1824
1825 case VA_ARG_EXPR:
1826 pp_string (buffer, "VA_ARG_EXPR <");
1827 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1828 pp_string (buffer, ">");
1829 break;
1830
1831 case TRY_FINALLY_EXPR:
1832 case TRY_CATCH_EXPR:
1833 pp_string (buffer, "try");
1834 newline_and_indent (buffer, spc+2);
1835 pp_string (buffer, "{");
1836 newline_and_indent (buffer, spc+4);
1837 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
1838 newline_and_indent (buffer, spc+2);
1839 pp_string (buffer, "}");
1840 newline_and_indent (buffer, spc);
1841 pp_string (buffer,
1842 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
1843 newline_and_indent (buffer, spc+2);
1844 pp_string (buffer, "{");
1845 newline_and_indent (buffer, spc+4);
1846 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
1847 newline_and_indent (buffer, spc+2);
1848 pp_string (buffer, "}");
1849 is_expr = false;
1850 break;
1851
1852 case CATCH_EXPR:
1853 pp_string (buffer, "catch (");
1854 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
1855 pp_string (buffer, ")");
1856 newline_and_indent (buffer, spc+2);
1857 pp_string (buffer, "{");
1858 newline_and_indent (buffer, spc+4);
1859 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
1860 newline_and_indent (buffer, spc+2);
1861 pp_string (buffer, "}");
1862 is_expr = false;
1863 break;
1864
1865 case EH_FILTER_EXPR:
1866 pp_string (buffer, "<<<eh_filter (");
1867 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
1868 pp_string (buffer, ")>>>");
1869 newline_and_indent (buffer, spc+2);
1870 pp_string (buffer, "{");
1871 newline_and_indent (buffer, spc+4);
1872 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
1873 newline_and_indent (buffer, spc+2);
1874 pp_string (buffer, "}");
1875 is_expr = false;
1876 break;
1877
6de9cd9a
DN
1878 case LABEL_EXPR:
1879 op0 = TREE_OPERAND (node, 0);
1880 /* If this is for break or continue, don't bother printing it. */
1881 if (DECL_NAME (op0))
1882 {
1883 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1884 if (strcmp (name, "break") == 0
1885 || strcmp (name, "continue") == 0)
1886 break;
1887 }
1888 dump_generic_node (buffer, op0, spc, flags, false);
1889 pp_character (buffer, ':');
1890 if (DECL_NONLOCAL (op0))
1891 pp_string (buffer, " [non-local]");
1892 break;
1893
6de9cd9a
DN
1894 case LOOP_EXPR:
1895 pp_string (buffer, "while (1)");
1896 if (!(flags & TDF_SLIM))
1897 {
1898 newline_and_indent (buffer, spc+2);
1899 pp_character (buffer, '{');
1900 newline_and_indent (buffer, spc+4);
1901 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
1902 newline_and_indent (buffer, spc+2);
1903 pp_character (buffer, '}');
1904 }
1905 is_expr = false;
1906 break;
1907
2e28e797
JH
1908 case PREDICT_EXPR:
1909 pp_string (buffer, "// predicted ");
1910 if (PREDICT_EXPR_OUTCOME (node))
1911 pp_string (buffer, "likely by ");
1912 else
1913 pp_string (buffer, "unlikely by ");
1914 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
1915 pp_string (buffer, " predictor.");
1916 break;
1917
6de9cd9a
DN
1918 case RETURN_EXPR:
1919 pp_string (buffer, "return");
1920 op0 = TREE_OPERAND (node, 0);
1921 if (op0)
1922 {
1923 pp_space (buffer);
726a989a
RB
1924 if (TREE_CODE (op0) == MODIFY_EXPR)
1925 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
07beea0d 1926 spc, flags, false);
6de9cd9a
DN
1927 else
1928 dump_generic_node (buffer, op0, spc, flags, false);
1929 }
1930 break;
1931
1932 case EXIT_EXPR:
1933 pp_string (buffer, "if (");
1934 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1935 pp_string (buffer, ") break");
1936 break;
1937
1938 case SWITCH_EXPR:
1939 pp_string (buffer, "switch (");
1940 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
1941 pp_character (buffer, ')');
1942 if (!(flags & TDF_SLIM))
1943 {
1944 newline_and_indent (buffer, spc+2);
1945 pp_character (buffer, '{');
1946 if (SWITCH_BODY (node))
1947 {
1948 newline_and_indent (buffer, spc+4);
953ff289
DN
1949 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
1950 true);
6de9cd9a
DN
1951 }
1952 else
1953 {
1954 tree vec = SWITCH_LABELS (node);
1955 size_t i, n = TREE_VEC_LENGTH (vec);
1956 for (i = 0; i < n; ++i)
1957 {
1958 tree elt = TREE_VEC_ELT (vec, i);
1959 newline_and_indent (buffer, spc+4);
953ff289
DN
1960 if (elt)
1961 {
1962 dump_generic_node (buffer, elt, spc+4, flags, false);
1963 pp_string (buffer, " goto ");
1964 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
1965 flags, true);
1966 pp_semicolon (buffer);
1967 }
1968 else
1969 pp_string (buffer, "case ???: goto ???;");
6de9cd9a
DN
1970 }
1971 }
1972 newline_and_indent (buffer, spc+2);
1973 pp_character (buffer, '}');
1974 }
1975 is_expr = false;
1976 break;
1977
1978 case GOTO_EXPR:
1979 op0 = GOTO_DESTINATION (node);
6615c446 1980 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
6de9cd9a
DN
1981 {
1982 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
1983 if (strcmp (name, "break") == 0
1984 || strcmp (name, "continue") == 0)
1985 {
1986 pp_string (buffer, name);
1987 break;
1988 }
1989 }
1990 pp_string (buffer, "goto ");
1991 dump_generic_node (buffer, op0, spc, flags, false);
1992 break;
1993
6de9cd9a
DN
1994 case ASM_EXPR:
1995 pp_string (buffer, "__asm__");
1996 if (ASM_VOLATILE_P (node))
1997 pp_string (buffer, " __volatile__");
1998 pp_character (buffer, '(');
1999 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
2000 pp_character (buffer, ':');
2001 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
2002 pp_character (buffer, ':');
2003 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
2004 if (ASM_CLOBBERS (node))
2005 {
2006 pp_character (buffer, ':');
2007 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
2008 }
2009 pp_string (buffer, ")");
2010 break;
2011
2012 case CASE_LABEL_EXPR:
2013 if (CASE_LOW (node) && CASE_HIGH (node))
2014 {
2015 pp_string (buffer, "case ");
2016 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2017 pp_string (buffer, " ... ");
2018 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
2019 }
2020 else if (CASE_LOW (node))
2021 {
2022 pp_string (buffer, "case ");
2023 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2024 }
2025 else
726a989a 2026 pp_string (buffer, "default");
6de9cd9a
DN
2027 pp_character (buffer, ':');
2028 break;
2029
0f59171d
RH
2030 case OBJ_TYPE_REF:
2031 pp_string (buffer, "OBJ_TYPE_REF(");
2032 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2033 pp_character (buffer, ';');
2034 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2035 pp_character (buffer, '-');
6de9cd9a 2036 pp_character (buffer, '>');
0f59171d
RH
2037 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2038 pp_character (buffer, ')');
6de9cd9a
DN
2039 break;
2040
6de9cd9a 2041 case SSA_NAME:
70b5e7dc
RG
2042 if (SSA_NAME_IDENTIFIER (node))
2043 dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
2044 spc, flags, false);
6de9cd9a
DN
2045 pp_string (buffer, "_");
2046 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
9fabf0d4
DN
2047 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2048 pp_string (buffer, "(ab)");
38635499
DN
2049 else if (SSA_NAME_IS_DEFAULT_DEF (node))
2050 pp_string (buffer, "(D)");
6de9cd9a
DN
2051 break;
2052
d25cee4d
RH
2053 case WITH_SIZE_EXPR:
2054 pp_string (buffer, "WITH_SIZE_EXPR <");
2055 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2056 pp_string (buffer, ", ");
2057 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2058 pp_string (buffer, ">");
2059 break;
2060
0bca51f0
DN
2061 case ASSERT_EXPR:
2062 pp_string (buffer, "ASSERT_EXPR <");
2063 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
2064 pp_string (buffer, ", ");
2065 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
2066 pp_string (buffer, ">");
2067 break;
2068
4619c701
SP
2069 case SCEV_KNOWN:
2070 pp_string (buffer, "scev_known");
2071 break;
2072
2073 case SCEV_NOT_KNOWN:
2074 pp_string (buffer, "scev_not_known");
2075 break;
2076
2077 case POLYNOMIAL_CHREC:
2078 pp_string (buffer, "{");
2079 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
2080 pp_string (buffer, ", +, ");
2081 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
2082 pp_string (buffer, "}_");
2083 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
2084 is_stmt = false;
2085 break;
2086
7ccf35ed
DN
2087 case REALIGN_LOAD_EXPR:
2088 pp_string (buffer, "REALIGN_LOAD <");
2089 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2090 pp_string (buffer, ", ");
2091 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2092 pp_string (buffer, ", ");
2093 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2094 pp_string (buffer, ">");
2095 break;
b8698a0f 2096
6337c1a2
DP
2097 case VEC_COND_EXPR:
2098 pp_string (buffer, " VEC_COND_EXPR < ");
2099 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
f90e8e2e
AS
2100 pp_string (buffer, " , ");
2101 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2102 pp_string (buffer, " , ");
2103 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2104 pp_string (buffer, " > ");
2105 break;
2106
2205ed25
RH
2107 case VEC_PERM_EXPR:
2108 pp_string (buffer, " VEC_PERM_EXPR < ");
f90e8e2e 2109 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
6337c1a2
DP
2110 pp_string (buffer, " , ");
2111 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2112 pp_string (buffer, " , ");
2113 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2114 pp_string (buffer, " > ");
2115 break;
2116
20f06221
DN
2117 case DOT_PROD_EXPR:
2118 pp_string (buffer, " DOT_PROD_EXPR < ");
2119 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
89d67cca 2120 pp_string (buffer, ", ");
20f06221 2121 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
89d67cca 2122 pp_string (buffer, ", ");
20f06221
DN
2123 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2124 pp_string (buffer, " > ");
2125 break;
2126
0354c0c7
BS
2127 case WIDEN_MULT_PLUS_EXPR:
2128 pp_string (buffer, " WIDEN_MULT_PLUS_EXPR < ");
2129 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2130 pp_string (buffer, ", ");
2131 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2132 pp_string (buffer, ", ");
2133 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2134 pp_string (buffer, " > ");
2135 break;
2136
2137 case WIDEN_MULT_MINUS_EXPR:
2138 pp_string (buffer, " WIDEN_MULT_MINUS_EXPR < ");
2139 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2140 pp_string (buffer, ", ");
2141 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2142 pp_string (buffer, ", ");
2143 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2144 pp_string (buffer, " > ");
2145 break;
2146
0f59b812
JJ
2147 case FMA_EXPR:
2148 pp_string (buffer, " FMA_EXPR < ");
2149 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2150 pp_string (buffer, ", ");
2151 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2152 pp_string (buffer, ", ");
2153 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2154 pp_string (buffer, " > ");
2155 break;
2156
953ff289
DN
2157 case OMP_PARALLEL:
2158 pp_string (buffer, "#pragma omp parallel");
2159 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
2160
2161 dump_omp_body:
2162 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2163 {
2164 newline_and_indent (buffer, spc + 2);
2165 pp_character (buffer, '{');
2166 newline_and_indent (buffer, spc + 4);
2167 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
2168 newline_and_indent (buffer, spc + 2);
2169 pp_character (buffer, '}');
2170 }
2171 is_expr = false;
2172 break;
2173
a68ab351
JJ
2174 case OMP_TASK:
2175 pp_string (buffer, "#pragma omp task");
2176 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
a68ab351
JJ
2177 goto dump_omp_body;
2178
953ff289
DN
2179 case OMP_FOR:
2180 pp_string (buffer, "#pragma omp for");
2181 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2182
2183 if (!(flags & TDF_SLIM))
2184 {
a68ab351
JJ
2185 int i;
2186
953ff289
DN
2187 if (OMP_FOR_PRE_BODY (node))
2188 {
2189 newline_and_indent (buffer, spc + 2);
2190 pp_character (buffer, '{');
2191 spc += 4;
2192 newline_and_indent (buffer, spc);
2193 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
2194 spc, flags, false);
2195 }
a68ab351
JJ
2196 spc -= 2;
2197 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2198 {
2199 spc += 2;
2200 newline_and_indent (buffer, spc);
2201 pp_string (buffer, "for (");
2202 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2203 spc, flags, false);
2204 pp_string (buffer, "; ");
2205 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_COND (node), i),
2206 spc, flags, false);
2207 pp_string (buffer, "; ");
2208 dump_generic_node (buffer, TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2209 spc, flags, false);
2210 pp_string (buffer, ")");
2211 }
953ff289
DN
2212 if (OMP_FOR_BODY (node))
2213 {
2214 newline_and_indent (buffer, spc + 2);
2215 pp_character (buffer, '{');
2216 newline_and_indent (buffer, spc + 4);
2217 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2218 false);
2219 newline_and_indent (buffer, spc + 2);
2220 pp_character (buffer, '}');
2221 }
a68ab351 2222 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
953ff289
DN
2223 if (OMP_FOR_PRE_BODY (node))
2224 {
2225 spc -= 4;
2226 newline_and_indent (buffer, spc + 2);
2227 pp_character (buffer, '}');
2228 }
2229 }
2230 is_expr = false;
2231 break;
2232
2233 case OMP_SECTIONS:
2234 pp_string (buffer, "#pragma omp sections");
2235 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2236 goto dump_omp_body;
2237
2238 case OMP_SECTION:
2239 pp_string (buffer, "#pragma omp section");
2240 goto dump_omp_body;
b8698a0f 2241
953ff289
DN
2242 case OMP_MASTER:
2243 pp_string (buffer, "#pragma omp master");
2244 goto dump_omp_body;
2245
2246 case OMP_ORDERED:
2247 pp_string (buffer, "#pragma omp ordered");
2248 goto dump_omp_body;
2249
2250 case OMP_CRITICAL:
2251 pp_string (buffer, "#pragma omp critical");
2252 if (OMP_CRITICAL_NAME (node))
2253 {
2254 pp_space (buffer);
2255 pp_character (buffer, '(');
2256 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2257 flags, false);
2258 pp_character (buffer, ')');
2259 }
2260 goto dump_omp_body;
2261
2262 case OMP_ATOMIC:
2263 pp_string (buffer, "#pragma omp atomic");
2264 newline_and_indent (buffer, spc + 2);
2265 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2266 pp_space (buffer);
2267 pp_character (buffer, '=');
2268 pp_space (buffer);
2269 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2270 break;
2271
20906c66
JJ
2272 case OMP_ATOMIC_READ:
2273 pp_string (buffer, "#pragma omp atomic read");
2274 newline_and_indent (buffer, spc + 2);
2275 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2276 pp_space (buffer);
2277 break;
2278
2279 case OMP_ATOMIC_CAPTURE_OLD:
2280 case OMP_ATOMIC_CAPTURE_NEW:
2281 pp_string (buffer, "#pragma omp atomic capture");
2282 newline_and_indent (buffer, spc + 2);
2283 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2284 pp_space (buffer);
2285 pp_character (buffer, '=');
2286 pp_space (buffer);
2287 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2288 break;
2289
953ff289
DN
2290 case OMP_SINGLE:
2291 pp_string (buffer, "#pragma omp single");
2292 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2293 goto dump_omp_body;
2294
aaf46ef9
DN
2295 case OMP_CLAUSE:
2296 dump_omp_clause (buffer, node, spc, flags);
2297 is_expr = false;
2298 break;
2299
0a35513e
AH
2300 case TRANSACTION_EXPR:
2301 if (TRANSACTION_EXPR_OUTER (node))
2302 pp_string (buffer, "__transaction_atomic [[outer]]");
2303 else if (TRANSACTION_EXPR_RELAXED (node))
2304 pp_string (buffer, "__transaction_relaxed");
2305 else
2306 pp_string (buffer, "__transaction_atomic");
2307 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2308 {
2309 newline_and_indent (buffer, spc);
2310 pp_character (buffer, '{');
2311 newline_and_indent (buffer, spc + 2);
2312 dump_generic_node (buffer, TRANSACTION_EXPR_BODY (node),
2313 spc + 2, flags, false);
2314 newline_and_indent (buffer, spc);
2315 pp_character (buffer, '}');
2316 }
2317 is_expr = false;
2318 break;
2319
61d3cdbb
DN
2320 case REDUC_MAX_EXPR:
2321 pp_string (buffer, " REDUC_MAX_EXPR < ");
2322 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2323 pp_string (buffer, " > ");
2324 break;
2325
2326 case REDUC_MIN_EXPR:
2327 pp_string (buffer, " REDUC_MIN_EXPR < ");
2328 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2329 pp_string (buffer, " > ");
2330 break;
2331
2332 case REDUC_PLUS_EXPR:
2333 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2334 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2335 pp_string (buffer, " > ");
2336 break;
2337
89d67cca 2338 case VEC_WIDEN_MULT_HI_EXPR:
89d67cca 2339 case VEC_WIDEN_MULT_LO_EXPR:
3f30a9a6
RH
2340 case VEC_WIDEN_MULT_EVEN_EXPR:
2341 case VEC_WIDEN_MULT_ODD_EXPR:
36ba4aae 2342 case VEC_WIDEN_LSHIFT_HI_EXPR:
36ba4aae 2343 case VEC_WIDEN_LSHIFT_LO_EXPR:
3f30a9a6
RH
2344 pp_character (buffer, ' ');
2345 for (str = tree_code_name [code]; *str; str++)
2346 pp_character (buffer, TOUPPER (*str));
2347 pp_string (buffer, " < ");
36ba4aae
IR
2348 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2349 pp_string (buffer, ", ");
2350 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2351 pp_string (buffer, " > ");
2352 break;
2353
89d67cca
DN
2354 case VEC_UNPACK_HI_EXPR:
2355 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2356 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2357 pp_string (buffer, " > ");
2358 break;
2359
2360 case VEC_UNPACK_LO_EXPR:
2361 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2362 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2363 pp_string (buffer, " > ");
2364 break;
2365
d9987fb4
UB
2366 case VEC_UNPACK_FLOAT_HI_EXPR:
2367 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2368 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2369 pp_string (buffer, " > ");
2370 break;
2371
2372 case VEC_UNPACK_FLOAT_LO_EXPR:
2373 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2374 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2375 pp_string (buffer, " > ");
2376 break;
2377
8115817b
UB
2378 case VEC_PACK_TRUNC_EXPR:
2379 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
89d67cca
DN
2380 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2381 pp_string (buffer, ", ");
2382 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2383 pp_string (buffer, " > ");
2384 break;
d9987fb4 2385
89d67cca
DN
2386 case VEC_PACK_SAT_EXPR:
2387 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2388 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2389 pp_string (buffer, ", ");
2390 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2391 pp_string (buffer, " > ");
2392 break;
d9987fb4
UB
2393
2394 case VEC_PACK_FIX_TRUNC_EXPR:
2395 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2396 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2397 pp_string (buffer, ", ");
2398 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2399 pp_string (buffer, " > ");
2400 break;
2401
953ff289 2402 case BLOCK:
65332587
DN
2403 dump_block_node (buffer, node, spc, flags);
2404 break;
953ff289 2405
6de9cd9a
DN
2406 default:
2407 NIY;
2408 }
2409
2410 if (is_stmt && is_expr)
2411 pp_semicolon (buffer);
438d798f
SM
2412
2413 /* If we're building a diagnostic, the formatted text will be written
2414 into BUFFER's stream by the caller; otherwise, write it now. */
2415 if (!(flags & TDF_DIAGNOSTIC))
2416 pp_write_text_to_stream (buffer);
6de9cd9a
DN
2417
2418 return spc;
2419}
2420
2421/* Print the declaration of a variable. */
2422
726a989a 2423void
6de9cd9a
DN
2424print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2425{
6de9cd9a
DN
2426 INDENT (spc);
2427
5f2dcbe1
RK
2428 if (TREE_CODE (t) == TYPE_DECL)
2429 pp_string (buffer, "typedef ");
2430
820cc88f 2431 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
6de9cd9a
DN
2432 pp_string (buffer, "register ");
2433
2434 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2435 pp_string (buffer, "extern ");
2436 else if (TREE_STATIC (t))
2437 pp_string (buffer, "static ");
2438
2439 /* Print the type and name. */
c31c32f9 2440 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
6de9cd9a
DN
2441 {
2442 tree tmp;
2443
2444 /* Print array's type. */
2445 tmp = TREE_TYPE (t);
2446 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2447 tmp = TREE_TYPE (tmp);
2448 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2449
2450 /* Print variable's name. */
2451 pp_space (buffer);
2452 dump_generic_node (buffer, t, spc, flags, false);
2453
2454 /* Print the dimensions. */
2455 tmp = TREE_TYPE (t);
2456 while (TREE_CODE (tmp) == ARRAY_TYPE)
2457 {
b16bcb17 2458 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
6de9cd9a
DN
2459 tmp = TREE_TYPE (tmp);
2460 }
2461 }
5f2dcbe1
RK
2462 else if (TREE_CODE (t) == FUNCTION_DECL)
2463 {
2464 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2465 pp_space (buffer);
2466 dump_decl_name (buffer, t, flags);
2467 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2468 }
6de9cd9a
DN
2469 else
2470 {
2471 /* Print type declaration. */
2472 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2473
2474 /* Print variable's name. */
2475 pp_space (buffer);
2476 dump_generic_node (buffer, t, spc, flags, false);
2477 }
2478
e670d9e4
RH
2479 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2480 {
2481 pp_string (buffer, " __asm__ ");
2482 pp_character (buffer, '(');
2483 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2484 pp_character (buffer, ')');
2485 }
2486
fa10beec 2487 /* The initial value of a function serves to determine whether the function
6de9cd9a
DN
2488 is declared or defined. So the following does not apply to function
2489 nodes. */
2490 if (TREE_CODE (t) != FUNCTION_DECL)
2491 {
2492 /* Print the initial value. */
2493 if (DECL_INITIAL (t))
2494 {
2495 pp_space (buffer);
2496 pp_character (buffer, '=');
2497 pp_space (buffer);
2498 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2499 }
2500 }
2501
953ff289
DN
2502 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2503 {
2504 pp_string (buffer, " [value-expr: ");
2505 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2506 pp_character (buffer, ']');
2507 }
2508
6de9cd9a
DN
2509 pp_character (buffer, ';');
2510}
2511
2512
2513/* Prints a structure: name, fields, and methods.
2514 FIXME: Still incomplete. */
2515
2516static void
ac545c64 2517print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
6de9cd9a
DN
2518{
2519 /* Print the name of the structure. */
2520 if (TYPE_NAME (node))
2521 {
2522 INDENT (spc);
2523 if (TREE_CODE (node) == RECORD_TYPE)
2524 pp_string (buffer, "struct ");
44de5aeb
RK
2525 else if ((TREE_CODE (node) == UNION_TYPE
2526 || TREE_CODE (node) == QUAL_UNION_TYPE))
6de9cd9a 2527 pp_string (buffer, "union ");
44de5aeb 2528
6de9cd9a
DN
2529 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2530 }
2531
2532 /* Print the contents of the structure. */
2533 pp_newline (buffer);
2534 INDENT (spc);
2535 pp_character (buffer, '{');
2536 pp_newline (buffer);
2537
2538 /* Print the fields of the structure. */
2539 {
2540 tree tmp;
2541 tmp = TYPE_FIELDS (node);
2542 while (tmp)
2543 {
2544 /* Avoid to print recursively the structure. */
2545 /* FIXME : Not implemented correctly...,
2546 what about the case when we have a cycle in the contain graph? ...
2547 Maybe this could be solved by looking at the scope in which the
2548 structure was declared. */
2549 if (TREE_TYPE (tmp) != node
413d3aa8
DN
2550 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2551 || TREE_TYPE (TREE_TYPE (tmp)) != node))
6de9cd9a
DN
2552 {
2553 print_declaration (buffer, tmp, spc+2, flags);
2554 pp_newline (buffer);
2555 }
910ad8de 2556 tmp = DECL_CHAIN (tmp);
6de9cd9a
DN
2557 }
2558 }
2559 INDENT (spc);
2560 pp_character (buffer, '}');
2561}
2562
0cf0d02b 2563/* Return the priority of the operator CODE.
6de9cd9a
DN
2564
2565 From lowest to highest precedence with either left-to-right (L-R)
2566 or right-to-left (R-L) associativity]:
2567
2568 1 [L-R] ,
2569 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2570 3 [R-L] ?:
2571 4 [L-R] ||
2572 5 [L-R] &&
2573 6 [L-R] |
2574 7 [L-R] ^
2575 8 [L-R] &
2576 9 [L-R] == !=
2577 10 [L-R] < <= > >=
2578 11 [L-R] << >>
2579 12 [L-R] + -
2580 13 [L-R] * / %
2581 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2582 15 [L-R] fn() [] -> .
2583
2584 unary +, - and * have higher precedence than the corresponding binary
2585 operators. */
2586
0cf0d02b
JJ
2587int
2588op_code_prio (enum tree_code code)
6de9cd9a 2589{
0cf0d02b 2590 switch (code)
6de9cd9a
DN
2591 {
2592 case TREE_LIST:
2593 case COMPOUND_EXPR:
2594 case BIND_EXPR:
2595 return 1;
2596
2597 case MODIFY_EXPR:
2598 case INIT_EXPR:
2599 return 2;
2600
2601 case COND_EXPR:
2602 return 3;
2603
2604 case TRUTH_OR_EXPR:
2605 case TRUTH_ORIF_EXPR:
2606 return 4;
2607
2608 case TRUTH_AND_EXPR:
2609 case TRUTH_ANDIF_EXPR:
2610 return 5;
2611
2612 case BIT_IOR_EXPR:
2613 return 6;
2614
2615 case BIT_XOR_EXPR:
2616 case TRUTH_XOR_EXPR:
2617 return 7;
2618
2619 case BIT_AND_EXPR:
2620 return 8;
2621
2622 case EQ_EXPR:
2623 case NE_EXPR:
2624 return 9;
2625
d1a7edaf
PB
2626 case UNLT_EXPR:
2627 case UNLE_EXPR:
2628 case UNGT_EXPR:
2629 case UNGE_EXPR:
2630 case UNEQ_EXPR:
2631 case LTGT_EXPR:
2632 case ORDERED_EXPR:
2633 case UNORDERED_EXPR:
6de9cd9a
DN
2634 case LT_EXPR:
2635 case LE_EXPR:
2636 case GT_EXPR:
2637 case GE_EXPR:
2638 return 10;
2639
2640 case LSHIFT_EXPR:
2641 case RSHIFT_EXPR:
2642 case LROTATE_EXPR:
2643 case RROTATE_EXPR:
36ba4aae
IR
2644 case VEC_WIDEN_LSHIFT_HI_EXPR:
2645 case VEC_WIDEN_LSHIFT_LO_EXPR:
2646 case WIDEN_LSHIFT_EXPR:
6de9cd9a
DN
2647 return 11;
2648
20f06221 2649 case WIDEN_SUM_EXPR:
6de9cd9a 2650 case PLUS_EXPR:
5be014d5 2651 case POINTER_PLUS_EXPR:
6de9cd9a
DN
2652 case MINUS_EXPR:
2653 return 12;
2654
89d67cca
DN
2655 case VEC_WIDEN_MULT_HI_EXPR:
2656 case VEC_WIDEN_MULT_LO_EXPR:
20f06221
DN
2657 case WIDEN_MULT_EXPR:
2658 case DOT_PROD_EXPR:
0354c0c7
BS
2659 case WIDEN_MULT_PLUS_EXPR:
2660 case WIDEN_MULT_MINUS_EXPR:
6de9cd9a 2661 case MULT_EXPR:
98449720 2662 case MULT_HIGHPART_EXPR:
6de9cd9a
DN
2663 case TRUNC_DIV_EXPR:
2664 case CEIL_DIV_EXPR:
2665 case FLOOR_DIV_EXPR:
2666 case ROUND_DIV_EXPR:
2667 case RDIV_EXPR:
2668 case EXACT_DIV_EXPR:
2669 case TRUNC_MOD_EXPR:
2670 case CEIL_MOD_EXPR:
2671 case FLOOR_MOD_EXPR:
2672 case ROUND_MOD_EXPR:
0f59b812 2673 case FMA_EXPR:
6de9cd9a
DN
2674 return 13;
2675
2676 case TRUTH_NOT_EXPR:
2677 case BIT_NOT_EXPR:
2678 case POSTINCREMENT_EXPR:
2679 case POSTDECREMENT_EXPR:
2680 case PREINCREMENT_EXPR:
2681 case PREDECREMENT_EXPR:
2682 case NEGATE_EXPR:
2683 case INDIRECT_REF:
2684 case ADDR_EXPR:
2685 case FLOAT_EXPR:
1043771b 2686 CASE_CONVERT:
6de9cd9a 2687 case FIX_TRUNC_EXPR:
6de9cd9a
DN
2688 case TARGET_EXPR:
2689 return 14;
2690
2691 case CALL_EXPR:
2692 case ARRAY_REF:
44de5aeb 2693 case ARRAY_RANGE_REF:
6de9cd9a
DN
2694 case COMPONENT_REF:
2695 return 15;
2696
2697 /* Special expressions. */
2698 case MIN_EXPR:
2699 case MAX_EXPR:
2700 case ABS_EXPR:
2701 case REALPART_EXPR:
2702 case IMAGPART_EXPR:
61d3cdbb
DN
2703 case REDUC_MAX_EXPR:
2704 case REDUC_MIN_EXPR:
2705 case REDUC_PLUS_EXPR:
a6b46ba2
DN
2706 case VEC_LSHIFT_EXPR:
2707 case VEC_RSHIFT_EXPR:
89d67cca
DN
2708 case VEC_UNPACK_HI_EXPR:
2709 case VEC_UNPACK_LO_EXPR:
d9987fb4
UB
2710 case VEC_UNPACK_FLOAT_HI_EXPR:
2711 case VEC_UNPACK_FLOAT_LO_EXPR:
8115817b 2712 case VEC_PACK_TRUNC_EXPR:
89d67cca 2713 case VEC_PACK_SAT_EXPR:
6de9cd9a
DN
2714 return 16;
2715
6de9cd9a
DN
2716 default:
2717 /* Return an arbitrarily high precedence to avoid surrounding single
2718 VAR_DECLs in ()s. */
2719 return 9999;
2720 }
2721}
2722
0cf0d02b
JJ
2723/* Return the priority of the operator OP. */
2724
2725int
2726op_prio (const_tree op)
2727{
2728 enum tree_code code;
2729
2730 if (op == NULL)
2731 return 9999;
2732
2733 code = TREE_CODE (op);
2734 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
2735 return op_prio (TREE_OPERAND (op, 0));
2736
2737 return op_code_prio (code);
2738}
6de9cd9a 2739
bbc8a8dc 2740/* Return the symbol associated with operator CODE. */
6de9cd9a 2741
bbc8a8dc
ZD
2742const char *
2743op_symbol_code (enum tree_code code)
6de9cd9a 2744{
953ff289 2745 switch (code)
6de9cd9a
DN
2746 {
2747 case MODIFY_EXPR:
2748 return "=";
2749
2750 case TRUTH_OR_EXPR:
2751 case TRUTH_ORIF_EXPR:
2752 return "||";
2753
2754 case TRUTH_AND_EXPR:
2755 case TRUTH_ANDIF_EXPR:
2756 return "&&";
2757
2758 case BIT_IOR_EXPR:
2759 return "|";
2760
2761 case TRUTH_XOR_EXPR:
2762 case BIT_XOR_EXPR:
2763 return "^";
2764
2765 case ADDR_EXPR:
2766 case BIT_AND_EXPR:
2767 return "&";
2768
d1a7edaf
PB
2769 case ORDERED_EXPR:
2770 return "ord";
2771 case UNORDERED_EXPR:
2772 return "unord";
2773
6de9cd9a 2774 case EQ_EXPR:
6de9cd9a 2775 return "==";
d1a7edaf
PB
2776 case UNEQ_EXPR:
2777 return "u==";
6de9cd9a
DN
2778
2779 case NE_EXPR:
2780 return "!=";
2781
2782 case LT_EXPR:
6de9cd9a 2783 return "<";
d1a7edaf
PB
2784 case UNLT_EXPR:
2785 return "u<";
6de9cd9a
DN
2786
2787 case LE_EXPR:
6de9cd9a 2788 return "<=";
d1a7edaf
PB
2789 case UNLE_EXPR:
2790 return "u<=";
6de9cd9a
DN
2791
2792 case GT_EXPR:
6de9cd9a 2793 return ">";
d1a7edaf
PB
2794 case UNGT_EXPR:
2795 return "u>";
6de9cd9a
DN
2796
2797 case GE_EXPR:
6de9cd9a 2798 return ">=";
d1a7edaf
PB
2799 case UNGE_EXPR:
2800 return "u>=";
2801
2802 case LTGT_EXPR:
2803 return "<>";
6de9cd9a
DN
2804
2805 case LSHIFT_EXPR:
2806 return "<<";
2807
2808 case RSHIFT_EXPR:
2809 return ">>";
2810
de3d4fc2
RG
2811 case LROTATE_EXPR:
2812 return "r<<";
2813
2814 case RROTATE_EXPR:
2815 return "r>>";
2816
a6b46ba2
DN
2817 case VEC_LSHIFT_EXPR:
2818 return "v<<";
2819
2820 case VEC_RSHIFT_EXPR:
2821 return "v>>";
5be014d5 2822
36ba4aae
IR
2823 case WIDEN_LSHIFT_EXPR:
2824 return "w<<";
2825
5be014d5
AP
2826 case POINTER_PLUS_EXPR:
2827 return "+";
b8698a0f 2828
6de9cd9a
DN
2829 case PLUS_EXPR:
2830 return "+";
2831
61d3cdbb
DN
2832 case REDUC_PLUS_EXPR:
2833 return "r+";
2834
20f06221
DN
2835 case WIDEN_SUM_EXPR:
2836 return "w+";
2837
2838 case WIDEN_MULT_EXPR:
2839 return "w*";
2840
98449720
RH
2841 case MULT_HIGHPART_EXPR:
2842 return "h*";
2843
6de9cd9a
DN
2844 case NEGATE_EXPR:
2845 case MINUS_EXPR:
2846 return "-";
2847
2848 case BIT_NOT_EXPR:
2849 return "~";
2850
2851 case TRUTH_NOT_EXPR:
2852 return "!";
2853
2854 case MULT_EXPR:
2855 case INDIRECT_REF:
2856 return "*";
2857
2858 case TRUNC_DIV_EXPR:
a0ca8e0c
RK
2859 case RDIV_EXPR:
2860 return "/";
2861
6de9cd9a 2862 case CEIL_DIV_EXPR:
a0ca8e0c
RK
2863 return "/[cl]";
2864
6de9cd9a 2865 case FLOOR_DIV_EXPR:
a0ca8e0c
RK
2866 return "/[fl]";
2867
6de9cd9a 2868 case ROUND_DIV_EXPR:
a0ca8e0c
RK
2869 return "/[rd]";
2870
6de9cd9a 2871 case EXACT_DIV_EXPR:
a0ca8e0c 2872 return "/[ex]";
6de9cd9a
DN
2873
2874 case TRUNC_MOD_EXPR:
a0ca8e0c
RK
2875 return "%";
2876
6de9cd9a 2877 case CEIL_MOD_EXPR:
a0ca8e0c
RK
2878 return "%[cl]";
2879
6de9cd9a 2880 case FLOOR_MOD_EXPR:
a0ca8e0c
RK
2881 return "%[fl]";
2882
6de9cd9a 2883 case ROUND_MOD_EXPR:
a0ca8e0c 2884 return "%[rd]";
6de9cd9a
DN
2885
2886 case PREDECREMENT_EXPR:
2887 return " --";
2888
2889 case PREINCREMENT_EXPR:
2890 return " ++";
2891
2892 case POSTDECREMENT_EXPR:
2893 return "-- ";
2894
2895 case POSTINCREMENT_EXPR:
2896 return "++ ";
2897
953ff289
DN
2898 case MAX_EXPR:
2899 return "max";
2900
2901 case MIN_EXPR:
2902 return "min";
2903
6de9cd9a
DN
2904 default:
2905 return "<<< ??? >>>";
2906 }
2907}
2908
bbc8a8dc
ZD
2909/* Return the symbol associated with operator OP. */
2910
953ff289 2911static const char *
ac545c64 2912op_symbol (const_tree op)
953ff289 2913{
bbc8a8dc 2914 return op_symbol_code (TREE_CODE (op));
953ff289
DN
2915}
2916
1aec401e
JM
2917/* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2918 the gimple_call_fn of a GIMPLE_CALL. */
6de9cd9a 2919
1aec401e 2920void
394bd84d 2921print_call_name (pretty_printer *buffer, tree node, int flags)
6de9cd9a 2922{
1aec401e 2923 tree op0 = node;
6de9cd9a
DN
2924
2925 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
2926 op0 = TREE_OPERAND (op0, 0);
2927
1aec401e 2928 again:
6de9cd9a
DN
2929 switch (TREE_CODE (op0))
2930 {
2931 case VAR_DECL:
2932 case PARM_DECL:
1aec401e 2933 case FUNCTION_DECL:
394bd84d 2934 dump_function_name (buffer, op0, flags);
6de9cd9a
DN
2935 break;
2936
2937 case ADDR_EXPR:
2938 case INDIRECT_REF:
2939 case NOP_EXPR:
1aec401e
JM
2940 op0 = TREE_OPERAND (op0, 0);
2941 goto again;
6de9cd9a
DN
2942
2943 case COND_EXPR:
2944 pp_string (buffer, "(");
394bd84d 2945 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
6de9cd9a 2946 pp_string (buffer, ") ? ");
394bd84d 2947 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
6de9cd9a 2948 pp_string (buffer, " : ");
394bd84d 2949 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
6de9cd9a
DN
2950 break;
2951
6de9cd9a
DN
2952 case ARRAY_REF:
2953 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
394bd84d 2954 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
6de9cd9a 2955 else
394bd84d 2956 dump_generic_node (buffer, op0, 0, flags, false);
6de9cd9a
DN
2957 break;
2958
70f34814
RG
2959 case MEM_REF:
2960 if (integer_zerop (TREE_OPERAND (op0, 1)))
2961 {
2962 op0 = TREE_OPERAND (op0, 0);
2963 goto again;
2964 }
2965 /* Fallthru. */
d69b8a03 2966 case COMPONENT_REF:
6de9cd9a 2967 case SSA_NAME:
0f59171d 2968 case OBJ_TYPE_REF:
394bd84d 2969 dump_generic_node (buffer, op0, 0, flags, false);
6de9cd9a
DN
2970 break;
2971
2972 default:
2973 NIY;
2974 }
2975}
2976
2977/* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2978
2979static void
2980pretty_print_string (pretty_printer *buffer, const char *str)
2981{
2982 if (str == NULL)
2983 return;
2984
2985 while (*str)
2986 {
2987 switch (str[0])
2988 {
2989 case '\b':
2990 pp_string (buffer, "\\b");
2991 break;
2992
2993 case '\f':
2994 pp_string (buffer, "\\f");
2995 break;
2996
2997 case '\n':
2998 pp_string (buffer, "\\n");
2999 break;
3000
3001 case '\r':
3002 pp_string (buffer, "\\r");
3003 break;
3004
3005 case '\t':
3006 pp_string (buffer, "\\t");
3007 break;
3008
3009 case '\v':
3010 pp_string (buffer, "\\v");
3011 break;
3012
3013 case '\\':
3014 pp_string (buffer, "\\\\");
3015 break;
3016
3017 case '\"':
3018 pp_string (buffer, "\\\"");
3019 break;
3020
3021 case '\'':
3022 pp_string (buffer, "\\'");
3023 break;
3024
4db60bd0 3025 /* No need to handle \0; the loop terminates on \0. */
6de9cd9a
DN
3026
3027 case '\1':
3028 pp_string (buffer, "\\1");
3029 break;
3030
3031 case '\2':
3032 pp_string (buffer, "\\2");
3033 break;
3034
3035 case '\3':
3036 pp_string (buffer, "\\3");
3037 break;
3038
3039 case '\4':
3040 pp_string (buffer, "\\4");
3041 break;
3042
3043 case '\5':
3044 pp_string (buffer, "\\5");
3045 break;
3046
3047 case '\6':
3048 pp_string (buffer, "\\6");
3049 break;
3050
3051 case '\7':
3052 pp_string (buffer, "\\7");
3053 break;
3054
3055 default:
3056 pp_character (buffer, str[0]);
3057 break;
3058 }
3059 str++;
3060 }
3061}
3062
3063static void
3064maybe_init_pretty_print (FILE *file)
3065{
3066 if (!initialized)
3067 {
3068 pp_construct (&buffer, /* prefix */NULL, /* line-width */0);
3069 pp_needs_newline (&buffer) = true;
f41c4af3 3070 pp_translate_identifiers (&buffer) = false;
6de9cd9a
DN
3071 initialized = 1;
3072 }
3073
3074 buffer.buffer->stream = file;
3075}
3076
3077static void
3078newline_and_indent (pretty_printer *buffer, int spc)
3079{
3080 pp_newline (buffer);
3081 INDENT (spc);
3082}
cf835838
JM
3083
3084/* Handle a %K format for TEXT. Separate from default_tree_printer so
3085 it can also be used in front ends.
3086 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3087*/
3088
3089void
3090percent_K_format (text_info *text)
3091{
3092 tree t = va_arg (*text->args_ptr, tree), block;
3093 gcc_assert (text->locus != NULL);
3094 *text->locus = EXPR_LOCATION (t);
3095 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3096 block = TREE_BLOCK (t);
3097 *pp_ti_abstract_origin (text) = NULL;
3098 while (block
3099 && TREE_CODE (block) == BLOCK
3100 && BLOCK_ABSTRACT_ORIGIN (block))
3101 {
3102 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3103
3104 while (TREE_CODE (ao) == BLOCK
3105 && BLOCK_ABSTRACT_ORIGIN (ao)
3106 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3107 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3108
3109 if (TREE_CODE (ao) == FUNCTION_DECL)
3110 {
3111 *pp_ti_abstract_origin (text) = block;
3112 break;
3113 }
3114 block = BLOCK_SUPERCONTEXT (block);
3115 }
3116}
3117
3118/* Print the identifier ID to PRETTY-PRINTER. */
3119
3120void
3121pp_base_tree_identifier (pretty_printer *pp, tree id)
3122{
3123 if (pp_translate_identifiers (pp))
3124 {
3125 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3126 pp_append_text (pp, text, text + strlen (text));
3127 }
3128 else
3129 pp_append_text (pp, IDENTIFIER_POINTER (id),
3130 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3131}
ea6cf778
DL
3132
3133/* A helper function that is used to dump function information before the
3134 function dump. */
3135
3136void
6d8402ac 3137dump_function_header (FILE *dump_file, tree fdecl, int flags)
ea6cf778
DL
3138{
3139 const char *dname, *aname;
3140 struct cgraph_node *node = cgraph_get_node (fdecl);
3141 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3142
3143 dname = lang_hooks.decl_printable_name (fdecl, 2);
3144
3145 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3146 aname = (IDENTIFIER_POINTER
3147 (DECL_ASSEMBLER_NAME (fdecl)));
3148 else
3149 aname = "<unset-asm-name>";
3150
6d8402ac
AO
3151 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3152 dname, aname, fun->funcdef_no);
3153 if (!(flags & TDF_NOUID))
3154 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
ea6cf778
DL
3155 if (node)
3156 {
6d8402ac 3157 fprintf (dump_file, ", cgraph_uid=%d)%s\n\n", node->uid,
ea6cf778
DL
3158 node->frequency == NODE_FREQUENCY_HOT
3159 ? " (hot)"
3160 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3161 ? " (unlikely executed)"
3162 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3163 ? " (executed once)"
3164 : "");
3165 }
3166 else
6d8402ac 3167 fprintf (dump_file, ")\n\n");
ea6cf778 3168}