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