OSDN Git Service

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