2 Copyright (C) 1987-2021 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 /* This recognizes rtx'en classified as expressions. These are always
1264 represent some action on values or results of other expression, that
1265 may be stored in objects representing values. */
1268 print_exp (pretty_printer
*pp
, const_rtx x
, int verbose
)
1276 for (i
= 0; i
< 4; i
++)
1282 switch (GET_CODE (x
))
1285 op
[0] = XEXP (x
, 0);
1286 if (CONST_INT_P (XEXP (x
, 1))
1287 && INTVAL (XEXP (x
, 1)) < 0)
1290 op
[1] = GEN_INT (-INTVAL (XEXP (x
, 1)));
1295 op
[1] = XEXP (x
, 1);
1299 op
[0] = XEXP (x
, 0);
1301 op
[1] = XEXP (x
, 1);
1305 op
[0] = XEXP (x
, 0);
1307 op
[1] = XEXP (x
, 1);
1311 op
[0] = XEXP (x
, 0);
1312 op
[1] = XEXP (x
, 1);
1316 op
[0] = XEXP (x
, 0);
1320 op
[0] = XEXP (x
, 0);
1322 op
[1] = XEXP (x
, 1);
1324 op
[2] = XEXP (x
, 2);
1328 op
[0] = XEXP (x
, 0);
1330 op
[1] = XEXP (x
, 1);
1333 op
[0] = XEXP (x
, 0);
1335 op
[1] = XEXP (x
, 1);
1339 op
[0] = XEXP (x
, 0);
1340 op
[1] = XEXP (x
, 1);
1343 op
[0] = XEXP (x
, 0);
1345 op
[1] = XEXP (x
, 1);
1349 op
[0] = XEXP (x
, 0);
1350 op
[1] = XEXP (x
, 1);
1354 op
[0] = XEXP (x
, 0);
1355 op
[1] = XEXP (x
, 1);
1359 op
[0] = XEXP (x
, 0);
1360 op
[1] = XEXP (x
, 1);
1364 op
[0] = XEXP (x
, 0);
1365 op
[1] = XEXP (x
, 1);
1369 op
[0] = XEXP (x
, 0);
1370 op
[1] = XEXP (x
, 1);
1374 op
[0] = XEXP (x
, 0);
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 op
[0] = XEXP (x
, 0);
1389 op
[1] = XEXP (x
, 1);
1392 op
[0] = XEXP (x
, 0);
1394 op
[1] = XEXP (x
, 1);
1397 op
[0] = XEXP (x
, 0);
1399 op
[1] = XEXP (x
, 1);
1402 op
[0] = XEXP (x
, 0);
1404 op
[1] = XEXP (x
, 1);
1407 op
[0] = XEXP (x
, 0);
1409 op
[1] = XEXP (x
, 1);
1412 op
[0] = XEXP (x
, 0);
1414 op
[1] = XEXP (x
, 1);
1417 op
[0] = XEXP (x
, 0);
1419 op
[1] = XEXP (x
, 1);
1422 op
[0] = XEXP (x
, 0);
1424 op
[1] = XEXP (x
, 1);
1427 op
[0] = XEXP (x
, 0);
1429 op
[1] = XEXP (x
, 1);
1432 op
[0] = XEXP (x
, 0);
1434 op
[1] = XEXP (x
, 1);
1437 op
[0] = XEXP (x
, 0);
1439 op
[1] = XEXP (x
, 1);
1442 op
[0] = XEXP (x
, 0);
1444 op
[1] = XEXP (x
, 1);
1447 fun
= (verbose
) ? "sign_extract" : "sxt";
1448 op
[0] = XEXP (x
, 0);
1449 op
[1] = XEXP (x
, 1);
1450 op
[2] = XEXP (x
, 2);
1453 fun
= (verbose
) ? "zero_extract" : "zxt";
1454 op
[0] = XEXP (x
, 0);
1455 op
[1] = XEXP (x
, 1);
1456 op
[2] = XEXP (x
, 2);
1459 fun
= (verbose
) ? "sign_extend" : "sxn";
1460 op
[0] = XEXP (x
, 0);
1463 fun
= (verbose
) ? "zero_extend" : "zxn";
1464 op
[0] = XEXP (x
, 0);
1467 fun
= (verbose
) ? "float_extend" : "fxn";
1468 op
[0] = XEXP (x
, 0);
1471 fun
= (verbose
) ? "trunc" : "trn";
1472 op
[0] = XEXP (x
, 0);
1474 case FLOAT_TRUNCATE
:
1475 fun
= (verbose
) ? "float_trunc" : "ftr";
1476 op
[0] = XEXP (x
, 0);
1479 fun
= (verbose
) ? "float" : "flt";
1480 op
[0] = XEXP (x
, 0);
1482 case UNSIGNED_FLOAT
:
1483 fun
= (verbose
) ? "uns_float" : "ufl";
1484 op
[0] = XEXP (x
, 0);
1488 op
[0] = XEXP (x
, 0);
1491 fun
= (verbose
) ? "uns_fix" : "ufx";
1492 op
[0] = XEXP (x
, 0);
1496 op
[0] = XEXP (x
, 0);
1500 op
[0] = XEXP (x
, 0);
1503 op
[0] = XEXP (x
, 0);
1507 op
[0] = XEXP (x
, 0);
1512 op
[0] = XEXP (XEXP (x
, 1), 0);
1514 op
[1] = XEXP (XEXP (x
, 1), 1);
1518 op
[0] = XEXP (XEXP (x
, 1), 0);
1520 op
[1] = XEXP (XEXP (x
, 1), 1);
1524 op
[0] = XEXP (x
, 0);
1528 op
[1] = XEXP (x
, 1);
1533 op
[0] = XEXP (x
, 0);
1535 op
[1] = XEXP (x
, 1);
1537 op
[2] = XEXP (x
, 2);
1542 op
[0] = TRAP_CONDITION (x
);
1546 op
[0] = XEXP (x
, 0);
1547 op
[1] = XEXP (x
, 1);
1548 op
[2] = XEXP (x
, 2);
1551 case UNSPEC_VOLATILE
:
1553 pp_string (pp
, "unspec");
1554 if (GET_CODE (x
) == UNSPEC_VOLATILE
)
1555 pp_string (pp
, "/v");
1556 pp_left_bracket (pp
);
1557 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1561 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1563 pp_string (pp
, "] ");
1564 pp_decimal_int (pp
, XINT (x
, 1));
1569 /* Most unhandled codes can be printed as pseudo-functions. */
1570 if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_UNARY
)
1572 fun
= GET_RTX_NAME (GET_CODE (x
));
1573 op
[0] = XEXP (x
, 0);
1575 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMPARE
1576 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_COMPARE
1577 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_BIN_ARITH
1578 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_ARITH
)
1580 fun
= GET_RTX_NAME (GET_CODE (x
));
1581 op
[0] = XEXP (x
, 0);
1582 op
[1] = XEXP (x
, 1);
1584 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_TERNARY
)
1586 fun
= GET_RTX_NAME (GET_CODE (x
));
1587 op
[0] = XEXP (x
, 0);
1588 op
[1] = XEXP (x
, 1);
1589 op
[2] = XEXP (x
, 2);
1592 /* Give up, just print the RTX name. */
1593 st
[0] = GET_RTX_NAME (GET_CODE (x
));
1598 /* Print this as a function? */
1601 pp_string (pp
, fun
);
1605 for (i
= 0; i
< 4; i
++)
1608 pp_string (pp
, st
[i
]);
1614 print_value (pp
, op
[i
], verbose
);
1619 pp_right_paren (pp
);
1622 /* Prints rtxes, I customarily classified as values. They're constants,
1623 registers, labels, symbols and memory accesses. */
1626 print_value (pretty_printer
*pp
, const_rtx x
, int verbose
)
1632 pp_string (pp
, "(nil)");
1635 switch (GET_CODE (x
))
1638 pp_scalar (pp
, HOST_WIDE_INT_PRINT_HEX
,
1639 (unsigned HOST_WIDE_INT
) INTVAL (x
));
1642 case CONST_WIDE_INT
:
1644 const char *sep
= "<";
1646 for (i
= CONST_WIDE_INT_NUNITS (x
) - 1; i
>= 0; i
--)
1648 pp_string (pp
, sep
);
1650 sprintf (tmp
, HOST_WIDE_INT_PRINT_HEX
,
1651 (unsigned HOST_WIDE_INT
) CONST_WIDE_INT_ELT (x
, i
));
1652 pp_string (pp
, tmp
);
1658 case CONST_POLY_INT
:
1659 pp_left_bracket (pp
);
1660 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[0], SIGNED
);
1661 for (unsigned int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
1663 pp_string (pp
, ", ");
1664 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[i
], SIGNED
);
1666 pp_right_bracket (pp
);
1670 if (FLOAT_MODE_P (GET_MODE (x
)))
1672 real_to_decimal (tmp
, CONST_DOUBLE_REAL_VALUE (x
),
1673 sizeof (tmp
), 0, 1);
1674 pp_string (pp
, tmp
);
1677 pp_printf (pp
, "<%wx,%wx>",
1678 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (x
),
1679 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_HIGH (x
));
1682 fixed_to_decimal (tmp
, CONST_FIXED_VALUE (x
), sizeof (tmp
));
1683 pp_string (pp
, tmp
);
1686 pp_string (pp
, "\"");
1687 pretty_print_string (pp
, XSTR (x
, 0), strlen (XSTR (x
, 0)));
1688 pp_string (pp
, "\"");
1691 pp_printf (pp
, "`%s'", XSTR (x
, 0));
1694 pp_printf (pp
, "L%d", INSN_UID (label_ref_label (x
)));
1698 case STRICT_LOW_PART
:
1699 pp_printf (pp
, "%s(", GET_RTX_NAME (GET_CODE (x
)));
1700 print_value (pp
, XEXP (x
, 0), verbose
);
1701 pp_right_paren (pp
);
1704 if (REGNO (x
) < FIRST_PSEUDO_REGISTER
)
1706 if (ISDIGIT (reg_names
[REGNO (x
)][0]))
1708 pp_string (pp
, reg_names
[REGNO (x
)]);
1711 pp_printf (pp
, "r%d", REGNO (x
));
1713 pp_printf (pp
, ":%s", GET_MODE_NAME (GET_MODE (x
)));
1716 print_value (pp
, SUBREG_REG (x
), verbose
);
1717 pp_printf (pp
, "#");
1718 pp_wide_integer (pp
, SUBREG_BYTE (x
));
1723 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1726 pp_left_bracket (pp
);
1727 print_value (pp
, XEXP (x
, 0), verbose
);
1728 pp_right_bracket (pp
);
1731 pp_printf (pp
, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x
)));
1734 print_exp (pp
, x
, verbose
);
1739 /* The next step in insn detalization, its pattern recognition. */
1742 print_pattern (pretty_printer
*pp
, const_rtx x
, int verbose
)
1746 pp_string (pp
, "(nil)");
1750 switch (GET_CODE (x
))
1753 print_value (pp
, SET_DEST (x
), verbose
);
1755 print_value (pp
, SET_SRC (x
), verbose
);
1760 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1763 print_exp (pp
, x
, verbose
);
1767 pp_printf (pp
, "%s ", GET_RTX_NAME (GET_CODE (x
)));
1768 print_value (pp
, XEXP (x
, 0), verbose
);
1771 pp_string (pp
, "loc ");
1772 print_value (pp
, PAT_VAR_LOCATION_LOC (x
), verbose
);
1776 if (GET_CODE (COND_EXEC_TEST (x
)) == NE
1777 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1778 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1779 else if (GET_CODE (COND_EXEC_TEST (x
)) == EQ
1780 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1782 pp_exclamation (pp
);
1783 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1786 print_value (pp
, COND_EXEC_TEST (x
), verbose
);
1787 pp_string (pp
, ") ");
1788 print_pattern (pp
, COND_EXEC_CODE (x
), verbose
);
1795 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1797 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1800 pp_right_brace (pp
);
1805 const rtx_sequence
*seq
= as_a
<const rtx_sequence
*> (x
);
1806 pp_string (pp
, "sequence{");
1807 if (INSN_P (seq
->element (0)))
1809 /* Print the sequence insns indented. */
1810 const char * save_print_rtx_head
= print_rtx_head
;
1811 char indented_print_rtx_head
[32];
1814 gcc_assert (strlen (print_rtx_head
) < sizeof (indented_print_rtx_head
) - 4);
1815 snprintf (indented_print_rtx_head
,
1816 sizeof (indented_print_rtx_head
),
1817 "%s ", print_rtx_head
);
1818 print_rtx_head
= indented_print_rtx_head
;
1819 for (int i
= 0; i
< seq
->len (); i
++)
1820 print_insn_with_notes (pp
, seq
->insn (i
));
1821 pp_printf (pp
, "%s ", save_print_rtx_head
);
1822 print_rtx_head
= save_print_rtx_head
;
1826 for (int i
= 0; i
< seq
->len (); i
++)
1828 print_pattern (pp
, seq
->element (i
), verbose
);
1832 pp_right_brace (pp
);
1836 pp_printf (pp
, "asm {%s}", XSTR (x
, 0));
1839 for (int i
= 0; i
< XVECLEN (x
, 0); i
++)
1841 print_value (pp
, XVECEXP (x
, 0, i
), verbose
);
1846 for (int i
= 0; i
< XVECLEN (x
, 1); i
++)
1848 print_value (pp
, XVECEXP (x
, 1, i
), verbose
);
1853 pp_string (pp
, "trap_if ");
1854 print_value (pp
, TRAP_CONDITION (x
), verbose
);
1857 case UNSPEC_VOLATILE
:
1858 /* Fallthru -- leave UNSPECs to print_exp. */
1860 print_value (pp
, x
, verbose
);
1862 } /* print_pattern */
1864 /* This is the main function in slim rtl visualization mechanism.
1866 X is an insn, to be printed into PP.
1868 This function tries to print it properly in human-readable form,
1869 resembling assembler mnemonics (instead of the older Lisp-style
1872 If VERBOSE is TRUE, insns are printed with more complete (but
1873 longer) pattern names and with extra information, and prefixed
1874 with their INSN_UIDs. */
1877 print_insn (pretty_printer
*pp
, const rtx_insn
*x
, int verbose
)
1881 /* Blech, pretty-print can't print integers with a specified width. */
1882 char uid_prefix
[32];
1883 snprintf (uid_prefix
, sizeof uid_prefix
, " %4d: ", INSN_UID (x
));
1884 pp_string (pp
, uid_prefix
);
1887 switch (GET_CODE (x
))
1890 print_pattern (pp
, PATTERN (x
), verbose
);
1895 if (DEBUG_MARKER_INSN_P (x
))
1897 switch (INSN_DEBUG_MARKER_KIND (x
))
1899 case NOTE_INSN_BEGIN_STMT
:
1900 pp_string (pp
, "debug begin stmt marker");
1903 case NOTE_INSN_INLINE_ENTRY
:
1904 pp_string (pp
, "debug inline entry marker");
1913 const char *name
= "?";
1916 if (DECL_P (INSN_VAR_LOCATION_DECL (x
)))
1918 tree id
= DECL_NAME (INSN_VAR_LOCATION_DECL (x
));
1920 name
= IDENTIFIER_POINTER (id
);
1921 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x
))
1924 sprintf (idbuf
, "D#%i",
1925 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x
)));
1930 sprintf (idbuf
, "D.%i",
1931 DECL_UID (INSN_VAR_LOCATION_DECL (x
)));
1935 pp_printf (pp
, "debug %s => ", name
);
1936 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x
)))
1937 pp_string (pp
, "optimized away");
1939 print_pattern (pp
, INSN_VAR_LOCATION_LOC (x
), verbose
);
1944 print_pattern (pp
, PATTERN (x
), verbose
);
1947 if (GET_CODE (PATTERN (x
)) == PARALLEL
)
1948 print_pattern (pp
, XVECEXP (PATTERN (x
), 0, 0), verbose
);
1950 print_pattern (pp
, PATTERN (x
), verbose
);
1953 pp_printf (pp
, "L%d:", INSN_UID (x
));
1955 case JUMP_TABLE_DATA
:
1956 pp_string (pp
, "jump_table_data{\n");
1957 print_pattern (pp
, PATTERN (x
), verbose
);
1958 pp_right_brace (pp
);
1961 pp_string (pp
, "barrier");
1965 pp_string (pp
, GET_NOTE_INSN_NAME (NOTE_KIND (x
)));
1966 switch (NOTE_KIND (x
))
1968 case NOTE_INSN_EH_REGION_BEG
:
1969 case NOTE_INSN_EH_REGION_END
:
1970 pp_printf (pp
, " %d", NOTE_EH_HANDLER (x
));
1973 case NOTE_INSN_BLOCK_BEG
:
1974 case NOTE_INSN_BLOCK_END
:
1975 pp_printf (pp
, " %d", BLOCK_NUMBER (NOTE_BLOCK (x
)));
1978 case NOTE_INSN_BASIC_BLOCK
:
1979 pp_printf (pp
, " %d", NOTE_BASIC_BLOCK (x
)->index
);
1982 case NOTE_INSN_DELETED_LABEL
:
1983 case NOTE_INSN_DELETED_DEBUG_LABEL
:
1985 const char *label
= NOTE_DELETED_LABEL_NAME (x
);
1988 pp_printf (pp
, " (\"%s\")", label
);
1992 case NOTE_INSN_VAR_LOCATION
:
1994 print_pattern (pp
, NOTE_VAR_LOCATION (x
), verbose
);
1995 pp_right_brace (pp
);
2008 /* Pretty-print a slim dump of X (an insn) to PP, including any register
2009 note attached to the instruction. */
2012 print_insn_with_notes (pretty_printer
*pp
, const rtx_insn
*x
)
2014 pp_string (pp
, print_rtx_head
);
2015 print_insn (pp
, x
, 1);
2017 if (INSN_P (x
) && REG_NOTES (x
))
2018 for (rtx note
= REG_NOTES (x
); note
; note
= XEXP (note
, 1))
2020 pp_printf (pp
, "%s %s ", print_rtx_head
,
2021 GET_REG_NOTE_NAME (REG_NOTE_KIND (note
)));
2022 if (GET_CODE (note
) == INT_LIST
)
2023 pp_printf (pp
, "%d", XINT (note
, 0));
2025 print_pattern (pp
, XEXP (note
, 0), 1);
2030 /* Print X, an RTL value node, to file F in slim format. Include
2031 additional information if VERBOSE is nonzero.
2033 Value nodes are constants, registers, labels, symbols and
2037 dump_value_slim (FILE *f
, const_rtx x
, int verbose
)
2039 pretty_printer rtl_slim_pp
;
2040 rtl_slim_pp
.buffer
->stream
= f
;
2041 print_value (&rtl_slim_pp
, x
, verbose
);
2042 pp_flush (&rtl_slim_pp
);
2045 /* Emit a slim dump of X (an insn) to the file F, including any register
2046 note attached to the instruction. */
2048 dump_insn_slim (FILE *f
, const rtx_insn
*x
)
2050 pretty_printer rtl_slim_pp
;
2051 rtl_slim_pp
.buffer
->stream
= f
;
2052 print_insn_with_notes (&rtl_slim_pp
, x
);
2053 pp_flush (&rtl_slim_pp
);
2056 /* Same as above, but stop at LAST or when COUNT == 0.
2057 If COUNT < 0 it will stop only at LAST or NULL rtx. */
2060 dump_rtl_slim (FILE *f
, const rtx_insn
*first
, const rtx_insn
*last
,
2061 int count
, int flags ATTRIBUTE_UNUSED
)
2063 const rtx_insn
*insn
, *tail
;
2064 pretty_printer rtl_slim_pp
;
2065 rtl_slim_pp
.buffer
->stream
= f
;
2067 tail
= last
? NEXT_INSN (last
) : NULL
;
2069 (insn
!= NULL
) && (insn
!= tail
) && (count
!= 0);
2070 insn
= NEXT_INSN (insn
))
2072 print_insn_with_notes (&rtl_slim_pp
, insn
);
2077 pp_flush (&rtl_slim_pp
);
2080 /* Dumps basic block BB to pretty-printer PP in slim form and without and
2081 no indentation, for use as a label of a DOT graph record-node. */
2084 rtl_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
2089 /* TODO: inter-bb stuff. */
2090 FOR_BB_INSNS (bb
, insn
)
2095 pp_write_text_to_stream (pp
);
2098 print_insn_with_notes (pp
, insn
);
2099 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2103 /* Pretty-print pattern X of some insn in non-verbose mode.
2104 Return a string pointer to the pretty-printer buffer.
2106 This function is only exported exists only to accommodate some older users
2107 of the slim RTL pretty printers. Please do not use it for new code. */
2110 str_pattern_slim (const_rtx x
)
2112 pretty_printer rtl_slim_pp
;
2113 print_pattern (&rtl_slim_pp
, x
, 0);
2114 return ggc_strdup (pp_formatted_text (&rtl_slim_pp
));
2117 /* Emit a slim dump of X (an insn) to stderr. */
2118 extern void debug_insn_slim (const rtx_insn
*);
2120 debug_insn_slim (const rtx_insn
*x
)
2122 dump_insn_slim (stderr
, x
);
2125 /* Same as above, but using dump_rtl_slim. */
2126 extern void debug_rtl_slim (FILE *, const rtx_insn
*, const rtx_insn
*,
2129 debug_rtl_slim (const rtx_insn
*first
, const rtx_insn
*last
, int count
,
2132 dump_rtl_slim (stderr
, first
, last
, count
, flags
);
2135 extern void debug_bb_slim (basic_block
);
2137 debug_bb_slim (basic_block bb
)
2139 debug_bb (bb
, TDF_SLIM
| TDF_BLOCKS
);
2142 extern void debug_bb_n_slim (int);
2144 debug_bb_n_slim (int n
)
2146 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, n
);
2153 # pragma GCC diagnostic pop