]>
Commit | Line | Data |
---|---|---|
52eeef3a | 1 | /* Prints out tree in human readable form - GNU C-compiler |
1e66ce77 | 2 | Copyright (C) 1990, 91, 93, 94, 95, 1996 Free Software Foundation, Inc. |
52eeef3a RS |
3 | |
4 | This file is part of GNU CC. | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
e99215a3 RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
52eeef3a RS |
20 | |
21 | ||
22 | #include "config.h" | |
23 | #include "tree.h" | |
24 | #include <stdio.h> | |
25 | ||
26 | extern char **tree_code_name; | |
27 | ||
28 | extern char *mode_name[]; | |
29 | ||
30 | void print_node (); | |
31 | void indent_to (); | |
32 | ||
33 | /* Define the hash table of nodes already seen. | |
34 | Such nodes are not repeated; brief cross-references are used. */ | |
35 | ||
36 | #define HASH_SIZE 37 | |
37 | ||
38 | struct bucket | |
39 | { | |
40 | tree node; | |
41 | struct bucket *next; | |
42 | }; | |
43 | ||
44 | static struct bucket **table; | |
45 | ||
46 | /* Print the node NODE on standard error, for debugging. | |
47 | Most nodes referred to by this one are printed recursively | |
48 | down to a depth of six. */ | |
49 | ||
50 | void | |
51 | debug_tree (node) | |
52 | tree node; | |
53 | { | |
54 | char *object = (char *) oballoc (0); | |
4c9a05bc | 55 | |
52eeef3a | 56 | table = (struct bucket **) oballoc (HASH_SIZE * sizeof (struct bucket *)); |
4c9a05bc | 57 | bzero ((char *) table, HASH_SIZE * sizeof (struct bucket *)); |
52eeef3a RS |
58 | print_node (stderr, "", node, 0); |
59 | table = 0; | |
60 | obfree (object); | |
61 | fprintf (stderr, "\n"); | |
62 | } | |
63 | ||
64 | /* Print a node in brief fashion, with just the code, address and name. */ | |
65 | ||
66 | void | |
67 | print_node_brief (file, prefix, node, indent) | |
68 | FILE *file; | |
69 | char *prefix; | |
70 | tree node; | |
71 | int indent; | |
72 | { | |
73 | char class; | |
74 | ||
75 | if (node == 0) | |
76 | return; | |
77 | ||
78 | class = TREE_CODE_CLASS (TREE_CODE (node)); | |
79 | ||
80 | /* Always print the slot this node is in, and its code, address and | |
81 | name if any. */ | |
82 | if (indent > 0) | |
83 | fprintf (file, " "); | |
906c4e36 | 84 | fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]); |
9520cb3e | 85 | fprintf (file, HOST_PTR_PRINTF, (HOST_WIDE_INT) node); |
52eeef3a RS |
86 | |
87 | if (class == 'd') | |
88 | { | |
89 | if (DECL_NAME (node)) | |
90 | fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node))); | |
91 | } | |
92 | else if (class == 't') | |
93 | { | |
94 | if (TYPE_NAME (node)) | |
95 | { | |
96 | if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) | |
97 | fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node))); | |
98 | else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL | |
99 | && DECL_NAME (TYPE_NAME (node))) | |
100 | fprintf (file, " %s", | |
101 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)))); | |
102 | } | |
103 | } | |
104 | if (TREE_CODE (node) == IDENTIFIER_NODE) | |
105 | fprintf (file, " %s", IDENTIFIER_POINTER (node)); | |
106 | /* We might as well always print the value of an integer. */ | |
107 | if (TREE_CODE (node) == INTEGER_CST) | |
108 | { | |
3e5f8018 RK |
109 | if (TREE_CONSTANT_OVERFLOW (node)) |
110 | fprintf (file, " overflow"); | |
111 | ||
1e66ce77 | 112 | fprintf (file, " "); |
52eeef3a | 113 | if (TREE_INT_CST_HIGH (node) == 0) |
1e66ce77 | 114 | fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node)); |
52eeef3a RS |
115 | else if (TREE_INT_CST_HIGH (node) == -1 |
116 | && TREE_INT_CST_LOW (node) != 0) | |
1e66ce77 RK |
117 | { |
118 | fprintf (file, "-"); | |
119 | fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, | |
910d1693 | 120 | -TREE_INT_CST_LOW (node)); |
1e66ce77 | 121 | } |
52eeef3a | 122 | else |
1e66ce77 | 123 | fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX, |
906c4e36 | 124 | TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node)); |
52eeef3a RS |
125 | } |
126 | if (TREE_CODE (node) == REAL_CST) | |
127 | { | |
7063dcbe RK |
128 | REAL_VALUE_TYPE d; |
129 | ||
86b38416 RK |
130 | if (TREE_OVERFLOW (node)) |
131 | fprintf (file, " overflow"); | |
132 | ||
133 | #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC) | |
7063dcbe | 134 | d = TREE_REAL_CST (node); |
86b38416 RK |
135 | if (REAL_VALUE_ISINF (d)) |
136 | fprintf (file, " Inf"); | |
137 | else if (REAL_VALUE_ISNAN (d)) | |
138 | fprintf (file, " Nan"); | |
139 | else | |
140 | { | |
141 | char string[100]; | |
142 | ||
143 | REAL_VALUE_TO_DECIMAL (d, "%e", string); | |
144 | fprintf (file, " %s", string); | |
145 | } | |
52eeef3a RS |
146 | #else |
147 | { | |
148 | int i; | |
48daf828 | 149 | unsigned char *p = (unsigned char *) &TREE_REAL_CST (node); |
52eeef3a RS |
150 | fprintf (file, " 0x"); |
151 | for (i = 0; i < sizeof TREE_REAL_CST (node); i++) | |
152 | fprintf (file, "%02x", *p++); | |
153 | fprintf (file, ""); | |
154 | } | |
86b38416 | 155 | #endif |
52eeef3a RS |
156 | } |
157 | ||
158 | fprintf (file, ">"); | |
159 | } | |
160 | ||
161 | void | |
162 | indent_to (file, column) | |
163 | FILE *file; | |
164 | int column; | |
165 | { | |
166 | int i; | |
167 | ||
168 | /* Since this is the long way, indent to desired column. */ | |
169 | if (column > 0) | |
170 | fprintf (file, "\n"); | |
171 | for (i = 0; i < column; i++) | |
172 | fprintf (file, " "); | |
173 | } | |
174 | \f | |
175 | /* Print the node NODE in full on file FILE, preceded by PREFIX, | |
176 | starting in column INDENT. */ | |
177 | ||
178 | void | |
179 | print_node (file, prefix, node, indent) | |
180 | FILE *file; | |
181 | char *prefix; | |
182 | tree node; | |
183 | int indent; | |
184 | { | |
185 | int hash; | |
186 | struct bucket *b; | |
187 | enum machine_mode mode; | |
188 | char class; | |
189 | int len; | |
190 | int first_rtl; | |
191 | int i; | |
192 | ||
193 | if (node == 0) | |
194 | return; | |
195 | ||
196 | class = TREE_CODE_CLASS (TREE_CODE (node)); | |
197 | ||
198 | /* Don't get too deep in nesting. If the user wants to see deeper, | |
199 | it is easy to use the address of a lowest-level node | |
200 | as an argument in another call to debug_tree. */ | |
201 | ||
202 | if (indent > 24) | |
203 | { | |
204 | print_node_brief (file, prefix, node, indent); | |
205 | return; | |
206 | } | |
207 | ||
208 | if (indent > 8 && (class == 't' || class == 'd')) | |
209 | { | |
210 | print_node_brief (file, prefix, node, indent); | |
211 | return; | |
212 | } | |
213 | ||
0f41302f | 214 | /* It is unsafe to look at any other filds of an ERROR_MARK node. */ |
52eeef3a RS |
215 | if (TREE_CODE (node) == ERROR_MARK) |
216 | { | |
217 | print_node_brief (file, prefix, node, indent); | |
218 | return; | |
219 | } | |
220 | ||
11f6a29c | 221 | hash = ((unsigned HOST_WIDE_INT) node) % HASH_SIZE; |
52eeef3a RS |
222 | |
223 | /* If node is in the table, just mention its address. */ | |
224 | for (b = table[hash]; b; b = b->next) | |
225 | if (b->node == node) | |
226 | { | |
227 | print_node_brief (file, prefix, node, indent); | |
228 | return; | |
229 | } | |
230 | ||
231 | /* Add this node to the table. */ | |
232 | b = (struct bucket *) oballoc (sizeof (struct bucket)); | |
233 | b->node = node; | |
234 | b->next = table[hash]; | |
235 | table[hash] = b; | |
236 | ||
237 | /* Indent to the specified column, since this is the long form. */ | |
238 | indent_to (file, indent); | |
239 | ||
240 | /* Print the slot this node is in, and its code, and address. */ | |
906c4e36 | 241 | fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]); |
9520cb3e | 242 | fprintf (file, HOST_PTR_PRINTF, (HOST_WIDE_INT) node); |
52eeef3a RS |
243 | |
244 | /* Print the name, if any. */ | |
245 | if (class == 'd') | |
246 | { | |
247 | if (DECL_NAME (node)) | |
248 | fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node))); | |
249 | } | |
250 | else if (class == 't') | |
251 | { | |
252 | if (TYPE_NAME (node)) | |
253 | { | |
254 | if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) | |
255 | fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node))); | |
256 | else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL | |
257 | && DECL_NAME (TYPE_NAME (node))) | |
258 | fprintf (file, " %s", | |
259 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)))); | |
260 | } | |
261 | } | |
262 | if (TREE_CODE (node) == IDENTIFIER_NODE) | |
263 | fprintf (file, " %s", IDENTIFIER_POINTER (node)); | |
264 | ||
265 | if (TREE_CODE (node) == INTEGER_CST) | |
266 | { | |
267 | if (indent <= 4) | |
268 | print_node_brief (file, "type", TREE_TYPE (node), indent + 4); | |
269 | } | |
270 | else | |
271 | { | |
272 | print_node (file, "type", TREE_TYPE (node), indent + 4); | |
273 | if (TREE_TYPE (node)) | |
274 | indent_to (file, indent + 3); | |
12642426 RK |
275 | |
276 | print_obstack_name ((char *) node, file, ""); | |
277 | indent_to (file, indent + 3); | |
52eeef3a RS |
278 | } |
279 | ||
280 | /* If a permanent object is in the wrong obstack, or the reverse, warn. */ | |
281 | if (object_permanent_p (node) != TREE_PERMANENT (node)) | |
282 | { | |
283 | if (TREE_PERMANENT (node)) | |
284 | fputs (" !!permanent object in non-permanent obstack!!", file); | |
285 | else | |
286 | fputs (" !!non-permanent object in permanent obstack!!", file); | |
287 | indent_to (file, indent + 3); | |
288 | } | |
289 | ||
290 | if (TREE_SIDE_EFFECTS (node)) | |
291 | fputs (" side-effects", file); | |
292 | if (TREE_READONLY (node)) | |
293 | fputs (" readonly", file); | |
294 | if (TREE_CONSTANT (node)) | |
295 | fputs (" constant", file); | |
296 | if (TREE_ADDRESSABLE (node)) | |
297 | fputs (" addressable", file); | |
298 | if (TREE_THIS_VOLATILE (node)) | |
299 | fputs (" volatile", file); | |
300 | if (TREE_UNSIGNED (node)) | |
301 | fputs (" unsigned", file); | |
302 | if (TREE_ASM_WRITTEN (node)) | |
303 | fputs (" asm_written", file); | |
304 | if (TREE_USED (node)) | |
305 | fputs (" used", file); | |
3110a56e RS |
306 | if (TREE_RAISES (node)) |
307 | fputs (" raises", file); | |
52eeef3a RS |
308 | if (TREE_PERMANENT (node)) |
309 | fputs (" permanent", file); | |
310 | if (TREE_PUBLIC (node)) | |
311 | fputs (" public", file); | |
312 | if (TREE_STATIC (node)) | |
313 | fputs (" static", file); | |
314 | if (TREE_LANG_FLAG_0 (node)) | |
315 | fputs (" tree_0", file); | |
316 | if (TREE_LANG_FLAG_1 (node)) | |
317 | fputs (" tree_1", file); | |
318 | if (TREE_LANG_FLAG_2 (node)) | |
319 | fputs (" tree_2", file); | |
320 | if (TREE_LANG_FLAG_3 (node)) | |
321 | fputs (" tree_3", file); | |
322 | if (TREE_LANG_FLAG_4 (node)) | |
323 | fputs (" tree_4", file); | |
324 | if (TREE_LANG_FLAG_5 (node)) | |
325 | fputs (" tree_5", file); | |
326 | if (TREE_LANG_FLAG_6 (node)) | |
327 | fputs (" tree_6", file); | |
328 | ||
329 | /* DECL_ nodes have additional attributes. */ | |
330 | ||
331 | switch (TREE_CODE_CLASS (TREE_CODE (node))) | |
332 | { | |
333 | case 'd': | |
334 | mode = DECL_MODE (node); | |
335 | ||
96a31ab8 RK |
336 | if (DECL_IGNORED_P (node)) |
337 | fputs (" ignored", file); | |
338 | if (DECL_ABSTRACT (node)) | |
339 | fputs (" abstract", file); | |
340 | if (DECL_IN_SYSTEM_HEADER (node)) | |
341 | fputs (" in_system_header", file); | |
342 | if (DECL_COMMON (node)) | |
343 | fputs (" common", file); | |
216d5cdd | 344 | if (DECL_EXTERNAL (node)) |
52eeef3a | 345 | fputs (" external", file); |
216d5cdd | 346 | if (DECL_REGISTER (node)) |
52eeef3a | 347 | fputs (" regdecl", file); |
96a31ab8 RK |
348 | if (DECL_PACKED (node)) |
349 | fputs (" packed", file); | |
350 | if (DECL_NONLOCAL (node)) | |
351 | fputs (" nonlocal", file); | |
216d5cdd | 352 | if (DECL_INLINE (node)) |
52eeef3a | 353 | fputs (" inline", file); |
96a31ab8 RK |
354 | |
355 | if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node)) | |
788d4ba0 | 356 | fputs (" suppress-debug", file); |
96a31ab8 RK |
357 | |
358 | if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node)) | |
359 | fputs (" built-in", file); | |
360 | if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN_NONANSI (node)) | |
361 | fputs (" built-in-nonansi", file); | |
362 | ||
363 | if (TREE_CODE (node) == FIELD_DECL && DECL_BIT_FIELD (node)) | |
52eeef3a | 364 | fputs (" bit-field", file); |
96a31ab8 RK |
365 | if (TREE_CODE (node) == LABEL_DECL && DECL_TOO_LATE (node)) |
366 | fputs (" too-late", file); | |
367 | if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node)) | |
368 | fputs (" in-text-section", file); | |
369 | ||
52eeef3a RS |
370 | if (DECL_VIRTUAL_P (node)) |
371 | fputs (" virtual", file); | |
96a31ab8 RK |
372 | if (DECL_DEFER_OUTPUT (node)) |
373 | fputs (" defer-output", file); | |
374 | if (DECL_TRANSPARENT_UNION (node)) | |
375 | fputs (" transparent-union", file); | |
376 | ||
52eeef3a RS |
377 | if (DECL_LANG_FLAG_0 (node)) |
378 | fputs (" decl_0", file); | |
379 | if (DECL_LANG_FLAG_1 (node)) | |
380 | fputs (" decl_1", file); | |
381 | if (DECL_LANG_FLAG_2 (node)) | |
382 | fputs (" decl_2", file); | |
383 | if (DECL_LANG_FLAG_3 (node)) | |
384 | fputs (" decl_3", file); | |
385 | if (DECL_LANG_FLAG_4 (node)) | |
386 | fputs (" decl_4", file); | |
387 | if (DECL_LANG_FLAG_5 (node)) | |
388 | fputs (" decl_5", file); | |
389 | if (DECL_LANG_FLAG_6 (node)) | |
390 | fputs (" decl_6", file); | |
391 | if (DECL_LANG_FLAG_7 (node)) | |
392 | fputs (" decl_7", file); | |
393 | ||
394 | fprintf (file, " %s", mode_name[(int) mode]); | |
395 | ||
396 | fprintf (file, " file %s line %d", | |
397 | DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node)); | |
398 | ||
399 | print_node (file, "size", DECL_SIZE (node), indent + 4); | |
400 | indent_to (file, indent + 3); | |
c0920bf9 RS |
401 | if (TREE_CODE (node) != FUNCTION_DECL) |
402 | fprintf (file, " align %d", DECL_ALIGN (node)); | |
216d5cdd | 403 | else if (DECL_INLINE (node)) |
c0920bf9 RS |
404 | fprintf (file, " frame_size %d", DECL_FRAME_SIZE (node)); |
405 | else if (DECL_BUILT_IN (node)) | |
406 | fprintf (file, " built-in code %d", DECL_FUNCTION_CODE (node)); | |
52eeef3a RS |
407 | if (TREE_CODE (node) == FIELD_DECL) |
408 | print_node (file, "bitpos", DECL_FIELD_BITPOS (node), indent + 4); | |
409 | print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4); | |
38d68645 | 410 | print_node_brief (file, "machine_attributes", DECL_MACHINE_ATTRIBUTES (node), indent + 4); |
c5caa350 CH |
411 | print_node_brief (file, "abstract_origin", |
412 | DECL_ABSTRACT_ORIGIN (node), indent + 4); | |
52eeef3a RS |
413 | |
414 | print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4); | |
415 | print_node (file, "result", DECL_RESULT (node), indent + 4); | |
416 | print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4); | |
417 | ||
418 | print_lang_decl (file, node, indent); | |
419 | ||
420 | if (DECL_RTL (node) != 0) | |
421 | { | |
422 | indent_to (file, indent + 4); | |
423 | print_rtl (file, DECL_RTL (node)); | |
424 | } | |
425 | ||
426 | if (DECL_SAVED_INSNS (node) != 0) | |
427 | { | |
428 | indent_to (file, indent + 4); | |
429 | if (TREE_CODE (node) == PARM_DECL) | |
430 | { | |
431 | fprintf (file, "incoming-rtl "); | |
432 | print_rtl (file, DECL_INCOMING_RTL (node)); | |
433 | } | |
434 | else if (TREE_CODE (node) == FUNCTION_DECL) | |
906c4e36 RK |
435 | { |
436 | fprintf (file, "saved-insns "); | |
9520cb3e RK |
437 | fprintf (file, HOST_PTR_PRINTF, |
438 | (HOST_WIDE_INT) DECL_SAVED_INSNS (node)); | |
906c4e36 | 439 | } |
52eeef3a RS |
440 | } |
441 | ||
442 | /* Print the decl chain only if decl is at second level. */ | |
443 | if (indent == 4) | |
444 | print_node (file, "chain", TREE_CHAIN (node), indent + 4); | |
445 | else | |
446 | print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4); | |
447 | break; | |
448 | ||
449 | case 't': | |
450 | if (TYPE_NO_FORCE_BLK (node)) | |
96a31ab8 RK |
451 | fputs (" no-force-blk", file); |
452 | if (TYPE_STRING_FLAG (node)) | |
453 | fputs (" string-flag", file); | |
454 | if (TYPE_NEEDS_CONSTRUCTING (node)) | |
455 | fputs (" needs-constructing", file); | |
456 | if (TYPE_TRANSPARENT_UNION (node)) | |
457 | fputs (" transparent-union", file); | |
3fc341ac RK |
458 | if (TYPE_PACKED (node)) |
459 | fputs (" packed", file); | |
96a31ab8 | 460 | |
52eeef3a RS |
461 | if (TYPE_LANG_FLAG_0 (node)) |
462 | fputs (" type_0", file); | |
463 | if (TYPE_LANG_FLAG_1 (node)) | |
464 | fputs (" type_1", file); | |
465 | if (TYPE_LANG_FLAG_2 (node)) | |
466 | fputs (" type_2", file); | |
467 | if (TYPE_LANG_FLAG_3 (node)) | |
468 | fputs (" type_3", file); | |
469 | if (TYPE_LANG_FLAG_4 (node)) | |
470 | fputs (" type_4", file); | |
471 | if (TYPE_LANG_FLAG_5 (node)) | |
472 | fputs (" type_5", file); | |
473 | if (TYPE_LANG_FLAG_6 (node)) | |
474 | fputs (" type_6", file); | |
475 | ||
476 | mode = TYPE_MODE (node); | |
477 | fprintf (file, " %s", mode_name[(int) mode]); | |
478 | ||
479 | print_node (file, "size", TYPE_SIZE (node), indent + 4); | |
480 | indent_to (file, indent + 3); | |
481 | ||
482 | fprintf (file, " align %d", TYPE_ALIGN (node)); | |
483 | fprintf (file, " symtab %d", TYPE_SYMTAB_ADDRESS (node)); | |
484 | ||
0c7f6f66 RK |
485 | print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4); |
486 | ||
52eeef3a RS |
487 | if (TREE_CODE (node) == ARRAY_TYPE || TREE_CODE (node) == SET_TYPE) |
488 | print_node (file, "domain", TYPE_DOMAIN (node), indent + 4); | |
89b48889 RS |
489 | else if (TREE_CODE (node) == INTEGER_TYPE |
490 | || TREE_CODE (node) == BOOLEAN_TYPE | |
491 | || TREE_CODE (node) == CHAR_TYPE) | |
52eeef3a RS |
492 | { |
493 | fprintf (file, " precision %d", TYPE_PRECISION (node)); | |
494 | print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4); | |
495 | print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4); | |
496 | } | |
497 | else if (TREE_CODE (node) == ENUMERAL_TYPE) | |
498 | { | |
499 | fprintf (file, " precision %d", TYPE_PRECISION (node)); | |
500 | print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4); | |
501 | print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4); | |
502 | print_node (file, "values", TYPE_VALUES (node), indent + 4); | |
503 | } | |
504 | else if (TREE_CODE (node) == REAL_TYPE) | |
505 | fprintf (file, " precision %d", TYPE_PRECISION (node)); | |
c1b98a95 RK |
506 | else if (TREE_CODE (node) == RECORD_TYPE |
507 | || TREE_CODE (node) == UNION_TYPE | |
508 | || TREE_CODE (node) == QUAL_UNION_TYPE) | |
52eeef3a RS |
509 | print_node (file, "fields", TYPE_FIELDS (node), indent + 4); |
510 | else if (TREE_CODE (node) == FUNCTION_TYPE || TREE_CODE (node) == METHOD_TYPE) | |
511 | { | |
512 | if (TYPE_METHOD_BASETYPE (node)) | |
513 | print_node_brief (file, "method basetype", TYPE_METHOD_BASETYPE (node), indent + 4); | |
514 | print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4); | |
515 | } | |
516 | if (TYPE_CONTEXT (node)) | |
517 | print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4); | |
518 | ||
519 | print_lang_type (file, node, indent); | |
520 | ||
521 | if (TYPE_POINTER_TO (node) || TREE_CHAIN (node)) | |
522 | indent_to (file, indent + 3); | |
523 | print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node), indent + 4); | |
524 | print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node), indent + 4); | |
525 | print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4); | |
526 | break; | |
527 | ||
3b59a331 RS |
528 | case 'b': |
529 | print_node (file, "vars", BLOCK_VARS (node), indent + 4); | |
530 | print_node (file, "tags", BLOCK_TYPE_TAGS (node), indent + 4); | |
531 | print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node), indent + 4); | |
532 | print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4); | |
533 | print_node (file, "chain", BLOCK_CHAIN (node), indent + 4); | |
534 | print_node (file, "abstract_origin", | |
535 | BLOCK_ABSTRACT_ORIGIN (node), indent + 4); | |
536 | return; | |
537 | ||
52eeef3a RS |
538 | case 'e': |
539 | case '<': | |
540 | case '1': | |
541 | case '2': | |
542 | case 'r': | |
543 | case 's': | |
544 | switch (TREE_CODE (node)) | |
545 | { | |
52eeef3a RS |
546 | case BIND_EXPR: |
547 | print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4); | |
548 | print_node (file, "body", TREE_OPERAND (node, 1), indent + 4); | |
bf1c6940 | 549 | print_node (file, "block", TREE_OPERAND (node, 2), indent + 4); |
52eeef3a RS |
550 | return; |
551 | } | |
552 | ||
553 | first_rtl = len = tree_code_length[(int) TREE_CODE (node)]; | |
554 | /* These kinds of nodes contain rtx's, not trees, | |
555 | after a certain point. Print the rtx's as rtx's. */ | |
556 | switch (TREE_CODE (node)) | |
557 | { | |
558 | case SAVE_EXPR: | |
559 | first_rtl = 2; | |
560 | break; | |
561 | case CALL_EXPR: | |
562 | first_rtl = 2; | |
563 | break; | |
564 | case METHOD_CALL_EXPR: | |
565 | first_rtl = 3; | |
566 | break; | |
567 | case WITH_CLEANUP_EXPR: | |
568 | /* Should be defined to be 2. */ | |
569 | first_rtl = 1; | |
570 | break; | |
571 | case RTL_EXPR: | |
572 | first_rtl = 0; | |
573 | } | |
574 | for (i = 0; i < len; i++) | |
575 | { | |
576 | if (i >= first_rtl) | |
577 | { | |
578 | indent_to (file, indent + 4); | |
579 | fprintf (file, "rtl %d ", i); | |
580 | if (TREE_OPERAND (node, i)) | |
024b05a7 | 581 | print_rtl (file, (struct rtx_def *) TREE_OPERAND (node, i)); |
52eeef3a RS |
582 | else |
583 | fprintf (file, "(nil)"); | |
584 | fprintf (file, "\n"); | |
585 | } | |
586 | else | |
587 | { | |
588 | char temp[10]; | |
589 | ||
590 | sprintf (temp, "arg %d", i); | |
591 | print_node (file, temp, TREE_OPERAND (node, i), indent + 4); | |
592 | } | |
593 | } | |
594 | break; | |
595 | ||
596 | case 'c': | |
597 | case 'x': | |
598 | switch (TREE_CODE (node)) | |
599 | { | |
600 | case INTEGER_CST: | |
3e5f8018 RK |
601 | if (TREE_CONSTANT_OVERFLOW (node)) |
602 | fprintf (file, " overflow"); | |
603 | ||
1e66ce77 | 604 | fprintf (file, " "); |
52eeef3a | 605 | if (TREE_INT_CST_HIGH (node) == 0) |
1e66ce77 | 606 | fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, |
910d1693 | 607 | TREE_INT_CST_LOW (node)); |
52eeef3a RS |
608 | else if (TREE_INT_CST_HIGH (node) == -1 |
609 | && TREE_INT_CST_LOW (node) != 0) | |
1e66ce77 RK |
610 | { |
611 | fprintf (file, "-"); | |
612 | fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, | |
613 | -TREE_INT_CST_LOW (node)); | |
614 | } | |
52eeef3a | 615 | else |
1e66ce77 | 616 | fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX, |
906c4e36 | 617 | TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node)); |
52eeef3a RS |
618 | break; |
619 | ||
620 | case REAL_CST: | |
52eeef3a | 621 | { |
7063dcbe RK |
622 | REAL_VALUE_TYPE d; |
623 | ||
86b38416 RK |
624 | if (TREE_OVERFLOW (node)) |
625 | fprintf (file, " overflow"); | |
626 | ||
627 | #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC) | |
7063dcbe | 628 | d = TREE_REAL_CST (node); |
86b38416 RK |
629 | if (REAL_VALUE_ISINF (d)) |
630 | fprintf (file, " Inf"); | |
631 | else if (REAL_VALUE_ISNAN (d)) | |
632 | fprintf (file, " Nan"); | |
633 | else | |
634 | { | |
635 | char string[100]; | |
636 | ||
637 | REAL_VALUE_TO_DECIMAL (d, "%e", string); | |
638 | fprintf (file, " %s", string); | |
639 | } | |
640 | #else | |
641 | { | |
642 | int i; | |
643 | unsigned char *p = (unsigned char *) &TREE_REAL_CST (node); | |
644 | fprintf (file, " 0x"); | |
645 | for (i = 0; i < sizeof TREE_REAL_CST (node); i++) | |
646 | fprintf (file, "%02x", *p++); | |
647 | fprintf (file, ""); | |
648 | } | |
649 | #endif | |
52eeef3a | 650 | } |
52eeef3a RS |
651 | break; |
652 | ||
653 | case COMPLEX_CST: | |
654 | print_node (file, "real", TREE_REALPART (node), indent + 4); | |
655 | print_node (file, "imag", TREE_IMAGPART (node), indent + 4); | |
656 | break; | |
657 | ||
658 | case STRING_CST: | |
659 | fprintf (file, " \"%s\"", TREE_STRING_POINTER (node)); | |
28d10cea RS |
660 | /* Print the chain at second level. */ |
661 | if (indent == 4) | |
662 | print_node (file, "chain", TREE_CHAIN (node), indent + 4); | |
663 | else | |
664 | print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4); | |
52eeef3a RS |
665 | break; |
666 | ||
667 | case IDENTIFIER_NODE: | |
668 | print_lang_identifier (file, node, indent); | |
669 | break; | |
670 | ||
671 | case TREE_LIST: | |
672 | print_node (file, "purpose", TREE_PURPOSE (node), indent + 4); | |
673 | print_node (file, "value", TREE_VALUE (node), indent + 4); | |
674 | print_node (file, "chain", TREE_CHAIN (node), indent + 4); | |
675 | break; | |
676 | ||
677 | case TREE_VEC: | |
678 | len = TREE_VEC_LENGTH (node); | |
679 | for (i = 0; i < len; i++) | |
3629f741 JW |
680 | if (TREE_VEC_ELT (node, i)) |
681 | { | |
682 | char temp[10]; | |
683 | sprintf (temp, "elt %d", i); | |
684 | indent_to (file, indent + 4); | |
685 | print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0); | |
686 | } | |
52eeef3a RS |
687 | break; |
688 | ||
689 | case OP_IDENTIFIER: | |
690 | print_node (file, "op1", TREE_PURPOSE (node), indent + 4); | |
691 | print_node (file, "op2", TREE_VALUE (node), indent + 4); | |
692 | } | |
693 | ||
694 | break; | |
695 | } | |
f6adcfdc RS |
696 | |
697 | fprintf (file, ">"); | |
52eeef3a | 698 | } |