* config/avr/avr-protos.h (avr_mode_code_base_reg_class): New prototype.
[official-gcc.git] / gcc / print-rtl.c
blobdb9c0fbbdd0b3086bb2877a246ef90587c85d82d
1 /* Print RTL for GCC.
2 Copyright (C) 1987, 1988, 1992, 1997, 1998, 1999, 2000, 2002, 2003,
3 2004, 2005, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
6 This file is part of GCC.
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
10 Software Foundation; either version 3, or (at your option) any later
11 version.
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.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
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
27 #include "config.h"
28 #endif
30 #include "system.h"
31 #include "coretypes.h"
32 #include "tm.h"
33 #include "rtl.h"
35 /* These headers all define things which are not available in
36 generator programs. */
37 #ifndef GENERATOR_FILE
38 #include "tree.h"
39 #include "flags.h"
40 #include "hard-reg-set.h"
41 #include "basic-block.h"
42 #include "diagnostic.h"
43 #include "tree-pretty-print.h"
44 #include "cselib.h"
45 #include "tree-pass.h"
46 #include "dwarf2out.h"
47 #endif
49 static FILE *outfile;
51 static int sawclose = 0;
53 static int indent;
55 static void print_rtx (const_rtx);
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. */
60 const char *print_rtx_head = "";
62 #ifdef GENERATOR_FILE
63 /* These are defined from the .opt file when not used in generator
64 programs. */
66 /* Nonzero means suppress output of instruction numbers
67 in debugging dumps.
68 This must be defined here so that programs like gencodes can be linked. */
69 int flag_dump_unnumbered = 0;
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;
75 #endif
77 /* Nonzero means use simplified format without flags, modes, etc. */
78 int flag_simple = 0;
80 /* Nonzero if we are dumping graphical description. */
81 int dump_for_graph;
83 #ifndef GENERATOR_FILE
84 void
85 print_mem_expr (FILE *outfile, const_tree expr)
87 fputc (' ', outfile);
88 print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
90 #endif
92 /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
94 static void
95 print_rtx (const_rtx in_rtx)
97 int i = 0;
98 int j;
99 const char *format_ptr;
100 int is_insn;
102 if (sawclose)
104 if (flag_simple)
105 fputc (' ', outfile);
106 else
107 fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
108 sawclose = 0;
111 if (in_rtx == 0)
113 fputs ("(nil)", outfile);
114 sawclose = 1;
115 return;
117 else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
119 fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx),
120 print_rtx_head, indent * 2, "");
121 sawclose = 1;
122 return;
125 is_insn = INSN_P (in_rtx);
127 /* When printing in VCG format we write INSNs, NOTE, LABEL, and BARRIER
128 in separate nodes and therefore have to handle them special here. */
129 if (dump_for_graph
130 && (is_insn || NOTE_P (in_rtx)
131 || LABEL_P (in_rtx) || BARRIER_P (in_rtx)))
133 i = 3;
134 indent = 0;
136 else
138 /* Print name of expression code. */
139 if (flag_simple && CONST_INT_P (in_rtx))
140 fputc ('(', outfile);
141 else
142 fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
144 if (! flag_simple)
146 if (RTX_FLAG (in_rtx, in_struct))
147 fputs ("/s", outfile);
149 if (RTX_FLAG (in_rtx, volatil))
150 fputs ("/v", outfile);
152 if (RTX_FLAG (in_rtx, unchanging))
153 fputs ("/u", outfile);
155 if (RTX_FLAG (in_rtx, frame_related))
156 fputs ("/f", outfile);
158 if (RTX_FLAG (in_rtx, jump))
159 fputs ("/j", outfile);
161 if (RTX_FLAG (in_rtx, call))
162 fputs ("/c", outfile);
164 if (RTX_FLAG (in_rtx, return_val))
165 fputs ("/i", outfile);
167 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
168 if ((GET_CODE (in_rtx) == EXPR_LIST
169 || GET_CODE (in_rtx) == INSN_LIST)
170 && (int)GET_MODE (in_rtx) < REG_NOTE_MAX)
171 fprintf (outfile, ":%s",
172 GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
174 /* For other rtl, print the mode if it's not VOID. */
175 else if (GET_MODE (in_rtx) != VOIDmode)
176 fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
178 #ifndef GENERATOR_FILE
179 if (GET_CODE (in_rtx) == VAR_LOCATION)
181 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST)
182 fputs (" <debug string placeholder>", outfile);
183 else
184 print_mem_expr (outfile, PAT_VAR_LOCATION_DECL (in_rtx));
185 fputc (' ', outfile);
186 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx));
187 if (PAT_VAR_LOCATION_STATUS (in_rtx)
188 == VAR_INIT_STATUS_UNINITIALIZED)
189 fprintf (outfile, " [uninit]");
190 sawclose = 1;
191 i = GET_RTX_LENGTH (VAR_LOCATION);
193 #endif
197 #ifndef GENERATOR_FILE
198 if (GET_CODE (in_rtx) == CONST_DOUBLE && FLOAT_MODE_P (GET_MODE (in_rtx)))
199 i = 5;
200 #endif
202 /* Get the format string and skip the first elements if we have handled
203 them already. */
204 format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i;
205 for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
206 switch (*format_ptr++)
208 const char *str;
210 case 'T':
211 str = XTMPL (in_rtx, i);
212 goto string;
214 case 'S':
215 case 's':
216 str = XSTR (in_rtx, i);
217 string:
219 if (str == 0)
220 fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile);
221 else
223 if (dump_for_graph)
224 fprintf (outfile, " (\\\"%s\\\")", str);
225 else
226 fprintf (outfile, " (\"%s\")", str);
228 sawclose = 1;
229 break;
231 /* 0 indicates a field for internal use that should not be printed.
232 An exception is the third field of a NOTE, where it indicates
233 that the field has several different valid contents. */
234 case '0':
235 if (i == 1 && REG_P (in_rtx))
237 if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
238 fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
240 #ifndef GENERATOR_FILE
241 else if (i == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
243 int flags = SYMBOL_REF_FLAGS (in_rtx);
244 if (flags)
245 fprintf (outfile, " [flags %#x]", flags);
247 else if (i == 2 && GET_CODE (in_rtx) == SYMBOL_REF)
249 tree decl = SYMBOL_REF_DECL (in_rtx);
250 if (decl)
251 print_node_brief (outfile, "", decl, dump_flags);
253 #endif
254 else if (i == 4 && NOTE_P (in_rtx))
256 switch (NOTE_KIND (in_rtx))
258 case NOTE_INSN_EH_REGION_BEG:
259 case NOTE_INSN_EH_REGION_END:
260 if (flag_dump_unnumbered)
261 fprintf (outfile, " #");
262 else
263 fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx));
264 sawclose = 1;
265 break;
267 case NOTE_INSN_BLOCK_BEG:
268 case NOTE_INSN_BLOCK_END:
269 #ifndef GENERATOR_FILE
270 dump_addr (outfile, " ", NOTE_BLOCK (in_rtx));
271 #endif
272 sawclose = 1;
273 break;
275 case NOTE_INSN_BASIC_BLOCK:
277 #ifndef GENERATOR_FILE
278 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
279 if (bb != 0)
280 fprintf (outfile, " [bb %d]", bb->index);
281 #endif
282 break;
285 case NOTE_INSN_DELETED_LABEL:
287 const char *label = NOTE_DELETED_LABEL_NAME (in_rtx);
288 if (label)
289 fprintf (outfile, " (\"%s\")", label);
290 else
291 fprintf (outfile, " \"\"");
293 break;
295 case NOTE_INSN_SWITCH_TEXT_SECTIONS:
297 #ifndef GENERATOR_FILE
298 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
299 if (bb != 0)
300 fprintf (outfile, " [bb %d]", bb->index);
301 #endif
302 break;
305 case NOTE_INSN_VAR_LOCATION:
306 case NOTE_INSN_CALL_ARG_LOCATION:
307 #ifndef GENERATOR_FILE
308 fputc (' ', outfile);
309 print_rtx (NOTE_VAR_LOCATION (in_rtx));
310 #endif
311 break;
313 case NOTE_INSN_CFI:
314 #ifndef GENERATOR_FILE
315 fputc ('\n', outfile);
316 output_cfi_directive (outfile, NOTE_CFI (in_rtx));
317 fputc ('\t', outfile);
318 #endif
319 break;
321 default:
322 break;
325 else if (i == 8 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL)
327 /* Output the JUMP_LABEL reference. */
328 fprintf (outfile, "\n%s%*s -> ", print_rtx_head, indent * 2, "");
329 if (GET_CODE (JUMP_LABEL (in_rtx)) == RETURN)
330 fprintf (outfile, "return");
331 else if (GET_CODE (JUMP_LABEL (in_rtx)) == SIMPLE_RETURN)
332 fprintf (outfile, "simple_return");
333 else
334 fprintf (outfile, "%d", INSN_UID (JUMP_LABEL (in_rtx)));
336 else if (i == 0 && GET_CODE (in_rtx) == VALUE)
338 #ifndef GENERATOR_FILE
339 cselib_val *val = CSELIB_VAL_PTR (in_rtx);
341 fprintf (outfile, " %u:%u", val->uid, val->hash);
342 dump_addr (outfile, " @", in_rtx);
343 dump_addr (outfile, "/", (void*)val);
344 #endif
346 else if (i == 0 && GET_CODE (in_rtx) == DEBUG_EXPR)
348 #ifndef GENERATOR_FILE
349 fprintf (outfile, " D#%i",
350 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx)));
351 #endif
353 else if (i == 0 && GET_CODE (in_rtx) == ENTRY_VALUE)
355 indent += 2;
356 if (!sawclose)
357 fprintf (outfile, " ");
358 print_rtx (ENTRY_VALUE_EXP (in_rtx));
359 indent -= 2;
361 break;
363 case 'e':
364 do_e:
365 indent += 2;
366 if (i == 7 && INSN_P (in_rtx))
367 /* Put REG_NOTES on their own line. */
368 fprintf (outfile, "\n%s%*s",
369 print_rtx_head, indent * 2, "");
370 if (!sawclose)
371 fprintf (outfile, " ");
372 print_rtx (XEXP (in_rtx, i));
373 indent -= 2;
374 break;
376 case 'E':
377 case 'V':
378 indent += 2;
379 if (sawclose)
381 fprintf (outfile, "\n%s%*s",
382 print_rtx_head, indent * 2, "");
383 sawclose = 0;
385 fputs (" [", outfile);
386 if (NULL != XVEC (in_rtx, i))
388 indent += 2;
389 if (XVECLEN (in_rtx, i))
390 sawclose = 1;
392 for (j = 0; j < XVECLEN (in_rtx, i); j++)
393 print_rtx (XVECEXP (in_rtx, i, j));
395 indent -= 2;
397 if (sawclose)
398 fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
400 fputs ("]", outfile);
401 sawclose = 1;
402 indent -= 2;
403 break;
405 case 'w':
406 if (! flag_simple)
407 fprintf (outfile, " ");
408 fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
409 if (! flag_simple)
410 fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
411 (unsigned HOST_WIDE_INT) XWINT (in_rtx, i));
412 break;
414 case 'i':
415 if (i == 5 && INSN_P (in_rtx))
417 #ifndef GENERATOR_FILE
418 /* Pretty-print insn locators. Ignore scoping as it is mostly
419 redundant with line number information and do not print anything
420 when there is no location information available. */
421 if (INSN_LOCATOR (in_rtx) && insn_file (in_rtx))
422 fprintf(outfile, " %s:%i", insn_file (in_rtx), insn_line (in_rtx));
423 #endif
425 else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
427 #ifndef GENERATOR_FILE
428 fprintf (outfile, " %s:%i",
429 locator_file (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)),
430 locator_line (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)));
431 #endif
433 else if (i == 1 && GET_CODE (in_rtx) == ASM_INPUT)
435 #ifndef GENERATOR_FILE
436 fprintf (outfile, " %s:%i",
437 locator_file (ASM_INPUT_SOURCE_LOCATION (in_rtx)),
438 locator_line (ASM_INPUT_SOURCE_LOCATION (in_rtx)));
439 #endif
441 else if (i == 6 && NOTE_P (in_rtx))
443 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
444 other times often contains garbage from INSN->NOTE death. */
445 if (NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_LABEL)
446 fprintf (outfile, " %d", XINT (in_rtx, i));
448 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
449 else if (i == 1
450 && GET_CODE (in_rtx) == UNSPEC_VOLATILE
451 && XINT (in_rtx, 1) >= 0
452 && XINT (in_rtx, 1) < NUM_UNSPECV_VALUES)
453 fprintf (outfile, " %s", unspecv_strings[XINT (in_rtx, 1)]);
454 #endif
455 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
456 else if (i == 1
457 && (GET_CODE (in_rtx) == UNSPEC
458 || GET_CODE (in_rtx) == UNSPEC_VOLATILE)
459 && XINT (in_rtx, 1) >= 0
460 && XINT (in_rtx, 1) < NUM_UNSPEC_VALUES)
461 fprintf (outfile, " %s", unspec_strings[XINT (in_rtx, 1)]);
462 #endif
463 else
465 int value = XINT (in_rtx, i);
466 const char *name;
468 #ifndef GENERATOR_FILE
469 if (REG_P (in_rtx) && value < FIRST_PSEUDO_REGISTER)
470 fprintf (outfile, " %d %s", REGNO (in_rtx),
471 reg_names[REGNO (in_rtx)]);
472 else if (REG_P (in_rtx)
473 && value <= LAST_VIRTUAL_REGISTER)
475 if (value == VIRTUAL_INCOMING_ARGS_REGNUM)
476 fprintf (outfile, " %d virtual-incoming-args", value);
477 else if (value == VIRTUAL_STACK_VARS_REGNUM)
478 fprintf (outfile, " %d virtual-stack-vars", value);
479 else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM)
480 fprintf (outfile, " %d virtual-stack-dynamic", value);
481 else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM)
482 fprintf (outfile, " %d virtual-outgoing-args", value);
483 else if (value == VIRTUAL_CFA_REGNUM)
484 fprintf (outfile, " %d virtual-cfa", value);
485 else if (value == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM)
486 fprintf (outfile, " %d virtual-preferred-stack-boundary",
487 value);
488 else
489 fprintf (outfile, " %d virtual-reg-%d", value,
490 value-FIRST_VIRTUAL_REGISTER);
492 else
493 #endif
494 if (flag_dump_unnumbered
495 && (is_insn || NOTE_P (in_rtx)))
496 fputc ('#', outfile);
497 else
498 fprintf (outfile, " %d", value);
500 #ifndef GENERATOR_FILE
501 if (REG_P (in_rtx) && REG_ATTRS (in_rtx))
503 fputs (" [", outfile);
504 if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx))
505 fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx));
506 if (REG_EXPR (in_rtx))
507 print_mem_expr (outfile, REG_EXPR (in_rtx));
509 if (REG_OFFSET (in_rtx))
510 fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC,
511 REG_OFFSET (in_rtx));
512 fputs (" ]", outfile);
514 #endif
516 if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
517 && XINT (in_rtx, i) >= 0
518 && (name = get_insn_name (XINT (in_rtx, i))) != NULL)
519 fprintf (outfile, " {%s}", name);
520 sawclose = 0;
522 break;
524 /* Print NOTE_INSN names rather than integer codes. */
526 case 'n':
527 fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i)));
528 sawclose = 0;
529 break;
531 case 'u':
532 if (XEXP (in_rtx, i) != NULL)
534 rtx sub = XEXP (in_rtx, i);
535 enum rtx_code subc = GET_CODE (sub);
537 if (GET_CODE (in_rtx) == LABEL_REF)
539 if (subc == NOTE
540 && NOTE_KIND (sub) == NOTE_INSN_DELETED_LABEL)
542 if (flag_dump_unnumbered)
543 fprintf (outfile, " [# deleted]");
544 else
545 fprintf (outfile, " [%d deleted]", INSN_UID (sub));
546 sawclose = 0;
547 break;
550 if (subc != CODE_LABEL)
551 goto do_e;
554 if (flag_dump_unnumbered
555 || (flag_dump_unnumbered_links && (i == 1 || i == 2)
556 && (INSN_P (in_rtx) || NOTE_P (in_rtx)
557 || LABEL_P (in_rtx) || BARRIER_P (in_rtx))))
558 fputs (" #", outfile);
559 else
560 fprintf (outfile, " %d", INSN_UID (sub));
562 else
563 fputs (" 0", outfile);
564 sawclose = 0;
565 break;
567 case 't':
568 #ifndef GENERATOR_FILE
569 if (i == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR)
570 print_mem_expr (outfile, DEBUG_IMPLICIT_PTR_DECL (in_rtx));
571 else if (i == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF)
572 print_mem_expr (outfile, DEBUG_PARAMETER_REF_DECL (in_rtx));
573 else
574 dump_addr (outfile, " ", XTREE (in_rtx, i));
575 #endif
576 break;
578 case '*':
579 fputs (" Unknown", outfile);
580 sawclose = 0;
581 break;
583 case 'B':
584 #ifndef GENERATOR_FILE
585 if (XBBDEF (in_rtx, i))
586 fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index);
587 #endif
588 break;
590 default:
591 gcc_unreachable ();
594 switch (GET_CODE (in_rtx))
596 #ifndef GENERATOR_FILE
597 case MEM:
598 if (__builtin_expect (final_insns_dump_p, false))
599 fprintf (outfile, " [");
600 else
601 fprintf (outfile, " [" HOST_WIDE_INT_PRINT_DEC,
602 (HOST_WIDE_INT) MEM_ALIAS_SET (in_rtx));
604 if (MEM_EXPR (in_rtx))
605 print_mem_expr (outfile, MEM_EXPR (in_rtx));
607 if (MEM_OFFSET_KNOWN_P (in_rtx))
608 fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC, MEM_OFFSET (in_rtx));
610 if (MEM_SIZE_KNOWN_P (in_rtx))
611 fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC, MEM_SIZE (in_rtx));
613 if (MEM_ALIGN (in_rtx) != 1)
614 fprintf (outfile, " A%u", MEM_ALIGN (in_rtx));
616 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx)))
617 fprintf (outfile, " AS%u", MEM_ADDR_SPACE (in_rtx));
619 fputc (']', outfile);
620 break;
622 case CONST_DOUBLE:
623 if (FLOAT_MODE_P (GET_MODE (in_rtx)))
625 char s[60];
627 real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
628 sizeof (s), 0, 1);
629 fprintf (outfile, " %s", s);
631 real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
632 sizeof (s), 0, 1);
633 fprintf (outfile, " [%s]", s);
635 break;
636 #endif
638 case CODE_LABEL:
639 fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx));
640 switch (LABEL_KIND (in_rtx))
642 case LABEL_NORMAL: break;
643 case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break;
644 case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break;
645 case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break;
646 default: gcc_unreachable ();
648 break;
650 default:
651 break;
654 if (dump_for_graph
655 && (is_insn || NOTE_P (in_rtx)
656 || LABEL_P (in_rtx) || BARRIER_P (in_rtx)))
657 sawclose = 0;
658 else
660 fputc (')', outfile);
661 sawclose = 1;
665 /* Print an rtx on the current line of FILE. Initially indent IND
666 characters. */
668 void
669 print_inline_rtx (FILE *outf, const_rtx x, int ind)
671 int oldsaw = sawclose;
672 int oldindent = indent;
674 sawclose = 0;
675 indent = ind;
676 outfile = outf;
677 print_rtx (x);
678 sawclose = oldsaw;
679 indent = oldindent;
682 /* Call this function from the debugger to see what X looks like. */
684 DEBUG_FUNCTION void
685 debug_rtx (const_rtx x)
687 outfile = stderr;
688 sawclose = 0;
689 print_rtx (x);
690 fprintf (stderr, "\n");
693 /* Count of rtx's to print with debug_rtx_list.
694 This global exists because gdb user defined commands have no arguments. */
696 DEBUG_VARIABLE int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */
698 /* Call this function to print list from X on.
700 N is a count of the rtx's to print. Positive values print from the specified
701 rtx on. Negative values print a window around the rtx.
702 EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */
704 DEBUG_FUNCTION void
705 debug_rtx_list (const_rtx x, int n)
707 int i,count;
708 const_rtx insn;
710 count = n == 0 ? 1 : n < 0 ? -n : n;
712 /* If we are printing a window, back up to the start. */
714 if (n < 0)
715 for (i = count / 2; i > 0; i--)
717 if (PREV_INSN (x) == 0)
718 break;
719 x = PREV_INSN (x);
722 for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
724 debug_rtx (insn);
725 fprintf (stderr, "\n");
729 /* Call this function to print an rtx list from START to END inclusive. */
731 DEBUG_FUNCTION void
732 debug_rtx_range (const_rtx start, const_rtx end)
734 while (1)
736 debug_rtx (start);
737 fprintf (stderr, "\n");
738 if (!start || start == end)
739 break;
740 start = NEXT_INSN (start);
744 /* Call this function to search an rtx list to find one with insn uid UID,
745 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
746 The found insn is returned to enable further debugging analysis. */
748 DEBUG_FUNCTION const_rtx
749 debug_rtx_find (const_rtx x, int uid)
751 while (x != 0 && INSN_UID (x) != uid)
752 x = NEXT_INSN (x);
753 if (x != 0)
755 debug_rtx_list (x, debug_rtx_count);
756 return x;
758 else
760 fprintf (stderr, "insn uid %d not found\n", uid);
761 return 0;
765 /* External entry point for printing a chain of insns
766 starting with RTX_FIRST onto file OUTF.
767 A blank line separates insns.
769 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
771 void
772 print_rtl (FILE *outf, const_rtx rtx_first)
774 const_rtx tmp_rtx;
776 outfile = outf;
777 sawclose = 0;
779 if (rtx_first == 0)
781 fputs (print_rtx_head, outf);
782 fputs ("(nil)\n", outf);
784 else
785 switch (GET_CODE (rtx_first))
787 case INSN:
788 case JUMP_INSN:
789 case CALL_INSN:
790 case NOTE:
791 case CODE_LABEL:
792 case BARRIER:
793 for (tmp_rtx = rtx_first; tmp_rtx != 0; tmp_rtx = NEXT_INSN (tmp_rtx))
795 fputs (print_rtx_head, outfile);
796 print_rtx (tmp_rtx);
797 fprintf (outfile, "\n");
799 break;
801 default:
802 fputs (print_rtx_head, outfile);
803 print_rtx (rtx_first);
807 /* Like print_rtx, except specify a file. */
808 /* Return nonzero if we actually printed anything. */
811 print_rtl_single (FILE *outf, const_rtx x)
813 outfile = outf;
814 sawclose = 0;
815 fputs (print_rtx_head, outfile);
816 print_rtx (x);
817 putc ('\n', outf);
818 return 1;
822 /* Like print_rtl except without all the detail; for example,
823 if RTX is a CONST_INT then print in decimal format. */
825 void
826 print_simple_rtl (FILE *outf, const_rtx x)
828 flag_simple = 1;
829 print_rtl (outf, x);
830 flag_simple = 0;