]>
Commit | Line | Data |
---|---|---|
5e6908ea | 1 | /* Print RTL for GCC. |
d1e082c2 | 2 | Copyright (C) 1987-2013 Free Software Foundation, Inc. |
e1a79915 | 3 | |
1322177d | 4 | This file is part of GCC. |
e1a79915 | 5 | |
1322177d LB |
6 | GCC is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free | |
9dcd6f09 | 8 | Software Foundation; either version 3, or (at your option) any later |
1322177d | 9 | version. |
e1a79915 | 10 | |
1322177d LB |
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | for more details. | |
e1a79915 RS |
15 | |
16 | You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ | |
e1a79915 | 19 | |
45c8116d ZW |
20 | /* This file is compiled twice: once for the generator programs, |
21 | once for the compiler. */ | |
22 | #ifdef GENERATOR_FILE | |
23 | #include "bconfig.h" | |
24 | #else | |
e1a79915 | 25 | #include "config.h" |
45c8116d ZW |
26 | #endif |
27 | ||
670ee920 | 28 | #include "system.h" |
4977bab6 ZW |
29 | #include "coretypes.h" |
30 | #include "tm.h" | |
e1a79915 | 31 | #include "rtl.h" |
738cc472 | 32 | |
45c8116d ZW |
33 | /* These headers all define things which are not available in |
34 | generator programs. */ | |
35 | #ifndef GENERATOR_FILE | |
738cc472 | 36 | #include "tree.h" |
d8a2d370 | 37 | #include "print-tree.h" |
b707b450 | 38 | #include "flags.h" |
efc9bd41 | 39 | #include "hard-reg-set.h" |
e881bb1b | 40 | #include "basic-block.h" |
55b34b5f | 41 | #include "diagnostic.h" |
cf835838 | 42 | #include "tree-pretty-print.h" |
b5b8b0ac | 43 | #include "cselib.h" |
7ee2468b | 44 | #include "dumpfile.h" /* for dump_flags */ |
2867fa7c | 45 | #include "dwarf2out.h" |
45c8116d | 46 | #endif |
cf99a734 | 47 | |
e1a79915 RS |
48 | static FILE *outfile; |
49 | ||
e1a79915 RS |
50 | static int sawclose = 0; |
51 | ||
1d79197a RK |
52 | static int indent; |
53 | ||
f7d504c2 | 54 | static void print_rtx (const_rtx); |
5edc9230 | 55 | |
c349e40b SC |
56 | /* String printed at beginning of each RTL when it is dumped. |
57 | This string is set to ASM_COMMENT_START when the RTL is dumped in | |
58 | the assembly output file. */ | |
47c10e9b | 59 | const char *print_rtx_head = ""; |
c349e40b | 60 | |
e90afde6 JM |
61 | #ifdef GENERATOR_FILE |
62 | /* These are defined from the .opt file when not used in generator | |
63 | programs. */ | |
64 | ||
9dbe7947 JH |
65 | /* Nonzero means suppress output of instruction numbers |
66 | in debugging dumps. | |
b707b450 | 67 | This must be defined here so that programs like gencodes can be linked. */ |
9ec36da5 | 68 | int flag_dump_unnumbered = 0; |
b707b450 | 69 | |
2aa7c49b AO |
70 | /* Nonzero means suppress output of instruction numbers for previous |
71 | and next insns in debugging dumps. | |
72 | This must be defined here so that programs like gencodes can be linked. */ | |
73 | int flag_dump_unnumbered_links = 0; | |
e90afde6 | 74 | #endif |
2aa7c49b | 75 | |
75b7557d MH |
76 | /* Nonzero means use simplified format without flags, modes, etc. */ |
77 | int flag_simple = 0; | |
78 | ||
45c8116d | 79 | #ifndef GENERATOR_FILE |
998d7deb | 80 | void |
f7d504c2 | 81 | print_mem_expr (FILE *outfile, const_tree expr) |
998d7deb | 82 | { |
55b34b5f | 83 | fputc (' ', outfile); |
831b9ef8 | 84 | print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags); |
998d7deb | 85 | } |
45c8116d | 86 | #endif |
998d7deb | 87 | |
e1a79915 RS |
88 | /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */ |
89 | ||
90 | static void | |
f7d504c2 | 91 | print_rtx (const_rtx in_rtx) |
e1a79915 | 92 | { |
b3694847 SS |
93 | int i = 0; |
94 | int j; | |
95 | const char *format_ptr; | |
96 | int is_insn; | |
e1a79915 RS |
97 | |
98 | if (sawclose) | |
99 | { | |
75b7557d MH |
100 | if (flag_simple) |
101 | fputc (' ', outfile); | |
102 | else | |
5e74f966 | 103 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, ""); |
e1a79915 RS |
104 | sawclose = 0; |
105 | } | |
106 | ||
107 | if (in_rtx == 0) | |
108 | { | |
735a0e33 | 109 | fputs ("(nil)", outfile); |
e1a79915 RS |
110 | sawclose = 1; |
111 | return; | |
112 | } | |
5e74f966 RK |
113 | else if (GET_CODE (in_rtx) > NUM_RTX_CODE) |
114 | { | |
8a2bbeef JJ |
115 | fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx), |
116 | print_rtx_head, indent * 2, ""); | |
5e74f966 RK |
117 | sawclose = 1; |
118 | return; | |
119 | } | |
e1a79915 | 120 | |
5e74f966 | 121 | is_insn = INSN_P (in_rtx); |
735a0e33 | 122 | |
a27a5de9 SB |
123 | /* Print name of expression code. */ |
124 | if (flag_simple && CONST_INT_P (in_rtx)) | |
125 | fputc ('(', outfile); | |
735a0e33 | 126 | else |
a27a5de9 | 127 | fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx))); |
6a4d6760 | 128 | |
a27a5de9 SB |
129 | if (! flag_simple) |
130 | { | |
131 | if (RTX_FLAG (in_rtx, in_struct)) | |
132 | fputs ("/s", outfile); | |
75b7557d | 133 | |
a27a5de9 SB |
134 | if (RTX_FLAG (in_rtx, volatil)) |
135 | fputs ("/v", outfile); | |
6a4d6760 | 136 | |
a27a5de9 SB |
137 | if (RTX_FLAG (in_rtx, unchanging)) |
138 | fputs ("/u", outfile); | |
6a4d6760 | 139 | |
a27a5de9 SB |
140 | if (RTX_FLAG (in_rtx, frame_related)) |
141 | fputs ("/f", outfile); | |
6a4d6760 | 142 | |
a27a5de9 SB |
143 | if (RTX_FLAG (in_rtx, jump)) |
144 | fputs ("/j", outfile); | |
6a4d6760 | 145 | |
a27a5de9 SB |
146 | if (RTX_FLAG (in_rtx, call)) |
147 | fputs ("/c", outfile); | |
75b7557d | 148 | |
a27a5de9 SB |
149 | if (RTX_FLAG (in_rtx, return_val)) |
150 | fputs ("/i", outfile); | |
6de9cd9a | 151 | |
a27a5de9 SB |
152 | /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */ |
153 | if ((GET_CODE (in_rtx) == EXPR_LIST | |
e5af9ddd RS |
154 | || GET_CODE (in_rtx) == INSN_LIST |
155 | || GET_CODE (in_rtx) == INT_LIST) | |
a27a5de9 SB |
156 | && (int)GET_MODE (in_rtx) < REG_NOTE_MAX) |
157 | fprintf (outfile, ":%s", | |
158 | GET_REG_NOTE_NAME (GET_MODE (in_rtx))); | |
52c5701b | 159 | |
a27a5de9 SB |
160 | /* For other rtl, print the mode if it's not VOID. */ |
161 | else if (GET_MODE (in_rtx) != VOIDmode) | |
162 | fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx))); | |
b5b8b0ac AO |
163 | |
164 | #ifndef GENERATOR_FILE | |
a27a5de9 SB |
165 | if (GET_CODE (in_rtx) == VAR_LOCATION) |
166 | { | |
167 | if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST) | |
168 | fputs (" <debug string placeholder>", outfile); | |
169 | else | |
170 | print_mem_expr (outfile, PAT_VAR_LOCATION_DECL (in_rtx)); | |
171 | fputc (' ', outfile); | |
172 | print_rtx (PAT_VAR_LOCATION_LOC (in_rtx)); | |
173 | if (PAT_VAR_LOCATION_STATUS (in_rtx) | |
174 | == VAR_INIT_STATUS_UNINITIALIZED) | |
175 | fprintf (outfile, " [uninit]"); | |
176 | sawclose = 1; | |
177 | i = GET_RTX_LENGTH (VAR_LOCATION); | |
735a0e33 | 178 | } |
a27a5de9 | 179 | #endif |
e1a79915 RS |
180 | } |
181 | ||
69bd00e6 | 182 | #ifndef GENERATOR_FILE |
48175537 | 183 | if (CONST_DOUBLE_AS_FLOAT_P (in_rtx)) |
69bd00e6 RH |
184 | i = 5; |
185 | #endif | |
186 | ||
735a0e33 UD |
187 | /* Get the format string and skip the first elements if we have handled |
188 | them already. */ | |
189 | format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i; | |
735a0e33 | 190 | for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++) |
e1a79915 RS |
191 | switch (*format_ptr++) |
192 | { | |
3b324340 ZW |
193 | const char *str; |
194 | ||
195 | case 'T': | |
196 | str = XTMPL (in_rtx, i); | |
197 | goto string; | |
198 | ||
e1a79915 RS |
199 | case 'S': |
200 | case 's': | |
3b324340 ZW |
201 | str = XSTR (in_rtx, i); |
202 | string: | |
203 | ||
204 | if (str == 0) | |
a27a5de9 | 205 | fputs (" \"\"", outfile); |
e1a79915 | 206 | else |
a27a5de9 | 207 | fprintf (outfile, " (\"%s\")", str); |
e1a79915 RS |
208 | sawclose = 1; |
209 | break; | |
210 | ||
8f985ec4 ZW |
211 | /* 0 indicates a field for internal use that should not be printed. |
212 | An exception is the third field of a NOTE, where it indicates | |
213 | that the field has several different valid contents. */ | |
e1a79915 | 214 | case '0': |
f8cfc6aa | 215 | if (i == 1 && REG_P (in_rtx)) |
08394eef BS |
216 | { |
217 | if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx)) | |
218 | fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx)); | |
08394eef | 219 | } |
52859c77 RH |
220 | #ifndef GENERATOR_FILE |
221 | else if (i == 1 && GET_CODE (in_rtx) == SYMBOL_REF) | |
222 | { | |
223 | int flags = SYMBOL_REF_FLAGS (in_rtx); | |
224 | if (flags) | |
a3f1cee4 | 225 | fprintf (outfile, " [flags %#x]", flags); |
52859c77 RH |
226 | } |
227 | else if (i == 2 && GET_CODE (in_rtx) == SYMBOL_REF) | |
228 | { | |
229 | tree decl = SYMBOL_REF_DECL (in_rtx); | |
230 | if (decl) | |
831b9ef8 | 231 | print_node_brief (outfile, "", decl, dump_flags); |
52859c77 RH |
232 | } |
233 | #endif | |
4b4bf941 | 234 | else if (i == 4 && NOTE_P (in_rtx)) |
8f985ec4 | 235 | { |
a38e7aa5 | 236 | switch (NOTE_KIND (in_rtx)) |
bf43101e | 237 | { |
994a57cd RH |
238 | case NOTE_INSN_EH_REGION_BEG: |
239 | case NOTE_INSN_EH_REGION_END: | |
f76ca83c GK |
240 | if (flag_dump_unnumbered) |
241 | fprintf (outfile, " #"); | |
242 | else | |
243 | fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx)); | |
bf43101e | 244 | sawclose = 1; |
994a57cd RH |
245 | break; |
246 | ||
247 | case NOTE_INSN_BLOCK_BEG: | |
248 | case NOTE_INSN_BLOCK_END: | |
24a7799e R |
249 | #ifndef GENERATOR_FILE |
250 | dump_addr (outfile, " ", NOTE_BLOCK (in_rtx)); | |
251 | #endif | |
8f985ec4 | 252 | sawclose = 1; |
994a57cd RH |
253 | break; |
254 | ||
994a57cd RH |
255 | case NOTE_INSN_BASIC_BLOCK: |
256 | { | |
45c8116d | 257 | #ifndef GENERATOR_FILE |
994a57cd RH |
258 | basic_block bb = NOTE_BASIC_BLOCK (in_rtx); |
259 | if (bb != 0) | |
0b17ab2f | 260 | fprintf (outfile, " [bb %d]", bb->index); |
45c8116d | 261 | #endif |
994a57cd RH |
262 | break; |
263 | } | |
264 | ||
be1bb652 | 265 | case NOTE_INSN_DELETED_LABEL: |
5619e52c | 266 | case NOTE_INSN_DELETED_DEBUG_LABEL: |
6773e15f PB |
267 | { |
268 | const char *label = NOTE_DELETED_LABEL_NAME (in_rtx); | |
269 | if (label) | |
270 | fprintf (outfile, " (\"%s\")", label); | |
271 | else | |
272 | fprintf (outfile, " \"\""); | |
273 | } | |
be1bb652 RH |
274 | break; |
275 | ||
87c8b4be | 276 | case NOTE_INSN_SWITCH_TEXT_SECTIONS: |
750054a2 | 277 | { |
45c8116d | 278 | #ifndef GENERATOR_FILE |
750054a2 CT |
279 | basic_block bb = NOTE_BASIC_BLOCK (in_rtx); |
280 | if (bb != 0) | |
281 | fprintf (outfile, " [bb %d]", bb->index); | |
45c8116d | 282 | #endif |
750054a2 CT |
283 | break; |
284 | } | |
b8698a0f | 285 | |
014a1138 | 286 | case NOTE_INSN_VAR_LOCATION: |
2b1c5433 | 287 | case NOTE_INSN_CALL_ARG_LOCATION: |
45c8116d | 288 | #ifndef GENERATOR_FILE |
b5b8b0ac AO |
289 | fputc (' ', outfile); |
290 | print_rtx (NOTE_VAR_LOCATION (in_rtx)); | |
45c8116d | 291 | #endif |
014a1138 JZ |
292 | break; |
293 | ||
2867fa7c RH |
294 | case NOTE_INSN_CFI: |
295 | #ifndef GENERATOR_FILE | |
296 | fputc ('\n', outfile); | |
297 | output_cfi_directive (outfile, NOTE_CFI (in_rtx)); | |
298 | fputc ('\t', outfile); | |
299 | #endif | |
300 | break; | |
301 | ||
994a57cd | 302 | default: |
a38e7aa5 | 303 | break; |
8f985ec4 ZW |
304 | } |
305 | } | |
137a05d3 | 306 | else if (i == 8 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL) |
dc0ff1c8 BS |
307 | { |
308 | /* Output the JUMP_LABEL reference. */ | |
309 | fprintf (outfile, "\n%s%*s -> ", print_rtx_head, indent * 2, ""); | |
310 | if (GET_CODE (JUMP_LABEL (in_rtx)) == RETURN) | |
311 | fprintf (outfile, "return"); | |
26898771 BS |
312 | else if (GET_CODE (JUMP_LABEL (in_rtx)) == SIMPLE_RETURN) |
313 | fprintf (outfile, "simple_return"); | |
dc0ff1c8 BS |
314 | else |
315 | fprintf (outfile, "%d", INSN_UID (JUMP_LABEL (in_rtx))); | |
316 | } | |
b5b8b0ac AO |
317 | else if (i == 0 && GET_CODE (in_rtx) == VALUE) |
318 | { | |
319 | #ifndef GENERATOR_FILE | |
320 | cselib_val *val = CSELIB_VAL_PTR (in_rtx); | |
321 | ||
5440c0e7 | 322 | fprintf (outfile, " %u:%u", val->uid, val->hash); |
b5b8b0ac AO |
323 | dump_addr (outfile, " @", in_rtx); |
324 | dump_addr (outfile, "/", (void*)val); | |
0ca5af51 AO |
325 | #endif |
326 | } | |
327 | else if (i == 0 && GET_CODE (in_rtx) == DEBUG_EXPR) | |
328 | { | |
329 | #ifndef GENERATOR_FILE | |
e4fb38bd JJ |
330 | fprintf (outfile, " D#%i", |
331 | DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx))); | |
b5b8b0ac AO |
332 | #endif |
333 | } | |
a58a8e4b JJ |
334 | else if (i == 0 && GET_CODE (in_rtx) == ENTRY_VALUE) |
335 | { | |
336 | indent += 2; | |
337 | if (!sawclose) | |
338 | fprintf (outfile, " "); | |
339 | print_rtx (ENTRY_VALUE_EXP (in_rtx)); | |
340 | indent -= 2; | |
341 | } | |
e1a79915 RS |
342 | break; |
343 | ||
344 | case 'e': | |
bcdaba58 | 345 | do_e: |
e1a79915 | 346 | indent += 2; |
418e920f BS |
347 | if (i == 7 && INSN_P (in_rtx)) |
348 | /* Put REG_NOTES on their own line. */ | |
349 | fprintf (outfile, "\n%s%*s", | |
350 | print_rtx_head, indent * 2, ""); | |
e1a79915 RS |
351 | if (!sawclose) |
352 | fprintf (outfile, " "); | |
353 | print_rtx (XEXP (in_rtx, i)); | |
354 | indent -= 2; | |
355 | break; | |
356 | ||
357 | case 'E': | |
358 | case 'V': | |
359 | indent += 2; | |
360 | if (sawclose) | |
361 | { | |
d558416e | 362 | fprintf (outfile, "\n%s%*s", |
6a4d6760 | 363 | print_rtx_head, indent * 2, ""); |
e1a79915 RS |
364 | sawclose = 0; |
365 | } | |
7f11f1f9 | 366 | fputs (" [", outfile); |
e1a79915 RS |
367 | if (NULL != XVEC (in_rtx, i)) |
368 | { | |
369 | indent += 2; | |
370 | if (XVECLEN (in_rtx, i)) | |
371 | sawclose = 1; | |
372 | ||
373 | for (j = 0; j < XVECLEN (in_rtx, i); j++) | |
374 | print_rtx (XVECEXP (in_rtx, i, j)); | |
375 | ||
376 | indent -= 2; | |
377 | } | |
378 | if (sawclose) | |
5e74f966 | 379 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, ""); |
e1a79915 | 380 | |
7f11f1f9 | 381 | fputs ("]", outfile); |
e1a79915 RS |
382 | sawclose = 1; |
383 | indent -= 2; | |
384 | break; | |
385 | ||
5bf665df | 386 | case 'w': |
75b7557d MH |
387 | if (! flag_simple) |
388 | fprintf (outfile, " "); | |
734de8c8 | 389 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i)); |
75b7557d | 390 | if (! flag_simple) |
90ff44cf | 391 | fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]", |
3d57d7ce | 392 | (unsigned HOST_WIDE_INT) XWINT (in_rtx, i)); |
5bf665df RK |
393 | break; |
394 | ||
e1a79915 | 395 | case 'i': |
418e920f | 396 | if (i == 5 && INSN_P (in_rtx)) |
0435312e JH |
397 | { |
398 | #ifndef GENERATOR_FILE | |
5368224f | 399 | /* Pretty-print insn locations. Ignore scoping as it is mostly |
0435312e JH |
400 | redundant with line number information and do not print anything |
401 | when there is no location information available. */ | |
5368224f | 402 | if (INSN_LOCATION (in_rtx) && insn_file (in_rtx)) |
c3284718 RS |
403 | fprintf (outfile, " %s:%i", insn_file (in_rtx), |
404 | insn_line (in_rtx)); | |
da1e1503 AO |
405 | #endif |
406 | } | |
407 | else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS) | |
408 | { | |
409 | #ifndef GENERATOR_FILE | |
410 | fprintf (outfile, " %s:%i", | |
5368224f DC |
411 | LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)), |
412 | LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx))); | |
da1e1503 AO |
413 | #endif |
414 | } | |
415 | else if (i == 1 && GET_CODE (in_rtx) == ASM_INPUT) | |
416 | { | |
417 | #ifndef GENERATOR_FILE | |
418 | fprintf (outfile, " %s:%i", | |
5368224f DC |
419 | LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx)), |
420 | LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx))); | |
0435312e JH |
421 | #endif |
422 | } | |
4b4bf941 | 423 | else if (i == 6 && NOTE_P (in_rtx)) |
25cff714 RH |
424 | { |
425 | /* This field is only used for NOTE_INSN_DELETED_LABEL, and | |
426 | other times often contains garbage from INSN->NOTE death. */ | |
5619e52c JJ |
427 | if (NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_LABEL |
428 | || NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_DEBUG_LABEL) | |
25cff714 RH |
429 | fprintf (outfile, " %d", XINT (in_rtx, i)); |
430 | } | |
0fe60a1b RS |
431 | #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0 |
432 | else if (i == 1 | |
433 | && GET_CODE (in_rtx) == UNSPEC_VOLATILE | |
434 | && XINT (in_rtx, 1) >= 0 | |
435 | && XINT (in_rtx, 1) < NUM_UNSPECV_VALUES) | |
436 | fprintf (outfile, " %s", unspecv_strings[XINT (in_rtx, 1)]); | |
437 | #endif | |
438 | #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0 | |
439 | else if (i == 1 | |
440 | && (GET_CODE (in_rtx) == UNSPEC | |
441 | || GET_CODE (in_rtx) == UNSPEC_VOLATILE) | |
442 | && XINT (in_rtx, 1) >= 0 | |
443 | && XINT (in_rtx, 1) < NUM_UNSPEC_VALUES) | |
444 | fprintf (outfile, " %s", unspec_strings[XINT (in_rtx, 1)]); | |
445 | #endif | |
25cff714 RH |
446 | else |
447 | { | |
b3694847 | 448 | int value = XINT (in_rtx, i); |
25cff714 | 449 | const char *name; |
cf99a734 | 450 | |
94134f42 | 451 | #ifndef GENERATOR_FILE |
c62c5441 AM |
452 | if (REG_P (in_rtx) && (unsigned) value < FIRST_PSEUDO_REGISTER) |
453 | fprintf (outfile, " %d %s", value, reg_names[value]); | |
f8cfc6aa | 454 | else if (REG_P (in_rtx) |
c62c5441 | 455 | && (unsigned) value <= LAST_VIRTUAL_REGISTER) |
25cff714 RH |
456 | { |
457 | if (value == VIRTUAL_INCOMING_ARGS_REGNUM) | |
458 | fprintf (outfile, " %d virtual-incoming-args", value); | |
459 | else if (value == VIRTUAL_STACK_VARS_REGNUM) | |
460 | fprintf (outfile, " %d virtual-stack-vars", value); | |
461 | else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM) | |
462 | fprintf (outfile, " %d virtual-stack-dynamic", value); | |
463 | else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM) | |
464 | fprintf (outfile, " %d virtual-outgoing-args", value); | |
465 | else if (value == VIRTUAL_CFA_REGNUM) | |
466 | fprintf (outfile, " %d virtual-cfa", value); | |
32990d5b JJ |
467 | else if (value == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM) |
468 | fprintf (outfile, " %d virtual-preferred-stack-boundary", | |
469 | value); | |
25cff714 RH |
470 | else |
471 | fprintf (outfile, " %d virtual-reg-%d", value, | |
472 | value-FIRST_VIRTUAL_REGISTER); | |
473 | } | |
94134f42 ZW |
474 | else |
475 | #endif | |
476 | if (flag_dump_unnumbered | |
4b4bf941 | 477 | && (is_insn || NOTE_P (in_rtx))) |
25cff714 RH |
478 | fputc ('#', outfile); |
479 | else | |
480 | fprintf (outfile, " %d", value); | |
481 | ||
45c8116d | 482 | #ifndef GENERATOR_FILE |
f8cfc6aa | 483 | if (REG_P (in_rtx) && REG_ATTRS (in_rtx)) |
a560d4d4 JH |
484 | { |
485 | fputs (" [", outfile); | |
486 | if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx)) | |
487 | fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx)); | |
488 | if (REG_EXPR (in_rtx)) | |
489 | print_mem_expr (outfile, REG_EXPR (in_rtx)); | |
490 | ||
491 | if (REG_OFFSET (in_rtx)) | |
90ff44cf KG |
492 | fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC, |
493 | REG_OFFSET (in_rtx)); | |
a560d4d4 JH |
494 | fputs (" ]", outfile); |
495 | } | |
45c8116d | 496 | #endif |
a560d4d4 | 497 | |
25cff714 RH |
498 | if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i) |
499 | && XINT (in_rtx, i) >= 0 | |
500 | && (name = get_insn_name (XINT (in_rtx, i))) != NULL) | |
501 | fprintf (outfile, " {%s}", name); | |
502 | sawclose = 0; | |
503 | } | |
e1a79915 RS |
504 | break; |
505 | ||
506 | /* Print NOTE_INSN names rather than integer codes. */ | |
507 | ||
508 | case 'n': | |
a38e7aa5 | 509 | fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i))); |
e1a79915 RS |
510 | sawclose = 0; |
511 | break; | |
512 | ||
513 | case 'u': | |
514 | if (XEXP (in_rtx, i) != NULL) | |
9ec36da5 | 515 | { |
556ffcc5 RH |
516 | rtx sub = XEXP (in_rtx, i); |
517 | enum rtx_code subc = GET_CODE (sub); | |
518 | ||
be1bb652 RH |
519 | if (GET_CODE (in_rtx) == LABEL_REF) |
520 | { | |
521 | if (subc == NOTE | |
a38e7aa5 | 522 | && NOTE_KIND (sub) == NOTE_INSN_DELETED_LABEL) |
be1bb652 RH |
523 | { |
524 | if (flag_dump_unnumbered) | |
525 | fprintf (outfile, " [# deleted]"); | |
526 | else | |
527 | fprintf (outfile, " [%d deleted]", INSN_UID (sub)); | |
528 | sawclose = 0; | |
529 | break; | |
530 | } | |
531 | ||
532 | if (subc != CODE_LABEL) | |
533 | goto do_e; | |
534 | } | |
bcdaba58 | 535 | |
2aa7c49b AO |
536 | if (flag_dump_unnumbered |
537 | || (flag_dump_unnumbered_links && (i == 1 || i == 2) | |
538 | && (INSN_P (in_rtx) || NOTE_P (in_rtx) | |
539 | || LABEL_P (in_rtx) || BARRIER_P (in_rtx)))) | |
be1bb652 | 540 | fputs (" #", outfile); |
9ec36da5 | 541 | else |
556ffcc5 | 542 | fprintf (outfile, " %d", INSN_UID (sub)); |
9ec36da5 | 543 | } |
e1a79915 | 544 | else |
d5e3e85b | 545 | fputs (" 0", outfile); |
d64be5ec CH |
546 | sawclose = 0; |
547 | break; | |
548 | ||
0dfa1860 | 549 | case 't': |
24a7799e | 550 | #ifndef GENERATOR_FILE |
c8a27c40 JJ |
551 | if (i == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR) |
552 | print_mem_expr (outfile, DEBUG_IMPLICIT_PTR_DECL (in_rtx)); | |
ddb555ed JJ |
553 | else if (i == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF) |
554 | print_mem_expr (outfile, DEBUG_PARAMETER_REF_DECL (in_rtx)); | |
c8a27c40 JJ |
555 | else |
556 | dump_addr (outfile, " ", XTREE (in_rtx, i)); | |
24a7799e | 557 | #endif |
0dfa1860 MM |
558 | break; |
559 | ||
d64be5ec | 560 | case '*': |
735a0e33 | 561 | fputs (" Unknown", outfile); |
e1a79915 RS |
562 | sawclose = 0; |
563 | break; | |
564 | ||
ba4f7968 | 565 | case 'B': |
45c8116d | 566 | #ifndef GENERATOR_FILE |
ba4f7968 JH |
567 | if (XBBDEF (in_rtx, i)) |
568 | fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index); | |
45c8116d | 569 | #endif |
ba4f7968 JH |
570 | break; |
571 | ||
e1a79915 | 572 | default: |
0e61db61 | 573 | gcc_unreachable (); |
e1a79915 RS |
574 | } |
575 | ||
be1bb652 RH |
576 | switch (GET_CODE (in_rtx)) |
577 | { | |
6ebd2ef4 | 578 | #ifndef GENERATOR_FILE |
be1bb652 | 579 | case MEM: |
6ca5d1f6 JJ |
580 | if (__builtin_expect (final_insns_dump_p, false)) |
581 | fprintf (outfile, " ["); | |
582 | else | |
583 | fprintf (outfile, " [" HOST_WIDE_INT_PRINT_DEC, | |
584 | (HOST_WIDE_INT) MEM_ALIAS_SET (in_rtx)); | |
998d7deb RH |
585 | |
586 | if (MEM_EXPR (in_rtx)) | |
587 | print_mem_expr (outfile, MEM_EXPR (in_rtx)); | |
738cc472 | 588 | |
527210c4 RS |
589 | if (MEM_OFFSET_KNOWN_P (in_rtx)) |
590 | fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC, MEM_OFFSET (in_rtx)); | |
738cc472 | 591 | |
f5541398 RS |
592 | if (MEM_SIZE_KNOWN_P (in_rtx)) |
593 | fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC, MEM_SIZE (in_rtx)); | |
738cc472 RK |
594 | |
595 | if (MEM_ALIGN (in_rtx) != 1) | |
596 | fprintf (outfile, " A%u", MEM_ALIGN (in_rtx)); | |
597 | ||
09e881c9 BE |
598 | if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx))) |
599 | fprintf (outfile, " AS%u", MEM_ADDR_SPACE (in_rtx)); | |
600 | ||
738cc472 | 601 | fputc (']', outfile); |
be1bb652 | 602 | break; |
5a0a1a66 | 603 | |
be1bb652 RH |
604 | case CONST_DOUBLE: |
605 | if (FLOAT_MODE_P (GET_MODE (in_rtx))) | |
606 | { | |
4fdbcfb2 | 607 | char s[60]; |
b216cd4a | 608 | |
da6eec72 RH |
609 | real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), |
610 | sizeof (s), 0, 1); | |
69bd00e6 RH |
611 | fprintf (outfile, " %s", s); |
612 | ||
da6eec72 RH |
613 | real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), |
614 | sizeof (s), 0, 1); | |
b216cd4a | 615 | fprintf (outfile, " [%s]", s); |
be1bb652 RH |
616 | } |
617 | break; | |
800d5c9e RH |
618 | #endif |
619 | ||
be1bb652 | 620 | case CODE_LABEL: |
c3c63936 | 621 | fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx)); |
0dc36574 ZW |
622 | switch (LABEL_KIND (in_rtx)) |
623 | { | |
624 | case LABEL_NORMAL: break; | |
625 | case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break; | |
626 | case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break; | |
627 | case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break; | |
e16acfcd | 628 | default: gcc_unreachable (); |
0dc36574 | 629 | } |
be1bb652 RH |
630 | break; |
631 | ||
be1bb652 RH |
632 | default: |
633 | break; | |
8cd0faaf | 634 | } |
c3c63936 | 635 | |
a27a5de9 SB |
636 | fputc (')', outfile); |
637 | sawclose = 1; | |
e1a79915 RS |
638 | } |
639 | ||
1d79197a RK |
640 | /* Print an rtx on the current line of FILE. Initially indent IND |
641 | characters. */ | |
642 | ||
643 | void | |
f7d504c2 | 644 | print_inline_rtx (FILE *outf, const_rtx x, int ind) |
1d79197a | 645 | { |
956d6950 JL |
646 | int oldsaw = sawclose; |
647 | int oldindent = indent; | |
648 | ||
1d79197a RK |
649 | sawclose = 0; |
650 | indent = ind; | |
651 | outfile = outf; | |
652 | print_rtx (x); | |
956d6950 JL |
653 | sawclose = oldsaw; |
654 | indent = oldindent; | |
1d79197a RK |
655 | } |
656 | ||
e1a79915 RS |
657 | /* Call this function from the debugger to see what X looks like. */ |
658 | ||
24e47c76 | 659 | DEBUG_FUNCTION void |
f7d504c2 | 660 | debug_rtx (const_rtx x) |
e1a79915 RS |
661 | { |
662 | outfile = stderr; | |
7f11f1f9 | 663 | sawclose = 0; |
e1a79915 RS |
664 | print_rtx (x); |
665 | fprintf (stderr, "\n"); | |
666 | } | |
667 | ||
7b3b6ae4 LC |
668 | /* Dump rtx REF. */ |
669 | ||
670 | DEBUG_FUNCTION void | |
671 | debug (const rtx_def &ref) | |
672 | { | |
673 | debug_rtx (&ref); | |
674 | } | |
675 | ||
676 | DEBUG_FUNCTION void | |
677 | debug (const rtx_def *ptr) | |
678 | { | |
679 | if (ptr) | |
680 | debug (*ptr); | |
681 | else | |
682 | fprintf (stderr, "<nil>\n"); | |
683 | } | |
684 | ||
716f003f DE |
685 | /* Count of rtx's to print with debug_rtx_list. |
686 | This global exists because gdb user defined commands have no arguments. */ | |
687 | ||
24e47c76 | 688 | DEBUG_VARIABLE int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */ |
716f003f DE |
689 | |
690 | /* Call this function to print list from X on. | |
691 | ||
692 | N is a count of the rtx's to print. Positive values print from the specified | |
693 | rtx on. Negative values print a window around the rtx. | |
694 | EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */ | |
695 | ||
24e47c76 | 696 | DEBUG_FUNCTION void |
f7d504c2 | 697 | debug_rtx_list (const_rtx x, int n) |
716f003f DE |
698 | { |
699 | int i,count; | |
f7d504c2 | 700 | const_rtx insn; |
716f003f DE |
701 | |
702 | count = n == 0 ? 1 : n < 0 ? -n : n; | |
703 | ||
704 | /* If we are printing a window, back up to the start. */ | |
705 | ||
706 | if (n < 0) | |
707 | for (i = count / 2; i > 0; i--) | |
708 | { | |
709 | if (PREV_INSN (x) == 0) | |
710 | break; | |
711 | x = PREV_INSN (x); | |
712 | } | |
713 | ||
714 | for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn)) | |
7f11f1f9 AS |
715 | { |
716 | debug_rtx (insn); | |
717 | fprintf (stderr, "\n"); | |
718 | } | |
716f003f DE |
719 | } |
720 | ||
4c85a96d RH |
721 | /* Call this function to print an rtx list from START to END inclusive. */ |
722 | ||
24e47c76 | 723 | DEBUG_FUNCTION void |
f7d504c2 | 724 | debug_rtx_range (const_rtx start, const_rtx end) |
4c85a96d RH |
725 | { |
726 | while (1) | |
727 | { | |
728 | debug_rtx (start); | |
7f11f1f9 | 729 | fprintf (stderr, "\n"); |
4c85a96d RH |
730 | if (!start || start == end) |
731 | break; | |
732 | start = NEXT_INSN (start); | |
733 | } | |
734 | } | |
735 | ||
716f003f DE |
736 | /* Call this function to search an rtx list to find one with insn uid UID, |
737 | and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT. | |
738 | The found insn is returned to enable further debugging analysis. */ | |
739 | ||
24e47c76 | 740 | DEBUG_FUNCTION const_rtx |
f7d504c2 | 741 | debug_rtx_find (const_rtx x, int uid) |
716f003f DE |
742 | { |
743 | while (x != 0 && INSN_UID (x) != uid) | |
744 | x = NEXT_INSN (x); | |
745 | if (x != 0) | |
746 | { | |
747 | debug_rtx_list (x, debug_rtx_count); | |
748 | return x; | |
749 | } | |
750 | else | |
751 | { | |
752 | fprintf (stderr, "insn uid %d not found\n", uid); | |
753 | return 0; | |
754 | } | |
755 | } | |
756 | ||
e1a79915 RS |
757 | /* External entry point for printing a chain of insns |
758 | starting with RTX_FIRST onto file OUTF. | |
759 | A blank line separates insns. | |
760 | ||
761 | If RTX_FIRST is not an insn, then it alone is printed, with no newline. */ | |
762 | ||
763 | void | |
f7d504c2 | 764 | print_rtl (FILE *outf, const_rtx rtx_first) |
e1a79915 | 765 | { |
f7d504c2 | 766 | const_rtx tmp_rtx; |
9dbe7947 | 767 | |
e1a79915 RS |
768 | outfile = outf; |
769 | sawclose = 0; | |
770 | ||
771 | if (rtx_first == 0) | |
c349e40b SC |
772 | { |
773 | fputs (print_rtx_head, outf); | |
774 | fputs ("(nil)\n", outf); | |
775 | } | |
e1a79915 RS |
776 | else |
777 | switch (GET_CODE (rtx_first)) | |
778 | { | |
779 | case INSN: | |
780 | case JUMP_INSN: | |
781 | case CALL_INSN: | |
782 | case NOTE: | |
783 | case CODE_LABEL: | |
39718607 | 784 | case JUMP_TABLE_DATA: |
e1a79915 | 785 | case BARRIER: |
9dbe7947 JH |
786 | for (tmp_rtx = rtx_first; tmp_rtx != 0; tmp_rtx = NEXT_INSN (tmp_rtx)) |
787 | { | |
788 | fputs (print_rtx_head, outfile); | |
789 | print_rtx (tmp_rtx); | |
790 | fprintf (outfile, "\n"); | |
791 | } | |
e1a79915 RS |
792 | break; |
793 | ||
794 | default: | |
6a4d6760 | 795 | fputs (print_rtx_head, outfile); |
e1a79915 RS |
796 | print_rtx (rtx_first); |
797 | } | |
798 | } | |
3e28fe44 MM |
799 | |
800 | /* Like print_rtx, except specify a file. */ | |
b707b450 | 801 | /* Return nonzero if we actually printed anything. */ |
3e28fe44 | 802 | |
b707b450 | 803 | int |
f7d504c2 | 804 | print_rtl_single (FILE *outf, const_rtx x) |
3e28fe44 | 805 | { |
df92c640 SB |
806 | return print_rtl_single_with_indent (outf, x, 0); |
807 | } | |
808 | ||
809 | /* Like print_rtl_single, except specify a file and indentation. */ | |
810 | ||
811 | int | |
812 | print_rtl_single_with_indent (FILE *outf, const_rtx x, int ind) | |
813 | { | |
814 | int old_indent = indent; | |
815 | char *s_indent = (char *) alloca ((size_t) ind + 1); | |
816 | memset ((void *) s_indent, ' ', (size_t) ind); | |
817 | s_indent[ind] = '\0'; | |
818 | ||
819 | indent = ind; | |
3e28fe44 MM |
820 | outfile = outf; |
821 | sawclose = 0; | |
df92c640 | 822 | fputs (s_indent, outfile); |
297e9b46 KZ |
823 | fputs (print_rtx_head, outfile); |
824 | print_rtx (x); | |
825 | putc ('\n', outf); | |
df92c640 | 826 | indent = old_indent; |
297e9b46 | 827 | return 1; |
3e28fe44 | 828 | } |
75b7557d MH |
829 | |
830 | ||
831 | /* Like print_rtl except without all the detail; for example, | |
832 | if RTX is a CONST_INT then print in decimal format. */ | |
833 | ||
834 | void | |
f7d504c2 | 835 | print_simple_rtl (FILE *outf, const_rtx x) |
75b7557d MH |
836 | { |
837 | flag_simple = 1; | |
838 | print_rtl (outf, x); | |
839 | flag_simple = 0; | |
840 | } |