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