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