]>
Commit | Line | Data |
---|---|---|
e1a79915 | 1 | /* Print RTL for GNU C Compiler. |
9311a396 | 2 | Copyright (C) 1987, 1988, 1992, 1997, 1998, 1999, 2000 |
c5c76735 | 3 | Free Software Foundation, Inc. |
e1a79915 | 4 | |
1322177d | 5 | This file is part of GCC. |
e1a79915 | 6 | |
1322177d LB |
7 | GCC is free software; you can redistribute it and/or modify it under |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 2, or (at your option) any later | |
10 | version. | |
e1a79915 | 11 | |
1322177d LB |
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
e1a79915 RS |
16 | |
17 | You should have received a copy of the GNU General Public License | |
1322177d LB |
18 | along with GCC; see the file COPYING. If not, write to the Free |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
e1a79915 RS |
21 | |
22 | ||
23 | #include "config.h" | |
670ee920 | 24 | #include "system.h" |
4977bab6 ZW |
25 | #include "coretypes.h" |
26 | #include "tm.h" | |
e1a79915 | 27 | #include "rtl.h" |
738cc472 RK |
28 | |
29 | /* We don't want the tree code checking code for the access to the | |
30 | DECL_NAME to be included in the gen* programs. */ | |
31 | #undef ENABLE_TREE_CHECKING | |
32 | #include "tree.h" | |
800d5c9e | 33 | #include "real.h" |
b707b450 | 34 | #include "flags.h" |
efc9bd41 | 35 | #include "hard-reg-set.h" |
e881bb1b | 36 | #include "basic-block.h" |
e1a79915 | 37 | |
cf99a734 RS |
38 | /* How to print out a register name. |
39 | We don't use PRINT_REG because some definitions of PRINT_REG | |
40 | don't work here. */ | |
41 | #ifndef DEBUG_PRINT_REG | |
42 | #define DEBUG_PRINT_REG(RTX, CODE, FILE) \ | |
43 | fprintf ((FILE), "%d %s", REGNO (RTX), reg_names[REGNO (RTX)]) | |
44 | #endif | |
45 | ||
46 | /* Array containing all of the register names */ | |
47 | ||
48 | #ifdef DEBUG_REGISTER_NAMES | |
fbd40359 ZW |
49 | static const char * const debug_reg_names[] = DEBUG_REGISTER_NAMES; |
50 | #define reg_names debug_reg_names | |
cf99a734 | 51 | #else |
e087aeb2 | 52 | const char * reg_names[] = REGISTER_NAMES; |
cf99a734 RS |
53 | #endif |
54 | ||
e1a79915 RS |
55 | static FILE *outfile; |
56 | ||
e1a79915 RS |
57 | static int sawclose = 0; |
58 | ||
1d79197a RK |
59 | static int indent; |
60 | ||
957e4763 | 61 | static void print_rtx PARAMS ((rtx)); |
5edc9230 | 62 | |
c349e40b SC |
63 | /* String printed at beginning of each RTL when it is dumped. |
64 | This string is set to ASM_COMMENT_START when the RTL is dumped in | |
65 | the assembly output file. */ | |
47c10e9b | 66 | const char *print_rtx_head = ""; |
c349e40b | 67 | |
b707b450 R |
68 | /* Nonzero means suppress output of instruction numbers and line number |
69 | notes in debugging dumps. | |
70 | This must be defined here so that programs like gencodes can be linked. */ | |
9ec36da5 | 71 | int flag_dump_unnumbered = 0; |
b707b450 | 72 | |
75b7557d MH |
73 | /* Nonzero means use simplified format without flags, modes, etc. */ |
74 | int flag_simple = 0; | |
75 | ||
735a0e33 UD |
76 | /* Nonzero if we are dumping graphical description. */ |
77 | int dump_for_graph; | |
78 | ||
b5d7770c AO |
79 | /* Nonzero to dump all call_placeholder alternatives. */ |
80 | static int debug_call_placeholder_verbose; | |
81 | ||
998d7deb RH |
82 | void |
83 | print_mem_expr (outfile, expr) | |
84 | FILE *outfile; | |
85 | tree expr; | |
86 | { | |
87 | if (TREE_CODE (expr) == COMPONENT_REF) | |
88 | { | |
89 | if (TREE_OPERAND (expr, 0)) | |
6a4d6760 | 90 | print_mem_expr (outfile, TREE_OPERAND (expr, 0)); |
998d7deb RH |
91 | else |
92 | fputs (" <variable>", outfile); | |
50f30e6b JJ |
93 | if (DECL_NAME (TREE_OPERAND (expr, 1))) |
94 | fprintf (outfile, ".%s", | |
95 | IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (expr, 1)))); | |
998d7deb | 96 | } |
c67a1cf6 RH |
97 | else if (TREE_CODE (expr) == INDIRECT_REF) |
98 | { | |
99 | fputs (" (*", outfile); | |
100 | print_mem_expr (outfile, TREE_OPERAND (expr, 0)); | |
101 | fputs (")", outfile); | |
102 | } | |
998d7deb RH |
103 | else if (DECL_NAME (expr)) |
104 | fprintf (outfile, " %s", IDENTIFIER_POINTER (DECL_NAME (expr))); | |
105 | else if (TREE_CODE (expr) == RESULT_DECL) | |
106 | fputs (" <result>", outfile); | |
107 | else | |
108 | fputs (" <anonymous>", outfile); | |
109 | } | |
110 | ||
e1a79915 RS |
111 | /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */ |
112 | ||
113 | static void | |
114 | print_rtx (in_rtx) | |
b3694847 | 115 | rtx in_rtx; |
e1a79915 | 116 | { |
b3694847 SS |
117 | int i = 0; |
118 | int j; | |
119 | const char *format_ptr; | |
120 | int is_insn; | |
c3c63936 | 121 | rtx tem; |
e1a79915 RS |
122 | |
123 | if (sawclose) | |
124 | { | |
75b7557d MH |
125 | if (flag_simple) |
126 | fputc (' ', outfile); | |
127 | else | |
5e74f966 | 128 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, ""); |
e1a79915 RS |
129 | sawclose = 0; |
130 | } | |
131 | ||
132 | if (in_rtx == 0) | |
133 | { | |
735a0e33 | 134 | fputs ("(nil)", outfile); |
e1a79915 RS |
135 | sawclose = 1; |
136 | return; | |
137 | } | |
5e74f966 RK |
138 | else if (GET_CODE (in_rtx) > NUM_RTX_CODE) |
139 | { | |
140 | fprintf (outfile, "(??? bad code %d\n)", GET_CODE (in_rtx)); | |
141 | sawclose = 1; | |
142 | return; | |
143 | } | |
e1a79915 | 144 | |
5e74f966 | 145 | is_insn = INSN_P (in_rtx); |
735a0e33 UD |
146 | |
147 | /* When printing in VCG format we write INSNs, NOTE, LABEL, and BARRIER | |
148 | in separate nodes and therefore have to handle them special here. */ | |
5e74f966 RK |
149 | if (dump_for_graph |
150 | && (is_insn || GET_CODE (in_rtx) == NOTE | |
151 | || GET_CODE (in_rtx) == CODE_LABEL || GET_CODE (in_rtx) == BARRIER)) | |
735a0e33 UD |
152 | { |
153 | i = 3; | |
154 | indent = 0; | |
155 | } | |
156 | else | |
157 | { | |
5e74f966 | 158 | /* Print name of expression code. */ |
75b7557d MH |
159 | if (flag_simple && GET_CODE (in_rtx) == CONST_INT) |
160 | fputc ('(', outfile); | |
161 | else | |
162 | fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx))); | |
6a4d6760 | 163 | |
75b7557d | 164 | if (! flag_simple) |
735a0e33 | 165 | { |
2adc7f12 | 166 | if (RTX_FLAG (in_rtx, in_struct)) |
75b7557d MH |
167 | fputs ("/s", outfile); |
168 | ||
2adc7f12 | 169 | if (RTX_FLAG (in_rtx, volatil)) |
75b7557d | 170 | fputs ("/v", outfile); |
6a4d6760 | 171 | |
2adc7f12 | 172 | if (RTX_FLAG (in_rtx, unchanging)) |
75b7557d | 173 | fputs ("/u", outfile); |
6a4d6760 | 174 | |
2adc7f12 | 175 | if (RTX_FLAG (in_rtx, integrated)) |
75b7557d | 176 | fputs ("/i", outfile); |
6a4d6760 | 177 | |
2adc7f12 | 178 | if (RTX_FLAG (in_rtx, frame_related)) |
75b7557d | 179 | fputs ("/f", outfile); |
6a4d6760 | 180 | |
2adc7f12 | 181 | if (RTX_FLAG (in_rtx, jump)) |
75b7557d | 182 | fputs ("/j", outfile); |
6a4d6760 | 183 | |
2adc7f12 | 184 | if (RTX_FLAG (in_rtx, call)) |
75b7557d MH |
185 | fputs ("/c", outfile); |
186 | ||
187 | if (GET_MODE (in_rtx) != VOIDmode) | |
188 | { | |
189 | /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */ | |
6a4d6760 | 190 | if (GET_CODE (in_rtx) == EXPR_LIST |
75b7557d MH |
191 | || GET_CODE (in_rtx) == INSN_LIST) |
192 | fprintf (outfile, ":%s", | |
193 | GET_REG_NOTE_NAME (GET_MODE (in_rtx))); | |
194 | else | |
195 | fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx))); | |
196 | } | |
735a0e33 | 197 | } |
e1a79915 RS |
198 | } |
199 | ||
69bd00e6 RH |
200 | #ifndef GENERATOR_FILE |
201 | if (GET_CODE (in_rtx) == CONST_DOUBLE && FLOAT_MODE_P (GET_MODE (in_rtx))) | |
202 | i = 5; | |
203 | #endif | |
204 | ||
735a0e33 UD |
205 | /* Get the format string and skip the first elements if we have handled |
206 | them already. */ | |
207 | format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i; | |
735a0e33 | 208 | for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++) |
e1a79915 RS |
209 | switch (*format_ptr++) |
210 | { | |
3b324340 ZW |
211 | const char *str; |
212 | ||
213 | case 'T': | |
214 | str = XTMPL (in_rtx, i); | |
215 | goto string; | |
216 | ||
e1a79915 RS |
217 | case 'S': |
218 | case 's': | |
3b324340 ZW |
219 | str = XSTR (in_rtx, i); |
220 | string: | |
221 | ||
222 | if (str == 0) | |
735a0e33 | 223 | fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile); |
e1a79915 | 224 | else |
913d0833 KG |
225 | { |
226 | if (dump_for_graph) | |
3b324340 | 227 | fprintf (outfile, " (\\\"%s\\\")", str); |
913d0833 | 228 | else |
3b324340 | 229 | fprintf (outfile, " (\"%s\")", str); |
913d0833 | 230 | } |
e1a79915 RS |
231 | sawclose = 1; |
232 | break; | |
233 | ||
8f985ec4 ZW |
234 | /* 0 indicates a field for internal use that should not be printed. |
235 | An exception is the third field of a NOTE, where it indicates | |
236 | that the field has several different valid contents. */ | |
e1a79915 | 237 | case '0': |
08394eef BS |
238 | if (i == 1 && GET_CODE (in_rtx) == REG) |
239 | { | |
240 | if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx)) | |
241 | fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx)); | |
242 | break; | |
243 | } | |
32c36ac8 | 244 | if (i == 4 && GET_CODE (in_rtx) == NOTE) |
8f985ec4 | 245 | { |
994a57cd | 246 | switch (NOTE_LINE_NUMBER (in_rtx)) |
bf43101e | 247 | { |
994a57cd RH |
248 | case NOTE_INSN_EH_REGION_BEG: |
249 | case NOTE_INSN_EH_REGION_END: | |
f76ca83c GK |
250 | if (flag_dump_unnumbered) |
251 | fprintf (outfile, " #"); | |
252 | else | |
253 | fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx)); | |
bf43101e | 254 | sawclose = 1; |
994a57cd RH |
255 | break; |
256 | ||
257 | case NOTE_INSN_BLOCK_BEG: | |
258 | case NOTE_INSN_BLOCK_END: | |
1a4450c7 | 259 | fprintf (outfile, " "); |
f76ca83c GK |
260 | if (flag_dump_unnumbered) |
261 | fprintf (outfile, "#"); | |
262 | else | |
6a4d6760 | 263 | fprintf (outfile, HOST_PTR_PRINTF, |
f76ca83c | 264 | (char *) NOTE_BLOCK (in_rtx)); |
8f985ec4 | 265 | sawclose = 1; |
994a57cd RH |
266 | break; |
267 | ||
994a57cd RH |
268 | case NOTE_INSN_BASIC_BLOCK: |
269 | { | |
270 | basic_block bb = NOTE_BASIC_BLOCK (in_rtx); | |
271 | if (bb != 0) | |
0b17ab2f | 272 | fprintf (outfile, " [bb %d]", bb->index); |
994a57cd RH |
273 | break; |
274 | } | |
275 | ||
276 | case NOTE_INSN_EXPECTED_VALUE: | |
277 | indent += 2; | |
278 | if (!sawclose) | |
279 | fprintf (outfile, " "); | |
280 | print_rtx (NOTE_EXPECTED_VALUE (in_rtx)); | |
281 | indent -= 2; | |
282 | break; | |
283 | ||
be1bb652 RH |
284 | case NOTE_INSN_DELETED_LABEL: |
285 | if (NOTE_SOURCE_FILE (in_rtx)) | |
286 | fprintf (outfile, " (\"%s\")", NOTE_SOURCE_FILE (in_rtx)); | |
287 | else | |
288 | fprintf (outfile, " \"\""); | |
289 | break; | |
290 | ||
6a4d6760 KH |
291 | case NOTE_INSN_PREDICTION: |
292 | if (NOTE_PREDICTION (in_rtx)) | |
293 | fprintf (outfile, " [ %d %d ] ", | |
294 | (int)NOTE_PREDICTION_ALG (in_rtx), | |
295 | (int) NOTE_PREDICTION_FLAGS (in_rtx)); | |
296 | else | |
297 | fprintf (outfile, " [ ERROR ]"); | |
298 | break; | |
299 | ||
994a57cd RH |
300 | default: |
301 | { | |
302 | const char * const str = X0STR (in_rtx, i); | |
303 | ||
304 | if (NOTE_LINE_NUMBER (in_rtx) < 0) | |
305 | ; | |
306 | else if (str == 0) | |
307 | fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile); | |
308 | else | |
309 | { | |
310 | if (dump_for_graph) | |
311 | fprintf (outfile, " (\\\"%s\\\")", str); | |
312 | else | |
313 | fprintf (outfile, " (\"%s\")", str); | |
314 | } | |
315 | break; | |
316 | } | |
8f985ec4 ZW |
317 | } |
318 | } | |
e1a79915 RS |
319 | break; |
320 | ||
321 | case 'e': | |
bcdaba58 | 322 | do_e: |
e1a79915 RS |
323 | indent += 2; |
324 | if (!sawclose) | |
325 | fprintf (outfile, " "); | |
326 | print_rtx (XEXP (in_rtx, i)); | |
327 | indent -= 2; | |
328 | break; | |
329 | ||
330 | case 'E': | |
331 | case 'V': | |
332 | indent += 2; | |
333 | if (sawclose) | |
334 | { | |
d558416e | 335 | fprintf (outfile, "\n%s%*s", |
6a4d6760 | 336 | print_rtx_head, indent * 2, ""); |
e1a79915 RS |
337 | sawclose = 0; |
338 | } | |
7f11f1f9 | 339 | fputs (" [", outfile); |
e1a79915 RS |
340 | if (NULL != XVEC (in_rtx, i)) |
341 | { | |
342 | indent += 2; | |
343 | if (XVECLEN (in_rtx, i)) | |
344 | sawclose = 1; | |
345 | ||
346 | for (j = 0; j < XVECLEN (in_rtx, i); j++) | |
347 | print_rtx (XVECEXP (in_rtx, i, j)); | |
348 | ||
349 | indent -= 2; | |
350 | } | |
351 | if (sawclose) | |
5e74f966 | 352 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, ""); |
e1a79915 | 353 | |
7f11f1f9 | 354 | fputs ("]", outfile); |
e1a79915 RS |
355 | sawclose = 1; |
356 | indent -= 2; | |
357 | break; | |
358 | ||
5bf665df | 359 | case 'w': |
75b7557d MH |
360 | if (! flag_simple) |
361 | fprintf (outfile, " "); | |
734de8c8 | 362 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i)); |
75b7557d MH |
363 | if (! flag_simple) |
364 | { | |
365 | fprintf (outfile, " ["); | |
366 | fprintf (outfile, HOST_WIDE_INT_PRINT_HEX, XWINT (in_rtx, i)); | |
367 | fprintf (outfile, "]"); | |
368 | } | |
5bf665df RK |
369 | break; |
370 | ||
e1a79915 | 371 | case 'i': |
32c36ac8 | 372 | if (i == 6 && GET_CODE (in_rtx) == NOTE) |
25cff714 RH |
373 | { |
374 | /* This field is only used for NOTE_INSN_DELETED_LABEL, and | |
375 | other times often contains garbage from INSN->NOTE death. */ | |
376 | if (NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_DELETED_LABEL) | |
377 | fprintf (outfile, " %d", XINT (in_rtx, i)); | |
378 | } | |
379 | else | |
380 | { | |
b3694847 | 381 | int value = XINT (in_rtx, i); |
25cff714 | 382 | const char *name; |
cf99a734 | 383 | |
25cff714 RH |
384 | if (GET_CODE (in_rtx) == REG && value < FIRST_PSEUDO_REGISTER) |
385 | { | |
386 | fputc (' ', outfile); | |
387 | DEBUG_PRINT_REG (in_rtx, 0, outfile); | |
388 | } | |
389 | else if (GET_CODE (in_rtx) == REG | |
390 | && value <= LAST_VIRTUAL_REGISTER) | |
391 | { | |
392 | if (value == VIRTUAL_INCOMING_ARGS_REGNUM) | |
393 | fprintf (outfile, " %d virtual-incoming-args", value); | |
394 | else if (value == VIRTUAL_STACK_VARS_REGNUM) | |
395 | fprintf (outfile, " %d virtual-stack-vars", value); | |
396 | else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM) | |
397 | fprintf (outfile, " %d virtual-stack-dynamic", value); | |
398 | else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM) | |
399 | fprintf (outfile, " %d virtual-outgoing-args", value); | |
400 | else if (value == VIRTUAL_CFA_REGNUM) | |
401 | fprintf (outfile, " %d virtual-cfa", value); | |
402 | else | |
403 | fprintf (outfile, " %d virtual-reg-%d", value, | |
404 | value-FIRST_VIRTUAL_REGISTER); | |
405 | } | |
406 | else if (flag_dump_unnumbered | |
407 | && (is_insn || GET_CODE (in_rtx) == NOTE)) | |
408 | fputc ('#', outfile); | |
409 | else | |
410 | fprintf (outfile, " %d", value); | |
411 | ||
a560d4d4 JH |
412 | if (GET_CODE (in_rtx) == REG && REG_ATTRS (in_rtx)) |
413 | { | |
414 | fputs (" [", outfile); | |
415 | if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx)) | |
416 | fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx)); | |
417 | if (REG_EXPR (in_rtx)) | |
418 | print_mem_expr (outfile, REG_EXPR (in_rtx)); | |
419 | ||
420 | if (REG_OFFSET (in_rtx)) | |
421 | { | |
422 | fputc ('+', outfile); | |
423 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, | |
424 | REG_OFFSET (in_rtx)); | |
425 | } | |
426 | fputs (" ]", outfile); | |
427 | } | |
428 | ||
25cff714 RH |
429 | if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i) |
430 | && XINT (in_rtx, i) >= 0 | |
431 | && (name = get_insn_name (XINT (in_rtx, i))) != NULL) | |
432 | fprintf (outfile, " {%s}", name); | |
433 | sawclose = 0; | |
434 | } | |
e1a79915 RS |
435 | break; |
436 | ||
437 | /* Print NOTE_INSN names rather than integer codes. */ | |
438 | ||
439 | case 'n': | |
dbbbbf3b JDA |
440 | if (XINT (in_rtx, i) >= (int) NOTE_INSN_BIAS |
441 | && XINT (in_rtx, i) < (int) NOTE_INSN_MAX) | |
e1a79915 RS |
442 | fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i))); |
443 | else | |
444 | fprintf (outfile, " %d", XINT (in_rtx, i)); | |
445 | sawclose = 0; | |
446 | break; | |
447 | ||
448 | case 'u': | |
449 | if (XEXP (in_rtx, i) != NULL) | |
9ec36da5 | 450 | { |
556ffcc5 RH |
451 | rtx sub = XEXP (in_rtx, i); |
452 | enum rtx_code subc = GET_CODE (sub); | |
453 | ||
be1bb652 RH |
454 | if (GET_CODE (in_rtx) == LABEL_REF) |
455 | { | |
456 | if (subc == NOTE | |
457 | && NOTE_LINE_NUMBER (sub) == NOTE_INSN_DELETED_LABEL) | |
458 | { | |
459 | if (flag_dump_unnumbered) | |
460 | fprintf (outfile, " [# deleted]"); | |
461 | else | |
462 | fprintf (outfile, " [%d deleted]", INSN_UID (sub)); | |
463 | sawclose = 0; | |
464 | break; | |
465 | } | |
466 | ||
467 | if (subc != CODE_LABEL) | |
468 | goto do_e; | |
469 | } | |
bcdaba58 | 470 | |
9ec36da5 | 471 | if (flag_dump_unnumbered) |
be1bb652 | 472 | fputs (" #", outfile); |
9ec36da5 | 473 | else |
556ffcc5 | 474 | fprintf (outfile, " %d", INSN_UID (sub)); |
9ec36da5 | 475 | } |
e1a79915 | 476 | else |
d5e3e85b | 477 | fputs (" 0", outfile); |
d64be5ec CH |
478 | sawclose = 0; |
479 | break; | |
480 | ||
0dfa1860 MM |
481 | case 'b': |
482 | if (XBITMAP (in_rtx, i) == NULL) | |
735a0e33 | 483 | fputs (" {null}", outfile); |
0dfa1860 MM |
484 | else |
485 | bitmap_print (outfile, XBITMAP (in_rtx, i), " {", "}"); | |
486 | sawclose = 0; | |
487 | break; | |
488 | ||
489 | case 't': | |
490 | putc (' ', outfile); | |
c6b0465b | 491 | fprintf (outfile, HOST_PTR_PRINTF, (char *) XTREE (in_rtx, i)); |
0dfa1860 MM |
492 | break; |
493 | ||
d64be5ec | 494 | case '*': |
735a0e33 | 495 | fputs (" Unknown", outfile); |
e1a79915 RS |
496 | sawclose = 0; |
497 | break; | |
498 | ||
ba4f7968 JH |
499 | case 'B': |
500 | if (XBBDEF (in_rtx, i)) | |
501 | fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index); | |
502 | break; | |
503 | ||
e1a79915 RS |
504 | default: |
505 | fprintf (stderr, | |
506 | "switch format wrong in rtl.print_rtx(). format was: %c.\n", | |
507 | format_ptr[-1]); | |
508 | abort (); | |
509 | } | |
510 | ||
be1bb652 RH |
511 | switch (GET_CODE (in_rtx)) |
512 | { | |
513 | case MEM: | |
738cc472 | 514 | fputs (" [", outfile); |
c5588504 | 515 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, MEM_ALIAS_SET (in_rtx)); |
998d7deb RH |
516 | |
517 | if (MEM_EXPR (in_rtx)) | |
518 | print_mem_expr (outfile, MEM_EXPR (in_rtx)); | |
738cc472 RK |
519 | |
520 | if (MEM_OFFSET (in_rtx)) | |
521 | { | |
522 | fputc ('+', outfile); | |
523 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, | |
524 | INTVAL (MEM_OFFSET (in_rtx))); | |
525 | } | |
526 | ||
527 | if (MEM_SIZE (in_rtx)) | |
528 | { | |
529 | fputs (" S", outfile); | |
530 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, | |
531 | INTVAL (MEM_SIZE (in_rtx))); | |
532 | } | |
533 | ||
534 | if (MEM_ALIGN (in_rtx) != 1) | |
535 | fprintf (outfile, " A%u", MEM_ALIGN (in_rtx)); | |
536 | ||
537 | fputc (']', outfile); | |
be1bb652 | 538 | break; |
5a0a1a66 | 539 | |
4d2d910c | 540 | #ifndef GENERATOR_FILE |
be1bb652 RH |
541 | case CONST_DOUBLE: |
542 | if (FLOAT_MODE_P (GET_MODE (in_rtx))) | |
543 | { | |
4fdbcfb2 | 544 | char s[60]; |
b216cd4a | 545 | |
da6eec72 RH |
546 | real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), |
547 | sizeof (s), 0, 1); | |
69bd00e6 RH |
548 | fprintf (outfile, " %s", s); |
549 | ||
da6eec72 RH |
550 | real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), |
551 | sizeof (s), 0, 1); | |
b216cd4a | 552 | fprintf (outfile, " [%s]", s); |
be1bb652 RH |
553 | } |
554 | break; | |
800d5c9e RH |
555 | #endif |
556 | ||
be1bb652 | 557 | case CODE_LABEL: |
c3c63936 | 558 | fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx)); |
0dc36574 ZW |
559 | switch (LABEL_KIND (in_rtx)) |
560 | { | |
561 | case LABEL_NORMAL: break; | |
562 | case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break; | |
563 | case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break; | |
564 | case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break; | |
565 | default: abort(); | |
566 | } | |
be1bb652 RH |
567 | break; |
568 | ||
569 | case CALL_PLACEHOLDER: | |
b5d7770c AO |
570 | if (debug_call_placeholder_verbose) |
571 | { | |
572 | fputs (" (cond [\n (const_string \"normal\") (sequence [", outfile); | |
573 | for (tem = XEXP (in_rtx, 0); tem != 0; tem = NEXT_INSN (tem)) | |
574 | { | |
575 | fputs ("\n ", outfile); | |
576 | print_inline_rtx (outfile, tem, 4); | |
577 | } | |
578 | ||
579 | tem = XEXP (in_rtx, 1); | |
580 | if (tem) | |
5e74f966 RK |
581 | fputs ("\n ])\n (const_string \"tail_call\") (sequence [", |
582 | outfile); | |
b5d7770c AO |
583 | for (; tem != 0; tem = NEXT_INSN (tem)) |
584 | { | |
585 | fputs ("\n ", outfile); | |
586 | print_inline_rtx (outfile, tem, 4); | |
587 | } | |
588 | ||
589 | tem = XEXP (in_rtx, 2); | |
590 | if (tem) | |
5e74f966 RK |
591 | fputs ("\n ])\n (const_string \"tail_recursion\") (sequence [", |
592 | outfile); | |
b5d7770c AO |
593 | for (; tem != 0; tem = NEXT_INSN (tem)) |
594 | { | |
595 | fputs ("\n ", outfile); | |
596 | print_inline_rtx (outfile, tem, 4); | |
597 | } | |
598 | ||
599 | fputs ("\n ])\n ])", outfile); | |
600 | break; | |
601 | } | |
602 | ||
be1bb652 RH |
603 | for (tem = XEXP (in_rtx, 0); tem != 0; tem = NEXT_INSN (tem)) |
604 | if (GET_CODE (tem) == CALL_INSN) | |
605 | { | |
606 | fprintf (outfile, " "); | |
607 | print_rtx (tem); | |
608 | break; | |
609 | } | |
610 | break; | |
611 | ||
612 | default: | |
613 | break; | |
8cd0faaf | 614 | } |
c3c63936 | 615 | |
735a0e33 UD |
616 | if (dump_for_graph |
617 | && (is_insn || GET_CODE (in_rtx) == NOTE | |
618 | || GET_CODE (in_rtx) == CODE_LABEL || GET_CODE (in_rtx) == BARRIER)) | |
619 | sawclose = 0; | |
620 | else | |
621 | { | |
622 | fputc (')', outfile); | |
623 | sawclose = 1; | |
624 | } | |
e1a79915 RS |
625 | } |
626 | ||
1d79197a RK |
627 | /* Print an rtx on the current line of FILE. Initially indent IND |
628 | characters. */ | |
629 | ||
630 | void | |
631 | print_inline_rtx (outf, x, ind) | |
632 | FILE *outf; | |
633 | rtx x; | |
9870475c | 634 | int ind; |
1d79197a | 635 | { |
956d6950 JL |
636 | int oldsaw = sawclose; |
637 | int oldindent = indent; | |
638 | ||
1d79197a RK |
639 | sawclose = 0; |
640 | indent = ind; | |
641 | outfile = outf; | |
642 | print_rtx (x); | |
956d6950 JL |
643 | sawclose = oldsaw; |
644 | indent = oldindent; | |
1d79197a RK |
645 | } |
646 | ||
e1a79915 RS |
647 | /* Call this function from the debugger to see what X looks like. */ |
648 | ||
649 | void | |
650 | debug_rtx (x) | |
651 | rtx x; | |
652 | { | |
653 | outfile = stderr; | |
7f11f1f9 | 654 | sawclose = 0; |
e1a79915 RS |
655 | print_rtx (x); |
656 | fprintf (stderr, "\n"); | |
657 | } | |
658 | ||
716f003f DE |
659 | /* Count of rtx's to print with debug_rtx_list. |
660 | This global exists because gdb user defined commands have no arguments. */ | |
661 | ||
662 | int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */ | |
663 | ||
664 | /* Call this function to print list from X on. | |
665 | ||
666 | N is a count of the rtx's to print. Positive values print from the specified | |
667 | rtx on. Negative values print a window around the rtx. | |
668 | EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */ | |
669 | ||
670 | void | |
671 | debug_rtx_list (x, n) | |
672 | rtx x; | |
673 | int n; | |
674 | { | |
675 | int i,count; | |
676 | rtx insn; | |
677 | ||
678 | count = n == 0 ? 1 : n < 0 ? -n : n; | |
679 | ||
680 | /* If we are printing a window, back up to the start. */ | |
681 | ||
682 | if (n < 0) | |
683 | for (i = count / 2; i > 0; i--) | |
684 | { | |
685 | if (PREV_INSN (x) == 0) | |
686 | break; | |
687 | x = PREV_INSN (x); | |
688 | } | |
689 | ||
690 | for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn)) | |
7f11f1f9 AS |
691 | { |
692 | debug_rtx (insn); | |
693 | fprintf (stderr, "\n"); | |
694 | } | |
716f003f DE |
695 | } |
696 | ||
4c85a96d RH |
697 | /* Call this function to print an rtx list from START to END inclusive. */ |
698 | ||
699 | void | |
700 | debug_rtx_range (start, end) | |
701 | rtx start, end; | |
702 | { | |
703 | while (1) | |
704 | { | |
705 | debug_rtx (start); | |
7f11f1f9 | 706 | fprintf (stderr, "\n"); |
4c85a96d RH |
707 | if (!start || start == end) |
708 | break; | |
709 | start = NEXT_INSN (start); | |
710 | } | |
711 | } | |
712 | ||
716f003f DE |
713 | /* Call this function to search an rtx list to find one with insn uid UID, |
714 | and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT. | |
715 | The found insn is returned to enable further debugging analysis. */ | |
716 | ||
717 | rtx | |
1d79197a | 718 | debug_rtx_find (x, uid) |
716f003f DE |
719 | rtx x; |
720 | int uid; | |
721 | { | |
722 | while (x != 0 && INSN_UID (x) != uid) | |
723 | x = NEXT_INSN (x); | |
724 | if (x != 0) | |
725 | { | |
726 | debug_rtx_list (x, debug_rtx_count); | |
727 | return x; | |
728 | } | |
729 | else | |
730 | { | |
731 | fprintf (stderr, "insn uid %d not found\n", uid); | |
732 | return 0; | |
733 | } | |
734 | } | |
735 | ||
e1a79915 RS |
736 | /* External entry point for printing a chain of insns |
737 | starting with RTX_FIRST onto file OUTF. | |
738 | A blank line separates insns. | |
739 | ||
740 | If RTX_FIRST is not an insn, then it alone is printed, with no newline. */ | |
741 | ||
742 | void | |
743 | print_rtl (outf, rtx_first) | |
744 | FILE *outf; | |
745 | rtx rtx_first; | |
746 | { | |
b3694847 | 747 | rtx tmp_rtx; |
e1a79915 RS |
748 | |
749 | outfile = outf; | |
750 | sawclose = 0; | |
751 | ||
752 | if (rtx_first == 0) | |
c349e40b SC |
753 | { |
754 | fputs (print_rtx_head, outf); | |
755 | fputs ("(nil)\n", outf); | |
756 | } | |
e1a79915 RS |
757 | else |
758 | switch (GET_CODE (rtx_first)) | |
759 | { | |
760 | case INSN: | |
761 | case JUMP_INSN: | |
762 | case CALL_INSN: | |
763 | case NOTE: | |
764 | case CODE_LABEL: | |
765 | case BARRIER: | |
c3c63936 RK |
766 | for (tmp_rtx = rtx_first; tmp_rtx != 0; tmp_rtx = NEXT_INSN (tmp_rtx)) |
767 | if (! flag_dump_unnumbered | |
768 | || GET_CODE (tmp_rtx) != NOTE || NOTE_LINE_NUMBER (tmp_rtx) < 0) | |
769 | { | |
6a4d6760 | 770 | fputs (print_rtx_head, outfile); |
c3c63936 RK |
771 | print_rtx (tmp_rtx); |
772 | fprintf (outfile, "\n"); | |
773 | } | |
e1a79915 RS |
774 | break; |
775 | ||
776 | default: | |
6a4d6760 | 777 | fputs (print_rtx_head, outfile); |
e1a79915 RS |
778 | print_rtx (rtx_first); |
779 | } | |
780 | } | |
3e28fe44 MM |
781 | |
782 | /* Like print_rtx, except specify a file. */ | |
b707b450 | 783 | /* Return nonzero if we actually printed anything. */ |
3e28fe44 | 784 | |
b707b450 | 785 | int |
3e28fe44 MM |
786 | print_rtl_single (outf, x) |
787 | FILE *outf; | |
788 | rtx x; | |
789 | { | |
790 | outfile = outf; | |
791 | sawclose = 0; | |
9ec36da5 JL |
792 | if (! flag_dump_unnumbered |
793 | || GET_CODE (x) != NOTE || NOTE_LINE_NUMBER (x) < 0) | |
794 | { | |
c349e40b | 795 | fputs (print_rtx_head, outfile); |
9ec36da5 JL |
796 | print_rtx (x); |
797 | putc ('\n', outf); | |
b707b450 | 798 | return 1; |
9ec36da5 | 799 | } |
b707b450 | 800 | return 0; |
3e28fe44 | 801 | } |
75b7557d MH |
802 | |
803 | ||
804 | /* Like print_rtl except without all the detail; for example, | |
805 | if RTX is a CONST_INT then print in decimal format. */ | |
806 | ||
807 | void | |
808 | print_simple_rtl (outf, x) | |
809 | FILE *outf; | |
810 | rtx x; | |
811 | { | |
812 | flag_simple = 1; | |
813 | print_rtl (outf, x); | |
814 | flag_simple = 0; | |
815 | } |