OSDN Git Service

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