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