]>
Commit | Line | Data |
---|---|---|
bccafa26 | 1 | /* Print RTL for GCC. |
978b9403 | 2 | Copyright (C) 1987, 1988, 1992, 1997, 1998, 1999, 2000, 2002, 2003, |
71e45bc2 | 3 | 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012 |
7014838c | 4 | Free Software Foundation, Inc. |
0b8a940f | 5 | |
f12b58b3 | 6 | This file is part of GCC. |
0b8a940f | 7 | |
f12b58b3 | 8 | GCC is free software; you can redistribute it and/or modify it under |
9 | the terms of the GNU General Public License as published by the Free | |
8c4c00c1 | 10 | Software Foundation; either version 3, or (at your option) any later |
f12b58b3 | 11 | version. |
0b8a940f | 12 | |
f12b58b3 | 13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
0b8a940f | 17 | |
18 | You should have received a copy of the GNU General Public License | |
8c4c00c1 | 19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
0b8a940f | 21 | |
690ff52f | 22 | /* This file is compiled twice: once for the generator programs, |
23 | once for the compiler. */ | |
24 | #ifdef GENERATOR_FILE | |
25 | #include "bconfig.h" | |
26 | #else | |
0b8a940f | 27 | #include "config.h" |
690ff52f | 28 | #endif |
29 | ||
405711de | 30 | #include "system.h" |
805e22b2 | 31 | #include "coretypes.h" |
32 | #include "tm.h" | |
0b8a940f | 33 | #include "rtl.h" |
96216d37 | 34 | |
690ff52f | 35 | /* These headers all define things which are not available in |
36 | generator programs. */ | |
37 | #ifndef GENERATOR_FILE | |
96216d37 | 38 | #include "tree.h" |
fd63ca43 | 39 | #include "flags.h" |
d6cb6164 | 40 | #include "hard-reg-set.h" |
71caadc0 | 41 | #include "basic-block.h" |
3a443843 | 42 | #include "diagnostic.h" |
ce084dfc | 43 | #include "tree-pretty-print.h" |
9845d120 | 44 | #include "cselib.h" |
b9ed1410 | 45 | #include "dumpfile.h" /* for dump_flags */ |
d53ccf7b | 46 | #include "dwarf2out.h" |
690ff52f | 47 | #endif |
2cc0ea94 | 48 | |
0b8a940f | 49 | static FILE *outfile; |
50 | ||
0b8a940f | 51 | static int sawclose = 0; |
52 | ||
6a71e6dc | 53 | static int indent; |
54 | ||
dd9b9fc5 | 55 | static void print_rtx (const_rtx); |
e2d60f26 | 56 | |
af5e5fd0 | 57 | /* String printed at beginning of each RTL when it is dumped. |
58 | This string is set to ASM_COMMENT_START when the RTL is dumped in | |
59 | the assembly output file. */ | |
52fd6db3 | 60 | const char *print_rtx_head = ""; |
af5e5fd0 | 61 | |
0f8defe5 | 62 | #ifdef GENERATOR_FILE |
63 | /* These are defined from the .opt file when not used in generator | |
64 | programs. */ | |
65 | ||
60ad3b0e | 66 | /* Nonzero means suppress output of instruction numbers |
67 | in debugging dumps. | |
fd63ca43 | 68 | This must be defined here so that programs like gencodes can be linked. */ |
9e042f31 | 69 | int flag_dump_unnumbered = 0; |
fd63ca43 | 70 | |
0a59e439 | 71 | /* Nonzero means suppress output of instruction numbers for previous |
72 | and next insns in debugging dumps. | |
73 | This must be defined here so that programs like gencodes can be linked. */ | |
74 | int flag_dump_unnumbered_links = 0; | |
0f8defe5 | 75 | #endif |
0a59e439 | 76 | |
ad4b6bdf | 77 | /* Nonzero means use simplified format without flags, modes, etc. */ |
78 | int flag_simple = 0; | |
79 | ||
690ff52f | 80 | #ifndef GENERATOR_FILE |
b10dbbca | 81 | void |
dd9b9fc5 | 82 | print_mem_expr (FILE *outfile, const_tree expr) |
b10dbbca | 83 | { |
3a443843 | 84 | fputc (' ', outfile); |
00753696 | 85 | print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags); |
b10dbbca | 86 | } |
690ff52f | 87 | #endif |
b10dbbca | 88 | |
0b8a940f | 89 | /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */ |
90 | ||
91 | static void | |
dd9b9fc5 | 92 | print_rtx (const_rtx in_rtx) |
0b8a940f | 93 | { |
19cb6b50 | 94 | int i = 0; |
95 | int j; | |
96 | const char *format_ptr; | |
97 | int is_insn; | |
0b8a940f | 98 | |
99 | if (sawclose) | |
100 | { | |
ad4b6bdf | 101 | if (flag_simple) |
102 | fputc (' ', outfile); | |
103 | else | |
9c59a260 | 104 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, ""); |
0b8a940f | 105 | sawclose = 0; |
106 | } | |
107 | ||
108 | if (in_rtx == 0) | |
109 | { | |
3eaf50a4 | 110 | fputs ("(nil)", outfile); |
0b8a940f | 111 | sawclose = 1; |
112 | return; | |
113 | } | |
9c59a260 | 114 | else if (GET_CODE (in_rtx) > NUM_RTX_CODE) |
115 | { | |
434b69b9 | 116 | fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx), |
117 | print_rtx_head, indent * 2, ""); | |
9c59a260 | 118 | sawclose = 1; |
119 | return; | |
120 | } | |
0b8a940f | 121 | |
9c59a260 | 122 | is_insn = INSN_P (in_rtx); |
3eaf50a4 | 123 | |
f4b3647a | 124 | /* Print name of expression code. */ |
125 | if (flag_simple && CONST_INT_P (in_rtx)) | |
126 | fputc ('(', outfile); | |
3eaf50a4 | 127 | else |
f4b3647a | 128 | fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx))); |
195731ad | 129 | |
f4b3647a | 130 | if (! flag_simple) |
131 | { | |
132 | if (RTX_FLAG (in_rtx, in_struct)) | |
133 | fputs ("/s", outfile); | |
ad4b6bdf | 134 | |
f4b3647a | 135 | if (RTX_FLAG (in_rtx, volatil)) |
136 | fputs ("/v", outfile); | |
195731ad | 137 | |
f4b3647a | 138 | if (RTX_FLAG (in_rtx, unchanging)) |
139 | fputs ("/u", outfile); | |
195731ad | 140 | |
f4b3647a | 141 | if (RTX_FLAG (in_rtx, frame_related)) |
142 | fputs ("/f", outfile); | |
195731ad | 143 | |
f4b3647a | 144 | if (RTX_FLAG (in_rtx, jump)) |
145 | fputs ("/j", outfile); | |
195731ad | 146 | |
f4b3647a | 147 | if (RTX_FLAG (in_rtx, call)) |
148 | fputs ("/c", outfile); | |
ad4b6bdf | 149 | |
f4b3647a | 150 | if (RTX_FLAG (in_rtx, return_val)) |
151 | fputs ("/i", outfile); | |
4ee9c684 | 152 | |
f4b3647a | 153 | /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */ |
154 | if ((GET_CODE (in_rtx) == EXPR_LIST | |
155 | || GET_CODE (in_rtx) == INSN_LIST) | |
156 | && (int)GET_MODE (in_rtx) < REG_NOTE_MAX) | |
157 | fprintf (outfile, ":%s", | |
158 | GET_REG_NOTE_NAME (GET_MODE (in_rtx))); | |
99caba0f | 159 | |
f4b3647a | 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))); | |
9845d120 | 163 | |
164 | #ifndef GENERATOR_FILE | |
f4b3647a | 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); | |
3eaf50a4 | 178 | } |
f4b3647a | 179 | #endif |
0b8a940f | 180 | } |
181 | ||
76834cda | 182 | #ifndef GENERATOR_FILE |
78f1962f | 183 | if (CONST_DOUBLE_AS_FLOAT_P (in_rtx)) |
76834cda | 184 | i = 5; |
185 | #endif | |
186 | ||
3eaf50a4 | 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; | |
3eaf50a4 | 190 | for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++) |
0b8a940f | 191 | switch (*format_ptr++) |
192 | { | |
9abd2cd7 | 193 | const char *str; |
194 | ||
195 | case 'T': | |
196 | str = XTMPL (in_rtx, i); | |
197 | goto string; | |
198 | ||
0b8a940f | 199 | case 'S': |
200 | case 's': | |
9abd2cd7 | 201 | str = XSTR (in_rtx, i); |
202 | string: | |
203 | ||
204 | if (str == 0) | |
f4b3647a | 205 | fputs (" \"\"", outfile); |
0b8a940f | 206 | else |
f4b3647a | 207 | fprintf (outfile, " (\"%s\")", str); |
0b8a940f | 208 | sawclose = 1; |
209 | break; | |
210 | ||
a4070a91 | 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. */ | |
0b8a940f | 214 | case '0': |
8ad4c111 | 215 | if (i == 1 && REG_P (in_rtx)) |
22cf44bc | 216 | { |
217 | if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx)) | |
218 | fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx)); | |
22cf44bc | 219 | } |
001be062 | 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) | |
3eb9ad16 | 225 | fprintf (outfile, " [flags %#x]", flags); |
001be062 | 226 | } |
227 | else if (i == 2 && GET_CODE (in_rtx) == SYMBOL_REF) | |
228 | { | |
229 | tree decl = SYMBOL_REF_DECL (in_rtx); | |
230 | if (decl) | |
00753696 | 231 | print_node_brief (outfile, "", decl, dump_flags); |
001be062 | 232 | } |
233 | #endif | |
6d7dc5b9 | 234 | else if (i == 4 && NOTE_P (in_rtx)) |
a4070a91 | 235 | { |
ad4583d9 | 236 | switch (NOTE_KIND (in_rtx)) |
cc102912 | 237 | { |
89cfe6e5 | 238 | case NOTE_INSN_EH_REGION_BEG: |
239 | case NOTE_INSN_EH_REGION_END: | |
dbbc6ff0 | 240 | if (flag_dump_unnumbered) |
241 | fprintf (outfile, " #"); | |
242 | else | |
243 | fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx)); | |
cc102912 | 244 | sawclose = 1; |
89cfe6e5 | 245 | break; |
246 | ||
247 | case NOTE_INSN_BLOCK_BEG: | |
248 | case NOTE_INSN_BLOCK_END: | |
969239ad | 249 | #ifndef GENERATOR_FILE |
250 | dump_addr (outfile, " ", NOTE_BLOCK (in_rtx)); | |
251 | #endif | |
a4070a91 | 252 | sawclose = 1; |
89cfe6e5 | 253 | break; |
254 | ||
89cfe6e5 | 255 | case NOTE_INSN_BASIC_BLOCK: |
256 | { | |
690ff52f | 257 | #ifndef GENERATOR_FILE |
89cfe6e5 | 258 | basic_block bb = NOTE_BASIC_BLOCK (in_rtx); |
259 | if (bb != 0) | |
b3d6de89 | 260 | fprintf (outfile, " [bb %d]", bb->index); |
690ff52f | 261 | #endif |
89cfe6e5 | 262 | break; |
263 | } | |
264 | ||
74b0991d | 265 | case NOTE_INSN_DELETED_LABEL: |
63f5ad44 | 266 | case NOTE_INSN_DELETED_DEBUG_LABEL: |
7bd3dcc4 | 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 | } | |
74b0991d | 274 | break; |
275 | ||
1897b881 | 276 | case NOTE_INSN_SWITCH_TEXT_SECTIONS: |
4f18499c | 277 | { |
690ff52f | 278 | #ifndef GENERATOR_FILE |
4f18499c | 279 | basic_block bb = NOTE_BASIC_BLOCK (in_rtx); |
280 | if (bb != 0) | |
281 | fprintf (outfile, " [bb %d]", bb->index); | |
690ff52f | 282 | #endif |
4f18499c | 283 | break; |
284 | } | |
48e1416a | 285 | |
5923a5e7 | 286 | case NOTE_INSN_VAR_LOCATION: |
4143d08b | 287 | case NOTE_INSN_CALL_ARG_LOCATION: |
690ff52f | 288 | #ifndef GENERATOR_FILE |
9845d120 | 289 | fputc (' ', outfile); |
290 | print_rtx (NOTE_VAR_LOCATION (in_rtx)); | |
690ff52f | 291 | #endif |
5923a5e7 | 292 | break; |
293 | ||
d53ccf7b | 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 | ||
89cfe6e5 | 302 | default: |
ad4583d9 | 303 | break; |
a4070a91 | 304 | } |
305 | } | |
59a373e1 | 306 | else if (i == 8 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL) |
4115ac36 | 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"); | |
9cb2517e | 312 | else if (GET_CODE (JUMP_LABEL (in_rtx)) == SIMPLE_RETURN) |
313 | fprintf (outfile, "simple_return"); | |
4115ac36 | 314 | else |
315 | fprintf (outfile, "%d", INSN_UID (JUMP_LABEL (in_rtx))); | |
316 | } | |
9845d120 | 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 | ||
01df1184 | 322 | fprintf (outfile, " %u:%u", val->uid, val->hash); |
9845d120 | 323 | dump_addr (outfile, " @", in_rtx); |
324 | dump_addr (outfile, "/", (void*)val); | |
688ff29b | 325 | #endif |
326 | } | |
327 | else if (i == 0 && GET_CODE (in_rtx) == DEBUG_EXPR) | |
328 | { | |
329 | #ifndef GENERATOR_FILE | |
23dd51cb | 330 | fprintf (outfile, " D#%i", |
331 | DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx))); | |
9845d120 | 332 | #endif |
333 | } | |
a5701bde | 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 | } | |
0b8a940f | 342 | break; |
343 | ||
344 | case 'e': | |
0922b1b8 | 345 | do_e: |
0b8a940f | 346 | indent += 2; |
3a55c112 | 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, ""); | |
0b8a940f | 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 | { | |
232309ab | 362 | fprintf (outfile, "\n%s%*s", |
195731ad | 363 | print_rtx_head, indent * 2, ""); |
0b8a940f | 364 | sawclose = 0; |
365 | } | |
68d9a03d | 366 | fputs (" [", outfile); |
0b8a940f | 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) | |
9c59a260 | 379 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, ""); |
0b8a940f | 380 | |
68d9a03d | 381 | fputs ("]", outfile); |
0b8a940f | 382 | sawclose = 1; |
383 | indent -= 2; | |
384 | break; | |
385 | ||
2d618a37 | 386 | case 'w': |
ad4b6bdf | 387 | if (! flag_simple) |
388 | fprintf (outfile, " "); | |
c6946bfc | 389 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i)); |
ad4b6bdf | 390 | if (! flag_simple) |
85aa12f7 | 391 | fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]", |
7df7561b | 392 | (unsigned HOST_WIDE_INT) XWINT (in_rtx, i)); |
2d618a37 | 393 | break; |
394 | ||
0b8a940f | 395 | case 'i': |
3a55c112 | 396 | if (i == 5 && INSN_P (in_rtx)) |
13751393 | 397 | { |
398 | #ifndef GENERATOR_FILE | |
5169661d | 399 | /* Pretty-print insn locations. Ignore scoping as it is mostly |
13751393 | 400 | redundant with line number information and do not print anything |
401 | when there is no location information available. */ | |
5169661d | 402 | if (INSN_LOCATION (in_rtx) && insn_file (in_rtx)) |
13751393 | 403 | fprintf(outfile, " %s:%i", insn_file (in_rtx), insn_line (in_rtx)); |
1500062c | 404 | #endif |
405 | } | |
406 | else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS) | |
407 | { | |
408 | #ifndef GENERATOR_FILE | |
409 | fprintf (outfile, " %s:%i", | |
5169661d | 410 | LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)), |
411 | LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx))); | |
1500062c | 412 | #endif |
413 | } | |
414 | else if (i == 1 && GET_CODE (in_rtx) == ASM_INPUT) | |
415 | { | |
416 | #ifndef GENERATOR_FILE | |
417 | fprintf (outfile, " %s:%i", | |
5169661d | 418 | LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx)), |
419 | LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx))); | |
13751393 | 420 | #endif |
421 | } | |
6d7dc5b9 | 422 | else if (i == 6 && NOTE_P (in_rtx)) |
66b6f98b | 423 | { |
424 | /* This field is only used for NOTE_INSN_DELETED_LABEL, and | |
425 | other times often contains garbage from INSN->NOTE death. */ | |
63f5ad44 | 426 | if (NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_LABEL |
427 | || NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_DEBUG_LABEL) | |
66b6f98b | 428 | fprintf (outfile, " %d", XINT (in_rtx, i)); |
429 | } | |
15f255bd | 430 | #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0 |
431 | else if (i == 1 | |
432 | && GET_CODE (in_rtx) == UNSPEC_VOLATILE | |
433 | && XINT (in_rtx, 1) >= 0 | |
434 | && XINT (in_rtx, 1) < NUM_UNSPECV_VALUES) | |
435 | fprintf (outfile, " %s", unspecv_strings[XINT (in_rtx, 1)]); | |
436 | #endif | |
437 | #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0 | |
438 | else if (i == 1 | |
439 | && (GET_CODE (in_rtx) == UNSPEC | |
440 | || GET_CODE (in_rtx) == UNSPEC_VOLATILE) | |
441 | && XINT (in_rtx, 1) >= 0 | |
442 | && XINT (in_rtx, 1) < NUM_UNSPEC_VALUES) | |
443 | fprintf (outfile, " %s", unspec_strings[XINT (in_rtx, 1)]); | |
444 | #endif | |
66b6f98b | 445 | else |
446 | { | |
19cb6b50 | 447 | int value = XINT (in_rtx, i); |
66b6f98b | 448 | const char *name; |
2cc0ea94 | 449 | |
15460c97 | 450 | #ifndef GENERATOR_FILE |
3546bf8d | 451 | if (REG_P (in_rtx) && (unsigned) value < FIRST_PSEUDO_REGISTER) |
452 | fprintf (outfile, " %d %s", value, reg_names[value]); | |
8ad4c111 | 453 | else if (REG_P (in_rtx) |
3546bf8d | 454 | && (unsigned) value <= LAST_VIRTUAL_REGISTER) |
66b6f98b | 455 | { |
456 | if (value == VIRTUAL_INCOMING_ARGS_REGNUM) | |
457 | fprintf (outfile, " %d virtual-incoming-args", value); | |
458 | else if (value == VIRTUAL_STACK_VARS_REGNUM) | |
459 | fprintf (outfile, " %d virtual-stack-vars", value); | |
460 | else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM) | |
461 | fprintf (outfile, " %d virtual-stack-dynamic", value); | |
462 | else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM) | |
463 | fprintf (outfile, " %d virtual-outgoing-args", value); | |
464 | else if (value == VIRTUAL_CFA_REGNUM) | |
465 | fprintf (outfile, " %d virtual-cfa", value); | |
60778e62 | 466 | else if (value == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM) |
467 | fprintf (outfile, " %d virtual-preferred-stack-boundary", | |
468 | value); | |
66b6f98b | 469 | else |
470 | fprintf (outfile, " %d virtual-reg-%d", value, | |
471 | value-FIRST_VIRTUAL_REGISTER); | |
472 | } | |
15460c97 | 473 | else |
474 | #endif | |
475 | if (flag_dump_unnumbered | |
6d7dc5b9 | 476 | && (is_insn || NOTE_P (in_rtx))) |
66b6f98b | 477 | fputc ('#', outfile); |
478 | else | |
479 | fprintf (outfile, " %d", value); | |
480 | ||
690ff52f | 481 | #ifndef GENERATOR_FILE |
8ad4c111 | 482 | if (REG_P (in_rtx) && REG_ATTRS (in_rtx)) |
ca74b940 | 483 | { |
484 | fputs (" [", outfile); | |
485 | if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx)) | |
486 | fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx)); | |
487 | if (REG_EXPR (in_rtx)) | |
488 | print_mem_expr (outfile, REG_EXPR (in_rtx)); | |
489 | ||
490 | if (REG_OFFSET (in_rtx)) | |
85aa12f7 | 491 | fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC, |
492 | REG_OFFSET (in_rtx)); | |
ca74b940 | 493 | fputs (" ]", outfile); |
494 | } | |
690ff52f | 495 | #endif |
ca74b940 | 496 | |
66b6f98b | 497 | if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i) |
498 | && XINT (in_rtx, i) >= 0 | |
499 | && (name = get_insn_name (XINT (in_rtx, i))) != NULL) | |
500 | fprintf (outfile, " {%s}", name); | |
501 | sawclose = 0; | |
502 | } | |
0b8a940f | 503 | break; |
504 | ||
505 | /* Print NOTE_INSN names rather than integer codes. */ | |
506 | ||
507 | case 'n': | |
ad4583d9 | 508 | fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i))); |
0b8a940f | 509 | sawclose = 0; |
510 | break; | |
511 | ||
512 | case 'u': | |
513 | if (XEXP (in_rtx, i) != NULL) | |
9e042f31 | 514 | { |
67b87c97 | 515 | rtx sub = XEXP (in_rtx, i); |
516 | enum rtx_code subc = GET_CODE (sub); | |
517 | ||
74b0991d | 518 | if (GET_CODE (in_rtx) == LABEL_REF) |
519 | { | |
520 | if (subc == NOTE | |
ad4583d9 | 521 | && NOTE_KIND (sub) == NOTE_INSN_DELETED_LABEL) |
74b0991d | 522 | { |
523 | if (flag_dump_unnumbered) | |
524 | fprintf (outfile, " [# deleted]"); | |
525 | else | |
526 | fprintf (outfile, " [%d deleted]", INSN_UID (sub)); | |
527 | sawclose = 0; | |
528 | break; | |
529 | } | |
530 | ||
531 | if (subc != CODE_LABEL) | |
532 | goto do_e; | |
533 | } | |
0922b1b8 | 534 | |
0a59e439 | 535 | if (flag_dump_unnumbered |
536 | || (flag_dump_unnumbered_links && (i == 1 || i == 2) | |
537 | && (INSN_P (in_rtx) || NOTE_P (in_rtx) | |
538 | || LABEL_P (in_rtx) || BARRIER_P (in_rtx)))) | |
74b0991d | 539 | fputs (" #", outfile); |
9e042f31 | 540 | else |
67b87c97 | 541 | fprintf (outfile, " %d", INSN_UID (sub)); |
9e042f31 | 542 | } |
0b8a940f | 543 | else |
af40d96f | 544 | fputs (" 0", outfile); |
50118dc3 | 545 | sawclose = 0; |
546 | break; | |
547 | ||
a3426c4c | 548 | case 't': |
969239ad | 549 | #ifndef GENERATOR_FILE |
f9c61ef7 | 550 | if (i == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR) |
551 | print_mem_expr (outfile, DEBUG_IMPLICIT_PTR_DECL (in_rtx)); | |
841424cc | 552 | else if (i == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF) |
553 | print_mem_expr (outfile, DEBUG_PARAMETER_REF_DECL (in_rtx)); | |
f9c61ef7 | 554 | else |
555 | dump_addr (outfile, " ", XTREE (in_rtx, i)); | |
969239ad | 556 | #endif |
a3426c4c | 557 | break; |
558 | ||
50118dc3 | 559 | case '*': |
3eaf50a4 | 560 | fputs (" Unknown", outfile); |
0b8a940f | 561 | sawclose = 0; |
562 | break; | |
563 | ||
ab87d1bc | 564 | case 'B': |
690ff52f | 565 | #ifndef GENERATOR_FILE |
ab87d1bc | 566 | if (XBBDEF (in_rtx, i)) |
567 | fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index); | |
690ff52f | 568 | #endif |
ab87d1bc | 569 | break; |
570 | ||
0b8a940f | 571 | default: |
1fa3a8f6 | 572 | gcc_unreachable (); |
0b8a940f | 573 | } |
574 | ||
74b0991d | 575 | switch (GET_CODE (in_rtx)) |
576 | { | |
52717541 | 577 | #ifndef GENERATOR_FILE |
74b0991d | 578 | case MEM: |
090bd40b | 579 | if (__builtin_expect (final_insns_dump_p, false)) |
580 | fprintf (outfile, " ["); | |
581 | else | |
582 | fprintf (outfile, " [" HOST_WIDE_INT_PRINT_DEC, | |
583 | (HOST_WIDE_INT) MEM_ALIAS_SET (in_rtx)); | |
b10dbbca | 584 | |
585 | if (MEM_EXPR (in_rtx)) | |
586 | print_mem_expr (outfile, MEM_EXPR (in_rtx)); | |
96216d37 | 587 | |
da443c27 | 588 | if (MEM_OFFSET_KNOWN_P (in_rtx)) |
589 | fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC, MEM_OFFSET (in_rtx)); | |
96216d37 | 590 | |
5b2a69fa | 591 | if (MEM_SIZE_KNOWN_P (in_rtx)) |
592 | fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC, MEM_SIZE (in_rtx)); | |
96216d37 | 593 | |
594 | if (MEM_ALIGN (in_rtx) != 1) | |
595 | fprintf (outfile, " A%u", MEM_ALIGN (in_rtx)); | |
596 | ||
bd1a81f7 | 597 | if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx))) |
598 | fprintf (outfile, " AS%u", MEM_ADDR_SPACE (in_rtx)); | |
599 | ||
96216d37 | 600 | fputc (']', outfile); |
74b0991d | 601 | break; |
a1355ed3 | 602 | |
74b0991d | 603 | case CONST_DOUBLE: |
604 | if (FLOAT_MODE_P (GET_MODE (in_rtx))) | |
605 | { | |
98367734 | 606 | char s[60]; |
badfe841 | 607 | |
c7fbc741 | 608 | real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), |
609 | sizeof (s), 0, 1); | |
76834cda | 610 | fprintf (outfile, " %s", s); |
611 | ||
c7fbc741 | 612 | real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), |
613 | sizeof (s), 0, 1); | |
badfe841 | 614 | fprintf (outfile, " [%s]", s); |
74b0991d | 615 | } |
616 | break; | |
56609c6c | 617 | #endif |
618 | ||
74b0991d | 619 | case CODE_LABEL: |
57404fb9 | 620 | fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx)); |
a7ae1e59 | 621 | switch (LABEL_KIND (in_rtx)) |
622 | { | |
623 | case LABEL_NORMAL: break; | |
624 | case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break; | |
625 | case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break; | |
626 | case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break; | |
876760f6 | 627 | default: gcc_unreachable (); |
a7ae1e59 | 628 | } |
74b0991d | 629 | break; |
630 | ||
74b0991d | 631 | default: |
632 | break; | |
bfee5366 | 633 | } |
57404fb9 | 634 | |
f4b3647a | 635 | fputc (')', outfile); |
636 | sawclose = 1; | |
0b8a940f | 637 | } |
638 | ||
6a71e6dc | 639 | /* Print an rtx on the current line of FILE. Initially indent IND |
640 | characters. */ | |
641 | ||
642 | void | |
dd9b9fc5 | 643 | print_inline_rtx (FILE *outf, const_rtx x, int ind) |
6a71e6dc | 644 | { |
ad87de1e | 645 | int oldsaw = sawclose; |
646 | int oldindent = indent; | |
647 | ||
6a71e6dc | 648 | sawclose = 0; |
649 | indent = ind; | |
650 | outfile = outf; | |
651 | print_rtx (x); | |
ad87de1e | 652 | sawclose = oldsaw; |
653 | indent = oldindent; | |
6a71e6dc | 654 | } |
655 | ||
0b8a940f | 656 | /* Call this function from the debugger to see what X looks like. */ |
657 | ||
4b987fac | 658 | DEBUG_FUNCTION void |
dd9b9fc5 | 659 | debug_rtx (const_rtx x) |
0b8a940f | 660 | { |
661 | outfile = stderr; | |
68d9a03d | 662 | sawclose = 0; |
0b8a940f | 663 | print_rtx (x); |
664 | fprintf (stderr, "\n"); | |
665 | } | |
666 | ||
1c8c3750 | 667 | /* Count of rtx's to print with debug_rtx_list. |
668 | This global exists because gdb user defined commands have no arguments. */ | |
669 | ||
4b987fac | 670 | DEBUG_VARIABLE int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */ |
1c8c3750 | 671 | |
672 | /* Call this function to print list from X on. | |
673 | ||
674 | N is a count of the rtx's to print. Positive values print from the specified | |
675 | rtx on. Negative values print a window around the rtx. | |
676 | EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */ | |
677 | ||
4b987fac | 678 | DEBUG_FUNCTION void |
dd9b9fc5 | 679 | debug_rtx_list (const_rtx x, int n) |
1c8c3750 | 680 | { |
681 | int i,count; | |
dd9b9fc5 | 682 | const_rtx insn; |
1c8c3750 | 683 | |
684 | count = n == 0 ? 1 : n < 0 ? -n : n; | |
685 | ||
686 | /* If we are printing a window, back up to the start. */ | |
687 | ||
688 | if (n < 0) | |
689 | for (i = count / 2; i > 0; i--) | |
690 | { | |
691 | if (PREV_INSN (x) == 0) | |
692 | break; | |
693 | x = PREV_INSN (x); | |
694 | } | |
695 | ||
696 | for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn)) | |
68d9a03d | 697 | { |
698 | debug_rtx (insn); | |
699 | fprintf (stderr, "\n"); | |
700 | } | |
1c8c3750 | 701 | } |
702 | ||
40977116 | 703 | /* Call this function to print an rtx list from START to END inclusive. */ |
704 | ||
4b987fac | 705 | DEBUG_FUNCTION void |
dd9b9fc5 | 706 | debug_rtx_range (const_rtx start, const_rtx end) |
40977116 | 707 | { |
708 | while (1) | |
709 | { | |
710 | debug_rtx (start); | |
68d9a03d | 711 | fprintf (stderr, "\n"); |
40977116 | 712 | if (!start || start == end) |
713 | break; | |
714 | start = NEXT_INSN (start); | |
715 | } | |
716 | } | |
717 | ||
1c8c3750 | 718 | /* Call this function to search an rtx list to find one with insn uid UID, |
719 | and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT. | |
720 | The found insn is returned to enable further debugging analysis. */ | |
721 | ||
4b987fac | 722 | DEBUG_FUNCTION const_rtx |
dd9b9fc5 | 723 | debug_rtx_find (const_rtx x, int uid) |
1c8c3750 | 724 | { |
725 | while (x != 0 && INSN_UID (x) != uid) | |
726 | x = NEXT_INSN (x); | |
727 | if (x != 0) | |
728 | { | |
729 | debug_rtx_list (x, debug_rtx_count); | |
730 | return x; | |
731 | } | |
732 | else | |
733 | { | |
734 | fprintf (stderr, "insn uid %d not found\n", uid); | |
735 | return 0; | |
736 | } | |
737 | } | |
738 | ||
0b8a940f | 739 | /* External entry point for printing a chain of insns |
740 | starting with RTX_FIRST onto file OUTF. | |
741 | A blank line separates insns. | |
742 | ||
743 | If RTX_FIRST is not an insn, then it alone is printed, with no newline. */ | |
744 | ||
745 | void | |
dd9b9fc5 | 746 | print_rtl (FILE *outf, const_rtx rtx_first) |
0b8a940f | 747 | { |
dd9b9fc5 | 748 | const_rtx tmp_rtx; |
60ad3b0e | 749 | |
0b8a940f | 750 | outfile = outf; |
751 | sawclose = 0; | |
752 | ||
753 | if (rtx_first == 0) | |
af5e5fd0 | 754 | { |
755 | fputs (print_rtx_head, outf); | |
756 | fputs ("(nil)\n", outf); | |
757 | } | |
0b8a940f | 758 | else |
759 | switch (GET_CODE (rtx_first)) | |
760 | { | |
761 | case INSN: | |
762 | case JUMP_INSN: | |
763 | case CALL_INSN: | |
764 | case NOTE: | |
765 | case CODE_LABEL: | |
766 | case BARRIER: | |
60ad3b0e | 767 | for (tmp_rtx = rtx_first; tmp_rtx != 0; tmp_rtx = NEXT_INSN (tmp_rtx)) |
768 | { | |
769 | fputs (print_rtx_head, outfile); | |
770 | print_rtx (tmp_rtx); | |
771 | fprintf (outfile, "\n"); | |
772 | } | |
0b8a940f | 773 | break; |
774 | ||
775 | default: | |
195731ad | 776 | fputs (print_rtx_head, outfile); |
0b8a940f | 777 | print_rtx (rtx_first); |
778 | } | |
779 | } | |
f34a52ce | 780 | |
781 | /* Like print_rtx, except specify a file. */ | |
fd63ca43 | 782 | /* Return nonzero if we actually printed anything. */ |
f34a52ce | 783 | |
fd63ca43 | 784 | int |
dd9b9fc5 | 785 | print_rtl_single (FILE *outf, const_rtx x) |
f34a52ce | 786 | { |
9631926a | 787 | return print_rtl_single_with_indent (outf, x, 0); |
788 | } | |
789 | ||
790 | /* Like print_rtl_single, except specify a file and indentation. */ | |
791 | ||
792 | int | |
793 | print_rtl_single_with_indent (FILE *outf, const_rtx x, int ind) | |
794 | { | |
795 | int old_indent = indent; | |
796 | char *s_indent = (char *) alloca ((size_t) ind + 1); | |
797 | memset ((void *) s_indent, ' ', (size_t) ind); | |
798 | s_indent[ind] = '\0'; | |
799 | ||
800 | indent = ind; | |
f34a52ce | 801 | outfile = outf; |
802 | sawclose = 0; | |
9631926a | 803 | fputs (s_indent, outfile); |
55420479 | 804 | fputs (print_rtx_head, outfile); |
805 | print_rtx (x); | |
806 | putc ('\n', outf); | |
9631926a | 807 | indent = old_indent; |
55420479 | 808 | return 1; |
f34a52ce | 809 | } |
ad4b6bdf | 810 | |
811 | ||
812 | /* Like print_rtl except without all the detail; for example, | |
813 | if RTX is a CONST_INT then print in decimal format. */ | |
814 | ||
815 | void | |
dd9b9fc5 | 816 | print_simple_rtl (FILE *outf, const_rtx x) |
ad4b6bdf | 817 | { |
818 | flag_simple = 1; | |
819 | print_rtl (outf, x); | |
820 | flag_simple = 0; | |
821 | } |