OSDN Git Service

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