OSDN Git Service

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