print-rtl.c revision 260918
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#ifndef GENERATOR_FILE
287		dump_addr (outfile, " ", NOTE_BLOCK (in_rtx));
288#endif
289		sawclose = 1;
290		break;
291
292	      case NOTE_INSN_BASIC_BLOCK:
293		{
294#ifndef GENERATOR_FILE
295		  basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
296		  if (bb != 0)
297		    fprintf (outfile, " [bb %d]", bb->index);
298#endif
299		  break;
300	        }
301
302	      case NOTE_INSN_EXPECTED_VALUE:
303		indent += 2;
304		if (!sawclose)
305		  fprintf (outfile, " ");
306		print_rtx (NOTE_EXPECTED_VALUE (in_rtx));
307		indent -= 2;
308		break;
309
310	      case NOTE_INSN_DELETED_LABEL:
311		{
312		  const char *label = NOTE_DELETED_LABEL_NAME (in_rtx);
313		  if (label)
314		    fprintf (outfile, " (\"%s\")", label);
315		  else
316		    fprintf (outfile, " \"\"");
317		}
318		break;
319
320	      case NOTE_INSN_SWITCH_TEXT_SECTIONS:
321		{
322#ifndef GENERATOR_FILE
323		  basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
324		  if (bb != 0)
325		    fprintf (outfile, " [bb %d]", bb->index);
326#endif
327		  break;
328		}
329
330	      case NOTE_INSN_VAR_LOCATION:
331#ifndef GENERATOR_FILE
332		fprintf (outfile, " (");
333		print_mem_expr (outfile, NOTE_VAR_LOCATION_DECL (in_rtx));
334		fprintf (outfile, " ");
335		print_rtx (NOTE_VAR_LOCATION_LOC (in_rtx));
336		fprintf (outfile, ")");
337#endif
338		break;
339
340	      default:
341		{
342		  const char * const str = X0STR (in_rtx, i);
343
344		  if (NOTE_LINE_NUMBER (in_rtx) < 0)
345		    ;
346		  else if (str == 0)
347		    fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile);
348		  else
349		    {
350		      if (dump_for_graph)
351		        fprintf (outfile, " (\\\"%s\\\")", str);
352		      else
353		        fprintf (outfile, " (\"%s\")", str);
354		    }
355		  break;
356		}
357	      }
358	  }
359	break;
360
361      case 'e':
362      do_e:
363	indent += 2;
364	if (!sawclose)
365	  fprintf (outfile, " ");
366	print_rtx (XEXP (in_rtx, i));
367	indent -= 2;
368	break;
369
370      case 'E':
371      case 'V':
372	indent += 2;
373	if (sawclose)
374	  {
375	    fprintf (outfile, "\n%s%*s",
376		     print_rtx_head, indent * 2, "");
377	    sawclose = 0;
378	  }
379	fputs (" [", outfile);
380	if (NULL != XVEC (in_rtx, i))
381	  {
382	    indent += 2;
383	    if (XVECLEN (in_rtx, i))
384	      sawclose = 1;
385
386	    for (j = 0; j < XVECLEN (in_rtx, i); j++)
387	      print_rtx (XVECEXP (in_rtx, i, j));
388
389	    indent -= 2;
390	  }
391	if (sawclose)
392	  fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
393
394	fputs ("]", outfile);
395	sawclose = 1;
396	indent -= 2;
397	break;
398
399      case 'w':
400	if (! flag_simple)
401	  fprintf (outfile, " ");
402	fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
403	if (! flag_simple)
404	  fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
405		   XWINT (in_rtx, i));
406	break;
407
408      case 'i':
409	if (i == 4 && INSN_P (in_rtx))
410	  {
411#ifndef GENERATOR_FILE
412	    /*  Pretty-print insn locators.  Ignore scoping as it is mostly
413		redundant with line number information and do not print anything
414		when there is no location information available.  */
415	    if (INSN_LOCATOR (in_rtx) && insn_file (in_rtx))
416	      fprintf(outfile, " %s:%i", insn_file (in_rtx), insn_line (in_rtx));
417#endif
418	  }
419	else if (i == 6 && NOTE_P (in_rtx))
420	  {
421	    /* This field is only used for NOTE_INSN_DELETED_LABEL, and
422	       other times often contains garbage from INSN->NOTE death.  */
423	    if (NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_DELETED_LABEL)
424	      fprintf (outfile, " %d",  XINT (in_rtx, i));
425	  }
426	else
427	  {
428	    int value = XINT (in_rtx, i);
429	    const char *name;
430
431#ifndef GENERATOR_FILE
432	    if (REG_P (in_rtx) && value < FIRST_PSEUDO_REGISTER)
433	      fprintf (outfile, " %d %s", REGNO (in_rtx),
434		       reg_names[REGNO (in_rtx)]);
435	    else if (REG_P (in_rtx)
436		     && value <= LAST_VIRTUAL_REGISTER)
437	      {
438		if (value == VIRTUAL_INCOMING_ARGS_REGNUM)
439		  fprintf (outfile, " %d virtual-incoming-args", value);
440		else if (value == VIRTUAL_STACK_VARS_REGNUM)
441		  fprintf (outfile, " %d virtual-stack-vars", value);
442		else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM)
443		  fprintf (outfile, " %d virtual-stack-dynamic", value);
444		else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM)
445		  fprintf (outfile, " %d virtual-outgoing-args", value);
446		else if (value == VIRTUAL_CFA_REGNUM)
447		  fprintf (outfile, " %d virtual-cfa", value);
448		else
449		  fprintf (outfile, " %d virtual-reg-%d", value,
450			   value-FIRST_VIRTUAL_REGISTER);
451	      }
452	    else
453#endif
454	      if (flag_dump_unnumbered
455		     && (is_insn || NOTE_P (in_rtx)))
456	      fputc ('#', outfile);
457	    else
458	      fprintf (outfile, " %d", value);
459
460#ifndef GENERATOR_FILE
461	    if (REG_P (in_rtx) && REG_ATTRS (in_rtx))
462	      {
463		fputs (" [", outfile);
464		if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx))
465		  fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx));
466		if (REG_EXPR (in_rtx))
467		  print_mem_expr (outfile, REG_EXPR (in_rtx));
468
469		if (REG_OFFSET (in_rtx))
470		  fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC,
471			   REG_OFFSET (in_rtx));
472		fputs (" ]", outfile);
473	      }
474#endif
475
476	    if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
477		&& XINT (in_rtx, i) >= 0
478		&& (name = get_insn_name (XINT (in_rtx, i))) != NULL)
479	      fprintf (outfile, " {%s}", name);
480	    sawclose = 0;
481	  }
482	break;
483
484      /* Print NOTE_INSN names rather than integer codes.  */
485
486      case 'n':
487	if (XINT (in_rtx, i) >= (int) NOTE_INSN_BIAS
488	    && XINT (in_rtx, i) < (int) NOTE_INSN_MAX)
489	  fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i)));
490	else
491	  fprintf (outfile, " %d", XINT (in_rtx, i));
492	sawclose = 0;
493	break;
494
495      case 'u':
496	if (XEXP (in_rtx, i) != NULL)
497	  {
498	    rtx sub = XEXP (in_rtx, i);
499	    enum rtx_code subc = GET_CODE (sub);
500
501	    if (GET_CODE (in_rtx) == LABEL_REF)
502	      {
503		if (subc == NOTE
504		    && NOTE_LINE_NUMBER (sub) == NOTE_INSN_DELETED_LABEL)
505		  {
506		    if (flag_dump_unnumbered)
507		      fprintf (outfile, " [# deleted]");
508		    else
509		      fprintf (outfile, " [%d deleted]", INSN_UID (sub));
510		    sawclose = 0;
511		    break;
512		  }
513
514		if (subc != CODE_LABEL)
515		  goto do_e;
516	      }
517
518	    if (flag_dump_unnumbered)
519	      fputs (" #", outfile);
520	    else
521	      fprintf (outfile, " %d", INSN_UID (sub));
522	  }
523	else
524	  fputs (" 0", outfile);
525	sawclose = 0;
526	break;
527
528      case 'b':
529#ifndef GENERATOR_FILE
530	if (XBITMAP (in_rtx, i) == NULL)
531	  fputs (" {null}", outfile);
532	else
533	  bitmap_print (outfile, XBITMAP (in_rtx, i), " {", "}");
534#endif
535	sawclose = 0;
536	break;
537
538      case 't':
539#ifndef GENERATOR_FILE
540	dump_addr (outfile, " ", XTREE (in_rtx, i));
541#endif
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	gcc_unreachable ();
558      }
559
560  switch (GET_CODE (in_rtx))
561    {
562#ifndef GENERATOR_FILE
563    case MEM:
564      fprintf (outfile, " [" HOST_WIDE_INT_PRINT_DEC, MEM_ALIAS_SET (in_rtx));
565
566      if (MEM_EXPR (in_rtx))
567	print_mem_expr (outfile, MEM_EXPR (in_rtx));
568
569      if (MEM_OFFSET (in_rtx))
570	fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC,
571		 INTVAL (MEM_OFFSET (in_rtx)));
572
573      if (MEM_SIZE (in_rtx))
574	fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC,
575		 INTVAL (MEM_SIZE (in_rtx)));
576
577      if (MEM_ALIGN (in_rtx) != 1)
578	fprintf (outfile, " A%u", MEM_ALIGN (in_rtx));
579
580      fputc (']', outfile);
581      break;
582
583    case CONST_DOUBLE:
584      if (FLOAT_MODE_P (GET_MODE (in_rtx)))
585	{
586	  char s[60];
587
588	  real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
589			   sizeof (s), 0, 1);
590	  fprintf (outfile, " %s", s);
591
592	  real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
593			       sizeof (s), 0, 1);
594	  fprintf (outfile, " [%s]", s);
595	}
596      break;
597#endif
598
599    case CODE_LABEL:
600      fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx));
601      switch (LABEL_KIND (in_rtx))
602	{
603	  case LABEL_NORMAL: break;
604	  case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break;
605	  case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break;
606	  case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break;
607	  default: gcc_unreachable ();
608	}
609/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
610      if (LABEL_ALIGN_LOG (in_rtx) > 0)
611	fprintf (outfile, " [log_align %u skip %u]", LABEL_ALIGN_LOG (in_rtx),
612		 LABEL_MAX_SKIP (in_rtx));
613/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
614      break;
615
616    default:
617      break;
618    }
619
620  if (dump_for_graph
621      && (is_insn || NOTE_P (in_rtx)
622	  || LABEL_P (in_rtx) || BARRIER_P (in_rtx)))
623    sawclose = 0;
624  else
625    {
626      fputc (')', outfile);
627      sawclose = 1;
628    }
629}
630
631/* Print an rtx on the current line of FILE.  Initially indent IND
632   characters.  */
633
634void
635print_inline_rtx (FILE *outf, rtx x, int ind)
636{
637  int oldsaw = sawclose;
638  int oldindent = indent;
639
640  sawclose = 0;
641  indent = ind;
642  outfile = outf;
643  print_rtx (x);
644  sawclose = oldsaw;
645  indent = oldindent;
646}
647
648/* Call this function from the debugger to see what X looks like.  */
649
650void
651debug_rtx (rtx x)
652{
653  outfile = stderr;
654  sawclose = 0;
655  print_rtx (x);
656  fprintf (stderr, "\n");
657}
658
659/* Count of rtx's to print with debug_rtx_list.
660   This global exists because gdb user defined commands have no arguments.  */
661
662int debug_rtx_count = 0;	/* 0 is treated as equivalent to 1 */
663
664/* Call this function to print list from X on.
665
666   N is a count of the rtx's to print. Positive values print from the specified
667   rtx on.  Negative values print a window around the rtx.
668   EG: -5 prints 2 rtx's on either side (in addition to the specified rtx).  */
669
670void
671debug_rtx_list (rtx x, int n)
672{
673  int i,count;
674  rtx insn;
675
676  count = n == 0 ? 1 : n < 0 ? -n : n;
677
678  /* If we are printing a window, back up to the start.  */
679
680  if (n < 0)
681    for (i = count / 2; i > 0; i--)
682      {
683	if (PREV_INSN (x) == 0)
684	  break;
685	x = PREV_INSN (x);
686      }
687
688  for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
689    {
690      debug_rtx (insn);
691      fprintf (stderr, "\n");
692    }
693}
694
695/* Call this function to print an rtx list from START to END inclusive.  */
696
697void
698debug_rtx_range (rtx start, rtx end)
699{
700  while (1)
701    {
702      debug_rtx (start);
703      fprintf (stderr, "\n");
704      if (!start || start == end)
705	break;
706      start = NEXT_INSN (start);
707    }
708}
709
710/* Call this function to search an rtx list to find one with insn uid UID,
711   and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
712   The found insn is returned to enable further debugging analysis.  */
713
714rtx
715debug_rtx_find (rtx x, int uid)
716{
717  while (x != 0 && INSN_UID (x) != uid)
718    x = NEXT_INSN (x);
719  if (x != 0)
720    {
721      debug_rtx_list (x, debug_rtx_count);
722      return x;
723    }
724  else
725    {
726      fprintf (stderr, "insn uid %d not found\n", uid);
727      return 0;
728    }
729}
730
731/* External entry point for printing a chain of insns
732   starting with RTX_FIRST onto file OUTF.
733   A blank line separates insns.
734
735   If RTX_FIRST is not an insn, then it alone is printed, with no newline.  */
736
737void
738print_rtl (FILE *outf, rtx rtx_first)
739{
740  rtx tmp_rtx;
741
742  outfile = outf;
743  sawclose = 0;
744
745  if (rtx_first == 0)
746    {
747      fputs (print_rtx_head, outf);
748      fputs ("(nil)\n", outf);
749    }
750  else
751    switch (GET_CODE (rtx_first))
752      {
753      case INSN:
754      case JUMP_INSN:
755      case CALL_INSN:
756      case NOTE:
757      case CODE_LABEL:
758      case BARRIER:
759	for (tmp_rtx = rtx_first; tmp_rtx != 0; tmp_rtx = NEXT_INSN (tmp_rtx))
760	  if (! flag_dump_unnumbered
761	      || !NOTE_P (tmp_rtx) || NOTE_LINE_NUMBER (tmp_rtx) < 0)
762	    {
763	      fputs (print_rtx_head, outfile);
764	      print_rtx (tmp_rtx);
765	      fprintf (outfile, "\n");
766	    }
767	break;
768
769      default:
770	fputs (print_rtx_head, outfile);
771	print_rtx (rtx_first);
772      }
773}
774
775/* Like print_rtx, except specify a file.  */
776/* Return nonzero if we actually printed anything.  */
777
778int
779print_rtl_single (FILE *outf, rtx x)
780{
781  outfile = outf;
782  sawclose = 0;
783  if (! flag_dump_unnumbered
784      || !NOTE_P (x) || NOTE_LINE_NUMBER (x) < 0)
785    {
786      fputs (print_rtx_head, outfile);
787      print_rtx (x);
788      putc ('\n', outf);
789      return 1;
790    }
791  return 0;
792}
793
794
795/* Like print_rtl except without all the detail; for example,
796   if RTX is a CONST_INT then print in decimal format.  */
797
798void
799print_simple_rtl (FILE *outf, rtx x)
800{
801  flag_simple = 1;
802  print_rtl (outf, x);
803  flag_simple = 0;
804}
805