* gcc.dg/vect/slp-9.c: Disable einline.
[official-gcc.git] / gcc / print-rtl.c
blob4824aba3f603a7ec72773d1eaeffb3b7a2d8080d
1 /* Print RTL for GCC.
2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* This file is compiled twice: once for the generator programs,
21 once for the compiler. */
22 #ifdef GENERATOR_FILE
23 #include "bconfig.h"
24 #else
25 #include "config.h"
26 #endif
28 #include "system.h"
29 #include "coretypes.h"
30 #include "tm.h"
31 #include "rtl.h"
33 /* These headers all define things which are not available in
34 generator programs. */
35 #ifndef GENERATOR_FILE
36 #include "tree.h"
37 #include "print-tree.h"
38 #include "flags.h"
39 #include "hard-reg-set.h"
40 #include "predict.h"
41 #include "vec.h"
42 #include "hashtab.h"
43 #include "hash-set.h"
44 #include "machmode.h"
45 #include "input.h"
46 #include "function.h"
47 #include "basic-block.h"
48 #include "diagnostic.h"
49 #include "tree-pretty-print.h"
50 #include "cselib.h"
51 #include "dumpfile.h" /* for dump_flags */
52 #include "dwarf2out.h"
53 #endif
55 static FILE *outfile;
57 static int sawclose = 0;
59 static int indent;
61 static bool in_call_function_usage;
63 static void print_rtx (const_rtx);
65 /* String printed at beginning of each RTL when it is dumped.
66 This string is set to ASM_COMMENT_START when the RTL is dumped in
67 the assembly output file. */
68 const char *print_rtx_head = "";
70 #ifdef GENERATOR_FILE
71 /* These are defined from the .opt file when not used in generator
72 programs. */
74 /* Nonzero means suppress output of instruction numbers
75 in debugging dumps.
76 This must be defined here so that programs like gencodes can be linked. */
77 int flag_dump_unnumbered = 0;
79 /* Nonzero means suppress output of instruction numbers for previous
80 and next insns in debugging dumps.
81 This must be defined here so that programs like gencodes can be linked. */
82 int flag_dump_unnumbered_links = 0;
83 #endif
85 /* Nonzero means use simplified format without flags, modes, etc. */
86 int flag_simple = 0;
88 #ifndef GENERATOR_FILE
89 void
90 print_mem_expr (FILE *outfile, const_tree expr)
92 fputc (' ', outfile);
93 print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
95 #endif
97 /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
99 static void
100 print_rtx (const_rtx in_rtx)
102 int i = 0;
103 int j;
104 const char *format_ptr;
105 int is_insn;
107 if (sawclose)
109 if (flag_simple)
110 fputc (' ', outfile);
111 else
112 fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
113 sawclose = 0;
116 if (in_rtx == 0)
118 fputs ("(nil)", outfile);
119 sawclose = 1;
120 return;
122 else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
124 fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx),
125 print_rtx_head, indent * 2, "");
126 sawclose = 1;
127 return;
130 is_insn = INSN_P (in_rtx);
132 /* Print name of expression code. */
133 if (flag_simple && CONST_INT_P (in_rtx))
134 fputc ('(', outfile);
135 else
136 fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
138 if (! flag_simple)
140 if (RTX_FLAG (in_rtx, in_struct))
141 fputs ("/s", outfile);
143 if (RTX_FLAG (in_rtx, volatil))
144 fputs ("/v", outfile);
146 if (RTX_FLAG (in_rtx, unchanging))
147 fputs ("/u", outfile);
149 if (RTX_FLAG (in_rtx, frame_related))
150 fputs ("/f", outfile);
152 if (RTX_FLAG (in_rtx, jump))
153 fputs ("/j", outfile);
155 if (RTX_FLAG (in_rtx, call))
156 fputs ("/c", outfile);
158 if (RTX_FLAG (in_rtx, return_val))
159 fputs ("/i", outfile);
161 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
162 if ((GET_CODE (in_rtx) == EXPR_LIST
163 || GET_CODE (in_rtx) == INSN_LIST
164 || GET_CODE (in_rtx) == INT_LIST)
165 && (int)GET_MODE (in_rtx) < REG_NOTE_MAX
166 && !in_call_function_usage)
167 fprintf (outfile, ":%s",
168 GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
170 /* For other rtl, print the mode if it's not VOID. */
171 else if (GET_MODE (in_rtx) != VOIDmode)
172 fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
174 #ifndef GENERATOR_FILE
175 if (GET_CODE (in_rtx) == VAR_LOCATION)
177 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST)
178 fputs (" <debug string placeholder>", outfile);
179 else
180 print_mem_expr (outfile, PAT_VAR_LOCATION_DECL (in_rtx));
181 fputc (' ', outfile);
182 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx));
183 if (PAT_VAR_LOCATION_STATUS (in_rtx)
184 == VAR_INIT_STATUS_UNINITIALIZED)
185 fprintf (outfile, " [uninit]");
186 sawclose = 1;
187 i = GET_RTX_LENGTH (VAR_LOCATION);
189 #endif
192 #ifndef GENERATOR_FILE
193 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx))
194 i = 5;
195 #endif
197 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx)))
199 if (flag_dump_unnumbered)
200 fprintf (outfile, " #");
201 else
202 fprintf (outfile, " %d", INSN_UID (in_rtx));
205 /* Get the format string and skip the first elements if we have handled
206 them already. */
207 format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i;
208 for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
209 switch (*format_ptr++)
211 const char *str;
213 case 'T':
214 str = XTMPL (in_rtx, i);
215 goto string;
217 case 'S':
218 case 's':
219 str = XSTR (in_rtx, i);
220 string:
222 if (str == 0)
223 fputs (" \"\"", outfile);
224 else
225 fprintf (outfile, " (\"%s\")", str);
226 sawclose = 1;
227 break;
229 /* 0 indicates a field for internal use that should not be printed.
230 An exception is the third field of a NOTE, where it indicates
231 that the field has several different valid contents. */
232 case '0':
233 #ifndef GENERATOR_FILE
234 if (i == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
236 int flags = SYMBOL_REF_FLAGS (in_rtx);
237 if (flags)
238 fprintf (outfile, " [flags %#x]", flags);
239 tree decl = SYMBOL_REF_DECL (in_rtx);
240 if (decl)
241 print_node_brief (outfile, "", decl, dump_flags);
243 else if (i == 3 && NOTE_P (in_rtx))
245 switch (NOTE_KIND (in_rtx))
247 case NOTE_INSN_EH_REGION_BEG:
248 case NOTE_INSN_EH_REGION_END:
249 if (flag_dump_unnumbered)
250 fprintf (outfile, " #");
251 else
252 fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx));
253 sawclose = 1;
254 break;
256 case NOTE_INSN_BLOCK_BEG:
257 case NOTE_INSN_BLOCK_END:
258 dump_addr (outfile, " ", NOTE_BLOCK (in_rtx));
259 sawclose = 1;
260 break;
262 case NOTE_INSN_BASIC_BLOCK:
264 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
265 if (bb != 0)
266 fprintf (outfile, " [bb %d]", bb->index);
267 break;
270 case NOTE_INSN_DELETED_LABEL:
271 case NOTE_INSN_DELETED_DEBUG_LABEL:
273 const char *label = NOTE_DELETED_LABEL_NAME (in_rtx);
274 if (label)
275 fprintf (outfile, " (\"%s\")", label);
276 else
277 fprintf (outfile, " \"\"");
279 break;
281 case NOTE_INSN_SWITCH_TEXT_SECTIONS:
283 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
284 if (bb != 0)
285 fprintf (outfile, " [bb %d]", bb->index);
286 break;
289 case NOTE_INSN_VAR_LOCATION:
290 case NOTE_INSN_CALL_ARG_LOCATION:
291 fputc (' ', outfile);
292 print_rtx (NOTE_VAR_LOCATION (in_rtx));
293 break;
295 case NOTE_INSN_CFI:
296 fputc ('\n', outfile);
297 output_cfi_directive (outfile, NOTE_CFI (in_rtx));
298 fputc ('\t', outfile);
299 break;
301 default:
302 break;
305 else if (i == 7 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL)
307 /* Output the JUMP_LABEL reference. */
308 fprintf (outfile, "\n%s%*s -> ", print_rtx_head, indent * 2, "");
309 if (GET_CODE (JUMP_LABEL (in_rtx)) == RETURN)
310 fprintf (outfile, "return");
311 else if (GET_CODE (JUMP_LABEL (in_rtx)) == SIMPLE_RETURN)
312 fprintf (outfile, "simple_return");
313 else
314 fprintf (outfile, "%d", INSN_UID (JUMP_LABEL (in_rtx)));
316 else if (i == 0 && GET_CODE (in_rtx) == VALUE)
318 cselib_val *val = CSELIB_VAL_PTR (in_rtx);
320 fprintf (outfile, " %u:%u", val->uid, val->hash);
321 dump_addr (outfile, " @", in_rtx);
322 dump_addr (outfile, "/", (void*)val);
324 else if (i == 0 && GET_CODE (in_rtx) == DEBUG_EXPR)
326 fprintf (outfile, " D#%i",
327 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx)));
329 else if (i == 0 && GET_CODE (in_rtx) == ENTRY_VALUE)
331 indent += 2;
332 if (!sawclose)
333 fprintf (outfile, " ");
334 print_rtx (ENTRY_VALUE_EXP (in_rtx));
335 indent -= 2;
337 #endif
338 break;
340 case 'e':
341 do_e:
342 indent += 2;
343 if (i == 6 && INSN_P (in_rtx))
344 /* Put REG_NOTES on their own line. */
345 fprintf (outfile, "\n%s%*s",
346 print_rtx_head, indent * 2, "");
347 if (!sawclose)
348 fprintf (outfile, " ");
349 if (i == 7 && CALL_P (in_rtx))
351 in_call_function_usage = true;
352 print_rtx (XEXP (in_rtx, i));
353 in_call_function_usage = false;
355 else
356 print_rtx (XEXP (in_rtx, i));
357 indent -= 2;
358 break;
360 case 'E':
361 case 'V':
362 indent += 2;
363 if (sawclose)
365 fprintf (outfile, "\n%s%*s",
366 print_rtx_head, indent * 2, "");
367 sawclose = 0;
369 fputs (" [", outfile);
370 if (NULL != XVEC (in_rtx, i))
372 indent += 2;
373 if (XVECLEN (in_rtx, i))
374 sawclose = 1;
376 for (j = 0; j < XVECLEN (in_rtx, i); j++)
377 print_rtx (XVECEXP (in_rtx, i, j));
379 indent -= 2;
381 if (sawclose)
382 fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
384 fputs ("]", outfile);
385 sawclose = 1;
386 indent -= 2;
387 break;
389 case 'w':
390 if (! flag_simple)
391 fprintf (outfile, " ");
392 fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
393 if (! flag_simple)
394 fprintf (outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
395 (unsigned HOST_WIDE_INT) XWINT (in_rtx, i));
396 break;
398 case 'i':
399 if (i == 4 && INSN_P (in_rtx))
401 #ifndef GENERATOR_FILE
402 const rtx_insn *in_insn = as_a <const rtx_insn *> (in_rtx);
404 /* Pretty-print insn locations. Ignore scoping as it is mostly
405 redundant with line number information and do not print anything
406 when there is no location information available. */
407 if (INSN_HAS_LOCATION (in_insn))
409 expanded_location xloc = insn_location (in_insn);
410 fprintf (outfile, " %s:%i", xloc.file, xloc.line);
412 #endif
414 else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
416 #ifndef GENERATOR_FILE
417 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
418 fprintf (outfile, " %s:%i",
419 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)),
420 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)));
421 #endif
423 else if (i == 1 && GET_CODE (in_rtx) == ASM_INPUT)
425 #ifndef GENERATOR_FILE
426 if (ASM_INPUT_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
427 fprintf (outfile, " %s:%i",
428 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx)),
429 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx)));
430 #endif
432 else if (i == 5 && NOTE_P (in_rtx))
434 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
435 other times often contains garbage from INSN->NOTE death. */
436 if (NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_LABEL
437 || NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_DEBUG_LABEL)
438 fprintf (outfile, " %d", XINT (in_rtx, i));
440 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
441 else if (i == 1
442 && GET_CODE (in_rtx) == UNSPEC_VOLATILE
443 && XINT (in_rtx, 1) >= 0
444 && XINT (in_rtx, 1) < NUM_UNSPECV_VALUES)
445 fprintf (outfile, " %s", unspecv_strings[XINT (in_rtx, 1)]);
446 #endif
447 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
448 else if (i == 1
449 && (GET_CODE (in_rtx) == UNSPEC
450 || GET_CODE (in_rtx) == UNSPEC_VOLATILE)
451 && XINT (in_rtx, 1) >= 0
452 && XINT (in_rtx, 1) < NUM_UNSPEC_VALUES)
453 fprintf (outfile, " %s", unspec_strings[XINT (in_rtx, 1)]);
454 #endif
455 else
457 int value = XINT (in_rtx, i);
458 const char *name;
460 #ifndef GENERATOR_FILE
461 if (REG_P (in_rtx) && (unsigned) value < FIRST_PSEUDO_REGISTER)
462 fprintf (outfile, " %d %s", value, reg_names[value]);
463 else if (REG_P (in_rtx)
464 && (unsigned) value <= LAST_VIRTUAL_REGISTER)
466 if (value == VIRTUAL_INCOMING_ARGS_REGNUM)
467 fprintf (outfile, " %d virtual-incoming-args", value);
468 else if (value == VIRTUAL_STACK_VARS_REGNUM)
469 fprintf (outfile, " %d virtual-stack-vars", value);
470 else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM)
471 fprintf (outfile, " %d virtual-stack-dynamic", value);
472 else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM)
473 fprintf (outfile, " %d virtual-outgoing-args", value);
474 else if (value == VIRTUAL_CFA_REGNUM)
475 fprintf (outfile, " %d virtual-cfa", value);
476 else if (value == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM)
477 fprintf (outfile, " %d virtual-preferred-stack-boundary",
478 value);
479 else
480 fprintf (outfile, " %d virtual-reg-%d", value,
481 value-FIRST_VIRTUAL_REGISTER);
483 else
484 #endif
485 if (flag_dump_unnumbered
486 && (is_insn || NOTE_P (in_rtx)))
487 fputc ('#', outfile);
488 else
489 fprintf (outfile, " %d", value);
491 #ifndef GENERATOR_FILE
492 if (REG_P (in_rtx) && REG_ATTRS (in_rtx))
494 fputs (" [", outfile);
495 if (ORIGINAL_REGNO (in_rtx) != REGNO (in_rtx))
496 fprintf (outfile, "orig:%i", ORIGINAL_REGNO (in_rtx));
497 if (REG_EXPR (in_rtx))
498 print_mem_expr (outfile, REG_EXPR (in_rtx));
500 if (REG_OFFSET (in_rtx))
501 fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC,
502 REG_OFFSET (in_rtx));
503 fputs (" ]", outfile);
505 if (REG_P (in_rtx) && REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
506 fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
507 #endif
509 if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
510 && XINT (in_rtx, i) >= 0
511 && (name = get_insn_name (XINT (in_rtx, i))) != NULL)
512 fprintf (outfile, " {%s}", name);
513 sawclose = 0;
515 break;
517 /* Print NOTE_INSN names rather than integer codes. */
519 case 'n':
520 fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i)));
521 sawclose = 0;
522 break;
524 case 'u':
525 if (XEXP (in_rtx, i) != NULL)
527 rtx sub = XEXP (in_rtx, i);
528 enum rtx_code subc = GET_CODE (sub);
530 if (GET_CODE (in_rtx) == LABEL_REF)
532 if (subc == NOTE
533 && NOTE_KIND (sub) == NOTE_INSN_DELETED_LABEL)
535 if (flag_dump_unnumbered)
536 fprintf (outfile, " [# deleted]");
537 else
538 fprintf (outfile, " [%d deleted]", INSN_UID (sub));
539 sawclose = 0;
540 break;
543 if (subc != CODE_LABEL)
544 goto do_e;
547 if (flag_dump_unnumbered
548 || (flag_dump_unnumbered_links && (i == 1 || i == 2)
549 && (INSN_P (in_rtx) || NOTE_P (in_rtx)
550 || LABEL_P (in_rtx) || BARRIER_P (in_rtx))))
551 fputs (" #", outfile);
552 else
553 fprintf (outfile, " %d", INSN_UID (sub));
555 else
556 fputs (" 0", outfile);
557 sawclose = 0;
558 break;
560 case 't':
561 #ifndef GENERATOR_FILE
562 if (i == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR)
563 print_mem_expr (outfile, DEBUG_IMPLICIT_PTR_DECL (in_rtx));
564 else if (i == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF)
565 print_mem_expr (outfile, DEBUG_PARAMETER_REF_DECL (in_rtx));
566 else
567 dump_addr (outfile, " ", XTREE (in_rtx, i));
568 #endif
569 break;
571 case '*':
572 fputs (" Unknown", outfile);
573 sawclose = 0;
574 break;
576 case 'B':
577 #ifndef GENERATOR_FILE
578 if (XBBDEF (in_rtx, i))
579 fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index);
580 #endif
581 break;
583 default:
584 gcc_unreachable ();
587 switch (GET_CODE (in_rtx))
589 #ifndef GENERATOR_FILE
590 case MEM:
591 if (__builtin_expect (final_insns_dump_p, false))
592 fprintf (outfile, " [");
593 else
594 fprintf (outfile, " [" HOST_WIDE_INT_PRINT_DEC,
595 (HOST_WIDE_INT) MEM_ALIAS_SET (in_rtx));
597 if (MEM_EXPR (in_rtx))
598 print_mem_expr (outfile, MEM_EXPR (in_rtx));
599 else
600 fputc (' ', outfile);
602 if (MEM_OFFSET_KNOWN_P (in_rtx))
603 fprintf (outfile, "+" HOST_WIDE_INT_PRINT_DEC, MEM_OFFSET (in_rtx));
605 if (MEM_SIZE_KNOWN_P (in_rtx))
606 fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC, MEM_SIZE (in_rtx));
608 if (MEM_ALIGN (in_rtx) != 1)
609 fprintf (outfile, " A%u", MEM_ALIGN (in_rtx));
611 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx)))
612 fprintf (outfile, " AS%u", MEM_ADDR_SPACE (in_rtx));
614 fputc (']', outfile);
615 break;
617 case CONST_DOUBLE:
618 if (FLOAT_MODE_P (GET_MODE (in_rtx)))
620 char s[60];
622 real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
623 sizeof (s), 0, 1);
624 fprintf (outfile, " %s", s);
626 real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
627 sizeof (s), 0, 1);
628 fprintf (outfile, " [%s]", s);
630 break;
632 case CONST_WIDE_INT:
633 fprintf (outfile, " ");
634 cwi_output_hex (outfile, in_rtx);
635 break;
636 #endif
638 case CODE_LABEL:
639 fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx));
640 switch (LABEL_KIND (in_rtx))
642 case LABEL_NORMAL: break;
643 case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break;
644 case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break;
645 case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break;
646 default: gcc_unreachable ();
648 break;
650 default:
651 break;
654 fputc (')', outfile);
655 sawclose = 1;
658 /* Print an rtx on the current line of FILE. Initially indent IND
659 characters. */
661 void
662 print_inline_rtx (FILE *outf, const_rtx x, int ind)
664 int oldsaw = sawclose;
665 int oldindent = indent;
667 sawclose = 0;
668 indent = ind;
669 outfile = outf;
670 print_rtx (x);
671 sawclose = oldsaw;
672 indent = oldindent;
675 /* Call this function from the debugger to see what X looks like. */
677 DEBUG_FUNCTION void
678 debug_rtx (const_rtx x)
680 outfile = stderr;
681 sawclose = 0;
682 print_rtx (x);
683 fprintf (stderr, "\n");
686 /* Dump rtx REF. */
688 DEBUG_FUNCTION void
689 debug (const rtx_def &ref)
691 debug_rtx (&ref);
694 DEBUG_FUNCTION void
695 debug (const rtx_def *ptr)
697 if (ptr)
698 debug (*ptr);
699 else
700 fprintf (stderr, "<nil>\n");
703 /* Count of rtx's to print with debug_rtx_list.
704 This global exists because gdb user defined commands have no arguments. */
706 DEBUG_VARIABLE int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */
708 /* Call this function to print list from X on.
710 N is a count of the rtx's to print. Positive values print from the specified
711 rtx_insn on. Negative values print a window around the rtx_insn.
712 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
713 rtx_insn). */
715 DEBUG_FUNCTION void
716 debug_rtx_list (const rtx_insn *x, int n)
718 int i,count;
719 const rtx_insn *insn;
721 count = n == 0 ? 1 : n < 0 ? -n : n;
723 /* If we are printing a window, back up to the start. */
725 if (n < 0)
726 for (i = count / 2; i > 0; i--)
728 if (PREV_INSN (x) == 0)
729 break;
730 x = PREV_INSN (x);
733 for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
735 debug_rtx (insn);
736 fprintf (stderr, "\n");
740 /* Call this function to print an rtx_insn list from START to END
741 inclusive. */
743 DEBUG_FUNCTION void
744 debug_rtx_range (const rtx_insn *start, const rtx_insn *end)
746 while (1)
748 debug_rtx (start);
749 fprintf (stderr, "\n");
750 if (!start || start == end)
751 break;
752 start = NEXT_INSN (start);
756 /* Call this function to search an rtx_insn list to find one with insn uid UID,
757 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
758 The found insn is returned to enable further debugging analysis. */
760 DEBUG_FUNCTION const_rtx
761 debug_rtx_find (const rtx_insn *x, int uid)
763 while (x != 0 && INSN_UID (x) != uid)
764 x = NEXT_INSN (x);
765 if (x != 0)
767 debug_rtx_list (x, debug_rtx_count);
768 return x;
770 else
772 fprintf (stderr, "insn uid %d not found\n", uid);
773 return 0;
777 /* External entry point for printing a chain of insns
778 starting with RTX_FIRST onto file OUTF.
779 A blank line separates insns.
781 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
783 void
784 print_rtl (FILE *outf, const_rtx rtx_first)
786 const rtx_insn *tmp_rtx;
788 outfile = outf;
789 sawclose = 0;
791 if (rtx_first == 0)
793 fputs (print_rtx_head, outf);
794 fputs ("(nil)\n", outf);
796 else
797 switch (GET_CODE (rtx_first))
799 case INSN:
800 case JUMP_INSN:
801 case CALL_INSN:
802 case NOTE:
803 case CODE_LABEL:
804 case JUMP_TABLE_DATA:
805 case BARRIER:
806 for (tmp_rtx = as_a <const rtx_insn *> (rtx_first);
807 tmp_rtx != 0;
808 tmp_rtx = NEXT_INSN (tmp_rtx))
810 fputs (print_rtx_head, outfile);
811 print_rtx (tmp_rtx);
812 fprintf (outfile, "\n");
814 break;
816 default:
817 fputs (print_rtx_head, outfile);
818 print_rtx (rtx_first);
822 /* Like print_rtx, except specify a file. */
823 /* Return nonzero if we actually printed anything. */
826 print_rtl_single (FILE *outf, const_rtx x)
828 return print_rtl_single_with_indent (outf, x, 0);
831 /* Like print_rtl_single, except specify a file and indentation. */
834 print_rtl_single_with_indent (FILE *outf, const_rtx x, int ind)
836 int old_indent = indent;
837 char *s_indent = (char *) alloca ((size_t) ind + 1);
838 memset ((void *) s_indent, ' ', (size_t) ind);
839 s_indent[ind] = '\0';
841 indent = ind;
842 outfile = outf;
843 sawclose = 0;
844 fputs (s_indent, outfile);
845 fputs (print_rtx_head, outfile);
846 print_rtx (x);
847 putc ('\n', outf);
848 indent = old_indent;
849 return 1;
853 /* Like print_rtl except without all the detail; for example,
854 if RTX is a CONST_INT then print in decimal format. */
856 void
857 print_simple_rtl (FILE *outf, const_rtx x)
859 flag_simple = 1;
860 print_rtl (outf, x);
861 flag_simple = 0;