]>
Commit | Line | Data |
---|---|---|
3ff560b7 | 1 | /* Prints out tree in human readable form - GNU C-compiler |
506f531e | 2 | Copyright (C) 1990, 1991, 1993, 1994 Free Software Foundation, Inc. |
3ff560b7 | 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); | |
748e6d74 | 54 | |
3ff560b7 | 55 | table = (struct bucket **) oballoc (HASH_SIZE * sizeof (struct bucket *)); |
748e6d74 | 56 | bzero ((char *) table, HASH_SIZE * sizeof (struct bucket *)); |
3ff560b7 | 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, " "); | |
b572011e | 83 | fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]); |
4e39123a | 84 | fprintf (file, HOST_PTR_PRINTF, (HOST_WIDE_INT) node); |
3ff560b7 | 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 | { | |
5575b8e4 | 108 | if (TREE_CONSTANT_OVERFLOW (node)) |
109 | fprintf (file, " overflow"); | |
110 | ||
3ff560b7 | 111 | if (TREE_INT_CST_HIGH (node) == 0) |
112 | fprintf (file, " %1u", TREE_INT_CST_LOW (node)); | |
113 | else if (TREE_INT_CST_HIGH (node) == -1 | |
114 | && TREE_INT_CST_LOW (node) != 0) | |
115 | fprintf (file, " -%1u", -TREE_INT_CST_LOW (node)); | |
116 | else | |
b572011e | 117 | fprintf (file, |
118 | #if HOST_BITS_PER_WIDE_INT == 64 | |
119 | #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT | |
120 | " 0x%lx%016lx", | |
121 | #else | |
122 | " 0x%x%016x", | |
123 | #endif | |
124 | #else | |
125 | #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT | |
126 | " 0x%lx%08lx", | |
127 | #else | |
128 | " 0x%x%08x", | |
129 | #endif | |
130 | #endif | |
131 | TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node)); | |
3ff560b7 | 132 | } |
133 | if (TREE_CODE (node) == REAL_CST) | |
134 | { | |
135 | #ifndef REAL_IS_NOT_DOUBLE | |
136 | fprintf (file, " %e", TREE_REAL_CST (node)); | |
137 | #else | |
138 | { | |
139 | int i; | |
dbe0a914 | 140 | unsigned char *p = (unsigned char *) &TREE_REAL_CST (node); |
3ff560b7 | 141 | fprintf (file, " 0x"); |
142 | for (i = 0; i < sizeof TREE_REAL_CST (node); i++) | |
143 | fprintf (file, "%02x", *p++); | |
144 | fprintf (file, ""); | |
145 | } | |
146 | #endif /* REAL_IS_NOT_DOUBLE */ | |
147 | } | |
148 | ||
149 | fprintf (file, ">"); | |
150 | } | |
151 | ||
152 | void | |
153 | indent_to (file, column) | |
154 | FILE *file; | |
155 | int column; | |
156 | { | |
157 | int i; | |
158 | ||
159 | /* Since this is the long way, indent to desired column. */ | |
160 | if (column > 0) | |
161 | fprintf (file, "\n"); | |
162 | for (i = 0; i < column; i++) | |
163 | fprintf (file, " "); | |
164 | } | |
165 | \f | |
166 | /* Print the node NODE in full on file FILE, preceded by PREFIX, | |
167 | starting in column INDENT. */ | |
168 | ||
169 | void | |
170 | print_node (file, prefix, node, indent) | |
171 | FILE *file; | |
172 | char *prefix; | |
173 | tree node; | |
174 | int indent; | |
175 | { | |
176 | int hash; | |
177 | struct bucket *b; | |
178 | enum machine_mode mode; | |
179 | char class; | |
180 | int len; | |
181 | int first_rtl; | |
182 | int i; | |
183 | ||
184 | if (node == 0) | |
185 | return; | |
186 | ||
187 | class = TREE_CODE_CLASS (TREE_CODE (node)); | |
188 | ||
189 | /* Don't get too deep in nesting. If the user wants to see deeper, | |
190 | it is easy to use the address of a lowest-level node | |
191 | as an argument in another call to debug_tree. */ | |
192 | ||
193 | if (indent > 24) | |
194 | { | |
195 | print_node_brief (file, prefix, node, indent); | |
196 | return; | |
197 | } | |
198 | ||
199 | if (indent > 8 && (class == 't' || class == 'd')) | |
200 | { | |
201 | print_node_brief (file, prefix, node, indent); | |
202 | return; | |
203 | } | |
204 | ||
205 | /* It is unsafe to look at any other filds of an ERROR_MARK node. */ | |
206 | if (TREE_CODE (node) == ERROR_MARK) | |
207 | { | |
208 | print_node_brief (file, prefix, node, indent); | |
209 | return; | |
210 | } | |
211 | ||
721bfcc7 | 212 | hash = ((unsigned HOST_WIDE_INT) node) % HASH_SIZE; |
3ff560b7 | 213 | |
214 | /* If node is in the table, just mention its address. */ | |
215 | for (b = table[hash]; b; b = b->next) | |
216 | if (b->node == node) | |
217 | { | |
218 | print_node_brief (file, prefix, node, indent); | |
219 | return; | |
220 | } | |
221 | ||
222 | /* Add this node to the table. */ | |
223 | b = (struct bucket *) oballoc (sizeof (struct bucket)); | |
224 | b->node = node; | |
225 | b->next = table[hash]; | |
226 | table[hash] = b; | |
227 | ||
228 | /* Indent to the specified column, since this is the long form. */ | |
229 | indent_to (file, indent); | |
230 | ||
231 | /* Print the slot this node is in, and its code, and address. */ | |
b572011e | 232 | fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]); |
4e39123a | 233 | fprintf (file, HOST_PTR_PRINTF, (HOST_WIDE_INT) node); |
3ff560b7 | 234 | |
235 | /* Print the name, if any. */ | |
236 | if (class == 'd') | |
237 | { | |
238 | if (DECL_NAME (node)) | |
239 | fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node))); | |
240 | } | |
241 | else if (class == 't') | |
242 | { | |
243 | if (TYPE_NAME (node)) | |
244 | { | |
245 | if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) | |
246 | fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node))); | |
247 | else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL | |
248 | && DECL_NAME (TYPE_NAME (node))) | |
249 | fprintf (file, " %s", | |
250 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)))); | |
251 | } | |
252 | } | |
253 | if (TREE_CODE (node) == IDENTIFIER_NODE) | |
254 | fprintf (file, " %s", IDENTIFIER_POINTER (node)); | |
255 | ||
256 | if (TREE_CODE (node) == INTEGER_CST) | |
257 | { | |
258 | if (indent <= 4) | |
259 | print_node_brief (file, "type", TREE_TYPE (node), indent + 4); | |
260 | } | |
261 | else | |
262 | { | |
263 | print_node (file, "type", TREE_TYPE (node), indent + 4); | |
264 | if (TREE_TYPE (node)) | |
265 | indent_to (file, indent + 3); | |
397933ca | 266 | |
267 | print_obstack_name ((char *) node, file, ""); | |
268 | indent_to (file, indent + 3); | |
3ff560b7 | 269 | } |
270 | ||
271 | /* If a permanent object is in the wrong obstack, or the reverse, warn. */ | |
272 | if (object_permanent_p (node) != TREE_PERMANENT (node)) | |
273 | { | |
274 | if (TREE_PERMANENT (node)) | |
275 | fputs (" !!permanent object in non-permanent obstack!!", file); | |
276 | else | |
277 | fputs (" !!non-permanent object in permanent obstack!!", file); | |
278 | indent_to (file, indent + 3); | |
279 | } | |
280 | ||
281 | if (TREE_SIDE_EFFECTS (node)) | |
282 | fputs (" side-effects", file); | |
283 | if (TREE_READONLY (node)) | |
284 | fputs (" readonly", file); | |
285 | if (TREE_CONSTANT (node)) | |
286 | fputs (" constant", file); | |
287 | if (TREE_ADDRESSABLE (node)) | |
288 | fputs (" addressable", file); | |
289 | if (TREE_THIS_VOLATILE (node)) | |
290 | fputs (" volatile", file); | |
291 | if (TREE_UNSIGNED (node)) | |
292 | fputs (" unsigned", file); | |
293 | if (TREE_ASM_WRITTEN (node)) | |
294 | fputs (" asm_written", file); | |
295 | if (TREE_USED (node)) | |
296 | fputs (" used", file); | |
9ed1ded5 | 297 | if (TREE_RAISES (node)) |
298 | fputs (" raises", file); | |
3ff560b7 | 299 | if (TREE_PERMANENT (node)) |
300 | fputs (" permanent", file); | |
301 | if (TREE_PUBLIC (node)) | |
302 | fputs (" public", file); | |
303 | if (TREE_STATIC (node)) | |
304 | fputs (" static", file); | |
305 | if (TREE_LANG_FLAG_0 (node)) | |
306 | fputs (" tree_0", file); | |
307 | if (TREE_LANG_FLAG_1 (node)) | |
308 | fputs (" tree_1", file); | |
309 | if (TREE_LANG_FLAG_2 (node)) | |
310 | fputs (" tree_2", file); | |
311 | if (TREE_LANG_FLAG_3 (node)) | |
312 | fputs (" tree_3", file); | |
313 | if (TREE_LANG_FLAG_4 (node)) | |
314 | fputs (" tree_4", file); | |
315 | if (TREE_LANG_FLAG_5 (node)) | |
316 | fputs (" tree_5", file); | |
317 | if (TREE_LANG_FLAG_6 (node)) | |
318 | fputs (" tree_6", file); | |
319 | ||
320 | /* DECL_ nodes have additional attributes. */ | |
321 | ||
322 | switch (TREE_CODE_CLASS (TREE_CODE (node))) | |
323 | { | |
324 | case 'd': | |
325 | mode = DECL_MODE (node); | |
326 | ||
2cf6e2c5 | 327 | if (DECL_EXTERNAL (node)) |
3ff560b7 | 328 | fputs (" external", file); |
2cf6e2c5 | 329 | if (DECL_NONLOCAL (node)) |
3ff560b7 | 330 | fputs (" nonlocal", file); |
2cf6e2c5 | 331 | if (DECL_REGISTER (node)) |
3ff560b7 | 332 | fputs (" regdecl", file); |
2cf6e2c5 | 333 | if (DECL_INLINE (node)) |
3ff560b7 | 334 | fputs (" inline", file); |
335 | if (DECL_BIT_FIELD (node)) | |
336 | fputs (" bit-field", file); | |
337 | if (DECL_VIRTUAL_P (node)) | |
338 | fputs (" virtual", file); | |
3ff560b7 | 339 | if (DECL_IGNORED_P (node)) |
340 | fputs (" ignored", file); | |
9ed1ded5 | 341 | if (DECL_IN_SYSTEM_HEADER (node)) |
342 | fputs (" in_system_header", file); | |
3ff560b7 | 343 | if (DECL_LANG_FLAG_0 (node)) |
344 | fputs (" decl_0", file); | |
345 | if (DECL_LANG_FLAG_1 (node)) | |
346 | fputs (" decl_1", file); | |
347 | if (DECL_LANG_FLAG_2 (node)) | |
348 | fputs (" decl_2", file); | |
349 | if (DECL_LANG_FLAG_3 (node)) | |
350 | fputs (" decl_3", file); | |
351 | if (DECL_LANG_FLAG_4 (node)) | |
352 | fputs (" decl_4", file); | |
353 | if (DECL_LANG_FLAG_5 (node)) | |
354 | fputs (" decl_5", file); | |
355 | if (DECL_LANG_FLAG_6 (node)) | |
356 | fputs (" decl_6", file); | |
357 | if (DECL_LANG_FLAG_7 (node)) | |
358 | fputs (" decl_7", file); | |
359 | ||
360 | fprintf (file, " %s", mode_name[(int) mode]); | |
361 | ||
362 | fprintf (file, " file %s line %d", | |
363 | DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node)); | |
364 | ||
365 | print_node (file, "size", DECL_SIZE (node), indent + 4); | |
366 | indent_to (file, indent + 3); | |
e5d7f72a | 367 | if (TREE_CODE (node) != FUNCTION_DECL) |
368 | fprintf (file, " align %d", DECL_ALIGN (node)); | |
2cf6e2c5 | 369 | else if (DECL_INLINE (node)) |
e5d7f72a | 370 | fprintf (file, " frame_size %d", DECL_FRAME_SIZE (node)); |
371 | else if (DECL_BUILT_IN (node)) | |
372 | fprintf (file, " built-in code %d", DECL_FUNCTION_CODE (node)); | |
3ff560b7 | 373 | if (TREE_CODE (node) == FIELD_DECL) |
374 | print_node (file, "bitpos", DECL_FIELD_BITPOS (node), indent + 4); | |
375 | print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4); | |
f7a75810 | 376 | print_node_brief (file, "abstract_origin", |
377 | DECL_ABSTRACT_ORIGIN (node), indent + 4); | |
3ff560b7 | 378 | |
379 | print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4); | |
380 | print_node (file, "result", DECL_RESULT (node), indent + 4); | |
381 | print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4); | |
382 | ||
383 | print_lang_decl (file, node, indent); | |
384 | ||
385 | if (DECL_RTL (node) != 0) | |
386 | { | |
387 | indent_to (file, indent + 4); | |
388 | print_rtl (file, DECL_RTL (node)); | |
389 | } | |
390 | ||
391 | if (DECL_SAVED_INSNS (node) != 0) | |
392 | { | |
393 | indent_to (file, indent + 4); | |
394 | if (TREE_CODE (node) == PARM_DECL) | |
395 | { | |
396 | fprintf (file, "incoming-rtl "); | |
397 | print_rtl (file, DECL_INCOMING_RTL (node)); | |
398 | } | |
399 | else if (TREE_CODE (node) == FUNCTION_DECL) | |
b572011e | 400 | { |
401 | fprintf (file, "saved-insns "); | |
4e39123a | 402 | fprintf (file, HOST_PTR_PRINTF, |
403 | (HOST_WIDE_INT) DECL_SAVED_INSNS (node)); | |
b572011e | 404 | } |
3ff560b7 | 405 | } |
406 | ||
407 | /* Print the decl chain only if decl is at second level. */ | |
408 | if (indent == 4) | |
409 | print_node (file, "chain", TREE_CHAIN (node), indent + 4); | |
410 | else | |
411 | print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4); | |
412 | break; | |
413 | ||
414 | case 't': | |
415 | if (TYPE_NO_FORCE_BLK (node)) | |
416 | fputs (" no_force_blk", file); | |
417 | if (TYPE_LANG_FLAG_0 (node)) | |
418 | fputs (" type_0", file); | |
419 | if (TYPE_LANG_FLAG_1 (node)) | |
420 | fputs (" type_1", file); | |
421 | if (TYPE_LANG_FLAG_2 (node)) | |
422 | fputs (" type_2", file); | |
423 | if (TYPE_LANG_FLAG_3 (node)) | |
424 | fputs (" type_3", file); | |
425 | if (TYPE_LANG_FLAG_4 (node)) | |
426 | fputs (" type_4", file); | |
427 | if (TYPE_LANG_FLAG_5 (node)) | |
428 | fputs (" type_5", file); | |
429 | if (TYPE_LANG_FLAG_6 (node)) | |
430 | fputs (" type_6", file); | |
431 | ||
432 | mode = TYPE_MODE (node); | |
433 | fprintf (file, " %s", mode_name[(int) mode]); | |
434 | ||
435 | print_node (file, "size", TYPE_SIZE (node), indent + 4); | |
436 | indent_to (file, indent + 3); | |
437 | ||
438 | fprintf (file, " align %d", TYPE_ALIGN (node)); | |
439 | fprintf (file, " symtab %d", TYPE_SYMTAB_ADDRESS (node)); | |
440 | ||
506f531e | 441 | print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4); |
442 | ||
3ff560b7 | 443 | if (TREE_CODE (node) == ARRAY_TYPE || TREE_CODE (node) == SET_TYPE) |
444 | print_node (file, "domain", TYPE_DOMAIN (node), indent + 4); | |
cf74ffc6 | 445 | else if (TREE_CODE (node) == INTEGER_TYPE |
446 | || TREE_CODE (node) == BOOLEAN_TYPE | |
447 | || TREE_CODE (node) == CHAR_TYPE) | |
3ff560b7 | 448 | { |
449 | fprintf (file, " precision %d", TYPE_PRECISION (node)); | |
450 | print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4); | |
451 | print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4); | |
452 | } | |
453 | else if (TREE_CODE (node) == ENUMERAL_TYPE) | |
454 | { | |
455 | fprintf (file, " precision %d", TYPE_PRECISION (node)); | |
456 | print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4); | |
457 | print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4); | |
458 | print_node (file, "values", TYPE_VALUES (node), indent + 4); | |
459 | } | |
460 | else if (TREE_CODE (node) == REAL_TYPE) | |
461 | fprintf (file, " precision %d", TYPE_PRECISION (node)); | |
7f8a347a | 462 | else if (TREE_CODE (node) == RECORD_TYPE |
463 | || TREE_CODE (node) == UNION_TYPE | |
464 | || TREE_CODE (node) == QUAL_UNION_TYPE) | |
3ff560b7 | 465 | print_node (file, "fields", TYPE_FIELDS (node), indent + 4); |
466 | else if (TREE_CODE (node) == FUNCTION_TYPE || TREE_CODE (node) == METHOD_TYPE) | |
467 | { | |
468 | if (TYPE_METHOD_BASETYPE (node)) | |
469 | print_node_brief (file, "method basetype", TYPE_METHOD_BASETYPE (node), indent + 4); | |
470 | print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4); | |
471 | } | |
472 | if (TYPE_CONTEXT (node)) | |
473 | print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4); | |
474 | ||
475 | print_lang_type (file, node, indent); | |
476 | ||
477 | if (TYPE_POINTER_TO (node) || TREE_CHAIN (node)) | |
478 | indent_to (file, indent + 3); | |
479 | print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node), indent + 4); | |
480 | print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node), indent + 4); | |
481 | print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4); | |
482 | break; | |
483 | ||
21b4c21c | 484 | case 'b': |
485 | print_node (file, "vars", BLOCK_VARS (node), indent + 4); | |
486 | print_node (file, "tags", BLOCK_TYPE_TAGS (node), indent + 4); | |
487 | print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node), indent + 4); | |
488 | print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4); | |
489 | print_node (file, "chain", BLOCK_CHAIN (node), indent + 4); | |
490 | print_node (file, "abstract_origin", | |
491 | BLOCK_ABSTRACT_ORIGIN (node), indent + 4); | |
492 | return; | |
493 | ||
3ff560b7 | 494 | case 'e': |
495 | case '<': | |
496 | case '1': | |
497 | case '2': | |
498 | case 'r': | |
499 | case 's': | |
500 | switch (TREE_CODE (node)) | |
501 | { | |
3ff560b7 | 502 | case BIND_EXPR: |
503 | print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4); | |
504 | print_node (file, "body", TREE_OPERAND (node, 1), indent + 4); | |
0f0b4dbc | 505 | print_node (file, "block", TREE_OPERAND (node, 2), indent + 4); |
3ff560b7 | 506 | return; |
507 | } | |
508 | ||
509 | first_rtl = len = tree_code_length[(int) TREE_CODE (node)]; | |
510 | /* These kinds of nodes contain rtx's, not trees, | |
511 | after a certain point. Print the rtx's as rtx's. */ | |
512 | switch (TREE_CODE (node)) | |
513 | { | |
514 | case SAVE_EXPR: | |
515 | first_rtl = 2; | |
516 | break; | |
517 | case CALL_EXPR: | |
518 | first_rtl = 2; | |
519 | break; | |
520 | case METHOD_CALL_EXPR: | |
521 | first_rtl = 3; | |
522 | break; | |
523 | case WITH_CLEANUP_EXPR: | |
524 | /* Should be defined to be 2. */ | |
525 | first_rtl = 1; | |
526 | break; | |
527 | case RTL_EXPR: | |
528 | first_rtl = 0; | |
529 | } | |
530 | for (i = 0; i < len; i++) | |
531 | { | |
532 | if (i >= first_rtl) | |
533 | { | |
534 | indent_to (file, indent + 4); | |
535 | fprintf (file, "rtl %d ", i); | |
536 | if (TREE_OPERAND (node, i)) | |
caa663b8 | 537 | print_rtl (file, (struct rtx_def *) TREE_OPERAND (node, i)); |
3ff560b7 | 538 | else |
539 | fprintf (file, "(nil)"); | |
540 | fprintf (file, "\n"); | |
541 | } | |
542 | else | |
543 | { | |
544 | char temp[10]; | |
545 | ||
546 | sprintf (temp, "arg %d", i); | |
547 | print_node (file, temp, TREE_OPERAND (node, i), indent + 4); | |
548 | } | |
549 | } | |
550 | break; | |
551 | ||
552 | case 'c': | |
553 | case 'x': | |
554 | switch (TREE_CODE (node)) | |
555 | { | |
556 | case INTEGER_CST: | |
5575b8e4 | 557 | if (TREE_CONSTANT_OVERFLOW (node)) |
558 | fprintf (file, " overflow"); | |
559 | ||
3ff560b7 | 560 | if (TREE_INT_CST_HIGH (node) == 0) |
561 | fprintf (file, " %1u", TREE_INT_CST_LOW (node)); | |
562 | else if (TREE_INT_CST_HIGH (node) == -1 | |
563 | && TREE_INT_CST_LOW (node) != 0) | |
564 | fprintf (file, " -%1u", -TREE_INT_CST_LOW (node)); | |
565 | else | |
b572011e | 566 | fprintf (file, |
567 | #if HOST_BITS_PER_WIDE_INT == 64 | |
568 | #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT | |
569 | " 0x%lx%016lx", | |
570 | #else | |
571 | " 0x%x%016x", | |
572 | #endif | |
573 | #else | |
574 | #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT | |
575 | " 0x%lx%08lx", | |
576 | #else | |
577 | " 0x%x%08x", | |
578 | #endif | |
579 | #endif | |
580 | TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node)); | |
3ff560b7 | 581 | break; |
582 | ||
583 | case REAL_CST: | |
584 | #ifndef REAL_IS_NOT_DOUBLE | |
585 | fprintf (file, " %e", TREE_REAL_CST (node)); | |
586 | #else | |
587 | { | |
588 | char *p = (char *) &TREE_REAL_CST (node); | |
589 | fprintf (file, " 0x"); | |
590 | for (i = 0; i < sizeof TREE_REAL_CST (node); i++) | |
591 | fprintf (file, "%02x", *p++); | |
592 | fprintf (file, ""); | |
593 | } | |
594 | #endif /* REAL_IS_NOT_DOUBLE */ | |
595 | break; | |
596 | ||
597 | case COMPLEX_CST: | |
598 | print_node (file, "real", TREE_REALPART (node), indent + 4); | |
599 | print_node (file, "imag", TREE_IMAGPART (node), indent + 4); | |
600 | break; | |
601 | ||
602 | case STRING_CST: | |
603 | fprintf (file, " \"%s\"", TREE_STRING_POINTER (node)); | |
0dc2bbb8 | 604 | /* Print the chain at second level. */ |
605 | if (indent == 4) | |
606 | print_node (file, "chain", TREE_CHAIN (node), indent + 4); | |
607 | else | |
608 | print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4); | |
3ff560b7 | 609 | break; |
610 | ||
611 | case IDENTIFIER_NODE: | |
612 | print_lang_identifier (file, node, indent); | |
613 | break; | |
614 | ||
615 | case TREE_LIST: | |
616 | print_node (file, "purpose", TREE_PURPOSE (node), indent + 4); | |
617 | print_node (file, "value", TREE_VALUE (node), indent + 4); | |
618 | print_node (file, "chain", TREE_CHAIN (node), indent + 4); | |
619 | break; | |
620 | ||
621 | case TREE_VEC: | |
622 | len = TREE_VEC_LENGTH (node); | |
623 | for (i = 0; i < len; i++) | |
0b68d9e6 | 624 | if (TREE_VEC_ELT (node, i)) |
625 | { | |
626 | char temp[10]; | |
627 | sprintf (temp, "elt %d", i); | |
628 | indent_to (file, indent + 4); | |
629 | print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0); | |
630 | } | |
3ff560b7 | 631 | break; |
632 | ||
633 | case OP_IDENTIFIER: | |
634 | print_node (file, "op1", TREE_PURPOSE (node), indent + 4); | |
635 | print_node (file, "op2", TREE_VALUE (node), indent + 4); | |
636 | } | |
637 | ||
638 | break; | |
639 | } | |
9e718c95 | 640 | |
641 | fprintf (file, ">"); | |
3ff560b7 | 642 | } |