2 Copyright (C) 1987-2017 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
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
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. */
29 #include "coretypes.h"
33 /* These headers all define things which are not available in
34 generator programs. */
35 #ifndef GENERATOR_FILE
38 #include "basic-block.h"
40 #include "print-tree.h"
44 #include "basic-block.h"
45 #include "diagnostic.h"
46 #include "tree-pretty-print.h"
47 #include "alloc-pool.h"
49 #include "dumpfile.h" /* for dump_flags */
50 #include "dwarf2out.h"
51 #include "pretty-print.h"
54 #include "print-rtl.h"
57 /* String printed at beginning of each RTL when it is dumped.
58 This string is set to ASM_COMMENT_START when the RTL is dumped in
59 the assembly output file. */
60 const char *print_rtx_head
= "";
63 /* These are defined from the .opt file when not used in generator
66 /* Nonzero means suppress output of instruction numbers
68 This must be defined here so that programs like gencodes can be linked. */
69 int flag_dump_unnumbered
= 0;
71 /* Nonzero means suppress output of instruction numbers for previous
72 and next insns in debugging dumps.
73 This must be defined here so that programs like gencodes can be linked. */
74 int flag_dump_unnumbered_links
= 0;
77 /* Constructor for rtx_writer. */
79 rtx_writer::rtx_writer (FILE *outf
, int ind
, bool simple
, bool compact
,
80 rtx_reuse_manager
*reuse_manager
)
81 : m_outfile (outf
), m_sawclose (0), m_indent (ind
),
82 m_in_call_function_usage (false), m_simple (simple
), m_compact (compact
),
83 m_rtx_reuse_manager (reuse_manager
)
87 #ifndef GENERATOR_FILE
89 /* rtx_reuse_manager's ctor. */
91 rtx_reuse_manager::rtx_reuse_manager ()
96 /* Determine if X is of a kind suitable for dumping via reuse_rtx. */
99 uses_rtx_reuse_p (const_rtx x
)
104 switch (GET_CODE (x
))
111 /* We don't use reuse_rtx for consts. */
118 /* Traverse X and its descendents, determining if we see any rtx more than
119 once. Any rtx suitable for "reuse_rtx" that is seen more than once is
123 rtx_reuse_manager::preprocess (const_rtx x
)
125 subrtx_iterator::array_type array
;
126 FOR_EACH_SUBRTX (iter
, array
, x
, NONCONST
)
127 if (uses_rtx_reuse_p (*iter
))
129 if (int *count
= m_rtx_occurrence_count
.get (*iter
))
132 m_rtx_reuse_ids
.put (*iter
, m_next_id
++);
135 m_rtx_occurrence_count
.put (*iter
, 1);
139 /* Return true iff X has been assigned a reuse ID. If it has,
140 and OUT is non-NULL, then write the reuse ID to *OUT. */
143 rtx_reuse_manager::has_reuse_id (const_rtx x
, int *out
)
145 int *id
= m_rtx_reuse_ids
.get (x
);
156 /* Determine if set_seen_def has been called for the given reuse ID. */
159 rtx_reuse_manager::seen_def_p (int reuse_id
)
161 return bitmap_bit_p (m_defs_seen
, reuse_id
);
164 /* Record that the definition of the given reuse ID has been seen. */
167 rtx_reuse_manager::set_seen_def (int reuse_id
)
169 bitmap_set_bit (m_defs_seen
, reuse_id
);
172 #endif /* #ifndef GENERATOR_FILE */
174 #ifndef GENERATOR_FILE
176 print_mem_expr (FILE *outfile
, const_tree expr
)
178 fputc (' ', outfile
);
179 print_generic_expr (outfile
, CONST_CAST_TREE (expr
), dump_flags
);
183 /* Subroutine of print_rtx_operand for handling code '0'.
184 0 indicates a field for internal use that should not be printed.
185 However there are various special cases, such as the third field
186 of a NOTE, where it indicates that the field has several different
190 rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED
,
191 int idx ATTRIBUTE_UNUSED
)
193 #ifndef GENERATOR_FILE
194 if (idx
== 1 && GET_CODE (in_rtx
) == SYMBOL_REF
)
196 int flags
= SYMBOL_REF_FLAGS (in_rtx
);
198 fprintf (m_outfile
, " [flags %#x]", flags
);
199 tree decl
= SYMBOL_REF_DECL (in_rtx
);
201 print_node_brief (m_outfile
, "", decl
, dump_flags
);
203 else if (idx
== 3 && NOTE_P (in_rtx
))
205 switch (NOTE_KIND (in_rtx
))
207 case NOTE_INSN_EH_REGION_BEG
:
208 case NOTE_INSN_EH_REGION_END
:
209 if (flag_dump_unnumbered
)
210 fprintf (m_outfile
, " #");
212 fprintf (m_outfile
, " %d", NOTE_EH_HANDLER (in_rtx
));
216 case NOTE_INSN_BLOCK_BEG
:
217 case NOTE_INSN_BLOCK_END
:
218 dump_addr (m_outfile
, " ", NOTE_BLOCK (in_rtx
));
222 case NOTE_INSN_BASIC_BLOCK
:
224 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
226 fprintf (m_outfile
, " [bb %d]", bb
->index
);
230 case NOTE_INSN_DELETED_LABEL
:
231 case NOTE_INSN_DELETED_DEBUG_LABEL
:
233 const char *label
= NOTE_DELETED_LABEL_NAME (in_rtx
);
235 fprintf (m_outfile
, " (\"%s\")", label
);
237 fprintf (m_outfile
, " \"\"");
241 case NOTE_INSN_SWITCH_TEXT_SECTIONS
:
243 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
245 fprintf (m_outfile
, " [bb %d]", bb
->index
);
249 case NOTE_INSN_VAR_LOCATION
:
250 case NOTE_INSN_CALL_ARG_LOCATION
:
251 fputc (' ', m_outfile
);
252 print_rtx (NOTE_VAR_LOCATION (in_rtx
));
256 fputc ('\n', m_outfile
);
257 output_cfi_directive (m_outfile
, NOTE_CFI (in_rtx
));
258 fputc ('\t', m_outfile
);
261 case NOTE_INSN_BEGIN_STMT
:
262 #ifndef GENERATOR_FILE
264 expanded_location xloc
265 = expand_location (NOTE_MARKER_LOCATION (in_rtx
));
266 fprintf (m_outfile
, " %s:%i", xloc
.file
, xloc
.line
);
275 else if (idx
== 7 && JUMP_P (in_rtx
) && JUMP_LABEL (in_rtx
) != NULL
278 /* Output the JUMP_LABEL reference. */
279 fprintf (m_outfile
, "\n%s%*s -> ", print_rtx_head
, m_indent
* 2, "");
280 if (GET_CODE (JUMP_LABEL (in_rtx
)) == RETURN
)
281 fprintf (m_outfile
, "return");
282 else if (GET_CODE (JUMP_LABEL (in_rtx
)) == SIMPLE_RETURN
)
283 fprintf (m_outfile
, "simple_return");
285 fprintf (m_outfile
, "%d", INSN_UID (JUMP_LABEL (in_rtx
)));
287 else if (idx
== 0 && GET_CODE (in_rtx
) == VALUE
)
289 cselib_val
*val
= CSELIB_VAL_PTR (in_rtx
);
291 fprintf (m_outfile
, " %u:%u", val
->uid
, val
->hash
);
292 dump_addr (m_outfile
, " @", in_rtx
);
293 dump_addr (m_outfile
, "/", (void*)val
);
295 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_EXPR
)
297 fprintf (m_outfile
, " D#%i",
298 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx
)));
300 else if (idx
== 0 && GET_CODE (in_rtx
) == ENTRY_VALUE
)
304 fprintf (m_outfile
, " ");
305 print_rtx (ENTRY_VALUE_EXP (in_rtx
));
311 /* Subroutine of print_rtx_operand for handling code 'e'.
312 Also called by print_rtx_operand_code_u for handling code 'u'
313 for LABEL_REFs when they don't reference a CODE_LABEL. */
316 rtx_writer::print_rtx_operand_code_e (const_rtx in_rtx
, int idx
)
319 if (idx
== 6 && INSN_P (in_rtx
))
320 /* Put REG_NOTES on their own line. */
321 fprintf (m_outfile
, "\n%s%*s",
322 print_rtx_head
, m_indent
* 2, "");
324 fprintf (m_outfile
, " ");
325 if (idx
== 7 && CALL_P (in_rtx
))
327 m_in_call_function_usage
= true;
328 print_rtx (XEXP (in_rtx
, idx
));
329 m_in_call_function_usage
= false;
332 print_rtx (XEXP (in_rtx
, idx
));
336 /* Subroutine of print_rtx_operand for handling codes 'E' and 'V'. */
339 rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx
, int idx
)
344 fprintf (m_outfile
, "\n%s%*s",
345 print_rtx_head
, m_indent
* 2, "");
348 fputs (" [", m_outfile
);
349 if (NULL
!= XVEC (in_rtx
, idx
))
352 if (XVECLEN (in_rtx
, idx
))
355 for (int j
= 0; j
< XVECLEN (in_rtx
, idx
); j
++)
356 print_rtx (XVECEXP (in_rtx
, idx
, j
));
361 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
363 fputs ("]", m_outfile
);
368 /* Subroutine of print_rtx_operand for handling code 'i'. */
371 rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx
, int idx
)
373 if (idx
== 4 && INSN_P (in_rtx
))
375 #ifndef GENERATOR_FILE
376 const rtx_insn
*in_insn
= as_a
<const rtx_insn
*> (in_rtx
);
378 /* Pretty-print insn locations. Ignore scoping as it is mostly
379 redundant with line number information and do not print anything
380 when there is no location information available. */
381 if (INSN_HAS_LOCATION (in_insn
))
383 expanded_location xloc
= insn_location (in_insn
);
384 fprintf (m_outfile
, " \"%s\":%i", xloc
.file
, xloc
.line
);
388 else if (idx
== 6 && GET_CODE (in_rtx
) == ASM_OPERANDS
)
390 #ifndef GENERATOR_FILE
391 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
392 fprintf (m_outfile
, " %s:%i",
393 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)),
394 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)));
397 else if (idx
== 1 && GET_CODE (in_rtx
) == ASM_INPUT
)
399 #ifndef GENERATOR_FILE
400 if (ASM_INPUT_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
401 fprintf (m_outfile
, " %s:%i",
402 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)),
403 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)));
406 else if (idx
== 5 && NOTE_P (in_rtx
))
408 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
409 other times often contains garbage from INSN->NOTE death. */
410 if (NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_LABEL
411 || NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_DEBUG_LABEL
)
412 fprintf (m_outfile
, " %d", XINT (in_rtx
, idx
));
414 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
416 && GET_CODE (in_rtx
) == UNSPEC_VOLATILE
417 && XINT (in_rtx
, 1) >= 0
418 && XINT (in_rtx
, 1) < NUM_UNSPECV_VALUES
)
419 fprintf (m_outfile
, " %s", unspecv_strings
[XINT (in_rtx
, 1)]);
421 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
423 && (GET_CODE (in_rtx
) == UNSPEC
424 || GET_CODE (in_rtx
) == UNSPEC_VOLATILE
)
425 && XINT (in_rtx
, 1) >= 0
426 && XINT (in_rtx
, 1) < NUM_UNSPEC_VALUES
)
427 fprintf (m_outfile
, " %s", unspec_strings
[XINT (in_rtx
, 1)]);
431 int value
= XINT (in_rtx
, idx
);
433 int is_insn
= INSN_P (in_rtx
);
435 /* Don't print INSN_CODEs in compact mode. */
436 if (m_compact
&& is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
))
442 if (flag_dump_unnumbered
443 && (is_insn
|| NOTE_P (in_rtx
)))
444 fputc ('#', m_outfile
);
446 fprintf (m_outfile
, " %d", value
);
448 if (is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
)
449 && XINT (in_rtx
, idx
) >= 0
450 && (name
= get_insn_name (XINT (in_rtx
, idx
))) != NULL
)
451 fprintf (m_outfile
, " {%s}", name
);
456 /* Subroutine of print_rtx_operand for handling code 'r'. */
459 rtx_writer::print_rtx_operand_code_r (const_rtx in_rtx
)
461 int is_insn
= INSN_P (in_rtx
);
462 unsigned int regno
= REGNO (in_rtx
);
464 #ifndef GENERATOR_FILE
465 /* For hard registers and virtuals, always print the
466 regno, except in compact mode. */
467 if (regno
<= LAST_VIRTUAL_REGISTER
&& !m_compact
)
468 fprintf (m_outfile
, " %d", regno
);
469 if (regno
< FIRST_PSEUDO_REGISTER
)
470 fprintf (m_outfile
, " %s", reg_names
[regno
]);
471 else if (regno
<= LAST_VIRTUAL_REGISTER
)
473 if (regno
== VIRTUAL_INCOMING_ARGS_REGNUM
)
474 fprintf (m_outfile
, " virtual-incoming-args");
475 else if (regno
== VIRTUAL_STACK_VARS_REGNUM
)
476 fprintf (m_outfile
, " virtual-stack-vars");
477 else if (regno
== VIRTUAL_STACK_DYNAMIC_REGNUM
)
478 fprintf (m_outfile
, " virtual-stack-dynamic");
479 else if (regno
== VIRTUAL_OUTGOING_ARGS_REGNUM
)
480 fprintf (m_outfile
, " virtual-outgoing-args");
481 else if (regno
== VIRTUAL_CFA_REGNUM
)
482 fprintf (m_outfile
, " virtual-cfa");
483 else if (regno
== VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM
)
484 fprintf (m_outfile
, " virtual-preferred-stack-boundary");
486 fprintf (m_outfile
, " virtual-reg-%d", regno
-FIRST_VIRTUAL_REGISTER
);
490 if (flag_dump_unnumbered
&& is_insn
)
491 fputc ('#', m_outfile
);
494 /* In compact mode, print pseudos with '< and '>' wrapping the regno,
495 offseting it by (LAST_VIRTUAL_REGISTER + 1), so that the
496 first non-virtual pseudo is dumped as "<0>". */
497 gcc_assert (regno
> LAST_VIRTUAL_REGISTER
);
498 fprintf (m_outfile
, " <%d>", regno
- (LAST_VIRTUAL_REGISTER
+ 1));
501 fprintf (m_outfile
, " %d", regno
);
503 #ifndef GENERATOR_FILE
504 if (REG_ATTRS (in_rtx
))
506 fputs (" [", m_outfile
);
507 if (regno
!= ORIGINAL_REGNO (in_rtx
))
508 fprintf (m_outfile
, "orig:%i", ORIGINAL_REGNO (in_rtx
));
509 if (REG_EXPR (in_rtx
))
510 print_mem_expr (m_outfile
, REG_EXPR (in_rtx
));
512 if (REG_OFFSET (in_rtx
))
513 fprintf (m_outfile
, "+" HOST_WIDE_INT_PRINT_DEC
,
514 REG_OFFSET (in_rtx
));
515 fputs (" ]", m_outfile
);
517 if (regno
!= ORIGINAL_REGNO (in_rtx
))
518 fprintf (m_outfile
, " [%d]", ORIGINAL_REGNO (in_rtx
));
522 /* Subroutine of print_rtx_operand for handling code 'u'. */
525 rtx_writer::print_rtx_operand_code_u (const_rtx in_rtx
, int idx
)
527 /* Don't print insn UIDs for PREV/NEXT_INSN in compact mode. */
528 if (m_compact
&& INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)) && idx
< 2)
531 if (XEXP (in_rtx
, idx
) != NULL
)
533 rtx sub
= XEXP (in_rtx
, idx
);
534 enum rtx_code subc
= GET_CODE (sub
);
536 if (GET_CODE (in_rtx
) == LABEL_REF
)
539 && NOTE_KIND (sub
) == NOTE_INSN_DELETED_LABEL
)
541 if (flag_dump_unnumbered
)
542 fprintf (m_outfile
, " [# deleted]");
544 fprintf (m_outfile
, " [%d deleted]", INSN_UID (sub
));
549 if (subc
!= CODE_LABEL
)
551 print_rtx_operand_code_e (in_rtx
, idx
);
556 if (flag_dump_unnumbered
557 || (flag_dump_unnumbered_links
&& idx
<= 1
558 && (INSN_P (in_rtx
) || NOTE_P (in_rtx
)
559 || LABEL_P (in_rtx
) || BARRIER_P (in_rtx
))))
560 fputs (" #", m_outfile
);
562 fprintf (m_outfile
, " %d", INSN_UID (sub
));
565 fputs (" 0", m_outfile
);
569 /* Subroutine of print_rtx. Print operand IDX of IN_RTX. */
572 rtx_writer::print_rtx_operand (const_rtx in_rtx
, int idx
)
574 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
576 switch (format_ptr
[idx
])
581 str
= XTMPL (in_rtx
, idx
);
586 str
= XSTR (in_rtx
, idx
);
590 fputs (" (nil)", m_outfile
);
592 fprintf (m_outfile
, " (\"%s\")", str
);
597 print_rtx_operand_code_0 (in_rtx
, idx
);
601 print_rtx_operand_code_e (in_rtx
, idx
);
606 print_rtx_operand_codes_E_and_V (in_rtx
, idx
);
611 fprintf (m_outfile
, " ");
612 fprintf (m_outfile
, HOST_WIDE_INT_PRINT_DEC
, XWINT (in_rtx
, idx
));
613 if (! m_simple
&& !m_compact
)
614 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_HEX
"]",
615 (unsigned HOST_WIDE_INT
) XWINT (in_rtx
, idx
));
619 print_rtx_operand_code_i (in_rtx
, idx
);
623 print_rtx_operand_code_r (in_rtx
);
626 /* Print NOTE_INSN names rather than integer codes. */
629 fprintf (m_outfile
, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx
, idx
)));
634 print_rtx_operand_code_u (in_rtx
, idx
);
638 #ifndef GENERATOR_FILE
639 if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_IMPLICIT_PTR
)
640 print_mem_expr (m_outfile
, DEBUG_IMPLICIT_PTR_DECL (in_rtx
));
641 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_PARAMETER_REF
)
642 print_mem_expr (m_outfile
, DEBUG_PARAMETER_REF_DECL (in_rtx
));
644 dump_addr (m_outfile
, " ", XTREE (in_rtx
, idx
));
649 fputs (" Unknown", m_outfile
);
654 /* Don't print basic block ids in compact mode. */
657 #ifndef GENERATOR_FILE
658 if (XBBDEF (in_rtx
, idx
))
659 fprintf (m_outfile
, " %i", XBBDEF (in_rtx
, idx
)->index
);
668 /* Subroutine of rtx_writer::print_rtx.
669 In compact mode, determine if operand IDX of IN_RTX is interesting
670 to dump, or (if in a trailing position) it can be omitted. */
673 rtx_writer::operand_has_default_value_p (const_rtx in_rtx
, int idx
)
675 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
677 switch (format_ptr
[idx
])
681 return XEXP (in_rtx
, idx
) == NULL_RTX
;
684 return XSTR (in_rtx
, idx
) == NULL
;
687 switch (GET_CODE (in_rtx
))
690 /* JUMP_LABELs are always omitted in compact mode, so treat
691 any value here as omittable, so that earlier operands can
692 potentially be omitted also. */
705 /* Print IN_RTX onto m_outfile. This is the recursive part of printing. */
708 rtx_writer::print_rtx (const_rtx in_rtx
)
715 fputc (' ', m_outfile
);
717 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
723 fputs ("(nil)", m_outfile
);
727 else if (GET_CODE (in_rtx
) > NUM_RTX_CODE
)
729 fprintf (m_outfile
, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx
),
730 print_rtx_head
, m_indent
* 2, "");
735 fputc ('(', m_outfile
);
737 /* Print name of expression code. */
740 #ifndef GENERATOR_FILE
741 if (m_rtx_reuse_manager
)
744 if (m_rtx_reuse_manager
->has_reuse_id (in_rtx
, &reuse_id
))
746 /* Have we already seen the defn of this rtx? */
747 if (m_rtx_reuse_manager
->seen_def_p (reuse_id
))
749 fprintf (m_outfile
, "reuse_rtx %i)", reuse_id
);
755 /* First time we've seen this reused-rtx. */
756 fprintf (m_outfile
, "%i|", reuse_id
);
757 m_rtx_reuse_manager
->set_seen_def (reuse_id
);
761 #endif /* #ifndef GENERATOR_FILE */
763 /* In compact mode, prefix the code of insns with "c",
764 giving "cinsn", "cnote" etc. */
765 if (m_compact
&& is_a
<const rtx_insn
*, const struct rtx_def
> (in_rtx
))
767 /* "ccode_label" is slightly awkward, so special-case it as
769 rtx_code code
= GET_CODE (in_rtx
);
770 if (code
== CODE_LABEL
)
771 fprintf (m_outfile
, "clabel");
773 fprintf (m_outfile
, "c%s", GET_RTX_NAME (code
));
775 else if (m_simple
&& CONST_INT_P (in_rtx
))
778 fprintf (m_outfile
, "%s", GET_RTX_NAME (GET_CODE (in_rtx
)));
782 if (RTX_FLAG (in_rtx
, in_struct
))
783 fputs ("/s", m_outfile
);
785 if (RTX_FLAG (in_rtx
, volatil
))
786 fputs ("/v", m_outfile
);
788 if (RTX_FLAG (in_rtx
, unchanging
))
789 fputs ("/u", m_outfile
);
791 if (RTX_FLAG (in_rtx
, frame_related
))
792 fputs ("/f", m_outfile
);
794 if (RTX_FLAG (in_rtx
, jump
))
795 fputs ("/j", m_outfile
);
797 if (RTX_FLAG (in_rtx
, call
))
798 fputs ("/c", m_outfile
);
800 if (RTX_FLAG (in_rtx
, return_val
))
801 fputs ("/i", m_outfile
);
803 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
804 if ((GET_CODE (in_rtx
) == EXPR_LIST
805 || GET_CODE (in_rtx
) == INSN_LIST
806 || GET_CODE (in_rtx
) == INT_LIST
)
807 && (int)GET_MODE (in_rtx
) < REG_NOTE_MAX
808 && !m_in_call_function_usage
)
809 fprintf (m_outfile
, ":%s",
810 GET_REG_NOTE_NAME (GET_MODE (in_rtx
)));
812 /* For other rtl, print the mode if it's not VOID. */
813 else if (GET_MODE (in_rtx
) != VOIDmode
)
814 fprintf (m_outfile
, ":%s", GET_MODE_NAME (GET_MODE (in_rtx
)));
816 #ifndef GENERATOR_FILE
817 if (GET_CODE (in_rtx
) == VAR_LOCATION
)
819 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx
)) == STRING_CST
)
820 fputs (" <debug string placeholder>", m_outfile
);
822 print_mem_expr (m_outfile
, PAT_VAR_LOCATION_DECL (in_rtx
));
823 fputc (' ', m_outfile
);
824 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx
));
825 if (PAT_VAR_LOCATION_STATUS (in_rtx
)
826 == VAR_INIT_STATUS_UNINITIALIZED
)
827 fprintf (m_outfile
, " [uninit]");
829 idx
= GET_RTX_LENGTH (VAR_LOCATION
);
834 #ifndef GENERATOR_FILE
835 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx
))
839 /* For insns, print the INSN_UID. */
840 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)))
842 if (flag_dump_unnumbered
)
843 fprintf (m_outfile
, " #");
845 fprintf (m_outfile
, " %d", INSN_UID (in_rtx
));
848 /* Determine which is the final operand to print.
849 In compact mode, skip trailing operands that have the default values
850 e.g. trailing "(nil)" values. */
851 int limit
= GET_RTX_LENGTH (GET_CODE (in_rtx
));
853 while (limit
> idx
&& operand_has_default_value_p (in_rtx
, limit
- 1))
856 /* Get the format string and skip the first elements if we have handled
859 for (; idx
< limit
; idx
++)
860 print_rtx_operand (in_rtx
, idx
);
862 switch (GET_CODE (in_rtx
))
864 #ifndef GENERATOR_FILE
866 if (__builtin_expect (final_insns_dump_p
, false))
867 fprintf (m_outfile
, " [");
869 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_DEC
,
870 (HOST_WIDE_INT
) MEM_ALIAS_SET (in_rtx
));
872 if (MEM_EXPR (in_rtx
))
873 print_mem_expr (m_outfile
, MEM_EXPR (in_rtx
));
875 fputc (' ', m_outfile
);
877 if (MEM_OFFSET_KNOWN_P (in_rtx
))
878 fprintf (m_outfile
, "+" HOST_WIDE_INT_PRINT_DEC
, MEM_OFFSET (in_rtx
));
880 if (MEM_SIZE_KNOWN_P (in_rtx
))
881 fprintf (m_outfile
, " S" HOST_WIDE_INT_PRINT_DEC
, MEM_SIZE (in_rtx
));
883 if (MEM_ALIGN (in_rtx
) != 1)
884 fprintf (m_outfile
, " A%u", MEM_ALIGN (in_rtx
));
886 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx
)))
887 fprintf (m_outfile
, " AS%u", MEM_ADDR_SPACE (in_rtx
));
889 fputc (']', m_outfile
);
893 if (FLOAT_MODE_P (GET_MODE (in_rtx
)))
897 real_to_decimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
899 fprintf (m_outfile
, " %s", s
);
901 real_to_hexadecimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
903 fprintf (m_outfile
, " [%s]", s
);
908 fprintf (m_outfile
, " ");
909 cwi_output_hex (m_outfile
, in_rtx
);
915 fprintf (m_outfile
, " [%d uses]", LABEL_NUSES (in_rtx
));
916 switch (LABEL_KIND (in_rtx
))
918 case LABEL_NORMAL
: break;
919 case LABEL_STATIC_ENTRY
: fputs (" [entry]", m_outfile
); break;
920 case LABEL_GLOBAL_ENTRY
: fputs (" [global entry]", m_outfile
); break;
921 case LABEL_WEAK_ENTRY
: fputs (" [weak entry]", m_outfile
); break;
922 default: gcc_unreachable ();
930 fputc (')', m_outfile
);
934 /* Emit a closing parenthesis and newline. */
937 rtx_writer::finish_directive ()
939 fprintf (m_outfile
, ")\n");
943 /* Print an rtx on the current line of FILE. Initially indent IND
947 print_inline_rtx (FILE *outf
, const_rtx x
, int ind
)
949 rtx_writer
w (outf
, ind
, false, false, NULL
);
953 /* Call this function from the debugger to see what X looks like. */
956 debug_rtx (const_rtx x
)
958 rtx_writer
w (stderr
, 0, false, false, NULL
);
960 fprintf (stderr
, "\n");
966 debug (const rtx_def
&ref
)
972 debug (const rtx_def
*ptr
)
977 fprintf (stderr
, "<nil>\n");
980 /* Like debug_rtx but with no newline, as debug_helper will add one.
982 Note: No debug_slim(rtx_insn *) variant implemented, as this
983 function can serve for both rtx and rtx_insn. */
986 debug_slim (const_rtx x
)
988 rtx_writer
w (stderr
, 0, false, false, NULL
);
992 DEFINE_DEBUG_VEC (rtx_def
*)
993 DEFINE_DEBUG_VEC (rtx_insn
*)
994 DEFINE_DEBUG_HASH_SET (rtx_def
*)
995 DEFINE_DEBUG_HASH_SET (rtx_insn
*)
997 /* Count of rtx's to print with debug_rtx_list.
998 This global exists because gdb user defined commands have no arguments. */
1000 DEBUG_VARIABLE
int debug_rtx_count
= 0; /* 0 is treated as equivalent to 1 */
1002 /* Call this function to print list from X on.
1004 N is a count of the rtx's to print. Positive values print from the specified
1005 rtx_insn on. Negative values print a window around the rtx_insn.
1006 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
1010 debug_rtx_list (const rtx_insn
*x
, int n
)
1013 const rtx_insn
*insn
;
1015 count
= n
== 0 ? 1 : n
< 0 ? -n
: n
;
1017 /* If we are printing a window, back up to the start. */
1020 for (i
= count
/ 2; i
> 0; i
--)
1022 if (PREV_INSN (x
) == 0)
1027 for (i
= count
, insn
= x
; i
> 0 && insn
!= 0; i
--, insn
= NEXT_INSN (insn
))
1030 fprintf (stderr
, "\n");
1034 /* Call this function to print an rtx_insn list from START to END
1038 debug_rtx_range (const rtx_insn
*start
, const rtx_insn
*end
)
1043 fprintf (stderr
, "\n");
1044 if (!start
|| start
== end
)
1046 start
= NEXT_INSN (start
);
1050 /* Call this function to search an rtx_insn list to find one with insn uid UID,
1051 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
1052 The found insn is returned to enable further debugging analysis. */
1054 DEBUG_FUNCTION
const rtx_insn
*
1055 debug_rtx_find (const rtx_insn
*x
, int uid
)
1057 while (x
!= 0 && INSN_UID (x
) != uid
)
1061 debug_rtx_list (x
, debug_rtx_count
);
1066 fprintf (stderr
, "insn uid %d not found\n", uid
);
1071 /* External entry point for printing a chain of insns
1072 starting with RTX_FIRST.
1073 A blank line separates insns.
1075 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1078 rtx_writer::print_rtl (const_rtx rtx_first
)
1080 const rtx_insn
*tmp_rtx
;
1084 fputs (print_rtx_head
, m_outfile
);
1085 fputs ("(nil)\n", m_outfile
);
1088 switch (GET_CODE (rtx_first
))
1095 case JUMP_TABLE_DATA
:
1097 for (tmp_rtx
= as_a
<const rtx_insn
*> (rtx_first
);
1099 tmp_rtx
= NEXT_INSN (tmp_rtx
))
1101 fputs (print_rtx_head
, m_outfile
);
1102 print_rtx (tmp_rtx
);
1103 fprintf (m_outfile
, "\n");
1108 fputs (print_rtx_head
, m_outfile
);
1109 print_rtx (rtx_first
);
1113 /* External entry point for printing a chain of insns
1114 starting with RTX_FIRST onto file OUTF.
1115 A blank line separates insns.
1117 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1120 print_rtl (FILE *outf
, const_rtx rtx_first
)
1122 rtx_writer
w (outf
, 0, false, false, NULL
);
1123 w
.print_rtl (rtx_first
);
1126 /* Like print_rtx, except specify a file. */
1127 /* Return nonzero if we actually printed anything. */
1130 print_rtl_single (FILE *outf
, const_rtx x
)
1132 rtx_writer
w (outf
, 0, false, false, NULL
);
1133 return w
.print_rtl_single_with_indent (x
, 0);
1136 /* Like print_rtl_single, except specify an indentation. */
1139 rtx_writer::print_rtl_single_with_indent (const_rtx x
, int ind
)
1141 char *s_indent
= (char *) alloca ((size_t) ind
+ 1);
1142 memset ((void *) s_indent
, ' ', (size_t) ind
);
1143 s_indent
[ind
] = '\0';
1144 fputs (s_indent
, m_outfile
);
1145 fputs (print_rtx_head
, m_outfile
);
1147 int old_indent
= m_indent
;
1151 putc ('\n', m_outfile
);
1152 m_indent
= old_indent
;
1157 /* Like print_rtl except without all the detail; for example,
1158 if RTX is a CONST_INT then print in decimal format. */
1161 print_simple_rtl (FILE *outf
, const_rtx x
)
1163 rtx_writer
w (outf
, 0, true, false, NULL
);
1167 /* Print the elements of VEC to FILE. */
1170 print_rtx_insn_vec (FILE *file
, const vec
<rtx_insn
*> &vec
)
1174 unsigned int len
= vec
.length ();
1175 for (unsigned int i
= 0; i
< len
; i
++)
1177 print_rtl (file
, vec
[i
]);
1185 #ifndef GENERATOR_FILE
1186 /* The functions below try to print RTL in a form resembling assembler
1187 mnemonics. Because this form is more concise than the "traditional" form
1188 of RTL printing in Lisp-style, the form printed by this file is called
1189 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
1190 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
1191 always printed in slim form.
1193 The normal interface to the functionality provided in this pretty-printer
1194 is through the dump_*_slim functions to print to a stream, or via the
1195 print_*_slim functions to print into a user's pretty-printer.
1197 It is also possible to obtain a string for a single pattern as a string
1198 pointer, via str_pattern_slim, but this usage is discouraged. */
1200 /* For insns we print patterns, and for some patterns we print insns... */
1201 static void print_insn_with_notes (pretty_printer
*, const rtx_insn
*);
1203 /* This recognizes rtx'en classified as expressions. These are always
1204 represent some action on values or results of other expression, that
1205 may be stored in objects representing values. */
1208 print_exp (pretty_printer
*pp
, const_rtx x
, int verbose
)
1216 for (i
= 0; i
< 4; i
++)
1222 switch (GET_CODE (x
))
1225 op
[0] = XEXP (x
, 0);
1226 if (CONST_INT_P (XEXP (x
, 1))
1227 && INTVAL (XEXP (x
, 1)) < 0)
1230 op
[1] = GEN_INT (-INTVAL (XEXP (x
, 1)));
1235 op
[1] = XEXP (x
, 1);
1239 op
[0] = XEXP (x
, 0);
1241 op
[1] = XEXP (x
, 1);
1245 op
[0] = XEXP (x
, 0);
1247 op
[1] = XEXP (x
, 1);
1251 op
[0] = XEXP (x
, 0);
1252 op
[1] = XEXP (x
, 1);
1256 op
[0] = XEXP (x
, 0);
1260 op
[0] = XEXP (x
, 0);
1262 op
[1] = XEXP (x
, 1);
1264 op
[2] = XEXP (x
, 2);
1268 op
[0] = XEXP (x
, 0);
1270 op
[1] = XEXP (x
, 1);
1273 op
[0] = XEXP (x
, 0);
1275 op
[1] = XEXP (x
, 1);
1279 op
[0] = XEXP (x
, 0);
1280 op
[1] = XEXP (x
, 1);
1283 op
[0] = XEXP (x
, 0);
1285 op
[1] = XEXP (x
, 1);
1289 op
[0] = XEXP (x
, 0);
1290 op
[1] = XEXP (x
, 1);
1294 op
[0] = XEXP (x
, 0);
1295 op
[1] = XEXP (x
, 1);
1299 op
[0] = XEXP (x
, 0);
1300 op
[1] = XEXP (x
, 1);
1304 op
[0] = XEXP (x
, 0);
1305 op
[1] = XEXP (x
, 1);
1309 op
[0] = XEXP (x
, 0);
1310 op
[1] = XEXP (x
, 1);
1314 op
[0] = XEXP (x
, 0);
1317 op
[0] = XEXP (x
, 0);
1319 op
[1] = XEXP (x
, 1);
1322 op
[0] = XEXP (x
, 0);
1324 op
[1] = XEXP (x
, 1);
1327 op
[0] = XEXP (x
, 0);
1329 op
[1] = XEXP (x
, 1);
1332 op
[0] = XEXP (x
, 0);
1334 op
[1] = XEXP (x
, 1);
1337 op
[0] = XEXP (x
, 0);
1339 op
[1] = XEXP (x
, 1);
1342 op
[0] = XEXP (x
, 0);
1344 op
[1] = XEXP (x
, 1);
1347 op
[0] = XEXP (x
, 0);
1349 op
[1] = XEXP (x
, 1);
1352 op
[0] = XEXP (x
, 0);
1354 op
[1] = XEXP (x
, 1);
1357 op
[0] = XEXP (x
, 0);
1359 op
[1] = XEXP (x
, 1);
1362 op
[0] = XEXP (x
, 0);
1364 op
[1] = XEXP (x
, 1);
1367 op
[0] = XEXP (x
, 0);
1369 op
[1] = XEXP (x
, 1);
1372 op
[0] = XEXP (x
, 0);
1374 op
[1] = XEXP (x
, 1);
1377 op
[0] = XEXP (x
, 0);
1379 op
[1] = XEXP (x
, 1);
1382 op
[0] = XEXP (x
, 0);
1384 op
[1] = XEXP (x
, 1);
1387 fun
= (verbose
) ? "sign_extract" : "sxt";
1388 op
[0] = XEXP (x
, 0);
1389 op
[1] = XEXP (x
, 1);
1390 op
[2] = XEXP (x
, 2);
1393 fun
= (verbose
) ? "zero_extract" : "zxt";
1394 op
[0] = XEXP (x
, 0);
1395 op
[1] = XEXP (x
, 1);
1396 op
[2] = XEXP (x
, 2);
1399 fun
= (verbose
) ? "sign_extend" : "sxn";
1400 op
[0] = XEXP (x
, 0);
1403 fun
= (verbose
) ? "zero_extend" : "zxn";
1404 op
[0] = XEXP (x
, 0);
1407 fun
= (verbose
) ? "float_extend" : "fxn";
1408 op
[0] = XEXP (x
, 0);
1411 fun
= (verbose
) ? "trunc" : "trn";
1412 op
[0] = XEXP (x
, 0);
1414 case FLOAT_TRUNCATE
:
1415 fun
= (verbose
) ? "float_trunc" : "ftr";
1416 op
[0] = XEXP (x
, 0);
1419 fun
= (verbose
) ? "float" : "flt";
1420 op
[0] = XEXP (x
, 0);
1422 case UNSIGNED_FLOAT
:
1423 fun
= (verbose
) ? "uns_float" : "ufl";
1424 op
[0] = XEXP (x
, 0);
1428 op
[0] = XEXP (x
, 0);
1431 fun
= (verbose
) ? "uns_fix" : "ufx";
1432 op
[0] = XEXP (x
, 0);
1436 op
[0] = XEXP (x
, 0);
1440 op
[0] = XEXP (x
, 0);
1443 op
[0] = XEXP (x
, 0);
1447 op
[0] = XEXP (x
, 0);
1452 op
[0] = XEXP (XEXP (x
, 1), 0);
1454 op
[1] = XEXP (XEXP (x
, 1), 1);
1458 op
[0] = XEXP (XEXP (x
, 1), 0);
1460 op
[1] = XEXP (XEXP (x
, 1), 1);
1464 op
[0] = XEXP (x
, 0);
1468 op
[1] = XEXP (x
, 1);
1473 op
[0] = XEXP (x
, 0);
1475 op
[1] = XEXP (x
, 1);
1477 op
[2] = XEXP (x
, 2);
1482 op
[0] = TRAP_CONDITION (x
);
1486 op
[0] = XEXP (x
, 0);
1487 op
[1] = XEXP (x
, 1);
1488 op
[2] = XEXP (x
, 2);
1491 case UNSPEC_VOLATILE
:
1493 pp_string (pp
, "unspec");
1494 if (GET_CODE (x
) == UNSPEC_VOLATILE
)
1495 pp_string (pp
, "/v");
1496 pp_left_bracket (pp
);
1497 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1501 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1503 pp_string (pp
, "] ");
1504 pp_decimal_int (pp
, XINT (x
, 1));
1509 /* Most unhandled codes can be printed as pseudo-functions. */
1510 if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_UNARY
)
1512 fun
= GET_RTX_NAME (GET_CODE (x
));
1513 op
[0] = XEXP (x
, 0);
1515 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMPARE
1516 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_COMPARE
1517 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_BIN_ARITH
1518 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_ARITH
)
1520 fun
= GET_RTX_NAME (GET_CODE (x
));
1521 op
[0] = XEXP (x
, 0);
1522 op
[1] = XEXP (x
, 1);
1524 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_TERNARY
)
1526 fun
= GET_RTX_NAME (GET_CODE (x
));
1527 op
[0] = XEXP (x
, 0);
1528 op
[1] = XEXP (x
, 1);
1529 op
[2] = XEXP (x
, 2);
1532 /* Give up, just print the RTX name. */
1533 st
[0] = GET_RTX_NAME (GET_CODE (x
));
1538 /* Print this as a function? */
1541 pp_string (pp
, fun
);
1545 for (i
= 0; i
< 4; i
++)
1548 pp_string (pp
, st
[i
]);
1554 print_value (pp
, op
[i
], verbose
);
1559 pp_right_paren (pp
);
1562 /* Prints rtxes, I customarily classified as values. They're constants,
1563 registers, labels, symbols and memory accesses. */
1566 print_value (pretty_printer
*pp
, const_rtx x
, int verbose
)
1572 pp_string (pp
, "(nil)");
1575 switch (GET_CODE (x
))
1578 pp_scalar (pp
, HOST_WIDE_INT_PRINT_HEX
,
1579 (unsigned HOST_WIDE_INT
) INTVAL (x
));
1582 case CONST_WIDE_INT
:
1584 const char *sep
= "<";
1586 for (i
= CONST_WIDE_INT_NUNITS (x
) - 1; i
>= 0; i
--)
1588 pp_string (pp
, sep
);
1590 sprintf (tmp
, HOST_WIDE_INT_PRINT_HEX
,
1591 (unsigned HOST_WIDE_INT
) CONST_WIDE_INT_ELT (x
, i
));
1592 pp_string (pp
, tmp
);
1599 if (FLOAT_MODE_P (GET_MODE (x
)))
1601 real_to_decimal (tmp
, CONST_DOUBLE_REAL_VALUE (x
),
1602 sizeof (tmp
), 0, 1);
1603 pp_string (pp
, tmp
);
1606 pp_printf (pp
, "<%wx,%wx>",
1607 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (x
),
1608 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_HIGH (x
));
1611 fixed_to_decimal (tmp
, CONST_FIXED_VALUE (x
), sizeof (tmp
));
1612 pp_string (pp
, tmp
);
1615 pp_printf (pp
, "\"%s\"", XSTR (x
, 0));
1618 pp_printf (pp
, "`%s'", XSTR (x
, 0));
1621 pp_printf (pp
, "L%d", INSN_UID (label_ref_label (x
)));
1625 case STRICT_LOW_PART
:
1626 pp_printf (pp
, "%s(", GET_RTX_NAME (GET_CODE (x
)));
1627 print_value (pp
, XEXP (x
, 0), verbose
);
1628 pp_right_paren (pp
);
1631 if (REGNO (x
) < FIRST_PSEUDO_REGISTER
)
1633 if (ISDIGIT (reg_names
[REGNO (x
)][0]))
1635 pp_string (pp
, reg_names
[REGNO (x
)]);
1638 pp_printf (pp
, "r%d", REGNO (x
));
1640 pp_printf (pp
, ":%s", GET_MODE_NAME (GET_MODE (x
)));
1643 print_value (pp
, SUBREG_REG (x
), verbose
);
1644 pp_printf (pp
, "#%d", SUBREG_BYTE (x
));
1649 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1652 pp_left_bracket (pp
);
1653 print_value (pp
, XEXP (x
, 0), verbose
);
1654 pp_right_bracket (pp
);
1657 pp_printf (pp
, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x
)));
1660 print_exp (pp
, x
, verbose
);
1665 /* The next step in insn detalization, its pattern recognition. */
1668 print_pattern (pretty_printer
*pp
, const_rtx x
, int verbose
)
1672 pp_string (pp
, "(nil)");
1676 switch (GET_CODE (x
))
1679 print_value (pp
, SET_DEST (x
), verbose
);
1681 print_value (pp
, SET_SRC (x
), verbose
);
1686 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1689 print_exp (pp
, x
, verbose
);
1693 pp_printf (pp
, "%s ", GET_RTX_NAME (GET_CODE (x
)));
1694 print_value (pp
, XEXP (x
, 0), verbose
);
1697 pp_string (pp
, "loc ");
1698 print_value (pp
, PAT_VAR_LOCATION_LOC (x
), verbose
);
1702 if (GET_CODE (COND_EXEC_TEST (x
)) == NE
1703 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1704 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1705 else if (GET_CODE (COND_EXEC_TEST (x
)) == EQ
1706 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1708 pp_exclamation (pp
);
1709 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1712 print_value (pp
, COND_EXEC_TEST (x
), verbose
);
1713 pp_string (pp
, ") ");
1714 print_pattern (pp
, COND_EXEC_CODE (x
), verbose
);
1721 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1723 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1726 pp_right_brace (pp
);
1731 const rtx_sequence
*seq
= as_a
<const rtx_sequence
*> (x
);
1732 pp_string (pp
, "sequence{");
1733 if (INSN_P (seq
->element (0)))
1735 /* Print the sequence insns indented. */
1736 const char * save_print_rtx_head
= print_rtx_head
;
1737 char indented_print_rtx_head
[32];
1740 gcc_assert (strlen (print_rtx_head
) < sizeof (indented_print_rtx_head
) - 4);
1741 snprintf (indented_print_rtx_head
,
1742 sizeof (indented_print_rtx_head
),
1743 "%s ", print_rtx_head
);
1744 print_rtx_head
= indented_print_rtx_head
;
1745 for (int i
= 0; i
< seq
->len (); i
++)
1746 print_insn_with_notes (pp
, seq
->insn (i
));
1747 pp_printf (pp
, "%s ", save_print_rtx_head
);
1748 print_rtx_head
= save_print_rtx_head
;
1752 for (int i
= 0; i
< seq
->len (); i
++)
1754 print_pattern (pp
, seq
->element (i
), verbose
);
1758 pp_right_brace (pp
);
1762 pp_printf (pp
, "asm {%s}", XSTR (x
, 0));
1765 for (int i
= 0; i
< XVECLEN (x
, 0); i
++)
1767 print_value (pp
, XVECEXP (x
, 0, i
), verbose
);
1772 for (int i
= 0; i
< XVECLEN (x
, 1); i
++)
1774 print_value (pp
, XVECEXP (x
, 1, i
), verbose
);
1779 pp_string (pp
, "trap_if ");
1780 print_value (pp
, TRAP_CONDITION (x
), verbose
);
1783 case UNSPEC_VOLATILE
:
1784 /* Fallthru -- leave UNSPECs to print_exp. */
1786 print_value (pp
, x
, verbose
);
1788 } /* print_pattern */
1790 /* This is the main function in slim rtl visualization mechanism.
1792 X is an insn, to be printed into PP.
1794 This function tries to print it properly in human-readable form,
1795 resembling assembler mnemonics (instead of the older Lisp-style
1798 If VERBOSE is TRUE, insns are printed with more complete (but
1799 longer) pattern names and with extra information, and prefixed
1800 with their INSN_UIDs. */
1803 print_insn (pretty_printer
*pp
, const rtx_insn
*x
, int verbose
)
1807 /* Blech, pretty-print can't print integers with a specified width. */
1808 char uid_prefix
[32];
1809 snprintf (uid_prefix
, sizeof uid_prefix
, " %4d: ", INSN_UID (x
));
1810 pp_string (pp
, uid_prefix
);
1813 switch (GET_CODE (x
))
1816 print_pattern (pp
, PATTERN (x
), verbose
);
1821 if (DEBUG_MARKER_INSN_P (x
))
1823 switch (INSN_DEBUG_MARKER_KIND (x
))
1825 case NOTE_INSN_BEGIN_STMT
:
1826 pp_string (pp
, "debug begin stmt marker");
1835 const char *name
= "?";
1838 if (DECL_P (INSN_VAR_LOCATION_DECL (x
)))
1840 tree id
= DECL_NAME (INSN_VAR_LOCATION_DECL (x
));
1842 name
= IDENTIFIER_POINTER (id
);
1843 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x
))
1846 sprintf (idbuf
, "D#%i",
1847 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x
)));
1852 sprintf (idbuf
, "D.%i",
1853 DECL_UID (INSN_VAR_LOCATION_DECL (x
)));
1857 pp_printf (pp
, "debug %s => ", name
);
1858 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x
)))
1859 pp_string (pp
, "optimized away");
1861 print_pattern (pp
, INSN_VAR_LOCATION_LOC (x
), verbose
);
1866 print_pattern (pp
, PATTERN (x
), verbose
);
1869 if (GET_CODE (PATTERN (x
)) == PARALLEL
)
1870 print_pattern (pp
, XVECEXP (PATTERN (x
), 0, 0), verbose
);
1872 print_pattern (pp
, PATTERN (x
), verbose
);
1875 pp_printf (pp
, "L%d:", INSN_UID (x
));
1877 case JUMP_TABLE_DATA
:
1878 pp_string (pp
, "jump_table_data{\n");
1879 print_pattern (pp
, PATTERN (x
), verbose
);
1880 pp_right_brace (pp
);
1883 pp_string (pp
, "barrier");
1887 pp_string (pp
, GET_NOTE_INSN_NAME (NOTE_KIND (x
)));
1888 switch (NOTE_KIND (x
))
1890 case NOTE_INSN_EH_REGION_BEG
:
1891 case NOTE_INSN_EH_REGION_END
:
1892 pp_printf (pp
, " %d", NOTE_EH_HANDLER (x
));
1895 case NOTE_INSN_BLOCK_BEG
:
1896 case NOTE_INSN_BLOCK_END
:
1897 pp_printf (pp
, " %d", BLOCK_NUMBER (NOTE_BLOCK (x
)));
1900 case NOTE_INSN_BASIC_BLOCK
:
1901 pp_printf (pp
, " %d", NOTE_BASIC_BLOCK (x
)->index
);
1904 case NOTE_INSN_DELETED_LABEL
:
1905 case NOTE_INSN_DELETED_DEBUG_LABEL
:
1907 const char *label
= NOTE_DELETED_LABEL_NAME (x
);
1910 pp_printf (pp
, " (\"%s\")", label
);
1914 case NOTE_INSN_VAR_LOCATION
:
1915 case NOTE_INSN_CALL_ARG_LOCATION
:
1917 print_pattern (pp
, NOTE_VAR_LOCATION (x
), verbose
);
1918 pp_right_brace (pp
);
1931 /* Pretty-print a slim dump of X (an insn) to PP, including any register
1932 note attached to the instruction. */
1935 print_insn_with_notes (pretty_printer
*pp
, const rtx_insn
*x
)
1937 pp_string (pp
, print_rtx_head
);
1938 print_insn (pp
, x
, 1);
1940 if (INSN_P (x
) && REG_NOTES (x
))
1941 for (rtx note
= REG_NOTES (x
); note
; note
= XEXP (note
, 1))
1943 pp_printf (pp
, "%s %s ", print_rtx_head
,
1944 GET_REG_NOTE_NAME (REG_NOTE_KIND (note
)));
1945 if (GET_CODE (note
) == INT_LIST
)
1946 pp_printf (pp
, "%d", XINT (note
, 0));
1948 print_pattern (pp
, XEXP (note
, 0), 1);
1953 /* Print X, an RTL value node, to file F in slim format. Include
1954 additional information if VERBOSE is nonzero.
1956 Value nodes are constants, registers, labels, symbols and
1960 dump_value_slim (FILE *f
, const_rtx x
, int verbose
)
1962 pretty_printer rtl_slim_pp
;
1963 rtl_slim_pp
.buffer
->stream
= f
;
1964 print_value (&rtl_slim_pp
, x
, verbose
);
1965 pp_flush (&rtl_slim_pp
);
1968 /* Emit a slim dump of X (an insn) to the file F, including any register
1969 note attached to the instruction. */
1971 dump_insn_slim (FILE *f
, const rtx_insn
*x
)
1973 pretty_printer rtl_slim_pp
;
1974 rtl_slim_pp
.buffer
->stream
= f
;
1975 print_insn_with_notes (&rtl_slim_pp
, x
);
1976 pp_flush (&rtl_slim_pp
);
1979 /* Same as above, but stop at LAST or when COUNT == 0.
1980 If COUNT < 0 it will stop only at LAST or NULL rtx. */
1983 dump_rtl_slim (FILE *f
, const rtx_insn
*first
, const rtx_insn
*last
,
1984 int count
, int flags ATTRIBUTE_UNUSED
)
1986 const rtx_insn
*insn
, *tail
;
1987 pretty_printer rtl_slim_pp
;
1988 rtl_slim_pp
.buffer
->stream
= f
;
1990 tail
= last
? NEXT_INSN (last
) : NULL
;
1992 (insn
!= NULL
) && (insn
!= tail
) && (count
!= 0);
1993 insn
= NEXT_INSN (insn
))
1995 print_insn_with_notes (&rtl_slim_pp
, insn
);
2000 pp_flush (&rtl_slim_pp
);
2003 /* Dumps basic block BB to pretty-printer PP in slim form and without and
2004 no indentation, for use as a label of a DOT graph record-node. */
2007 rtl_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
2012 /* TODO: inter-bb stuff. */
2013 FOR_BB_INSNS (bb
, insn
)
2018 pp_write_text_to_stream (pp
);
2021 print_insn_with_notes (pp
, insn
);
2022 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2026 /* Pretty-print pattern X of some insn in non-verbose mode.
2027 Return a string pointer to the pretty-printer buffer.
2029 This function is only exported exists only to accommodate some older users
2030 of the slim RTL pretty printers. Please do not use it for new code. */
2033 str_pattern_slim (const_rtx x
)
2035 pretty_printer rtl_slim_pp
;
2036 print_pattern (&rtl_slim_pp
, x
, 0);
2037 return ggc_strdup (pp_formatted_text (&rtl_slim_pp
));
2040 /* Emit a slim dump of X (an insn) to stderr. */
2041 extern void debug_insn_slim (const rtx_insn
*);
2043 debug_insn_slim (const rtx_insn
*x
)
2045 dump_insn_slim (stderr
, x
);
2048 /* Same as above, but using dump_rtl_slim. */
2049 extern void debug_rtl_slim (FILE *, const rtx_insn
*, const rtx_insn
*,
2052 debug_rtl_slim (const rtx_insn
*first
, const rtx_insn
*last
, int count
,
2055 dump_rtl_slim (stderr
, first
, last
, count
, flags
);
2058 extern void debug_bb_slim (basic_block
);
2060 debug_bb_slim (basic_block bb
)
2062 dump_bb (stderr
, bb
, 0, TDF_SLIM
| TDF_BLOCKS
);
2065 extern void debug_bb_n_slim (int);
2067 debug_bb_n_slim (int n
)
2069 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, n
);