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