compiler: Recognize 64-bit symbol tables in archives.
[official-gcc.git] / gcc / print-rtl.c
blob80ec96e9c0d9e6d8f59dc252f6abd6f8934afec1
1 /* Print RTL for GCC.
2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
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
8 Software Foundation; either version 3, or (at your option) any later
9 version.
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.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
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
25 #include "config.h"
26 #endif
28 #include "system.h"
29 #include "coretypes.h"
30 #include "tm.h"
31 #include "rtl.h"
33 /* These headers all define things which are not available in
34 generator programs. */
35 #ifndef GENERATOR_FILE
36 #include "tree.h"
37 #include "print-tree.h"
38 #include "flags.h"
39 #include "hard-reg-set.h"
40 #include "basic-block.h"
41 #include "diagnostic.h"
42 #include "tree-pretty-print.h"
43 #include "cselib.h"
44 #include "dumpfile.h" /* for dump_flags */
45 #include "dwarf2out.h"
46 #endif
48 static FILE *outfile;
50 static int sawclose = 0;
52 static int indent;
54 static bool in_call_function_usage;
56 static void print_rtx (const_rtx);
58 /* String printed at beginning of each RTL when it is dumped.
59 This string is set to ASM_COMMENT_START when the RTL is dumped in
60 the assembly output file. */
61 const char *print_rtx_head = "";
63 #ifdef GENERATOR_FILE
64 /* These are defined from the .opt file when not used in generator
65 programs. */
67 /* Nonzero means suppress output of instruction numbers
68 in debugging dumps.
69 This must be defined here so that programs like gencodes can be linked. */
70 int flag_dump_unnumbered = 0;
72 /* Nonzero means suppress output of instruction numbers for previous
73 and next insns in debugging dumps.
74 This must be defined here so that programs like gencodes can be linked. */
75 int flag_dump_unnumbered_links = 0;
76 #endif
78 /* Nonzero means use simplified format without flags, modes, etc. */
79 int flag_simple = 0;
81 #ifndef GENERATOR_FILE
82 void
83 print_mem_expr (FILE *outfile, const_tree expr)
85 fputc (' ', outfile);
86 print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
88 #endif
90 /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
92 static void
93 print_rtx (const_rtx in_rtx)
95 int i = 0;
96 int j;
97 const char *format_ptr;
98 int is_insn;
100 if (sawclose)
102 if (flag_simple)
103 fputc (' ', outfile);
104 else
105 fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
106 sawclose = 0;
109 if (in_rtx == 0)
111 fputs ("(nil)", outfile);
112 sawclose = 1;
113 return;
115 else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
117 fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx),
118 print_rtx_head, indent * 2, "");
119 sawclose = 1;
120 return;
123 is_insn = INSN_P (in_rtx);
125 /* Print name of expression code. */
126 if (flag_simple && CONST_INT_P (in_rtx))
127 fputc ('(', outfile);
128 else
129 fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
131 if (! flag_simple)
133 if (RTX_FLAG (in_rtx, in_struct))
134 fputs ("/s", outfile);
136 if (RTX_FLAG (in_rtx, volatil))
137 fputs ("/v", outfile);
139 if (RTX_FLAG (in_rtx, unchanging))
140 fputs ("/u", outfile);
142 if (RTX_FLAG (in_rtx, frame_related))
143 fputs ("/f", outfile);
145 if (RTX_FLAG (in_rtx, jump))
146 fputs ("/j", outfile);
148 if (RTX_FLAG (in_rtx, call))
149 fputs ("/c", outfile);
151 if (RTX_FLAG (in_rtx, return_val))
152 fputs ("/i", outfile);
154 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
155 if ((GET_CODE (in_rtx) == EXPR_LIST
156 || GET_CODE (in_rtx) == INSN_LIST
157 || GET_CODE (in_rtx) == INT_LIST)
158 && (int)GET_MODE (in_rtx) < REG_NOTE_MAX
159 && !in_call_function_usage)
160 fprintf (outfile, ":%s",
161 GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
163 /* For other rtl, print the mode if it's not VOID. */
164 else if (GET_MODE (in_rtx) != VOIDmode)
165 fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
167 #ifndef GENERATOR_FILE
168 if (GET_CODE (in_rtx) == VAR_LOCATION)
170 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST)
171 fputs (" <debug string placeholder>", outfile);
172 else
173 print_mem_expr (outfile, PAT_VAR_LOCATION_DECL (in_rtx));
174 fputc (' ', outfile);
175 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx));
176 if (PAT_VAR_LOCATION_STATUS (in_rtx)
177 == VAR_INIT_STATUS_UNINITIALIZED)
178 fprintf (outfile, " [uninit]");
179 sawclose = 1;
180 i = GET_RTX_LENGTH (VAR_LOCATION);
182 #endif
185 #ifndef GENERATOR_FILE
186 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx))
187 i = 5;
188 #endif
190 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx)))
192 if (flag_dump_unnumbered)
193 fprintf (outfile, " #");
194 else
195 fprintf (outfile, " %d", INSN_UID (in_rtx));
198 /* Get the format string and skip the first elements if we have handled
199 them already. */
200 format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i;
201 for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
202 switch (*format_ptr++)
204 const char *str;
206 case 'T':
207 str = XTMPL (in_rtx, i);
208 goto string;
210 case 'S':
211 case 's':
212 str = XSTR (in_rtx, i);
213 string:
215 if (str == 0)
216 fputs (" \"\"", outfile);
217 else
218 fprintf (outfile, " (\"%s\")", str);
219 sawclose = 1;
220 break;
222 /* 0 indicates a field for internal use that should not be printed.
223 An exception is the third field of a NOTE, where it indicates
224 that the field has several different valid contents. */
225 case '0':
226 #ifndef GENERATOR_FILE
227 if (i == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
229 int flags = SYMBOL_REF_FLAGS (in_rtx);
230 if (flags)
231 fprintf (outfile, " [flags %#x]", flags);
232 tree decl = SYMBOL_REF_DECL (in_rtx);
233 if (decl)
234 print_node_brief (outfile, "", decl, dump_flags);
236 else if (i == 3 && NOTE_P (in_rtx))
238 switch (NOTE_KIND (in_rtx))
240 case NOTE_INSN_EH_REGION_BEG:
241 case NOTE_INSN_EH_REGION_END:
242 if (flag_dump_unnumbered)
243 fprintf (outfile, " #");
244 else
245 fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx));
246 sawclose = 1;
247 break;
249 case NOTE_INSN_BLOCK_BEG:
250 case NOTE_INSN_BLOCK_END:
251 dump_addr (outfile, " ", NOTE_BLOCK (in_rtx));
252 sawclose = 1;
253 break;
255 case NOTE_INSN_BASIC_BLOCK:
257 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
258 if (bb != 0)
259 fprintf (outfile, " [bb %d]", bb->index);
260 break;
263 case NOTE_INSN_DELETED_LABEL:
264 case NOTE_INSN_DELETED_DEBUG_LABEL:
266 const char *label = NOTE_DELETED_LABEL_NAME (in_rtx);
267 if (label)
268 fprintf (outfile, " (\"%s\")", label);
269 else
270 fprintf (outfile, " \"\"");
272 break;
274 case NOTE_INSN_SWITCH_TEXT_SECTIONS:
276 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
277 if (bb != 0)
278 fprintf (outfile, " [bb %d]", bb->index);
279 break;
282 case NOTE_INSN_VAR_LOCATION:
283 case NOTE_INSN_CALL_ARG_LOCATION:
284 fputc (' ', outfile);
285 print_rtx (NOTE_VAR_LOCATION (in_rtx));
286 break;
288 case NOTE_INSN_CFI:
289 fputc ('\n', outfile);
290 output_cfi_directive (outfile, NOTE_CFI (in_rtx));
291 fputc ('\t', outfile);
292 break;
294 default:
295 break;
298 else if (i == 7 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL)
300 /* Output the JUMP_LABEL reference. */
301 fprintf (outfile, "\n%s%*s -> ", print_rtx_head, indent * 2, "");
302 if (GET_CODE (JUMP_LABEL (in_rtx)) == RETURN)
303 fprintf (outfile, "return");
304 else if (GET_CODE (JUMP_LABEL (in_rtx)) == SIMPLE_RETURN)
305 fprintf (outfile, "simple_return");
306 else
307 fprintf (outfile, "%d", INSN_UID (JUMP_LABEL (in_rtx)));
309 else if (i == 0 && GET_CODE (in_rtx) == VALUE)
311 cselib_val *val = CSELIB_VAL_PTR (in_rtx);
313 fprintf (outfile, " %u:%u", val->uid, val->hash);
314 dump_addr (outfile, " @", in_rtx);
315 dump_addr (outfile, "/", (void*)val);
317 else if (i == 0 && GET_CODE (in_rtx) == DEBUG_EXPR)
319 fprintf (outfile, " D#%i",
320 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx)));
322 else if (i == 0 && GET_CODE (in_rtx) == ENTRY_VALUE)
324 indent += 2;
325 if (!sawclose)
326 fprintf (outfile, " ");
327 print_rtx (ENTRY_VALUE_EXP (in_rtx));
328 indent -= 2;
330 #endif
331 break;
333 case 'e':
334 do_e:
335 indent += 2;
336 if (i == 6 && INSN_P (in_rtx))
337 /* Put REG_NOTES on their own line. */
338 fprintf (outfile, "\n%s%*s",
339 print_rtx_head, indent * 2, "");
340 if (!sawclose)
341 fprintf (outfile, " ");
342 if (i == 7 && CALL_P (in_rtx))
344 in_call_function_usage = true;
345 print_rtx (XEXP (in_rtx, i));
346 in_call_function_usage = false;
348 else
349 print_rtx (XEXP (in_rtx, i));
350 indent -= 2;
351 break;
353 case 'E':
354 case 'V':
355 indent += 2;
356 if (sawclose)
358 fprintf (outfile, "\n%s%*s",
359 print_rtx_head, indent * 2, "");
360 sawclose = 0;
362 fputs (" [", outfile);
363 if (NULL != XVEC (in_rtx, i))
365 indent += 2;
366 if (XVECLEN (in_rtx, i))
367 sawclose = 1;
369 for (j = 0; j < XVECLEN (in_rtx, i); j++)
370 print_rtx (XVECEXP (in_rtx, i, j));
372 indent -= 2;
374 if (sawclose)
375 fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
377 fputs ("]", outfile);
378 sawclose = 1;
379 indent -= 2;
380 break;
382 case 'w':
383 if (! flag_simple)
384 fprintf (outfile, " ");
385 fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
386 if (! flag_simple)
387 fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
388 (unsigned HOST_WIDE_INT) XWINT (in_rtx, i));
389 break;
391 case 'i':
392 if (i == 4 && INSN_P (in_rtx))
394 #ifndef GENERATOR_FILE
395 const rtx_insn *in_insn = as_a <const rtx_insn *> (in_rtx);
397 /* Pretty-print insn locations. Ignore scoping as it is mostly
398 redundant with line number information and do not print anything
399 when there is no location information available. */
400 if (INSN_HAS_LOCATION (in_insn))
402 expanded_location xloc = insn_location (in_insn);
403 fprintf (outfile, " %s:%i", xloc.file, xloc.line);
405 #endif
407 else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
409 #ifndef GENERATOR_FILE
410 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
411 fprintf (outfile, " %s:%i",
412 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)),
413 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)));
414 #endif
416 else if (i == 1 && GET_CODE (in_rtx) == ASM_INPUT)
418 #ifndef GENERATOR_FILE
419 if (ASM_INPUT_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
420 fprintf (outfile, " %s:%i",
421 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx)),
422 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx)));
423 #endif
425 else if (i == 5 && NOTE_P (in_rtx))
427 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
428 other times often contains garbage from INSN->NOTE death. */
429 if (NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_LABEL
430 || NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_DEBUG_LABEL)
431 fprintf (outfile, " %d", XINT (in_rtx, i));
433 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
434 else if (i == 1
435 && GET_CODE (in_rtx) == UNSPEC_VOLATILE
436 && XINT (in_rtx, 1) >= 0
437 && XINT (in_rtx, 1) < NUM_UNSPECV_VALUES)
438 fprintf (outfile, " %s", unspecv_strings[XINT (in_rtx, 1)]);
439 #endif
440 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
441 else if (i == 1
442 && (GET_CODE (in_rtx) == UNSPEC
443 || GET_CODE (in_rtx) == UNSPEC_VOLATILE)
444 && XINT (in_rtx, 1) >= 0
445 && XINT (in_rtx, 1) < NUM_UNSPEC_VALUES)
446 fprintf (outfile, " %s", unspec_strings[XINT (in_rtx, 1)]);
447 #endif
448 else
450 int value = XINT (in_rtx, i);
451 const char *name;
453 #ifndef GENERATOR_FILE
454 if (REG_P (in_rtx) && (unsigned) value < FIRST_PSEUDO_REGISTER)
455 fprintf (outfile, " %d %s", value, reg_names[value]);
456 else if (REG_P (in_rtx)
457 && (unsigned) value <= LAST_VIRTUAL_REGISTER)
459 if (value == VIRTUAL_INCOMING_ARGS_REGNUM)
460 fprintf (outfile, " %d virtual-incoming-args", value);
461 else if (value == VIRTUAL_STACK_VARS_REGNUM)
462 fprintf (outfile, " %d virtual-stack-vars", value);
463 else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM)
464 fprintf (outfile, " %d virtual-stack-dynamic", value);
465 else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM)
466 fprintf (outfile, " %d virtual-outgoing-args", value);
467 else if (value == VIRTUAL_CFA_REGNUM)
468 fprintf (outfile, " %d virtual-cfa", value);
469 else if (value == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM)
470 fprintf (outfile, " %d virtual-preferred-stack-boundary",
471 value);
472 else
473 fprintf (outfile, " %d virtual-reg-%d", value,
474 value-FIRST_VIRTUAL_REGISTER);
476 else
477 #endif
478 if (flag_dump_unnumbered
479 && (is_insn || NOTE_P (in_rtx)))
480 fputc ('#', outfile);
481 else
482 fprintf (outfile, " %d", value);
484 #ifndef GENERATOR_FILE
485 if (REG_P (in_rtx) && REG_ATTRS (in_rtx))
487 fputs (" [", outfile);
488 if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx))
489 fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx));
490 if (REG_EXPR (in_rtx))
491 print_mem_expr (outfile, REG_EXPR (in_rtx));
493 if (REG_OFFSET (in_rtx))
494 fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC,
495 REG_OFFSET (in_rtx));
496 fputs (" ]", outfile);
498 if (REG_P (in_rtx) && REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
499 fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
500 #endif
502 if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
503 && XINT (in_rtx, i) >= 0
504 && (name = get_insn_name (XINT (in_rtx, i))) != NULL)
505 fprintf (outfile, " {%s}", name);
506 sawclose = 0;
508 break;
510 /* Print NOTE_INSN names rather than integer codes. */
512 case 'n':
513 fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i)));
514 sawclose = 0;
515 break;
517 case 'u':
518 if (XEXP (in_rtx, i) != NULL)
520 rtx sub = XEXP (in_rtx, i);
521 enum rtx_code subc = GET_CODE (sub);
523 if (GET_CODE (in_rtx) == LABEL_REF)
525 if (subc == NOTE
526 && NOTE_KIND (sub) == NOTE_INSN_DELETED_LABEL)
528 if (flag_dump_unnumbered)
529 fprintf (outfile, " [# deleted]");
530 else
531 fprintf (outfile, " [%d deleted]", INSN_UID (sub));
532 sawclose = 0;
533 break;
536 if (subc != CODE_LABEL)
537 goto do_e;
540 if (flag_dump_unnumbered
541 || (flag_dump_unnumbered_links && (i == 1 || i == 2)
542 && (INSN_P (in_rtx) || NOTE_P (in_rtx)
543 || LABEL_P (in_rtx) || BARRIER_P (in_rtx))))
544 fputs (" #", outfile);
545 else
546 fprintf (outfile, " %d", INSN_UID (sub));
548 else
549 fputs (" 0", outfile);
550 sawclose = 0;
551 break;
553 case 't':
554 #ifndef GENERATOR_FILE
555 if (i == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR)
556 print_mem_expr (outfile, DEBUG_IMPLICIT_PTR_DECL (in_rtx));
557 else if (i == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF)
558 print_mem_expr (outfile, DEBUG_PARAMETER_REF_DECL (in_rtx));
559 else
560 dump_addr (outfile, " ", XTREE (in_rtx, i));
561 #endif
562 break;
564 case '*':
565 fputs (" Unknown", outfile);
566 sawclose = 0;
567 break;
569 case 'B':
570 #ifndef GENERATOR_FILE
571 if (XBBDEF (in_rtx, i))
572 fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index);
573 #endif
574 break;
576 default:
577 gcc_unreachable ();
580 switch (GET_CODE (in_rtx))
582 #ifndef GENERATOR_FILE
583 case MEM:
584 if (__builtin_expect (final_insns_dump_p, false))
585 fprintf (outfile, " [");
586 else
587 fprintf (outfile, " [" HOST_WIDE_INT_PRINT_DEC,
588 (HOST_WIDE_INT) MEM_ALIAS_SET (in_rtx));
590 if (MEM_EXPR (in_rtx))
591 print_mem_expr (outfile, MEM_EXPR (in_rtx));
592 else
593 fputc (' ', outfile);
595 if (MEM_OFFSET_KNOWN_P (in_rtx))
596 fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC, MEM_OFFSET (in_rtx));
598 if (MEM_SIZE_KNOWN_P (in_rtx))
599 fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC, MEM_SIZE (in_rtx));
601 if (MEM_ALIGN (in_rtx) != 1)
602 fprintf (outfile, " A%u", MEM_ALIGN (in_rtx));
604 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx)))
605 fprintf (outfile, " AS%u", MEM_ADDR_SPACE (in_rtx));
607 fputc (']', outfile);
608 break;
610 case CONST_DOUBLE:
611 if (FLOAT_MODE_P (GET_MODE (in_rtx)))
613 char s[60];
615 real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
616 sizeof (s), 0, 1);
617 fprintf (outfile, " %s", s);
619 real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
620 sizeof (s), 0, 1);
621 fprintf (outfile, " [%s]", s);
623 break;
625 case CONST_WIDE_INT:
626 fprintf (outfile, " ");
627 cwi_output_hex (outfile, in_rtx);
628 break;
629 #endif
631 case CODE_LABEL:
632 fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx));
633 switch (LABEL_KIND (in_rtx))
635 case LABEL_NORMAL: break;
636 case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break;
637 case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break;
638 case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break;
639 default: gcc_unreachable ();
641 break;
643 default:
644 break;
647 fputc (')', outfile);
648 sawclose = 1;
651 /* Print an rtx on the current line of FILE. Initially indent IND
652 characters. */
654 void
655 print_inline_rtx (FILE *outf, const_rtx x, int ind)
657 int oldsaw = sawclose;
658 int oldindent = indent;
660 sawclose = 0;
661 indent = ind;
662 outfile = outf;
663 print_rtx (x);
664 sawclose = oldsaw;
665 indent = oldindent;
668 /* Call this function from the debugger to see what X looks like. */
670 DEBUG_FUNCTION void
671 debug_rtx (const_rtx x)
673 outfile = stderr;
674 sawclose = 0;
675 print_rtx (x);
676 fprintf (stderr, "\n");
679 /* Dump rtx REF. */
681 DEBUG_FUNCTION void
682 debug (const rtx_def &ref)
684 debug_rtx (&ref);
687 DEBUG_FUNCTION void
688 debug (const rtx_def *ptr)
690 if (ptr)
691 debug (*ptr);
692 else
693 fprintf (stderr, "<nil>\n");
696 /* Count of rtx's to print with debug_rtx_list.
697 This global exists because gdb user defined commands have no arguments. */
699 DEBUG_VARIABLE int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */
701 /* Call this function to print list from X on.
703 N is a count of the rtx's to print. Positive values print from the specified
704 rtx_insn on. Negative values print a window around the rtx_insn.
705 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
706 rtx_insn). */
708 DEBUG_FUNCTION void
709 debug_rtx_list (const rtx_insn *x, int n)
711 int i,count;
712 const rtx_insn *insn;
714 count = n == 0 ? 1 : n < 0 ? -n : n;
716 /* If we are printing a window, back up to the start. */
718 if (n < 0)
719 for (i = count / 2; i > 0; i--)
721 if (PREV_INSN (x) == 0)
722 break;
723 x = PREV_INSN (x);
726 for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
728 debug_rtx (insn);
729 fprintf (stderr, "\n");
733 /* Call this function to print an rtx_insn list from START to END
734 inclusive. */
736 DEBUG_FUNCTION void
737 debug_rtx_range (const rtx_insn *start, const rtx_insn *end)
739 while (1)
741 debug_rtx (start);
742 fprintf (stderr, "\n");
743 if (!start || start == end)
744 break;
745 start = NEXT_INSN (start);
749 /* Call this function to search an rtx_insn list to find one with insn uid UID,
750 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
751 The found insn is returned to enable further debugging analysis. */
753 DEBUG_FUNCTION const_rtx
754 debug_rtx_find (const rtx_insn *x, int uid)
756 while (x != 0 && INSN_UID (x) != uid)
757 x = NEXT_INSN (x);
758 if (x != 0)
760 debug_rtx_list (x, debug_rtx_count);
761 return x;
763 else
765 fprintf (stderr, "insn uid %d not found\n", uid);
766 return 0;
770 /* External entry point for printing a chain of insns
771 starting with RTX_FIRST onto file OUTF.
772 A blank line separates insns.
774 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
776 void
777 print_rtl (FILE *outf, const_rtx rtx_first)
779 const rtx_insn *tmp_rtx;
781 outfile = outf;
782 sawclose = 0;
784 if (rtx_first == 0)
786 fputs (print_rtx_head, outf);
787 fputs ("(nil)\n", outf);
789 else
790 switch (GET_CODE (rtx_first))
792 case INSN:
793 case JUMP_INSN:
794 case CALL_INSN:
795 case NOTE:
796 case CODE_LABEL:
797 case JUMP_TABLE_DATA:
798 case BARRIER:
799 for (tmp_rtx = as_a <const rtx_insn *> (rtx_first);
800 tmp_rtx != 0;
801 tmp_rtx = NEXT_INSN (tmp_rtx))
803 fputs (print_rtx_head, outfile);
804 print_rtx (tmp_rtx);
805 fprintf (outfile, "\n");
807 break;
809 default:
810 fputs (print_rtx_head, outfile);
811 print_rtx (rtx_first);
815 /* Like print_rtx, except specify a file. */
816 /* Return nonzero if we actually printed anything. */
819 print_rtl_single (FILE *outf, const_rtx x)
821 return print_rtl_single_with_indent (outf, x, 0);
824 /* Like print_rtl_single, except specify a file and indentation. */
827 print_rtl_single_with_indent (FILE *outf, const_rtx x, int ind)
829 int old_indent = indent;
830 char *s_indent = (char *) alloca ((size_t) ind + 1);
831 memset ((void *) s_indent, ' ', (size_t) ind);
832 s_indent[ind] = '\0';
834 indent = ind;
835 outfile = outf;
836 sawclose = 0;
837 fputs (s_indent, outfile);
838 fputs (print_rtx_head, outfile);
839 print_rtx (x);
840 putc ('\n', outf);
841 indent = old_indent;
842 return 1;
846 /* Like print_rtl except without all the detail; for example,
847 if RTX is a CONST_INT then print in decimal format. */
849 void
850 print_simple_rtl (FILE *outf, const_rtx x)
852 flag_simple = 1;
853 print_rtl (outf, x);
854 flag_simple = 0;