OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [tree-pretty-print.c] - Blame information for rev 693

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.