2 Copyright (C) 1987-2020 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"
39 #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 /* Disable warnings about quoting issues in the pp_xxx calls below
58 that (intentionally) don't follow GCC diagnostic conventions. */
60 # pragma GCC diagnostic push
61 # pragma GCC diagnostic ignored "-Wformat-diag"
64 /* String printed at beginning of each RTL when it is dumped.
65 This string is set to ASM_COMMENT_START when the RTL is dumped in
66 the assembly output file. */
67 const char *print_rtx_head
= "";
70 /* These are defined from the .opt file when not used in generator
73 /* Nonzero means suppress output of instruction numbers
75 This must be defined here so that programs like gencodes can be linked. */
76 int flag_dump_unnumbered
= 0;
78 /* Nonzero means suppress output of instruction numbers for previous
79 and next insns in debugging dumps.
80 This must be defined here so that programs like gencodes can be linked. */
81 int flag_dump_unnumbered_links
= 0;
84 /* Constructor for rtx_writer. */
86 rtx_writer::rtx_writer (FILE *outf
, int ind
, bool simple
, bool compact
,
87 rtx_reuse_manager
*reuse_manager
)
88 : m_outfile (outf
), m_sawclose (0), m_indent (ind
),
89 m_in_call_function_usage (false), m_simple (simple
), m_compact (compact
),
90 m_rtx_reuse_manager (reuse_manager
)
94 #ifndef GENERATOR_FILE
96 /* rtx_reuse_manager's ctor. */
98 rtx_reuse_manager::rtx_reuse_manager ()
103 /* Determine if X is of a kind suitable for dumping via reuse_rtx. */
106 uses_rtx_reuse_p (const_rtx x
)
111 switch (GET_CODE (x
))
118 /* We don't use reuse_rtx for consts. */
125 /* Traverse X and its descendents, determining if we see any rtx more than
126 once. Any rtx suitable for "reuse_rtx" that is seen more than once is
130 rtx_reuse_manager::preprocess (const_rtx x
)
132 subrtx_iterator::array_type array
;
133 FOR_EACH_SUBRTX (iter
, array
, x
, NONCONST
)
134 if (uses_rtx_reuse_p (*iter
))
136 if (int *count
= m_rtx_occurrence_count
.get (*iter
))
139 m_rtx_reuse_ids
.put (*iter
, m_next_id
++);
142 m_rtx_occurrence_count
.put (*iter
, 1);
146 /* Return true iff X has been assigned a reuse ID. If it has,
147 and OUT is non-NULL, then write the reuse ID to *OUT. */
150 rtx_reuse_manager::has_reuse_id (const_rtx x
, int *out
)
152 int *id
= m_rtx_reuse_ids
.get (x
);
163 /* Determine if set_seen_def has been called for the given reuse ID. */
166 rtx_reuse_manager::seen_def_p (int reuse_id
)
168 return bitmap_bit_p (m_defs_seen
, reuse_id
);
171 /* Record that the definition of the given reuse ID has been seen. */
174 rtx_reuse_manager::set_seen_def (int reuse_id
)
176 bitmap_set_bit (m_defs_seen
, reuse_id
);
179 #endif /* #ifndef GENERATOR_FILE */
181 #ifndef GENERATOR_FILE
183 print_mem_expr (FILE *outfile
, const_tree expr
)
185 fputc (' ', outfile
);
186 print_generic_expr (outfile
, CONST_CAST_TREE (expr
),
187 dump_flags
| TDF_SLIM
);
191 /* Print X to FILE. */
194 print_poly_int (FILE *file
, poly_int64 x
)
196 HOST_WIDE_INT const_x
;
197 if (x
.is_constant (&const_x
))
198 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, const_x
);
201 fprintf (file
, "[" HOST_WIDE_INT_PRINT_DEC
, x
.coeffs
[0]);
202 for (int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
203 fprintf (file
, ", " HOST_WIDE_INT_PRINT_DEC
, x
.coeffs
[i
]);
208 /* Subroutine of print_rtx_operand for handling code '0'.
209 0 indicates a field for internal use that should not be printed.
210 However there are various special cases, such as the third field
211 of a NOTE, where it indicates that the field has several different
215 rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED
,
216 int idx ATTRIBUTE_UNUSED
)
218 #ifndef GENERATOR_FILE
219 if (idx
== 1 && GET_CODE (in_rtx
) == SYMBOL_REF
)
221 int flags
= SYMBOL_REF_FLAGS (in_rtx
);
223 fprintf (m_outfile
, " [flags %#x]", flags
);
224 tree decl
= SYMBOL_REF_DECL (in_rtx
);
226 print_node_brief (m_outfile
, "", decl
, dump_flags
);
228 else if (idx
== 3 && NOTE_P (in_rtx
))
230 switch (NOTE_KIND (in_rtx
))
232 case NOTE_INSN_EH_REGION_BEG
:
233 case NOTE_INSN_EH_REGION_END
:
234 if (flag_dump_unnumbered
)
235 fprintf (m_outfile
, " #");
237 fprintf (m_outfile
, " %d", NOTE_EH_HANDLER (in_rtx
));
241 case NOTE_INSN_BLOCK_BEG
:
242 case NOTE_INSN_BLOCK_END
:
243 dump_addr (m_outfile
, " ", NOTE_BLOCK (in_rtx
));
247 case NOTE_INSN_BASIC_BLOCK
:
249 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
251 fprintf (m_outfile
, " [bb %d]", bb
->index
);
255 case NOTE_INSN_DELETED_LABEL
:
256 case NOTE_INSN_DELETED_DEBUG_LABEL
:
258 const char *label
= NOTE_DELETED_LABEL_NAME (in_rtx
);
260 fprintf (m_outfile
, " (\"%s\")", label
);
262 fprintf (m_outfile
, " \"\"");
266 case NOTE_INSN_SWITCH_TEXT_SECTIONS
:
268 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
270 fprintf (m_outfile
, " [bb %d]", bb
->index
);
274 case NOTE_INSN_VAR_LOCATION
:
275 fputc (' ', m_outfile
);
276 print_rtx (NOTE_VAR_LOCATION (in_rtx
));
280 fputc ('\n', m_outfile
);
281 output_cfi_directive (m_outfile
, NOTE_CFI (in_rtx
));
282 fputc ('\t', m_outfile
);
285 case NOTE_INSN_BEGIN_STMT
:
286 case NOTE_INSN_INLINE_ENTRY
:
287 #ifndef GENERATOR_FILE
289 expanded_location xloc
290 = expand_location (NOTE_MARKER_LOCATION (in_rtx
));
291 fprintf (m_outfile
, " %s:%i", xloc
.file
, xloc
.line
);
300 else if (idx
== 7 && JUMP_P (in_rtx
) && JUMP_LABEL (in_rtx
) != NULL
303 /* Output the JUMP_LABEL reference. */
304 fprintf (m_outfile
, "\n%s%*s -> ", print_rtx_head
, m_indent
* 2, "");
305 if (GET_CODE (JUMP_LABEL (in_rtx
)) == RETURN
)
306 fprintf (m_outfile
, "return");
307 else if (GET_CODE (JUMP_LABEL (in_rtx
)) == SIMPLE_RETURN
)
308 fprintf (m_outfile
, "simple_return");
310 fprintf (m_outfile
, "%d", INSN_UID (JUMP_LABEL (in_rtx
)));
312 else if (idx
== 0 && GET_CODE (in_rtx
) == VALUE
)
314 cselib_val
*val
= CSELIB_VAL_PTR (in_rtx
);
316 fprintf (m_outfile
, " %u:%u", val
->uid
, val
->hash
);
317 dump_addr (m_outfile
, " @", in_rtx
);
318 dump_addr (m_outfile
, "/", (void*)val
);
320 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_EXPR
)
322 fprintf (m_outfile
, " D#%i",
323 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx
)));
325 else if (idx
== 0 && GET_CODE (in_rtx
) == ENTRY_VALUE
)
329 fprintf (m_outfile
, " ");
330 print_rtx (ENTRY_VALUE_EXP (in_rtx
));
336 /* Subroutine of print_rtx_operand for handling code 'e'.
337 Also called by print_rtx_operand_code_u for handling code 'u'
338 for LABEL_REFs when they don't reference a CODE_LABEL. */
341 rtx_writer::print_rtx_operand_code_e (const_rtx in_rtx
, int idx
)
344 if (idx
== 6 && INSN_P (in_rtx
))
345 /* Put REG_NOTES on their own line. */
346 fprintf (m_outfile
, "\n%s%*s",
347 print_rtx_head
, m_indent
* 2, "");
349 fprintf (m_outfile
, " ");
350 if (idx
== 7 && CALL_P (in_rtx
))
352 m_in_call_function_usage
= true;
353 print_rtx (XEXP (in_rtx
, idx
));
354 m_in_call_function_usage
= false;
357 print_rtx (XEXP (in_rtx
, idx
));
361 /* Subroutine of print_rtx_operand for handling codes 'E' and 'V'. */
364 rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx
, int idx
)
369 fprintf (m_outfile
, "\n%s%*s",
370 print_rtx_head
, m_indent
* 2, "");
373 fputs (" [", m_outfile
);
374 if (XVEC (in_rtx
, idx
) != NULL
)
377 if (XVECLEN (in_rtx
, idx
))
380 for (int j
= 0; j
< XVECLEN (in_rtx
, idx
); j
++)
384 print_rtx (XVECEXP (in_rtx
, idx
, j
));
385 for (j1
= j
+ 1; j1
< XVECLEN (in_rtx
, idx
); j1
++)
386 if (XVECEXP (in_rtx
, idx
, j
) != XVECEXP (in_rtx
, idx
, j1
))
391 fprintf (m_outfile
, " repeated x%i", j1
- j
);
399 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
401 fputs ("]", m_outfile
);
406 /* Subroutine of print_rtx_operand for handling code 'i'. */
409 rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx
, int idx
)
411 if (idx
== 4 && INSN_P (in_rtx
))
413 #ifndef GENERATOR_FILE
414 const rtx_insn
*in_insn
= as_a
<const rtx_insn
*> (in_rtx
);
416 /* Pretty-print insn locations. Ignore scoping as it is mostly
417 redundant with line number information and do not print anything
418 when there is no location information available. */
419 if (INSN_HAS_LOCATION (in_insn
))
421 expanded_location xloc
= insn_location (in_insn
);
422 fprintf (m_outfile
, " \"%s\":%i:%i", xloc
.file
, xloc
.line
,
427 else if (idx
== 6 && GET_CODE (in_rtx
) == ASM_OPERANDS
)
429 #ifndef GENERATOR_FILE
430 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
431 fprintf (m_outfile
, " %s:%i",
432 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)),
433 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)));
436 else if (idx
== 1 && GET_CODE (in_rtx
) == ASM_INPUT
)
438 #ifndef GENERATOR_FILE
439 if (ASM_INPUT_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
440 fprintf (m_outfile
, " %s:%i",
441 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)),
442 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)));
445 else if (idx
== 5 && NOTE_P (in_rtx
))
447 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
448 other times often contains garbage from INSN->NOTE death. */
449 if (NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_LABEL
450 || NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_DEBUG_LABEL
)
451 fprintf (m_outfile
, " %d", XINT (in_rtx
, idx
));
453 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
455 && GET_CODE (in_rtx
) == UNSPEC_VOLATILE
456 && XINT (in_rtx
, 1) >= 0
457 && XINT (in_rtx
, 1) < NUM_UNSPECV_VALUES
)
458 fprintf (m_outfile
, " %s", unspecv_strings
[XINT (in_rtx
, 1)]);
460 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
462 && (GET_CODE (in_rtx
) == UNSPEC
463 || GET_CODE (in_rtx
) == UNSPEC_VOLATILE
)
464 && XINT (in_rtx
, 1) >= 0
465 && XINT (in_rtx
, 1) < NUM_UNSPEC_VALUES
)
466 fprintf (m_outfile
, " %s", unspec_strings
[XINT (in_rtx
, 1)]);
470 int value
= XINT (in_rtx
, idx
);
472 int is_insn
= INSN_P (in_rtx
);
474 /* Don't print INSN_CODEs in compact mode. */
475 if (m_compact
&& is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
))
481 if (flag_dump_unnumbered
482 && (is_insn
|| NOTE_P (in_rtx
)))
483 fputc ('#', m_outfile
);
485 fprintf (m_outfile
, " %d", value
);
487 if (is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
)
488 && XINT (in_rtx
, idx
) >= 0
489 && (name
= get_insn_name (XINT (in_rtx
, idx
))) != NULL
)
490 fprintf (m_outfile
, " {%s}", name
);
495 /* Subroutine of print_rtx_operand for handling code 'r'. */
498 rtx_writer::print_rtx_operand_code_r (const_rtx in_rtx
)
500 int is_insn
= INSN_P (in_rtx
);
501 unsigned int regno
= REGNO (in_rtx
);
503 #ifndef GENERATOR_FILE
504 /* For hard registers and virtuals, always print the
505 regno, except in compact mode. */
506 if (regno
<= LAST_VIRTUAL_REGISTER
&& !m_compact
)
507 fprintf (m_outfile
, " %d", regno
);
508 if (regno
< FIRST_PSEUDO_REGISTER
)
509 fprintf (m_outfile
, " %s", reg_names
[regno
]);
510 else if (regno
<= LAST_VIRTUAL_REGISTER
)
512 if (regno
== VIRTUAL_INCOMING_ARGS_REGNUM
)
513 fprintf (m_outfile
, " virtual-incoming-args");
514 else if (regno
== VIRTUAL_STACK_VARS_REGNUM
)
515 fprintf (m_outfile
, " virtual-stack-vars");
516 else if (regno
== VIRTUAL_STACK_DYNAMIC_REGNUM
)
517 fprintf (m_outfile
, " virtual-stack-dynamic");
518 else if (regno
== VIRTUAL_OUTGOING_ARGS_REGNUM
)
519 fprintf (m_outfile
, " virtual-outgoing-args");
520 else if (regno
== VIRTUAL_CFA_REGNUM
)
521 fprintf (m_outfile
, " virtual-cfa");
522 else if (regno
== VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM
)
523 fprintf (m_outfile
, " virtual-preferred-stack-boundary");
525 fprintf (m_outfile
, " virtual-reg-%d", regno
-FIRST_VIRTUAL_REGISTER
);
529 if (flag_dump_unnumbered
&& is_insn
)
530 fputc ('#', m_outfile
);
533 /* In compact mode, print pseudos with '< and '>' wrapping the regno,
534 offseting it by (LAST_VIRTUAL_REGISTER + 1), so that the
535 first non-virtual pseudo is dumped as "<0>". */
536 gcc_assert (regno
> LAST_VIRTUAL_REGISTER
);
537 fprintf (m_outfile
, " <%d>", regno
- (LAST_VIRTUAL_REGISTER
+ 1));
540 fprintf (m_outfile
, " %d", regno
);
542 #ifndef GENERATOR_FILE
543 if (REG_ATTRS (in_rtx
))
545 fputs (" [", m_outfile
);
546 if (regno
!= ORIGINAL_REGNO (in_rtx
))
547 fprintf (m_outfile
, "orig:%i", ORIGINAL_REGNO (in_rtx
));
548 if (REG_EXPR (in_rtx
))
549 print_mem_expr (m_outfile
, REG_EXPR (in_rtx
));
551 if (maybe_ne (REG_OFFSET (in_rtx
), 0))
553 fprintf (m_outfile
, "+");
554 print_poly_int (m_outfile
, REG_OFFSET (in_rtx
));
556 fputs (" ]", m_outfile
);
558 if (regno
!= ORIGINAL_REGNO (in_rtx
))
559 fprintf (m_outfile
, " [%d]", ORIGINAL_REGNO (in_rtx
));
563 /* Subroutine of print_rtx_operand for handling code 'u'. */
566 rtx_writer::print_rtx_operand_code_u (const_rtx in_rtx
, int idx
)
568 /* Don't print insn UIDs for PREV/NEXT_INSN in compact mode. */
569 if (m_compact
&& INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)) && idx
< 2)
572 if (XEXP (in_rtx
, idx
) != NULL
)
574 rtx sub
= XEXP (in_rtx
, idx
);
575 enum rtx_code subc
= GET_CODE (sub
);
577 if (GET_CODE (in_rtx
) == LABEL_REF
)
580 && NOTE_KIND (sub
) == NOTE_INSN_DELETED_LABEL
)
582 if (flag_dump_unnumbered
)
583 fprintf (m_outfile
, " [# deleted]");
585 fprintf (m_outfile
, " [%d deleted]", INSN_UID (sub
));
590 if (subc
!= CODE_LABEL
)
592 print_rtx_operand_code_e (in_rtx
, idx
);
597 if (flag_dump_unnumbered
598 || (flag_dump_unnumbered_links
&& idx
<= 1
599 && (INSN_P (in_rtx
) || NOTE_P (in_rtx
)
600 || LABEL_P (in_rtx
) || BARRIER_P (in_rtx
))))
601 fputs (" #", m_outfile
);
603 fprintf (m_outfile
, " %d", INSN_UID (sub
));
606 fputs (" 0", m_outfile
);
610 /* Subroutine of print_rtx. Print operand IDX of IN_RTX. */
613 rtx_writer::print_rtx_operand (const_rtx in_rtx
, int idx
)
615 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
617 switch (format_ptr
[idx
])
622 str
= XTMPL (in_rtx
, idx
);
627 str
= XSTR (in_rtx
, idx
);
631 fputs (" (nil)", m_outfile
);
633 fprintf (m_outfile
, " (\"%s\")", str
);
638 print_rtx_operand_code_0 (in_rtx
, idx
);
642 print_rtx_operand_code_e (in_rtx
, idx
);
647 print_rtx_operand_codes_E_and_V (in_rtx
, idx
);
652 fprintf (m_outfile
, " ");
653 fprintf (m_outfile
, HOST_WIDE_INT_PRINT_DEC
, XWINT (in_rtx
, idx
));
654 if (! m_simple
&& !m_compact
)
655 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_HEX
"]",
656 (unsigned HOST_WIDE_INT
) XWINT (in_rtx
, idx
));
660 print_rtx_operand_code_i (in_rtx
, idx
);
664 fprintf (m_outfile
, " ");
665 print_poly_int (m_outfile
, SUBREG_BYTE (in_rtx
));
669 print_rtx_operand_code_r (in_rtx
);
672 /* Print NOTE_INSN names rather than integer codes. */
675 fprintf (m_outfile
, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx
, idx
)));
680 print_rtx_operand_code_u (in_rtx
, idx
);
684 #ifndef GENERATOR_FILE
685 if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_IMPLICIT_PTR
)
686 print_mem_expr (m_outfile
, DEBUG_IMPLICIT_PTR_DECL (in_rtx
));
687 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_PARAMETER_REF
)
688 print_mem_expr (m_outfile
, DEBUG_PARAMETER_REF_DECL (in_rtx
));
690 dump_addr (m_outfile
, " ", XTREE (in_rtx
, idx
));
695 fputs (" Unknown", m_outfile
);
700 /* Don't print basic block ids in compact mode. */
703 #ifndef GENERATOR_FILE
704 if (XBBDEF (in_rtx
, idx
))
705 fprintf (m_outfile
, " %i", XBBDEF (in_rtx
, idx
)->index
);
714 /* Subroutine of rtx_writer::print_rtx.
715 In compact mode, determine if operand IDX of IN_RTX is interesting
716 to dump, or (if in a trailing position) it can be omitted. */
719 rtx_writer::operand_has_default_value_p (const_rtx in_rtx
, int idx
)
721 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
723 switch (format_ptr
[idx
])
727 return XEXP (in_rtx
, idx
) == NULL_RTX
;
730 return XSTR (in_rtx
, idx
) == NULL
;
733 switch (GET_CODE (in_rtx
))
736 /* JUMP_LABELs are always omitted in compact mode, so treat
737 any value here as omittable, so that earlier operands can
738 potentially be omitted also. */
751 /* Print IN_RTX onto m_outfile. This is the recursive part of printing. */
754 rtx_writer::print_rtx (const_rtx in_rtx
)
761 fputc (' ', m_outfile
);
763 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
769 fputs ("(nil)", m_outfile
);
773 else if (GET_CODE (in_rtx
) > NUM_RTX_CODE
)
775 fprintf (m_outfile
, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx
),
776 print_rtx_head
, m_indent
* 2, "");
781 fputc ('(', m_outfile
);
783 /* Print name of expression code. */
786 #ifndef GENERATOR_FILE
787 if (m_rtx_reuse_manager
)
790 if (m_rtx_reuse_manager
->has_reuse_id (in_rtx
, &reuse_id
))
792 /* Have we already seen the defn of this rtx? */
793 if (m_rtx_reuse_manager
->seen_def_p (reuse_id
))
795 fprintf (m_outfile
, "reuse_rtx %i)", reuse_id
);
801 /* First time we've seen this reused-rtx. */
802 fprintf (m_outfile
, "%i|", reuse_id
);
803 m_rtx_reuse_manager
->set_seen_def (reuse_id
);
807 #endif /* #ifndef GENERATOR_FILE */
809 /* In compact mode, prefix the code of insns with "c",
810 giving "cinsn", "cnote" etc. */
811 if (m_compact
&& is_a
<const rtx_insn
*, const struct rtx_def
> (in_rtx
))
813 /* "ccode_label" is slightly awkward, so special-case it as
815 rtx_code code
= GET_CODE (in_rtx
);
816 if (code
== CODE_LABEL
)
817 fprintf (m_outfile
, "clabel");
819 fprintf (m_outfile
, "c%s", GET_RTX_NAME (code
));
821 else if (m_simple
&& CONST_INT_P (in_rtx
))
824 fprintf (m_outfile
, "%s", GET_RTX_NAME (GET_CODE (in_rtx
)));
828 if (RTX_FLAG (in_rtx
, in_struct
))
829 fputs ("/s", m_outfile
);
831 if (RTX_FLAG (in_rtx
, volatil
))
832 fputs ("/v", m_outfile
);
834 if (RTX_FLAG (in_rtx
, unchanging
))
835 fputs ("/u", m_outfile
);
837 if (RTX_FLAG (in_rtx
, frame_related
))
838 fputs ("/f", m_outfile
);
840 if (RTX_FLAG (in_rtx
, jump
))
841 fputs ("/j", m_outfile
);
843 if (RTX_FLAG (in_rtx
, call
))
844 fputs ("/c", m_outfile
);
846 if (RTX_FLAG (in_rtx
, return_val
))
847 fputs ("/i", m_outfile
);
849 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
850 if ((GET_CODE (in_rtx
) == EXPR_LIST
851 || GET_CODE (in_rtx
) == INSN_LIST
852 || GET_CODE (in_rtx
) == INT_LIST
)
853 && (int)GET_MODE (in_rtx
) < REG_NOTE_MAX
854 && !m_in_call_function_usage
)
855 fprintf (m_outfile
, ":%s",
856 GET_REG_NOTE_NAME (GET_MODE (in_rtx
)));
858 /* For other rtl, print the mode if it's not VOID. */
859 else if (GET_MODE (in_rtx
) != VOIDmode
)
860 fprintf (m_outfile
, ":%s", GET_MODE_NAME (GET_MODE (in_rtx
)));
862 #ifndef GENERATOR_FILE
863 if (GET_CODE (in_rtx
) == VAR_LOCATION
)
865 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx
)) == STRING_CST
)
866 fputs (" <debug string placeholder>", m_outfile
);
868 print_mem_expr (m_outfile
, PAT_VAR_LOCATION_DECL (in_rtx
));
869 fputc (' ', m_outfile
);
870 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx
));
871 if (PAT_VAR_LOCATION_STATUS (in_rtx
)
872 == VAR_INIT_STATUS_UNINITIALIZED
)
873 fprintf (m_outfile
, " [uninit]");
875 idx
= GET_RTX_LENGTH (VAR_LOCATION
);
880 #ifndef GENERATOR_FILE
881 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx
))
885 /* For insns, print the INSN_UID. */
886 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)))
888 if (flag_dump_unnumbered
)
889 fprintf (m_outfile
, " #");
891 fprintf (m_outfile
, " %d", INSN_UID (in_rtx
));
894 /* Determine which is the final operand to print.
895 In compact mode, skip trailing operands that have the default values
896 e.g. trailing "(nil)" values. */
897 int limit
= GET_RTX_LENGTH (GET_CODE (in_rtx
));
899 while (limit
> idx
&& operand_has_default_value_p (in_rtx
, limit
- 1))
902 /* Get the format string and skip the first elements if we have handled
905 for (; idx
< limit
; idx
++)
906 print_rtx_operand (in_rtx
, idx
);
908 switch (GET_CODE (in_rtx
))
910 #ifndef GENERATOR_FILE
912 if (__builtin_expect (final_insns_dump_p
, false))
913 fprintf (m_outfile
, " [");
915 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_DEC
,
916 (HOST_WIDE_INT
) MEM_ALIAS_SET (in_rtx
));
918 if (MEM_EXPR (in_rtx
))
919 print_mem_expr (m_outfile
, MEM_EXPR (in_rtx
));
921 fputc (' ', m_outfile
);
923 if (MEM_OFFSET_KNOWN_P (in_rtx
))
925 fprintf (m_outfile
, "+");
926 print_poly_int (m_outfile
, MEM_OFFSET (in_rtx
));
929 if (MEM_SIZE_KNOWN_P (in_rtx
))
931 fprintf (m_outfile
, " S");
932 print_poly_int (m_outfile
, MEM_SIZE (in_rtx
));
935 if (MEM_ALIGN (in_rtx
) != 1)
936 fprintf (m_outfile
, " A%u", MEM_ALIGN (in_rtx
));
938 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx
)))
939 fprintf (m_outfile
, " AS%u", MEM_ADDR_SPACE (in_rtx
));
941 fputc (']', m_outfile
);
945 if (FLOAT_MODE_P (GET_MODE (in_rtx
)))
949 real_to_decimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
951 fprintf (m_outfile
, " %s", s
);
953 real_to_hexadecimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
955 fprintf (m_outfile
, " [%s]", s
);
960 fprintf (m_outfile
, " ");
961 cwi_output_hex (m_outfile
, in_rtx
);
965 fprintf (m_outfile
, " [");
966 print_dec (CONST_POLY_INT_COEFFS (in_rtx
)[0], m_outfile
, SIGNED
);
967 for (unsigned int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
969 fprintf (m_outfile
, ", ");
970 print_dec (CONST_POLY_INT_COEFFS (in_rtx
)[i
], m_outfile
, SIGNED
);
972 fprintf (m_outfile
, "]");
978 fprintf (m_outfile
, " [%d uses]", LABEL_NUSES (in_rtx
));
979 switch (LABEL_KIND (in_rtx
))
981 case LABEL_NORMAL
: break;
982 case LABEL_STATIC_ENTRY
: fputs (" [entry]", m_outfile
); break;
983 case LABEL_GLOBAL_ENTRY
: fputs (" [global entry]", m_outfile
); break;
984 case LABEL_WEAK_ENTRY
: fputs (" [weak entry]", m_outfile
); break;
985 default: gcc_unreachable ();
993 fputc (')', m_outfile
);
997 /* Emit a closing parenthesis and newline. */
1000 rtx_writer::finish_directive ()
1002 fprintf (m_outfile
, ")\n");
1006 /* Print an rtx on the current line of FILE. Initially indent IND
1010 print_inline_rtx (FILE *outf
, const_rtx x
, int ind
)
1012 rtx_writer
w (outf
, ind
, false, false, NULL
);
1016 /* Call this function from the debugger to see what X looks like. */
1019 debug_rtx (const_rtx x
)
1021 rtx_writer
w (stderr
, 0, false, false, NULL
);
1023 fprintf (stderr
, "\n");
1029 debug (const rtx_def
&ref
)
1035 debug (const rtx_def
*ptr
)
1040 fprintf (stderr
, "<nil>\n");
1043 /* Like debug_rtx but with no newline, as debug_helper will add one.
1045 Note: No debug_slim(rtx_insn *) variant implemented, as this
1046 function can serve for both rtx and rtx_insn. */
1049 debug_slim (const_rtx x
)
1051 rtx_writer
w (stderr
, 0, false, false, NULL
);
1055 DEFINE_DEBUG_VEC (rtx_def
*)
1056 DEFINE_DEBUG_VEC (rtx_insn
*)
1057 DEFINE_DEBUG_HASH_SET (rtx_def
*)
1058 DEFINE_DEBUG_HASH_SET (rtx_insn
*)
1060 /* Count of rtx's to print with debug_rtx_list.
1061 This global exists because gdb user defined commands have no arguments. */
1063 DEBUG_VARIABLE
int debug_rtx_count
= 0; /* 0 is treated as equivalent to 1 */
1065 /* Call this function to print list from X on.
1067 N is a count of the rtx's to print. Positive values print from the specified
1068 rtx_insn on. Negative values print a window around the rtx_insn.
1069 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
1073 debug_rtx_list (const rtx_insn
*x
, int n
)
1076 const rtx_insn
*insn
;
1078 count
= n
== 0 ? 1 : n
< 0 ? -n
: n
;
1080 /* If we are printing a window, back up to the start. */
1083 for (i
= count
/ 2; i
> 0; i
--)
1085 if (PREV_INSN (x
) == 0)
1090 for (i
= count
, insn
= x
; i
> 0 && insn
!= 0; i
--, insn
= NEXT_INSN (insn
))
1093 fprintf (stderr
, "\n");
1097 /* Call this function to print an rtx_insn list from START to END
1101 debug_rtx_range (const rtx_insn
*start
, const rtx_insn
*end
)
1106 fprintf (stderr
, "\n");
1107 if (!start
|| start
== end
)
1109 start
= NEXT_INSN (start
);
1113 /* Call this function to search an rtx_insn list to find one with insn uid UID,
1114 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
1115 The found insn is returned to enable further debugging analysis. */
1117 DEBUG_FUNCTION
const rtx_insn
*
1118 debug_rtx_find (const rtx_insn
*x
, int uid
)
1120 while (x
!= 0 && INSN_UID (x
) != uid
)
1124 debug_rtx_list (x
, debug_rtx_count
);
1129 fprintf (stderr
, "insn uid %d not found\n", uid
);
1134 /* External entry point for printing a chain of insns
1135 starting with RTX_FIRST.
1136 A blank line separates insns.
1138 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1141 rtx_writer::print_rtl (const_rtx rtx_first
)
1143 const rtx_insn
*tmp_rtx
;
1147 fputs (print_rtx_head
, m_outfile
);
1148 fputs ("(nil)\n", m_outfile
);
1151 switch (GET_CODE (rtx_first
))
1158 case JUMP_TABLE_DATA
:
1160 for (tmp_rtx
= as_a
<const rtx_insn
*> (rtx_first
);
1162 tmp_rtx
= NEXT_INSN (tmp_rtx
))
1164 fputs (print_rtx_head
, m_outfile
);
1165 print_rtx (tmp_rtx
);
1166 fprintf (m_outfile
, "\n");
1171 fputs (print_rtx_head
, m_outfile
);
1172 print_rtx (rtx_first
);
1176 /* External entry point for printing a chain of insns
1177 starting with RTX_FIRST onto file OUTF.
1178 A blank line separates insns.
1180 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1183 print_rtl (FILE *outf
, const_rtx rtx_first
)
1185 rtx_writer
w (outf
, 0, false, false, NULL
);
1186 w
.print_rtl (rtx_first
);
1189 /* Like print_rtx, except specify a file. */
1190 /* Return nonzero if we actually printed anything. */
1193 print_rtl_single (FILE *outf
, const_rtx x
)
1195 rtx_writer
w (outf
, 0, false, false, NULL
);
1196 return w
.print_rtl_single_with_indent (x
, 0);
1199 /* Like print_rtl_single, except specify an indentation. */
1202 rtx_writer::print_rtl_single_with_indent (const_rtx x
, int ind
)
1204 char *s_indent
= (char *) alloca ((size_t) ind
+ 1);
1205 memset ((void *) s_indent
, ' ', (size_t) ind
);
1206 s_indent
[ind
] = '\0';
1207 fputs (s_indent
, m_outfile
);
1208 fputs (print_rtx_head
, m_outfile
);
1210 int old_indent
= m_indent
;
1214 putc ('\n', m_outfile
);
1215 m_indent
= old_indent
;
1220 /* Like print_rtl except without all the detail; for example,
1221 if RTX is a CONST_INT then print in decimal format. */
1224 print_simple_rtl (FILE *outf
, const_rtx x
)
1226 rtx_writer
w (outf
, 0, true, false, NULL
);
1230 /* Print the elements of VEC to FILE. */
1233 print_rtx_insn_vec (FILE *file
, const vec
<rtx_insn
*> &vec
)
1237 unsigned int len
= vec
.length ();
1238 for (unsigned int i
= 0; i
< len
; i
++)
1240 print_rtl (file
, vec
[i
]);
1248 #ifndef GENERATOR_FILE
1249 /* The functions below try to print RTL in a form resembling assembler
1250 mnemonics. Because this form is more concise than the "traditional" form
1251 of RTL printing in Lisp-style, the form printed by this file is called
1252 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
1253 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
1254 always printed in slim form.
1256 The normal interface to the functionality provided in this pretty-printer
1257 is through the dump_*_slim functions to print to a stream, or via the
1258 print_*_slim functions to print into a user's pretty-printer.
1260 It is also possible to obtain a string for a single pattern as a string
1261 pointer, via str_pattern_slim, but this usage is discouraged. */
1263 /* For insns we print patterns, and for some patterns we print insns... */
1264 static void print_insn_with_notes (pretty_printer
*, const rtx_insn
*);
1266 /* This recognizes rtx'en classified as expressions. These are always
1267 represent some action on values or results of other expression, that
1268 may be stored in objects representing values. */
1271 print_exp (pretty_printer
*pp
, const_rtx x
, int verbose
)
1279 for (i
= 0; i
< 4; i
++)
1285 switch (GET_CODE (x
))
1288 op
[0] = XEXP (x
, 0);
1289 if (CONST_INT_P (XEXP (x
, 1))
1290 && INTVAL (XEXP (x
, 1)) < 0)
1293 op
[1] = GEN_INT (-INTVAL (XEXP (x
, 1)));
1298 op
[1] = XEXP (x
, 1);
1302 op
[0] = XEXP (x
, 0);
1304 op
[1] = XEXP (x
, 1);
1308 op
[0] = XEXP (x
, 0);
1310 op
[1] = XEXP (x
, 1);
1314 op
[0] = XEXP (x
, 0);
1315 op
[1] = XEXP (x
, 1);
1319 op
[0] = XEXP (x
, 0);
1323 op
[0] = XEXP (x
, 0);
1325 op
[1] = XEXP (x
, 1);
1327 op
[2] = XEXP (x
, 2);
1331 op
[0] = XEXP (x
, 0);
1333 op
[1] = XEXP (x
, 1);
1336 op
[0] = XEXP (x
, 0);
1338 op
[1] = XEXP (x
, 1);
1342 op
[0] = XEXP (x
, 0);
1343 op
[1] = XEXP (x
, 1);
1346 op
[0] = XEXP (x
, 0);
1348 op
[1] = XEXP (x
, 1);
1352 op
[0] = XEXP (x
, 0);
1353 op
[1] = XEXP (x
, 1);
1357 op
[0] = XEXP (x
, 0);
1358 op
[1] = XEXP (x
, 1);
1362 op
[0] = XEXP (x
, 0);
1363 op
[1] = XEXP (x
, 1);
1367 op
[0] = XEXP (x
, 0);
1368 op
[1] = XEXP (x
, 1);
1372 op
[0] = XEXP (x
, 0);
1373 op
[1] = XEXP (x
, 1);
1377 op
[0] = XEXP (x
, 0);
1380 op
[0] = XEXP (x
, 0);
1382 op
[1] = XEXP (x
, 1);
1385 op
[0] = XEXP (x
, 0);
1387 op
[1] = XEXP (x
, 1);
1390 op
[0] = XEXP (x
, 0);
1392 op
[1] = XEXP (x
, 1);
1395 op
[0] = XEXP (x
, 0);
1397 op
[1] = XEXP (x
, 1);
1400 op
[0] = XEXP (x
, 0);
1402 op
[1] = XEXP (x
, 1);
1405 op
[0] = XEXP (x
, 0);
1407 op
[1] = XEXP (x
, 1);
1410 op
[0] = XEXP (x
, 0);
1412 op
[1] = XEXP (x
, 1);
1415 op
[0] = XEXP (x
, 0);
1417 op
[1] = XEXP (x
, 1);
1420 op
[0] = XEXP (x
, 0);
1422 op
[1] = XEXP (x
, 1);
1425 op
[0] = XEXP (x
, 0);
1427 op
[1] = XEXP (x
, 1);
1430 op
[0] = XEXP (x
, 0);
1432 op
[1] = XEXP (x
, 1);
1435 op
[0] = XEXP (x
, 0);
1437 op
[1] = XEXP (x
, 1);
1440 op
[0] = XEXP (x
, 0);
1442 op
[1] = XEXP (x
, 1);
1445 op
[0] = XEXP (x
, 0);
1447 op
[1] = XEXP (x
, 1);
1450 fun
= (verbose
) ? "sign_extract" : "sxt";
1451 op
[0] = XEXP (x
, 0);
1452 op
[1] = XEXP (x
, 1);
1453 op
[2] = XEXP (x
, 2);
1456 fun
= (verbose
) ? "zero_extract" : "zxt";
1457 op
[0] = XEXP (x
, 0);
1458 op
[1] = XEXP (x
, 1);
1459 op
[2] = XEXP (x
, 2);
1462 fun
= (verbose
) ? "sign_extend" : "sxn";
1463 op
[0] = XEXP (x
, 0);
1466 fun
= (verbose
) ? "zero_extend" : "zxn";
1467 op
[0] = XEXP (x
, 0);
1470 fun
= (verbose
) ? "float_extend" : "fxn";
1471 op
[0] = XEXP (x
, 0);
1474 fun
= (verbose
) ? "trunc" : "trn";
1475 op
[0] = XEXP (x
, 0);
1477 case FLOAT_TRUNCATE
:
1478 fun
= (verbose
) ? "float_trunc" : "ftr";
1479 op
[0] = XEXP (x
, 0);
1482 fun
= (verbose
) ? "float" : "flt";
1483 op
[0] = XEXP (x
, 0);
1485 case UNSIGNED_FLOAT
:
1486 fun
= (verbose
) ? "uns_float" : "ufl";
1487 op
[0] = XEXP (x
, 0);
1491 op
[0] = XEXP (x
, 0);
1494 fun
= (verbose
) ? "uns_fix" : "ufx";
1495 op
[0] = XEXP (x
, 0);
1499 op
[0] = XEXP (x
, 0);
1503 op
[0] = XEXP (x
, 0);
1506 op
[0] = XEXP (x
, 0);
1510 op
[0] = XEXP (x
, 0);
1515 op
[0] = XEXP (XEXP (x
, 1), 0);
1517 op
[1] = XEXP (XEXP (x
, 1), 1);
1521 op
[0] = XEXP (XEXP (x
, 1), 0);
1523 op
[1] = XEXP (XEXP (x
, 1), 1);
1527 op
[0] = XEXP (x
, 0);
1531 op
[1] = XEXP (x
, 1);
1536 op
[0] = XEXP (x
, 0);
1538 op
[1] = XEXP (x
, 1);
1540 op
[2] = XEXP (x
, 2);
1545 op
[0] = TRAP_CONDITION (x
);
1549 op
[0] = XEXP (x
, 0);
1550 op
[1] = XEXP (x
, 1);
1551 op
[2] = XEXP (x
, 2);
1554 case UNSPEC_VOLATILE
:
1556 pp_string (pp
, "unspec");
1557 if (GET_CODE (x
) == UNSPEC_VOLATILE
)
1558 pp_string (pp
, "/v");
1559 pp_left_bracket (pp
);
1560 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1564 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1566 pp_string (pp
, "] ");
1567 pp_decimal_int (pp
, XINT (x
, 1));
1572 /* Most unhandled codes can be printed as pseudo-functions. */
1573 if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_UNARY
)
1575 fun
= GET_RTX_NAME (GET_CODE (x
));
1576 op
[0] = XEXP (x
, 0);
1578 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMPARE
1579 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_COMPARE
1580 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_BIN_ARITH
1581 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_ARITH
)
1583 fun
= GET_RTX_NAME (GET_CODE (x
));
1584 op
[0] = XEXP (x
, 0);
1585 op
[1] = XEXP (x
, 1);
1587 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_TERNARY
)
1589 fun
= GET_RTX_NAME (GET_CODE (x
));
1590 op
[0] = XEXP (x
, 0);
1591 op
[1] = XEXP (x
, 1);
1592 op
[2] = XEXP (x
, 2);
1595 /* Give up, just print the RTX name. */
1596 st
[0] = GET_RTX_NAME (GET_CODE (x
));
1601 /* Print this as a function? */
1604 pp_string (pp
, fun
);
1608 for (i
= 0; i
< 4; i
++)
1611 pp_string (pp
, st
[i
]);
1617 print_value (pp
, op
[i
], verbose
);
1622 pp_right_paren (pp
);
1625 /* Prints rtxes, I customarily classified as values. They're constants,
1626 registers, labels, symbols and memory accesses. */
1629 print_value (pretty_printer
*pp
, const_rtx x
, int verbose
)
1635 pp_string (pp
, "(nil)");
1638 switch (GET_CODE (x
))
1641 pp_scalar (pp
, HOST_WIDE_INT_PRINT_HEX
,
1642 (unsigned HOST_WIDE_INT
) INTVAL (x
));
1645 case CONST_WIDE_INT
:
1647 const char *sep
= "<";
1649 for (i
= CONST_WIDE_INT_NUNITS (x
) - 1; i
>= 0; i
--)
1651 pp_string (pp
, sep
);
1653 sprintf (tmp
, HOST_WIDE_INT_PRINT_HEX
,
1654 (unsigned HOST_WIDE_INT
) CONST_WIDE_INT_ELT (x
, i
));
1655 pp_string (pp
, tmp
);
1661 case CONST_POLY_INT
:
1662 pp_left_bracket (pp
);
1663 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[0], SIGNED
);
1664 for (unsigned int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
1666 pp_string (pp
, ", ");
1667 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[i
], SIGNED
);
1669 pp_right_bracket (pp
);
1673 if (FLOAT_MODE_P (GET_MODE (x
)))
1675 real_to_decimal (tmp
, CONST_DOUBLE_REAL_VALUE (x
),
1676 sizeof (tmp
), 0, 1);
1677 pp_string (pp
, tmp
);
1680 pp_printf (pp
, "<%wx,%wx>",
1681 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (x
),
1682 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_HIGH (x
));
1685 fixed_to_decimal (tmp
, CONST_FIXED_VALUE (x
), sizeof (tmp
));
1686 pp_string (pp
, tmp
);
1689 pp_string (pp
, "\"");
1690 pretty_print_string (pp
, XSTR (x
, 0), strlen (XSTR (x
, 0)));
1691 pp_string (pp
, "\"");
1694 pp_printf (pp
, "`%s'", XSTR (x
, 0));
1697 pp_printf (pp
, "L%d", INSN_UID (label_ref_label (x
)));
1701 case STRICT_LOW_PART
:
1702 pp_printf (pp
, "%s(", GET_RTX_NAME (GET_CODE (x
)));
1703 print_value (pp
, XEXP (x
, 0), verbose
);
1704 pp_right_paren (pp
);
1707 if (REGNO (x
) < FIRST_PSEUDO_REGISTER
)
1709 if (ISDIGIT (reg_names
[REGNO (x
)][0]))
1711 pp_string (pp
, reg_names
[REGNO (x
)]);
1714 pp_printf (pp
, "r%d", REGNO (x
));
1716 pp_printf (pp
, ":%s", GET_MODE_NAME (GET_MODE (x
)));
1719 print_value (pp
, SUBREG_REG (x
), verbose
);
1720 pp_printf (pp
, "#");
1721 pp_wide_integer (pp
, SUBREG_BYTE (x
));
1726 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1729 pp_left_bracket (pp
);
1730 print_value (pp
, XEXP (x
, 0), verbose
);
1731 pp_right_bracket (pp
);
1734 pp_printf (pp
, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x
)));
1737 print_exp (pp
, x
, verbose
);
1742 /* The next step in insn detalization, its pattern recognition. */
1745 print_pattern (pretty_printer
*pp
, const_rtx x
, int verbose
)
1749 pp_string (pp
, "(nil)");
1753 switch (GET_CODE (x
))
1756 print_value (pp
, SET_DEST (x
), verbose
);
1758 print_value (pp
, SET_SRC (x
), verbose
);
1763 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1766 print_exp (pp
, x
, verbose
);
1770 pp_printf (pp
, "%s ", GET_RTX_NAME (GET_CODE (x
)));
1771 print_value (pp
, XEXP (x
, 0), verbose
);
1774 pp_string (pp
, "loc ");
1775 print_value (pp
, PAT_VAR_LOCATION_LOC (x
), verbose
);
1779 if (GET_CODE (COND_EXEC_TEST (x
)) == NE
1780 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1781 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1782 else if (GET_CODE (COND_EXEC_TEST (x
)) == EQ
1783 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1785 pp_exclamation (pp
);
1786 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1789 print_value (pp
, COND_EXEC_TEST (x
), verbose
);
1790 pp_string (pp
, ") ");
1791 print_pattern (pp
, COND_EXEC_CODE (x
), verbose
);
1798 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1800 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1803 pp_right_brace (pp
);
1808 const rtx_sequence
*seq
= as_a
<const rtx_sequence
*> (x
);
1809 pp_string (pp
, "sequence{");
1810 if (INSN_P (seq
->element (0)))
1812 /* Print the sequence insns indented. */
1813 const char * save_print_rtx_head
= print_rtx_head
;
1814 char indented_print_rtx_head
[32];
1817 gcc_assert (strlen (print_rtx_head
) < sizeof (indented_print_rtx_head
) - 4);
1818 snprintf (indented_print_rtx_head
,
1819 sizeof (indented_print_rtx_head
),
1820 "%s ", print_rtx_head
);
1821 print_rtx_head
= indented_print_rtx_head
;
1822 for (int i
= 0; i
< seq
->len (); i
++)
1823 print_insn_with_notes (pp
, seq
->insn (i
));
1824 pp_printf (pp
, "%s ", save_print_rtx_head
);
1825 print_rtx_head
= save_print_rtx_head
;
1829 for (int i
= 0; i
< seq
->len (); i
++)
1831 print_pattern (pp
, seq
->element (i
), verbose
);
1835 pp_right_brace (pp
);
1839 pp_printf (pp
, "asm {%s}", XSTR (x
, 0));
1842 for (int i
= 0; i
< XVECLEN (x
, 0); i
++)
1844 print_value (pp
, XVECEXP (x
, 0, i
), verbose
);
1849 for (int i
= 0; i
< XVECLEN (x
, 1); i
++)
1851 print_value (pp
, XVECEXP (x
, 1, i
), verbose
);
1856 pp_string (pp
, "trap_if ");
1857 print_value (pp
, TRAP_CONDITION (x
), verbose
);
1860 case UNSPEC_VOLATILE
:
1861 /* Fallthru -- leave UNSPECs to print_exp. */
1863 print_value (pp
, x
, verbose
);
1865 } /* print_pattern */
1867 /* This is the main function in slim rtl visualization mechanism.
1869 X is an insn, to be printed into PP.
1871 This function tries to print it properly in human-readable form,
1872 resembling assembler mnemonics (instead of the older Lisp-style
1875 If VERBOSE is TRUE, insns are printed with more complete (but
1876 longer) pattern names and with extra information, and prefixed
1877 with their INSN_UIDs. */
1880 print_insn (pretty_printer
*pp
, const rtx_insn
*x
, int verbose
)
1884 /* Blech, pretty-print can't print integers with a specified width. */
1885 char uid_prefix
[32];
1886 snprintf (uid_prefix
, sizeof uid_prefix
, " %4d: ", INSN_UID (x
));
1887 pp_string (pp
, uid_prefix
);
1890 switch (GET_CODE (x
))
1893 print_pattern (pp
, PATTERN (x
), verbose
);
1898 if (DEBUG_MARKER_INSN_P (x
))
1900 switch (INSN_DEBUG_MARKER_KIND (x
))
1902 case NOTE_INSN_BEGIN_STMT
:
1903 pp_string (pp
, "debug begin stmt marker");
1906 case NOTE_INSN_INLINE_ENTRY
:
1907 pp_string (pp
, "debug inline entry marker");
1916 const char *name
= "?";
1919 if (DECL_P (INSN_VAR_LOCATION_DECL (x
)))
1921 tree id
= DECL_NAME (INSN_VAR_LOCATION_DECL (x
));
1923 name
= IDENTIFIER_POINTER (id
);
1924 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x
))
1927 sprintf (idbuf
, "D#%i",
1928 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x
)));
1933 sprintf (idbuf
, "D.%i",
1934 DECL_UID (INSN_VAR_LOCATION_DECL (x
)));
1938 pp_printf (pp
, "debug %s => ", name
);
1939 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x
)))
1940 pp_string (pp
, "optimized away");
1942 print_pattern (pp
, INSN_VAR_LOCATION_LOC (x
), verbose
);
1947 print_pattern (pp
, PATTERN (x
), verbose
);
1950 if (GET_CODE (PATTERN (x
)) == PARALLEL
)
1951 print_pattern (pp
, XVECEXP (PATTERN (x
), 0, 0), verbose
);
1953 print_pattern (pp
, PATTERN (x
), verbose
);
1956 pp_printf (pp
, "L%d:", INSN_UID (x
));
1958 case JUMP_TABLE_DATA
:
1959 pp_string (pp
, "jump_table_data{\n");
1960 print_pattern (pp
, PATTERN (x
), verbose
);
1961 pp_right_brace (pp
);
1964 pp_string (pp
, "barrier");
1968 pp_string (pp
, GET_NOTE_INSN_NAME (NOTE_KIND (x
)));
1969 switch (NOTE_KIND (x
))
1971 case NOTE_INSN_EH_REGION_BEG
:
1972 case NOTE_INSN_EH_REGION_END
:
1973 pp_printf (pp
, " %d", NOTE_EH_HANDLER (x
));
1976 case NOTE_INSN_BLOCK_BEG
:
1977 case NOTE_INSN_BLOCK_END
:
1978 pp_printf (pp
, " %d", BLOCK_NUMBER (NOTE_BLOCK (x
)));
1981 case NOTE_INSN_BASIC_BLOCK
:
1982 pp_printf (pp
, " %d", NOTE_BASIC_BLOCK (x
)->index
);
1985 case NOTE_INSN_DELETED_LABEL
:
1986 case NOTE_INSN_DELETED_DEBUG_LABEL
:
1988 const char *label
= NOTE_DELETED_LABEL_NAME (x
);
1991 pp_printf (pp
, " (\"%s\")", label
);
1995 case NOTE_INSN_VAR_LOCATION
:
1997 print_pattern (pp
, NOTE_VAR_LOCATION (x
), verbose
);
1998 pp_right_brace (pp
);
2011 /* Pretty-print a slim dump of X (an insn) to PP, including any register
2012 note attached to the instruction. */
2015 print_insn_with_notes (pretty_printer
*pp
, const rtx_insn
*x
)
2017 pp_string (pp
, print_rtx_head
);
2018 print_insn (pp
, x
, 1);
2020 if (INSN_P (x
) && REG_NOTES (x
))
2021 for (rtx note
= REG_NOTES (x
); note
; note
= XEXP (note
, 1))
2023 pp_printf (pp
, "%s %s ", print_rtx_head
,
2024 GET_REG_NOTE_NAME (REG_NOTE_KIND (note
)));
2025 if (GET_CODE (note
) == INT_LIST
)
2026 pp_printf (pp
, "%d", XINT (note
, 0));
2028 print_pattern (pp
, XEXP (note
, 0), 1);
2033 /* Print X, an RTL value node, to file F in slim format. Include
2034 additional information if VERBOSE is nonzero.
2036 Value nodes are constants, registers, labels, symbols and
2040 dump_value_slim (FILE *f
, const_rtx x
, int verbose
)
2042 pretty_printer rtl_slim_pp
;
2043 rtl_slim_pp
.buffer
->stream
= f
;
2044 print_value (&rtl_slim_pp
, x
, verbose
);
2045 pp_flush (&rtl_slim_pp
);
2048 /* Emit a slim dump of X (an insn) to the file F, including any register
2049 note attached to the instruction. */
2051 dump_insn_slim (FILE *f
, const rtx_insn
*x
)
2053 pretty_printer rtl_slim_pp
;
2054 rtl_slim_pp
.buffer
->stream
= f
;
2055 print_insn_with_notes (&rtl_slim_pp
, x
);
2056 pp_flush (&rtl_slim_pp
);
2059 /* Same as above, but stop at LAST or when COUNT == 0.
2060 If COUNT < 0 it will stop only at LAST or NULL rtx. */
2063 dump_rtl_slim (FILE *f
, const rtx_insn
*first
, const rtx_insn
*last
,
2064 int count
, int flags ATTRIBUTE_UNUSED
)
2066 const rtx_insn
*insn
, *tail
;
2067 pretty_printer rtl_slim_pp
;
2068 rtl_slim_pp
.buffer
->stream
= f
;
2070 tail
= last
? NEXT_INSN (last
) : NULL
;
2072 (insn
!= NULL
) && (insn
!= tail
) && (count
!= 0);
2073 insn
= NEXT_INSN (insn
))
2075 print_insn_with_notes (&rtl_slim_pp
, insn
);
2080 pp_flush (&rtl_slim_pp
);
2083 /* Dumps basic block BB to pretty-printer PP in slim form and without and
2084 no indentation, for use as a label of a DOT graph record-node. */
2087 rtl_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
2092 /* TODO: inter-bb stuff. */
2093 FOR_BB_INSNS (bb
, insn
)
2098 pp_write_text_to_stream (pp
);
2101 print_insn_with_notes (pp
, insn
);
2102 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2106 /* Pretty-print pattern X of some insn in non-verbose mode.
2107 Return a string pointer to the pretty-printer buffer.
2109 This function is only exported exists only to accommodate some older users
2110 of the slim RTL pretty printers. Please do not use it for new code. */
2113 str_pattern_slim (const_rtx x
)
2115 pretty_printer rtl_slim_pp
;
2116 print_pattern (&rtl_slim_pp
, x
, 0);
2117 return ggc_strdup (pp_formatted_text (&rtl_slim_pp
));
2120 /* Emit a slim dump of X (an insn) to stderr. */
2121 extern void debug_insn_slim (const rtx_insn
*);
2123 debug_insn_slim (const rtx_insn
*x
)
2125 dump_insn_slim (stderr
, x
);
2128 /* Same as above, but using dump_rtl_slim. */
2129 extern void debug_rtl_slim (FILE *, const rtx_insn
*, const rtx_insn
*,
2132 debug_rtl_slim (const rtx_insn
*first
, const rtx_insn
*last
, int count
,
2135 dump_rtl_slim (stderr
, first
, last
, count
, flags
);
2138 extern void debug_bb_slim (basic_block
);
2140 debug_bb_slim (basic_block bb
)
2142 debug_bb (bb
, TDF_SLIM
| TDF_BLOCKS
);
2145 extern void debug_bb_n_slim (int);
2147 debug_bb_n_slim (int n
)
2149 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, n
);
2156 # pragma GCC diagnostic pop