OSDN Git Service

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