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