2 Copyright (C) 1987-2022 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 ATTRIBUTE_UNUSED
)
88 : m_outfile (outf
), m_sawclose (0), m_indent (ind
),
89 m_in_call_function_usage (false), m_simple (simple
), m_compact (compact
)
90 #ifndef GENERATOR_FILE
91 , m_rtx_reuse_manager (reuse_manager
)
96 #ifndef GENERATOR_FILE
98 /* rtx_reuse_manager's ctor. */
100 rtx_reuse_manager::rtx_reuse_manager ()
105 /* Determine if X is of a kind suitable for dumping via reuse_rtx. */
108 uses_rtx_reuse_p (const_rtx x
)
113 switch (GET_CODE (x
))
120 /* We don't use reuse_rtx for consts. */
127 /* Traverse X and its descendents, determining if we see any rtx more than
128 once. Any rtx suitable for "reuse_rtx" that is seen more than once is
132 rtx_reuse_manager::preprocess (const_rtx x
)
134 subrtx_iterator::array_type array
;
135 FOR_EACH_SUBRTX (iter
, array
, x
, NONCONST
)
136 if (uses_rtx_reuse_p (*iter
))
138 if (int *count
= m_rtx_occurrence_count
.get (*iter
))
141 m_rtx_reuse_ids
.put (*iter
, m_next_id
++);
144 m_rtx_occurrence_count
.put (*iter
, 1);
148 /* Return true iff X has been assigned a reuse ID. If it has,
149 and OUT is non-NULL, then write the reuse ID to *OUT. */
152 rtx_reuse_manager::has_reuse_id (const_rtx x
, int *out
)
154 int *id
= m_rtx_reuse_ids
.get (x
);
165 /* Determine if set_seen_def has been called for the given reuse ID. */
168 rtx_reuse_manager::seen_def_p (int reuse_id
)
170 return bitmap_bit_p (m_defs_seen
, reuse_id
);
173 /* Record that the definition of the given reuse ID has been seen. */
176 rtx_reuse_manager::set_seen_def (int reuse_id
)
178 bitmap_set_bit (m_defs_seen
, reuse_id
);
181 #endif /* #ifndef GENERATOR_FILE */
183 #ifndef GENERATOR_FILE
185 print_mem_expr (FILE *outfile
, const_tree expr
)
187 fputc (' ', outfile
);
188 print_generic_expr (outfile
, CONST_CAST_TREE (expr
),
189 dump_flags
| TDF_SLIM
);
193 /* Print X to FILE. */
196 print_poly_int (FILE *file
, poly_int64 x
)
198 HOST_WIDE_INT const_x
;
199 if (x
.is_constant (&const_x
))
200 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, const_x
);
203 fprintf (file
, "[" HOST_WIDE_INT_PRINT_DEC
, x
.coeffs
[0]);
204 for (int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
205 fprintf (file
, ", " HOST_WIDE_INT_PRINT_DEC
, x
.coeffs
[i
]);
210 /* Subroutine of print_rtx_operand for handling code '0'.
211 0 indicates a field for internal use that should not be printed.
212 However there are various special cases, such as the third field
213 of a NOTE, where it indicates that the field has several different
217 rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED
,
218 int idx ATTRIBUTE_UNUSED
)
220 #ifndef GENERATOR_FILE
221 if (idx
== 1 && GET_CODE (in_rtx
) == SYMBOL_REF
)
223 int flags
= SYMBOL_REF_FLAGS (in_rtx
);
225 fprintf (m_outfile
, " [flags %#x]", flags
);
226 tree decl
= SYMBOL_REF_DECL (in_rtx
);
228 print_node_brief (m_outfile
, "", decl
, dump_flags
);
230 else if (idx
== 3 && NOTE_P (in_rtx
))
232 switch (NOTE_KIND (in_rtx
))
234 case NOTE_INSN_EH_REGION_BEG
:
235 case NOTE_INSN_EH_REGION_END
:
236 if (flag_dump_unnumbered
)
237 fprintf (m_outfile
, " #");
239 fprintf (m_outfile
, " %d", NOTE_EH_HANDLER (in_rtx
));
243 case NOTE_INSN_BLOCK_BEG
:
244 case NOTE_INSN_BLOCK_END
:
245 dump_addr (m_outfile
, " ", NOTE_BLOCK (in_rtx
));
249 case NOTE_INSN_BASIC_BLOCK
:
251 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
253 fprintf (m_outfile
, " [bb %d]", bb
->index
);
257 case NOTE_INSN_DELETED_LABEL
:
258 case NOTE_INSN_DELETED_DEBUG_LABEL
:
260 const char *label
= NOTE_DELETED_LABEL_NAME (in_rtx
);
262 fprintf (m_outfile
, " (\"%s\")", label
);
264 fprintf (m_outfile
, " \"\"");
268 case NOTE_INSN_SWITCH_TEXT_SECTIONS
:
270 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
272 fprintf (m_outfile
, " [bb %d]", bb
->index
);
276 case NOTE_INSN_VAR_LOCATION
:
277 fputc (' ', m_outfile
);
278 print_rtx (NOTE_VAR_LOCATION (in_rtx
));
282 fputc ('\n', m_outfile
);
283 output_cfi_directive (m_outfile
, NOTE_CFI (in_rtx
));
284 fputc ('\t', m_outfile
);
287 case NOTE_INSN_BEGIN_STMT
:
288 case NOTE_INSN_INLINE_ENTRY
:
289 #ifndef GENERATOR_FILE
291 expanded_location xloc
292 = expand_location (NOTE_MARKER_LOCATION (in_rtx
));
293 fprintf (m_outfile
, " %s:%i", xloc
.file
, xloc
.line
);
302 else if (idx
== 7 && JUMP_P (in_rtx
) && JUMP_LABEL (in_rtx
) != NULL
305 /* Output the JUMP_LABEL reference. */
306 fprintf (m_outfile
, "\n%s%*s -> ", print_rtx_head
, m_indent
* 2, "");
307 if (GET_CODE (JUMP_LABEL (in_rtx
)) == RETURN
)
308 fprintf (m_outfile
, "return");
309 else if (GET_CODE (JUMP_LABEL (in_rtx
)) == SIMPLE_RETURN
)
310 fprintf (m_outfile
, "simple_return");
312 fprintf (m_outfile
, "%d", INSN_UID (JUMP_LABEL (in_rtx
)));
314 else if (idx
== 0 && GET_CODE (in_rtx
) == VALUE
)
316 cselib_val
*val
= CSELIB_VAL_PTR (in_rtx
);
318 fprintf (m_outfile
, " %u:%u", val
->uid
, val
->hash
);
319 dump_addr (m_outfile
, " @", in_rtx
);
320 dump_addr (m_outfile
, "/", (void*)val
);
322 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_EXPR
)
324 fprintf (m_outfile
, " D#%i",
325 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx
)));
327 else if (idx
== 0 && GET_CODE (in_rtx
) == ENTRY_VALUE
)
331 fprintf (m_outfile
, " ");
332 print_rtx (ENTRY_VALUE_EXP (in_rtx
));
338 /* Subroutine of print_rtx_operand for handling code 'e'.
339 Also called by print_rtx_operand_code_u for handling code 'u'
340 for LABEL_REFs when they don't reference a CODE_LABEL. */
343 rtx_writer::print_rtx_operand_code_e (const_rtx in_rtx
, int idx
)
346 if (idx
== 6 && INSN_P (in_rtx
))
347 /* Put REG_NOTES on their own line. */
348 fprintf (m_outfile
, "\n%s%*s",
349 print_rtx_head
, m_indent
* 2, "");
351 fprintf (m_outfile
, " ");
352 if (idx
== 7 && CALL_P (in_rtx
))
354 m_in_call_function_usage
= true;
355 print_rtx (XEXP (in_rtx
, idx
));
356 m_in_call_function_usage
= false;
359 print_rtx (XEXP (in_rtx
, idx
));
363 /* Subroutine of print_rtx_operand for handling codes 'E' and 'V'. */
366 rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx
, int idx
)
371 fprintf (m_outfile
, "\n%s%*s",
372 print_rtx_head
, m_indent
* 2, "");
375 if (GET_CODE (in_rtx
) == CONST_VECTOR
376 && !GET_MODE_NUNITS (GET_MODE (in_rtx
)).is_constant ()
377 && CONST_VECTOR_DUPLICATE_P (in_rtx
))
378 fprintf (m_outfile
, " repeat");
379 fputs (" [", m_outfile
);
380 if (XVEC (in_rtx
, idx
) != NULL
)
383 if (XVECLEN (in_rtx
, idx
))
386 int barrier
= XVECLEN (in_rtx
, idx
);
387 if (GET_CODE (in_rtx
) == CONST_VECTOR
388 && !GET_MODE_NUNITS (GET_MODE (in_rtx
)).is_constant ())
389 barrier
= CONST_VECTOR_NPATTERNS (in_rtx
);
391 for (int j
= 0; j
< XVECLEN (in_rtx
, idx
); j
++)
397 fprintf (m_outfile
, "\n%s%*s",
398 print_rtx_head
, m_indent
* 2, "");
399 if (!CONST_VECTOR_STEPPED_P (in_rtx
))
400 fprintf (m_outfile
, "repeat [");
401 else if (CONST_VECTOR_NPATTERNS (in_rtx
) == 1)
402 fprintf (m_outfile
, "stepped [");
404 fprintf (m_outfile
, "stepped (interleave %d) [",
405 CONST_VECTOR_NPATTERNS (in_rtx
));
409 print_rtx (XVECEXP (in_rtx
, idx
, j
));
410 int limit
= MIN (barrier
, XVECLEN (in_rtx
, idx
));
411 for (j1
= j
+ 1; j1
< limit
; j1
++)
412 if (XVECEXP (in_rtx
, idx
, j
) != XVECEXP (in_rtx
, idx
, j1
))
417 fprintf (m_outfile
, " repeated x%i", j1
- j
);
422 if (barrier
< XVECLEN (in_rtx
, idx
))
425 fprintf (m_outfile
, "\n%s%*s]", print_rtx_head
, m_indent
* 2, "");
431 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
433 fputs ("]", m_outfile
);
438 /* Subroutine of print_rtx_operand for handling code 'i'. */
441 rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx
, int idx
)
443 if (idx
== 4 && INSN_P (in_rtx
))
445 #ifndef GENERATOR_FILE
446 const rtx_insn
*in_insn
= as_a
<const rtx_insn
*> (in_rtx
);
448 /* Pretty-print insn locations. Ignore scoping as it is mostly
449 redundant with line number information and do not print anything
450 when there is no location information available. */
451 if (INSN_HAS_LOCATION (in_insn
))
453 expanded_location xloc
= insn_location (in_insn
);
454 fprintf (m_outfile
, " \"%s\":%i:%i", xloc
.file
, xloc
.line
,
456 int discriminator
= insn_discriminator (in_insn
);
458 fprintf (m_outfile
, " discrim %d", discriminator
);
463 else if (idx
== 6 && GET_CODE (in_rtx
) == ASM_OPERANDS
)
465 #ifndef GENERATOR_FILE
466 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
467 fprintf (m_outfile
, " %s:%i",
468 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)),
469 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)));
472 else if (idx
== 1 && GET_CODE (in_rtx
) == ASM_INPUT
)
474 #ifndef GENERATOR_FILE
475 if (ASM_INPUT_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
476 fprintf (m_outfile
, " %s:%i",
477 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)),
478 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)));
481 else if (idx
== 5 && NOTE_P (in_rtx
))
483 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
484 other times often contains garbage from INSN->NOTE death. */
485 if (NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_LABEL
486 || NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_DEBUG_LABEL
)
487 fprintf (m_outfile
, " %d", XINT (in_rtx
, idx
));
489 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
491 && GET_CODE (in_rtx
) == UNSPEC_VOLATILE
492 && XINT (in_rtx
, 1) >= 0
493 && XINT (in_rtx
, 1) < NUM_UNSPECV_VALUES
)
494 fprintf (m_outfile
, " %s", unspecv_strings
[XINT (in_rtx
, 1)]);
496 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
498 && (GET_CODE (in_rtx
) == UNSPEC
499 || GET_CODE (in_rtx
) == UNSPEC_VOLATILE
)
500 && XINT (in_rtx
, 1) >= 0
501 && XINT (in_rtx
, 1) < NUM_UNSPEC_VALUES
)
502 fprintf (m_outfile
, " %s", unspec_strings
[XINT (in_rtx
, 1)]);
506 int value
= XINT (in_rtx
, idx
);
508 int is_insn
= INSN_P (in_rtx
);
510 /* Don't print INSN_CODEs in compact mode. */
511 if (m_compact
&& is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
))
517 if (flag_dump_unnumbered
518 && (is_insn
|| NOTE_P (in_rtx
)))
519 fputc ('#', m_outfile
);
521 fprintf (m_outfile
, " %d", value
);
523 if (is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
)
524 && XINT (in_rtx
, idx
) >= 0
525 && (name
= get_insn_name (XINT (in_rtx
, idx
))) != NULL
)
526 fprintf (m_outfile
, " {%s}", name
);
531 /* Subroutine of print_rtx_operand for handling code 'r'. */
534 rtx_writer::print_rtx_operand_code_r (const_rtx in_rtx
)
536 int is_insn
= INSN_P (in_rtx
);
537 unsigned int regno
= REGNO (in_rtx
);
539 #ifndef GENERATOR_FILE
540 /* For hard registers and virtuals, always print the
541 regno, except in compact mode. */
542 if (regno
<= LAST_VIRTUAL_REGISTER
&& !m_compact
)
543 fprintf (m_outfile
, " %d", regno
);
544 if (regno
< FIRST_PSEUDO_REGISTER
)
545 fprintf (m_outfile
, " %s", reg_names
[regno
]);
546 else if (regno
<= LAST_VIRTUAL_REGISTER
)
548 if (regno
== VIRTUAL_INCOMING_ARGS_REGNUM
)
549 fprintf (m_outfile
, " virtual-incoming-args");
550 else if (regno
== VIRTUAL_STACK_VARS_REGNUM
)
551 fprintf (m_outfile
, " virtual-stack-vars");
552 else if (regno
== VIRTUAL_STACK_DYNAMIC_REGNUM
)
553 fprintf (m_outfile
, " virtual-stack-dynamic");
554 else if (regno
== VIRTUAL_OUTGOING_ARGS_REGNUM
)
555 fprintf (m_outfile
, " virtual-outgoing-args");
556 else if (regno
== VIRTUAL_CFA_REGNUM
)
557 fprintf (m_outfile
, " virtual-cfa");
558 else if (regno
== VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM
)
559 fprintf (m_outfile
, " virtual-preferred-stack-boundary");
561 fprintf (m_outfile
, " virtual-reg-%d", regno
-FIRST_VIRTUAL_REGISTER
);
565 if (flag_dump_unnumbered
&& is_insn
)
566 fputc ('#', m_outfile
);
569 /* In compact mode, print pseudos with '< and '>' wrapping the regno,
570 offseting it by (LAST_VIRTUAL_REGISTER + 1), so that the
571 first non-virtual pseudo is dumped as "<0>". */
572 gcc_assert (regno
> LAST_VIRTUAL_REGISTER
);
573 fprintf (m_outfile
, " <%d>", regno
- (LAST_VIRTUAL_REGISTER
+ 1));
576 fprintf (m_outfile
, " %d", regno
);
578 #ifndef GENERATOR_FILE
579 if (REG_ATTRS (in_rtx
))
581 fputs (" [", m_outfile
);
582 if (regno
!= ORIGINAL_REGNO (in_rtx
))
583 fprintf (m_outfile
, "orig:%i", ORIGINAL_REGNO (in_rtx
));
584 if (REG_EXPR (in_rtx
))
585 print_mem_expr (m_outfile
, REG_EXPR (in_rtx
));
587 if (maybe_ne (REG_OFFSET (in_rtx
), 0))
589 fprintf (m_outfile
, "+");
590 print_poly_int (m_outfile
, REG_OFFSET (in_rtx
));
592 fputs (" ]", m_outfile
);
594 if (regno
!= ORIGINAL_REGNO (in_rtx
))
595 fprintf (m_outfile
, " [%d]", ORIGINAL_REGNO (in_rtx
));
599 /* Subroutine of print_rtx_operand for handling code 'u'. */
602 rtx_writer::print_rtx_operand_code_u (const_rtx in_rtx
, int idx
)
604 /* Don't print insn UIDs for PREV/NEXT_INSN in compact mode. */
605 if (m_compact
&& INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)) && idx
< 2)
608 if (XEXP (in_rtx
, idx
) != NULL
)
610 rtx sub
= XEXP (in_rtx
, idx
);
611 enum rtx_code subc
= GET_CODE (sub
);
613 if (GET_CODE (in_rtx
) == LABEL_REF
)
616 && NOTE_KIND (sub
) == NOTE_INSN_DELETED_LABEL
)
618 if (flag_dump_unnumbered
)
619 fprintf (m_outfile
, " [# deleted]");
621 fprintf (m_outfile
, " [%d deleted]", INSN_UID (sub
));
626 if (subc
!= CODE_LABEL
)
628 print_rtx_operand_code_e (in_rtx
, idx
);
633 if (flag_dump_unnumbered
634 || (flag_dump_unnumbered_links
&& idx
<= 1
635 && (INSN_P (in_rtx
) || NOTE_P (in_rtx
)
636 || LABEL_P (in_rtx
) || BARRIER_P (in_rtx
))))
637 fputs (" #", m_outfile
);
639 fprintf (m_outfile
, " %d", INSN_UID (sub
));
642 fputs (" 0", m_outfile
);
646 /* Subroutine of print_rtx. Print operand IDX of IN_RTX. */
649 rtx_writer::print_rtx_operand (const_rtx in_rtx
, int idx
)
651 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
653 switch (format_ptr
[idx
])
658 str
= XTMPL (in_rtx
, idx
);
663 str
= XSTR (in_rtx
, idx
);
667 fputs (" (nil)", m_outfile
);
669 fprintf (m_outfile
, " (\"%s\")", str
);
674 print_rtx_operand_code_0 (in_rtx
, idx
);
678 print_rtx_operand_code_e (in_rtx
, idx
);
683 print_rtx_operand_codes_E_and_V (in_rtx
, idx
);
688 fprintf (m_outfile
, " ");
689 fprintf (m_outfile
, HOST_WIDE_INT_PRINT_DEC
, XWINT (in_rtx
, idx
));
690 if (! m_simple
&& !m_compact
)
691 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_HEX
"]",
692 (unsigned HOST_WIDE_INT
) XWINT (in_rtx
, idx
));
696 print_rtx_operand_code_i (in_rtx
, idx
);
700 fprintf (m_outfile
, " ");
701 print_poly_int (m_outfile
, SUBREG_BYTE (in_rtx
));
705 print_rtx_operand_code_r (in_rtx
);
708 /* Print NOTE_INSN names rather than integer codes. */
711 fprintf (m_outfile
, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx
, idx
)));
716 print_rtx_operand_code_u (in_rtx
, idx
);
720 #ifndef GENERATOR_FILE
721 if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_IMPLICIT_PTR
)
722 print_mem_expr (m_outfile
, DEBUG_IMPLICIT_PTR_DECL (in_rtx
));
723 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_PARAMETER_REF
)
724 print_mem_expr (m_outfile
, DEBUG_PARAMETER_REF_DECL (in_rtx
));
726 dump_addr (m_outfile
, " ", XTREE (in_rtx
, idx
));
731 fputs (" Unknown", m_outfile
);
736 /* Don't print basic block ids in compact mode. */
739 #ifndef GENERATOR_FILE
740 if (XBBDEF (in_rtx
, idx
))
741 fprintf (m_outfile
, " %i", XBBDEF (in_rtx
, idx
)->index
);
750 /* Subroutine of rtx_writer::print_rtx.
751 In compact mode, determine if operand IDX of IN_RTX is interesting
752 to dump, or (if in a trailing position) it can be omitted. */
755 rtx_writer::operand_has_default_value_p (const_rtx in_rtx
, int idx
)
757 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
759 switch (format_ptr
[idx
])
763 return XEXP (in_rtx
, idx
) == NULL_RTX
;
766 return XSTR (in_rtx
, idx
) == NULL
;
769 switch (GET_CODE (in_rtx
))
772 /* JUMP_LABELs are always omitted in compact mode, so treat
773 any value here as omittable, so that earlier operands can
774 potentially be omitted also. */
787 /* Print IN_RTX onto m_outfile. This is the recursive part of printing. */
790 rtx_writer::print_rtx (const_rtx in_rtx
)
797 fputc (' ', m_outfile
);
799 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
805 fputs ("(nil)", m_outfile
);
809 else if (GET_CODE (in_rtx
) > NUM_RTX_CODE
)
811 fprintf (m_outfile
, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx
),
812 print_rtx_head
, m_indent
* 2, "");
817 fputc ('(', m_outfile
);
819 /* Print name of expression code. */
822 #ifndef GENERATOR_FILE
823 if (m_rtx_reuse_manager
)
826 if (m_rtx_reuse_manager
->has_reuse_id (in_rtx
, &reuse_id
))
828 /* Have we already seen the defn of this rtx? */
829 if (m_rtx_reuse_manager
->seen_def_p (reuse_id
))
831 fprintf (m_outfile
, "reuse_rtx %i)", reuse_id
);
837 /* First time we've seen this reused-rtx. */
838 fprintf (m_outfile
, "%i|", reuse_id
);
839 m_rtx_reuse_manager
->set_seen_def (reuse_id
);
843 #endif /* #ifndef GENERATOR_FILE */
845 /* In compact mode, prefix the code of insns with "c",
846 giving "cinsn", "cnote" etc. */
847 if (m_compact
&& is_a
<const rtx_insn
*, const struct rtx_def
> (in_rtx
))
849 /* "ccode_label" is slightly awkward, so special-case it as
851 rtx_code code
= GET_CODE (in_rtx
);
852 if (code
== CODE_LABEL
)
853 fprintf (m_outfile
, "clabel");
855 fprintf (m_outfile
, "c%s", GET_RTX_NAME (code
));
857 else if (m_simple
&& CONST_INT_P (in_rtx
))
860 fprintf (m_outfile
, "%s", GET_RTX_NAME (GET_CODE (in_rtx
)));
864 if (RTX_FLAG (in_rtx
, in_struct
))
865 fputs ("/s", m_outfile
);
867 if (RTX_FLAG (in_rtx
, volatil
))
868 fputs ("/v", m_outfile
);
870 if (RTX_FLAG (in_rtx
, unchanging
))
871 fputs ("/u", m_outfile
);
873 if (RTX_FLAG (in_rtx
, frame_related
))
874 fputs ("/f", m_outfile
);
876 if (RTX_FLAG (in_rtx
, jump
))
877 fputs ("/j", m_outfile
);
879 if (RTX_FLAG (in_rtx
, call
))
880 fputs ("/c", m_outfile
);
882 if (RTX_FLAG (in_rtx
, return_val
))
883 fputs ("/i", m_outfile
);
885 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
886 if ((GET_CODE (in_rtx
) == EXPR_LIST
887 || GET_CODE (in_rtx
) == INSN_LIST
888 || GET_CODE (in_rtx
) == INT_LIST
)
889 && (int)GET_MODE (in_rtx
) < REG_NOTE_MAX
890 && !m_in_call_function_usage
)
891 fprintf (m_outfile
, ":%s",
892 GET_REG_NOTE_NAME (GET_MODE (in_rtx
)));
894 /* For other rtl, print the mode if it's not VOID. */
895 else if (GET_MODE (in_rtx
) != VOIDmode
)
896 fprintf (m_outfile
, ":%s", GET_MODE_NAME (GET_MODE (in_rtx
)));
898 #ifndef GENERATOR_FILE
899 if (GET_CODE (in_rtx
) == VAR_LOCATION
)
901 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx
)) == STRING_CST
)
902 fputs (" <debug string placeholder>", m_outfile
);
904 print_mem_expr (m_outfile
, PAT_VAR_LOCATION_DECL (in_rtx
));
905 fputc (' ', m_outfile
);
906 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx
));
907 if (PAT_VAR_LOCATION_STATUS (in_rtx
)
908 == VAR_INIT_STATUS_UNINITIALIZED
)
909 fprintf (m_outfile
, " [uninit]");
911 idx
= GET_RTX_LENGTH (VAR_LOCATION
);
916 #ifndef GENERATOR_FILE
917 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx
))
921 /* For insns, print the INSN_UID. */
922 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)))
924 if (flag_dump_unnumbered
)
925 fprintf (m_outfile
, " #");
927 fprintf (m_outfile
, " %d", INSN_UID (in_rtx
));
930 /* Determine which is the final operand to print.
931 In compact mode, skip trailing operands that have the default values
932 e.g. trailing "(nil)" values. */
933 int limit
= GET_RTX_LENGTH (GET_CODE (in_rtx
));
935 while (limit
> idx
&& operand_has_default_value_p (in_rtx
, limit
- 1))
938 /* Get the format string and skip the first elements if we have handled
941 for (; idx
< limit
; idx
++)
942 print_rtx_operand (in_rtx
, idx
);
944 switch (GET_CODE (in_rtx
))
946 #ifndef GENERATOR_FILE
948 if (UNLIKELY (final_insns_dump_p
))
949 fprintf (m_outfile
, " [");
951 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_DEC
,
952 (HOST_WIDE_INT
) MEM_ALIAS_SET (in_rtx
));
954 if (MEM_EXPR (in_rtx
))
955 print_mem_expr (m_outfile
, MEM_EXPR (in_rtx
));
957 fputc (' ', m_outfile
);
959 if (MEM_OFFSET_KNOWN_P (in_rtx
))
961 fprintf (m_outfile
, "+");
962 print_poly_int (m_outfile
, MEM_OFFSET (in_rtx
));
965 if (MEM_SIZE_KNOWN_P (in_rtx
))
967 fprintf (m_outfile
, " S");
968 print_poly_int (m_outfile
, MEM_SIZE (in_rtx
));
971 if (MEM_ALIGN (in_rtx
) != 1)
972 fprintf (m_outfile
, " A%u", MEM_ALIGN (in_rtx
));
974 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx
)))
975 fprintf (m_outfile
, " AS%u", MEM_ADDR_SPACE (in_rtx
));
977 fputc (']', m_outfile
);
981 if (FLOAT_MODE_P (GET_MODE (in_rtx
)))
985 real_to_decimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
987 fprintf (m_outfile
, " %s", s
);
989 real_to_hexadecimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
991 fprintf (m_outfile
, " [%s]", s
);
996 fprintf (m_outfile
, " ");
997 cwi_output_hex (m_outfile
, in_rtx
);
1000 case CONST_POLY_INT
:
1001 fprintf (m_outfile
, " [");
1002 print_dec (CONST_POLY_INT_COEFFS (in_rtx
)[0], m_outfile
, SIGNED
);
1003 for (unsigned int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
1005 fprintf (m_outfile
, ", ");
1006 print_dec (CONST_POLY_INT_COEFFS (in_rtx
)[i
], m_outfile
, SIGNED
);
1008 fprintf (m_outfile
, "]");
1014 fprintf (m_outfile
, " [%d uses]", LABEL_NUSES (in_rtx
));
1015 switch (LABEL_KIND (in_rtx
))
1017 case LABEL_NORMAL
: break;
1018 case LABEL_STATIC_ENTRY
: fputs (" [entry]", m_outfile
); break;
1019 case LABEL_GLOBAL_ENTRY
: fputs (" [global entry]", m_outfile
); break;
1020 case LABEL_WEAK_ENTRY
: fputs (" [weak entry]", m_outfile
); break;
1021 default: gcc_unreachable ();
1029 fputc (')', m_outfile
);
1033 /* Emit a closing parenthesis and newline. */
1036 rtx_writer::finish_directive ()
1038 fprintf (m_outfile
, ")\n");
1042 /* Print an rtx on the current line of FILE. Initially indent IND
1046 print_inline_rtx (FILE *outf
, const_rtx x
, int ind
)
1048 rtx_writer
w (outf
, ind
, false, false, NULL
);
1052 /* Call this function from the debugger to see what X looks like. */
1055 debug_rtx (const_rtx x
)
1057 rtx_writer
w (stderr
, 0, false, false, NULL
);
1059 fprintf (stderr
, "\n");
1065 debug (const rtx_def
&ref
)
1071 debug (const rtx_def
*ptr
)
1076 fprintf (stderr
, "<nil>\n");
1079 /* Like debug_rtx but with no newline, as debug_helper will add one.
1081 Note: No debug_slim(rtx_insn *) variant implemented, as this
1082 function can serve for both rtx and rtx_insn. */
1085 debug_slim (const_rtx x
)
1087 rtx_writer
w (stderr
, 0, false, false, NULL
);
1091 DEFINE_DEBUG_VEC (rtx_def
*)
1092 DEFINE_DEBUG_VEC (rtx_insn
*)
1093 DEFINE_DEBUG_HASH_SET (rtx_def
*)
1094 DEFINE_DEBUG_HASH_SET (rtx_insn
*)
1096 /* Count of rtx's to print with debug_rtx_list.
1097 This global exists because gdb user defined commands have no arguments. */
1099 DEBUG_VARIABLE
int debug_rtx_count
= 0; /* 0 is treated as equivalent to 1 */
1101 /* Call this function to print list from X on.
1103 N is a count of the rtx's to print. Positive values print from the specified
1104 rtx_insn on. Negative values print a window around the rtx_insn.
1105 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
1109 debug_rtx_list (const rtx_insn
*x
, int n
)
1112 const rtx_insn
*insn
;
1114 count
= n
== 0 ? 1 : n
< 0 ? -n
: n
;
1116 /* If we are printing a window, back up to the start. */
1119 for (i
= count
/ 2; i
> 0; i
--)
1121 if (PREV_INSN (x
) == 0)
1126 for (i
= count
, insn
= x
; i
> 0 && insn
!= 0; i
--, insn
= NEXT_INSN (insn
))
1129 fprintf (stderr
, "\n");
1133 /* Call this function to print an rtx_insn list from START to END
1137 debug_rtx_range (const rtx_insn
*start
, const rtx_insn
*end
)
1142 fprintf (stderr
, "\n");
1143 if (!start
|| start
== end
)
1145 start
= NEXT_INSN (start
);
1149 /* Call this function to search an rtx_insn list to find one with insn uid UID,
1150 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
1151 The found insn is returned to enable further debugging analysis. */
1153 DEBUG_FUNCTION
const rtx_insn
*
1154 debug_rtx_find (const rtx_insn
*x
, int uid
)
1156 while (x
!= 0 && INSN_UID (x
) != uid
)
1160 debug_rtx_list (x
, debug_rtx_count
);
1165 fprintf (stderr
, "insn uid %d not found\n", uid
);
1170 /* External entry point for printing a chain of insns
1171 starting with RTX_FIRST.
1172 A blank line separates insns.
1174 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1177 rtx_writer::print_rtl (const_rtx rtx_first
)
1179 const rtx_insn
*tmp_rtx
;
1183 fputs (print_rtx_head
, m_outfile
);
1184 fputs ("(nil)\n", m_outfile
);
1187 switch (GET_CODE (rtx_first
))
1194 case JUMP_TABLE_DATA
:
1196 for (tmp_rtx
= as_a
<const rtx_insn
*> (rtx_first
);
1198 tmp_rtx
= NEXT_INSN (tmp_rtx
))
1200 fputs (print_rtx_head
, m_outfile
);
1201 print_rtx (tmp_rtx
);
1202 fprintf (m_outfile
, "\n");
1207 fputs (print_rtx_head
, m_outfile
);
1208 print_rtx (rtx_first
);
1212 /* External entry point for printing a chain of insns
1213 starting with RTX_FIRST onto file OUTF.
1214 A blank line separates insns.
1216 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1219 print_rtl (FILE *outf
, const_rtx rtx_first
)
1221 rtx_writer
w (outf
, 0, false, false, NULL
);
1222 w
.print_rtl (rtx_first
);
1225 /* Like print_rtx, except specify a file. */
1226 /* Return nonzero if we actually printed anything. */
1229 print_rtl_single (FILE *outf
, const_rtx x
)
1231 rtx_writer
w (outf
, 0, false, false, NULL
);
1232 return w
.print_rtl_single_with_indent (x
, 0);
1235 /* Like print_rtl_single, except specify an indentation. */
1238 rtx_writer::print_rtl_single_with_indent (const_rtx x
, int ind
)
1240 char *s_indent
= (char *) alloca ((size_t) ind
+ 1);
1241 memset ((void *) s_indent
, ' ', (size_t) ind
);
1242 s_indent
[ind
] = '\0';
1243 fputs (s_indent
, m_outfile
);
1244 fputs (print_rtx_head
, m_outfile
);
1246 int old_indent
= m_indent
;
1250 putc ('\n', m_outfile
);
1251 m_indent
= old_indent
;
1256 /* Like print_rtl except without all the detail; for example,
1257 if RTX is a CONST_INT then print in decimal format. */
1260 print_simple_rtl (FILE *outf
, const_rtx x
)
1262 rtx_writer
w (outf
, 0, true, false, NULL
);
1266 /* Print the elements of VEC to FILE. */
1269 print_rtx_insn_vec (FILE *file
, const vec
<rtx_insn
*> &vec
)
1273 unsigned int len
= vec
.length ();
1274 for (unsigned int i
= 0; i
< len
; i
++)
1276 print_rtl_single (file
, vec
[i
]);
1284 #ifndef GENERATOR_FILE
1285 /* The functions below try to print RTL in a form resembling assembler
1286 mnemonics. Because this form is more concise than the "traditional" form
1287 of RTL printing in Lisp-style, the form printed by this file is called
1288 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
1289 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
1290 always printed in slim form.
1292 The normal interface to the functionality provided in this pretty-printer
1293 is through the dump_*_slim functions to print to a stream, or via the
1294 print_*_slim functions to print into a user's pretty-printer.
1296 It is also possible to obtain a string for a single pattern as a string
1297 pointer, via str_pattern_slim, but this usage is discouraged. */
1299 /* This recognizes rtx'en classified as expressions. These are always
1300 represent some action on values or results of other expression, that
1301 may be stored in objects representing values. */
1304 print_exp (pretty_printer
*pp
, const_rtx x
, int verbose
)
1312 for (i
= 0; i
< 4; i
++)
1318 switch (GET_CODE (x
))
1321 op
[0] = XEXP (x
, 0);
1322 if (CONST_INT_P (XEXP (x
, 1))
1323 && INTVAL (XEXP (x
, 1)) < 0)
1326 op
[1] = GEN_INT (-INTVAL (XEXP (x
, 1)));
1331 op
[1] = XEXP (x
, 1);
1335 op
[0] = XEXP (x
, 0);
1337 op
[1] = XEXP (x
, 1);
1341 op
[0] = XEXP (x
, 0);
1343 op
[1] = XEXP (x
, 1);
1347 op
[0] = XEXP (x
, 0);
1348 op
[1] = XEXP (x
, 1);
1352 op
[0] = XEXP (x
, 0);
1356 op
[0] = XEXP (x
, 0);
1358 op
[1] = XEXP (x
, 1);
1360 op
[2] = XEXP (x
, 2);
1364 op
[0] = XEXP (x
, 0);
1366 op
[1] = XEXP (x
, 1);
1369 op
[0] = XEXP (x
, 0);
1371 op
[1] = XEXP (x
, 1);
1375 op
[0] = XEXP (x
, 0);
1376 op
[1] = XEXP (x
, 1);
1379 op
[0] = XEXP (x
, 0);
1381 op
[1] = XEXP (x
, 1);
1385 op
[0] = XEXP (x
, 0);
1386 op
[1] = XEXP (x
, 1);
1390 op
[0] = XEXP (x
, 0);
1391 op
[1] = XEXP (x
, 1);
1395 op
[0] = XEXP (x
, 0);
1396 op
[1] = XEXP (x
, 1);
1400 op
[0] = XEXP (x
, 0);
1401 op
[1] = XEXP (x
, 1);
1405 op
[0] = XEXP (x
, 0);
1406 op
[1] = XEXP (x
, 1);
1410 op
[0] = XEXP (x
, 0);
1413 op
[0] = XEXP (x
, 0);
1415 op
[1] = XEXP (x
, 1);
1418 op
[0] = XEXP (x
, 0);
1420 op
[1] = XEXP (x
, 1);
1423 op
[0] = XEXP (x
, 0);
1425 op
[1] = XEXP (x
, 1);
1428 op
[0] = XEXP (x
, 0);
1430 op
[1] = XEXP (x
, 1);
1433 op
[0] = XEXP (x
, 0);
1435 op
[1] = XEXP (x
, 1);
1438 op
[0] = XEXP (x
, 0);
1440 op
[1] = XEXP (x
, 1);
1443 op
[0] = XEXP (x
, 0);
1445 op
[1] = XEXP (x
, 1);
1448 op
[0] = XEXP (x
, 0);
1450 op
[1] = XEXP (x
, 1);
1453 op
[0] = XEXP (x
, 0);
1455 op
[1] = XEXP (x
, 1);
1458 op
[0] = XEXP (x
, 0);
1460 op
[1] = XEXP (x
, 1);
1463 op
[0] = XEXP (x
, 0);
1465 op
[1] = XEXP (x
, 1);
1468 op
[0] = XEXP (x
, 0);
1470 op
[1] = XEXP (x
, 1);
1473 op
[0] = XEXP (x
, 0);
1475 op
[1] = XEXP (x
, 1);
1478 op
[0] = XEXP (x
, 0);
1480 op
[1] = XEXP (x
, 1);
1483 fun
= (verbose
) ? "sign_extract" : "sxt";
1484 op
[0] = XEXP (x
, 0);
1485 op
[1] = XEXP (x
, 1);
1486 op
[2] = XEXP (x
, 2);
1489 fun
= (verbose
) ? "zero_extract" : "zxt";
1490 op
[0] = XEXP (x
, 0);
1491 op
[1] = XEXP (x
, 1);
1492 op
[2] = XEXP (x
, 2);
1495 fun
= (verbose
) ? "sign_extend" : "sxn";
1496 op
[0] = XEXP (x
, 0);
1499 fun
= (verbose
) ? "zero_extend" : "zxn";
1500 op
[0] = XEXP (x
, 0);
1503 fun
= (verbose
) ? "float_extend" : "fxn";
1504 op
[0] = XEXP (x
, 0);
1507 fun
= (verbose
) ? "trunc" : "trn";
1508 op
[0] = XEXP (x
, 0);
1510 case FLOAT_TRUNCATE
:
1511 fun
= (verbose
) ? "float_trunc" : "ftr";
1512 op
[0] = XEXP (x
, 0);
1515 fun
= (verbose
) ? "float" : "flt";
1516 op
[0] = XEXP (x
, 0);
1518 case UNSIGNED_FLOAT
:
1519 fun
= (verbose
) ? "uns_float" : "ufl";
1520 op
[0] = XEXP (x
, 0);
1524 op
[0] = XEXP (x
, 0);
1527 fun
= (verbose
) ? "uns_fix" : "ufx";
1528 op
[0] = XEXP (x
, 0);
1532 op
[0] = XEXP (x
, 0);
1536 op
[0] = XEXP (x
, 0);
1539 op
[0] = XEXP (x
, 0);
1543 op
[0] = XEXP (x
, 0);
1548 op
[0] = XEXP (XEXP (x
, 1), 0);
1550 op
[1] = XEXP (XEXP (x
, 1), 1);
1554 op
[0] = XEXP (XEXP (x
, 1), 0);
1556 op
[1] = XEXP (XEXP (x
, 1), 1);
1560 op
[0] = XEXP (x
, 0);
1564 op
[1] = XEXP (x
, 1);
1569 op
[0] = XEXP (x
, 0);
1571 op
[1] = XEXP (x
, 1);
1573 op
[2] = XEXP (x
, 2);
1578 op
[0] = TRAP_CONDITION (x
);
1582 op
[0] = XEXP (x
, 0);
1583 op
[1] = XEXP (x
, 1);
1584 op
[2] = XEXP (x
, 2);
1587 case UNSPEC_VOLATILE
:
1589 pp_string (pp
, "unspec");
1590 if (GET_CODE (x
) == UNSPEC_VOLATILE
)
1591 pp_string (pp
, "/v");
1592 pp_left_bracket (pp
);
1593 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1597 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1599 pp_string (pp
, "] ");
1600 pp_decimal_int (pp
, XINT (x
, 1));
1605 /* Most unhandled codes can be printed as pseudo-functions. */
1606 if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_UNARY
)
1608 fun
= GET_RTX_NAME (GET_CODE (x
));
1609 op
[0] = XEXP (x
, 0);
1611 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMPARE
1612 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_COMPARE
1613 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_BIN_ARITH
1614 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_ARITH
)
1616 fun
= GET_RTX_NAME (GET_CODE (x
));
1617 op
[0] = XEXP (x
, 0);
1618 op
[1] = XEXP (x
, 1);
1620 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_TERNARY
)
1622 fun
= GET_RTX_NAME (GET_CODE (x
));
1623 op
[0] = XEXP (x
, 0);
1624 op
[1] = XEXP (x
, 1);
1625 op
[2] = XEXP (x
, 2);
1628 /* Give up, just print the RTX name. */
1629 st
[0] = GET_RTX_NAME (GET_CODE (x
));
1634 /* Print this as a function? */
1637 pp_string (pp
, fun
);
1641 for (i
= 0; i
< 4; i
++)
1644 pp_string (pp
, st
[i
]);
1650 print_value (pp
, op
[i
], verbose
);
1655 pp_right_paren (pp
);
1658 /* Prints rtxes, I customarily classified as values. They're constants,
1659 registers, labels, symbols and memory accesses. */
1662 print_value (pretty_printer
*pp
, const_rtx x
, int verbose
)
1668 pp_string (pp
, "(nil)");
1671 switch (GET_CODE (x
))
1674 pp_scalar (pp
, HOST_WIDE_INT_PRINT_HEX
,
1675 (unsigned HOST_WIDE_INT
) INTVAL (x
));
1678 case CONST_WIDE_INT
:
1680 const char *sep
= "<";
1682 for (i
= CONST_WIDE_INT_NUNITS (x
) - 1; i
>= 0; i
--)
1684 pp_string (pp
, sep
);
1686 sprintf (tmp
, HOST_WIDE_INT_PRINT_HEX
,
1687 (unsigned HOST_WIDE_INT
) CONST_WIDE_INT_ELT (x
, i
));
1688 pp_string (pp
, tmp
);
1694 case CONST_POLY_INT
:
1695 pp_left_bracket (pp
);
1696 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[0], SIGNED
);
1697 for (unsigned int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
1699 pp_string (pp
, ", ");
1700 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[i
], SIGNED
);
1702 pp_right_bracket (pp
);
1706 if (FLOAT_MODE_P (GET_MODE (x
)))
1708 real_to_decimal (tmp
, CONST_DOUBLE_REAL_VALUE (x
),
1709 sizeof (tmp
), 0, 1);
1710 pp_string (pp
, tmp
);
1713 pp_printf (pp
, "<%wx,%wx>",
1714 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (x
),
1715 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_HIGH (x
));
1718 fixed_to_decimal (tmp
, CONST_FIXED_VALUE (x
), sizeof (tmp
));
1719 pp_string (pp
, tmp
);
1722 pp_string (pp
, "\"");
1723 pretty_print_string (pp
, XSTR (x
, 0), strlen (XSTR (x
, 0)));
1724 pp_string (pp
, "\"");
1727 pp_printf (pp
, "`%s'", XSTR (x
, 0));
1730 pp_printf (pp
, "L%d", INSN_UID (label_ref_label (x
)));
1734 case STRICT_LOW_PART
:
1735 pp_printf (pp
, "%s(", GET_RTX_NAME (GET_CODE (x
)));
1736 print_value (pp
, XEXP (x
, 0), verbose
);
1737 pp_right_paren (pp
);
1740 if (REGNO (x
) < FIRST_PSEUDO_REGISTER
)
1742 if (ISDIGIT (reg_names
[REGNO (x
)][0]))
1744 pp_string (pp
, reg_names
[REGNO (x
)]);
1747 pp_printf (pp
, "r%d", REGNO (x
));
1749 pp_printf (pp
, ":%s", GET_MODE_NAME (GET_MODE (x
)));
1752 print_value (pp
, SUBREG_REG (x
), verbose
);
1753 pp_printf (pp
, "#");
1754 pp_wide_integer (pp
, SUBREG_BYTE (x
));
1758 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1761 pp_left_bracket (pp
);
1762 print_value (pp
, XEXP (x
, 0), verbose
);
1763 pp_right_bracket (pp
);
1766 pp_printf (pp
, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x
)));
1769 print_exp (pp
, x
, verbose
);
1774 /* The next step in insn detalization, its pattern recognition. */
1777 print_pattern (pretty_printer
*pp
, const_rtx x
, int verbose
)
1781 pp_string (pp
, "(nil)");
1785 switch (GET_CODE (x
))
1788 print_value (pp
, SET_DEST (x
), verbose
);
1790 print_value (pp
, SET_SRC (x
), verbose
);
1795 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1798 print_exp (pp
, x
, verbose
);
1802 pp_printf (pp
, "%s ", GET_RTX_NAME (GET_CODE (x
)));
1803 print_value (pp
, XEXP (x
, 0), verbose
);
1806 pp_string (pp
, "loc ");
1807 print_value (pp
, PAT_VAR_LOCATION_LOC (x
), verbose
);
1811 if (GET_CODE (COND_EXEC_TEST (x
)) == NE
1812 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1813 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1814 else if (GET_CODE (COND_EXEC_TEST (x
)) == EQ
1815 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1817 pp_exclamation (pp
);
1818 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1821 print_value (pp
, COND_EXEC_TEST (x
), verbose
);
1822 pp_string (pp
, ") ");
1823 print_pattern (pp
, COND_EXEC_CODE (x
), verbose
);
1830 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1832 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1835 pp_right_brace (pp
);
1840 const rtx_sequence
*seq
= as_a
<const rtx_sequence
*> (x
);
1841 pp_string (pp
, "sequence{");
1842 if (INSN_P (seq
->element (0)))
1844 /* Print the sequence insns indented. */
1845 const char * save_print_rtx_head
= print_rtx_head
;
1846 char indented_print_rtx_head
[32];
1849 gcc_assert (strlen (print_rtx_head
) < sizeof (indented_print_rtx_head
) - 4);
1850 snprintf (indented_print_rtx_head
,
1851 sizeof (indented_print_rtx_head
),
1852 "%s ", print_rtx_head
);
1853 print_rtx_head
= indented_print_rtx_head
;
1854 for (int i
= 0; i
< seq
->len (); i
++)
1855 print_insn_with_notes (pp
, seq
->insn (i
));
1856 pp_printf (pp
, "%s ", save_print_rtx_head
);
1857 print_rtx_head
= save_print_rtx_head
;
1861 for (int i
= 0; i
< seq
->len (); i
++)
1863 print_pattern (pp
, seq
->element (i
), verbose
);
1867 pp_right_brace (pp
);
1871 pp_printf (pp
, "asm {%s}", XSTR (x
, 0));
1874 for (int i
= 0; i
< XVECLEN (x
, 0); i
++)
1876 print_value (pp
, XVECEXP (x
, 0, i
), verbose
);
1881 for (int i
= 0; i
< XVECLEN (x
, 1); i
++)
1883 print_value (pp
, XVECEXP (x
, 1, i
), verbose
);
1888 pp_string (pp
, "trap_if ");
1889 print_value (pp
, TRAP_CONDITION (x
), verbose
);
1892 case UNSPEC_VOLATILE
:
1893 /* Fallthru -- leave UNSPECs to print_exp. */
1895 print_value (pp
, x
, verbose
);
1897 } /* print_pattern */
1899 /* This is the main function in slim rtl visualization mechanism.
1901 X is an insn, to be printed into PP.
1903 This function tries to print it properly in human-readable form,
1904 resembling assembler mnemonics (instead of the older Lisp-style
1907 If VERBOSE is TRUE, insns are printed with more complete (but
1908 longer) pattern names and with extra information, and prefixed
1909 with their INSN_UIDs. */
1912 print_insn (pretty_printer
*pp
, const rtx_insn
*x
, int verbose
)
1916 /* Blech, pretty-print can't print integers with a specified width. */
1917 char uid_prefix
[32];
1918 snprintf (uid_prefix
, sizeof uid_prefix
, " %4d: ", INSN_UID (x
));
1919 pp_string (pp
, uid_prefix
);
1922 switch (GET_CODE (x
))
1925 print_pattern (pp
, PATTERN (x
), verbose
);
1930 if (DEBUG_MARKER_INSN_P (x
))
1932 switch (INSN_DEBUG_MARKER_KIND (x
))
1934 case NOTE_INSN_BEGIN_STMT
:
1935 pp_string (pp
, "debug begin stmt marker");
1938 case NOTE_INSN_INLINE_ENTRY
:
1939 pp_string (pp
, "debug inline entry marker");
1948 const char *name
= "?";
1951 if (DECL_P (INSN_VAR_LOCATION_DECL (x
)))
1953 tree id
= DECL_NAME (INSN_VAR_LOCATION_DECL (x
));
1955 name
= IDENTIFIER_POINTER (id
);
1956 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x
))
1959 sprintf (idbuf
, "D#%i",
1960 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x
)));
1965 sprintf (idbuf
, "D.%i",
1966 DECL_UID (INSN_VAR_LOCATION_DECL (x
)));
1970 pp_printf (pp
, "debug %s => ", name
);
1971 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x
)))
1972 pp_string (pp
, "optimized away");
1974 print_pattern (pp
, INSN_VAR_LOCATION_LOC (x
), verbose
);
1979 print_pattern (pp
, PATTERN (x
), verbose
);
1982 if (GET_CODE (PATTERN (x
)) == PARALLEL
)
1983 print_pattern (pp
, XVECEXP (PATTERN (x
), 0, 0), verbose
);
1985 print_pattern (pp
, PATTERN (x
), verbose
);
1988 pp_printf (pp
, "L%d:", INSN_UID (x
));
1990 case JUMP_TABLE_DATA
:
1991 pp_string (pp
, "jump_table_data{\n");
1992 print_pattern (pp
, PATTERN (x
), verbose
);
1993 pp_right_brace (pp
);
1996 pp_string (pp
, "barrier");
2000 pp_string (pp
, GET_NOTE_INSN_NAME (NOTE_KIND (x
)));
2001 switch (NOTE_KIND (x
))
2003 case NOTE_INSN_EH_REGION_BEG
:
2004 case NOTE_INSN_EH_REGION_END
:
2005 pp_printf (pp
, " %d", NOTE_EH_HANDLER (x
));
2008 case NOTE_INSN_BLOCK_BEG
:
2009 case NOTE_INSN_BLOCK_END
:
2010 pp_printf (pp
, " %d", BLOCK_NUMBER (NOTE_BLOCK (x
)));
2013 case NOTE_INSN_BASIC_BLOCK
:
2014 pp_printf (pp
, " %d", NOTE_BASIC_BLOCK (x
)->index
);
2017 case NOTE_INSN_DELETED_LABEL
:
2018 case NOTE_INSN_DELETED_DEBUG_LABEL
:
2020 const char *label
= NOTE_DELETED_LABEL_NAME (x
);
2023 pp_printf (pp
, " (\"%s\")", label
);
2027 case NOTE_INSN_VAR_LOCATION
:
2029 print_pattern (pp
, NOTE_VAR_LOCATION (x
), verbose
);
2030 pp_right_brace (pp
);
2043 /* Pretty-print a slim dump of X (an insn) to PP, including any register
2044 note attached to the instruction. */
2047 print_insn_with_notes (pretty_printer
*pp
, const rtx_insn
*x
)
2049 pp_string (pp
, print_rtx_head
);
2050 print_insn (pp
, x
, 1);
2052 if (INSN_P (x
) && REG_NOTES (x
))
2053 for (rtx note
= REG_NOTES (x
); note
; note
= XEXP (note
, 1))
2055 pp_printf (pp
, "%s %s ", print_rtx_head
,
2056 GET_REG_NOTE_NAME (REG_NOTE_KIND (note
)));
2057 if (GET_CODE (note
) == INT_LIST
)
2058 pp_printf (pp
, "%d", XINT (note
, 0));
2060 print_pattern (pp
, XEXP (note
, 0), 1);
2065 /* Print X, an RTL value node, to file F in slim format. Include
2066 additional information if VERBOSE is nonzero.
2068 Value nodes are constants, registers, labels, symbols and
2072 dump_value_slim (FILE *f
, const_rtx x
, int verbose
)
2074 pretty_printer rtl_slim_pp
;
2075 rtl_slim_pp
.buffer
->stream
= f
;
2076 print_value (&rtl_slim_pp
, x
, verbose
);
2077 pp_flush (&rtl_slim_pp
);
2080 /* Emit a slim dump of X (an insn) to the file F, including any register
2081 note attached to the instruction. */
2083 dump_insn_slim (FILE *f
, const rtx_insn
*x
)
2085 pretty_printer rtl_slim_pp
;
2086 rtl_slim_pp
.buffer
->stream
= f
;
2087 print_insn_with_notes (&rtl_slim_pp
, x
);
2088 pp_flush (&rtl_slim_pp
);
2091 /* Same as above, but stop at LAST or when COUNT == 0.
2092 If COUNT < 0 it will stop only at LAST or NULL rtx. */
2095 dump_rtl_slim (FILE *f
, const rtx_insn
*first
, const rtx_insn
*last
,
2096 int count
, int flags ATTRIBUTE_UNUSED
)
2098 const rtx_insn
*insn
, *tail
;
2099 pretty_printer rtl_slim_pp
;
2100 rtl_slim_pp
.buffer
->stream
= f
;
2102 tail
= last
? NEXT_INSN (last
) : NULL
;
2104 (insn
!= NULL
) && (insn
!= tail
) && (count
!= 0);
2105 insn
= NEXT_INSN (insn
))
2107 print_insn_with_notes (&rtl_slim_pp
, insn
);
2112 pp_flush (&rtl_slim_pp
);
2115 /* Dumps basic block BB to pretty-printer PP in slim form and without and
2116 no indentation, for use as a label of a DOT graph record-node. */
2119 rtl_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
2124 /* TODO: inter-bb stuff. */
2125 FOR_BB_INSNS (bb
, insn
)
2130 pp_write_text_to_stream (pp
);
2133 print_insn_with_notes (pp
, insn
);
2134 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2138 /* Pretty-print pattern X of some insn in non-verbose mode.
2139 Return a string pointer to the pretty-printer buffer.
2141 This function is only exported exists only to accommodate some older users
2142 of the slim RTL pretty printers. Please do not use it for new code. */
2145 str_pattern_slim (const_rtx x
)
2147 pretty_printer rtl_slim_pp
;
2148 print_pattern (&rtl_slim_pp
, x
, 0);
2149 return ggc_strdup (pp_formatted_text (&rtl_slim_pp
));
2152 /* Emit a slim dump of X (an insn) to stderr. */
2153 extern void debug_insn_slim (const rtx_insn
*);
2155 debug_insn_slim (const rtx_insn
*x
)
2157 dump_insn_slim (stderr
, x
);
2160 /* Same as above, but using dump_rtl_slim. */
2161 extern void debug_rtl_slim (FILE *, const rtx_insn
*, const rtx_insn
*,
2164 debug_rtl_slim (const rtx_insn
*first
, const rtx_insn
*last
, int count
,
2167 dump_rtl_slim (stderr
, first
, last
, count
, flags
);
2170 extern void debug_bb_slim (basic_block
);
2172 debug_bb_slim (basic_block bb
)
2174 debug_bb (bb
, TDF_SLIM
| TDF_BLOCKS
);
2177 extern void debug_bb_n_slim (int);
2179 debug_bb_n_slim (int n
)
2181 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, n
);
2188 # pragma GCC diagnostic pop