2 Copyright (C) 1987-2024 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. */
28 #define INCLUDE_MEMORY
30 #include "coretypes.h"
34 /* These headers all define things which are not available in
35 generator programs. */
36 #ifndef GENERATOR_FILE
39 #include "basic-block.h"
40 #include "print-tree.h"
45 #include "basic-block.h"
46 #include "diagnostic.h"
47 #include "tree-pretty-print.h"
48 #include "alloc-pool.h"
50 #include "dumpfile.h" /* for dump_flags */
51 #include "dwarf2out.h"
52 #include "pretty-print.h"
55 #include "print-rtl.h"
58 /* Disable warnings about quoting issues in the pp_xxx calls below
59 that (intentionally) don't follow GCC diagnostic conventions. */
61 # pragma GCC diagnostic push
62 # pragma GCC diagnostic ignored "-Wformat-diag"
65 /* String printed at beginning of each RTL when it is dumped.
66 This string is set to ASM_COMMENT_START when the RTL is dumped in
67 the assembly output file. */
68 const char *print_rtx_head
= "";
71 /* These are defined from the .opt file when not used in generator
74 /* Nonzero means suppress output of instruction numbers
76 This must be defined here so that programs like gencodes can be linked. */
77 int flag_dump_unnumbered
= 0;
79 /* Nonzero means suppress output of instruction numbers for previous
80 and next insns in debugging dumps.
81 This must be defined here so that programs like gencodes can be linked. */
82 int flag_dump_unnumbered_links
= 0;
85 /* Constructor for rtx_writer. */
87 rtx_writer::rtx_writer (FILE *outf
, int ind
, bool simple
, bool compact
,
88 rtx_reuse_manager
*reuse_manager ATTRIBUTE_UNUSED
)
89 : m_outfile (outf
), m_indent (ind
), m_sawclose (false),
90 m_in_call_function_usage (false), m_simple (simple
), m_compact (compact
)
91 #ifndef GENERATOR_FILE
92 , m_rtx_reuse_manager (reuse_manager
)
97 #ifndef GENERATOR_FILE
99 /* rtx_reuse_manager's ctor. */
101 rtx_reuse_manager::rtx_reuse_manager ()
106 /* Determine if X is of a kind suitable for dumping via reuse_rtx. */
109 uses_rtx_reuse_p (const_rtx x
)
114 switch (GET_CODE (x
))
121 /* We don't use reuse_rtx for consts. */
128 /* Traverse X and its descendents, determining if we see any rtx more than
129 once. Any rtx suitable for "reuse_rtx" that is seen more than once is
133 rtx_reuse_manager::preprocess (const_rtx x
)
135 subrtx_iterator::array_type array
;
136 FOR_EACH_SUBRTX (iter
, array
, x
, NONCONST
)
137 if (uses_rtx_reuse_p (*iter
))
139 if (int *count
= m_rtx_occurrence_count
.get (*iter
))
142 m_rtx_reuse_ids
.put (*iter
, m_next_id
++);
145 m_rtx_occurrence_count
.put (*iter
, 1);
149 /* Return true iff X has been assigned a reuse ID. If it has,
150 and OUT is non-NULL, then write the reuse ID to *OUT. */
153 rtx_reuse_manager::has_reuse_id (const_rtx x
, int *out
)
155 int *id
= m_rtx_reuse_ids
.get (x
);
166 /* Determine if set_seen_def has been called for the given reuse ID. */
169 rtx_reuse_manager::seen_def_p (int reuse_id
)
171 return bitmap_bit_p (m_defs_seen
, reuse_id
);
174 /* Record that the definition of the given reuse ID has been seen. */
177 rtx_reuse_manager::set_seen_def (int reuse_id
)
179 bitmap_set_bit (m_defs_seen
, reuse_id
);
182 #endif /* #ifndef GENERATOR_FILE */
184 #ifndef GENERATOR_FILE
186 print_mem_expr (FILE *outfile
, const_tree expr
)
188 fputc (' ', outfile
);
189 print_generic_expr (outfile
, CONST_CAST_TREE (expr
),
190 dump_flags
| TDF_SLIM
);
194 /* Print X to FILE. */
197 print_poly_int (FILE *file
, poly_int64 x
)
199 HOST_WIDE_INT const_x
;
200 if (x
.is_constant (&const_x
))
201 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, const_x
);
204 fprintf (file
, "[" HOST_WIDE_INT_PRINT_DEC
, x
.coeffs
[0]);
205 for (int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
206 fprintf (file
, ", " HOST_WIDE_INT_PRINT_DEC
, x
.coeffs
[i
]);
211 /* Subroutine of print_rtx_operand for handling code '0'.
212 0 indicates a field for internal use that should not be printed.
213 However there are various special cases, such as the third field
214 of a NOTE, where it indicates that the field has several different
218 rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED
,
219 int idx ATTRIBUTE_UNUSED
)
221 #ifndef GENERATOR_FILE
222 if (idx
== 1 && GET_CODE (in_rtx
) == SYMBOL_REF
)
224 int flags
= SYMBOL_REF_FLAGS (in_rtx
);
226 fprintf (m_outfile
, " [flags %#x]", flags
);
227 tree decl
= SYMBOL_REF_DECL (in_rtx
);
229 print_node_brief (m_outfile
, "", decl
, dump_flags
);
231 else if (idx
== 3 && NOTE_P (in_rtx
))
233 switch (NOTE_KIND (in_rtx
))
235 case NOTE_INSN_EH_REGION_BEG
:
236 case NOTE_INSN_EH_REGION_END
:
237 if (flag_dump_unnumbered
)
238 fprintf (m_outfile
, " #");
240 fprintf (m_outfile
, " %d", NOTE_EH_HANDLER (in_rtx
));
244 case NOTE_INSN_BLOCK_BEG
:
245 case NOTE_INSN_BLOCK_END
:
246 dump_addr (m_outfile
, " ", NOTE_BLOCK (in_rtx
));
250 case NOTE_INSN_BASIC_BLOCK
:
252 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
254 fprintf (m_outfile
, " [bb %d]", bb
->index
);
258 case NOTE_INSN_DELETED_LABEL
:
259 case NOTE_INSN_DELETED_DEBUG_LABEL
:
261 const char *label
= NOTE_DELETED_LABEL_NAME (in_rtx
);
263 fprintf (m_outfile
, " (\"%s\")", label
);
265 fprintf (m_outfile
, " \"\"");
269 case NOTE_INSN_SWITCH_TEXT_SECTIONS
:
271 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
273 fprintf (m_outfile
, " [bb %d]", bb
->index
);
277 case NOTE_INSN_VAR_LOCATION
:
278 fputc (' ', m_outfile
);
279 print_rtx (NOTE_VAR_LOCATION (in_rtx
));
283 fputc ('\n', m_outfile
);
284 output_cfi_directive (m_outfile
, NOTE_CFI (in_rtx
));
285 fputc ('\t', m_outfile
);
288 case NOTE_INSN_BEGIN_STMT
:
289 case NOTE_INSN_INLINE_ENTRY
:
290 #ifndef GENERATOR_FILE
292 expanded_location xloc
293 = expand_location (NOTE_MARKER_LOCATION (in_rtx
));
294 fprintf (m_outfile
, " %s:%i", xloc
.file
, xloc
.line
);
303 else if (idx
== 7 && JUMP_P (in_rtx
) && JUMP_LABEL (in_rtx
) != NULL
306 /* Output the JUMP_LABEL reference. */
307 fprintf (m_outfile
, "\n%s%*s -> ", print_rtx_head
, m_indent
* 2, "");
308 if (GET_CODE (JUMP_LABEL (in_rtx
)) == RETURN
)
309 fprintf (m_outfile
, "return");
310 else if (GET_CODE (JUMP_LABEL (in_rtx
)) == SIMPLE_RETURN
)
311 fprintf (m_outfile
, "simple_return");
313 fprintf (m_outfile
, "%d", INSN_UID (JUMP_LABEL (in_rtx
)));
315 else if (idx
== 0 && GET_CODE (in_rtx
) == VALUE
)
317 cselib_val
*val
= CSELIB_VAL_PTR (in_rtx
);
319 fprintf (m_outfile
, " %u:%u", val
->uid
, val
->hash
);
320 dump_addr (m_outfile
, " @", in_rtx
);
321 dump_addr (m_outfile
, "/", (void*)val
);
323 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_EXPR
)
325 fprintf (m_outfile
, " D#%i",
326 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx
)));
328 else if (idx
== 0 && GET_CODE (in_rtx
) == ENTRY_VALUE
)
332 fprintf (m_outfile
, " ");
333 print_rtx (ENTRY_VALUE_EXP (in_rtx
));
339 /* Subroutine of print_rtx_operand for handling code 'e'.
340 Also called by print_rtx_operand_code_u for handling code 'u'
341 for LABEL_REFs when they don't reference a CODE_LABEL. */
344 rtx_writer::print_rtx_operand_code_e (const_rtx in_rtx
, int idx
)
347 if (idx
== 6 && INSN_P (in_rtx
))
348 /* Put REG_NOTES on their own line. */
349 fprintf (m_outfile
, "\n%s%*s",
350 print_rtx_head
, m_indent
* 2, "");
352 fprintf (m_outfile
, " ");
353 if (idx
== 7 && CALL_P (in_rtx
))
355 m_in_call_function_usage
= true;
356 print_rtx (XEXP (in_rtx
, idx
));
357 m_in_call_function_usage
= false;
360 print_rtx (XEXP (in_rtx
, idx
));
364 /* Subroutine of print_rtx_operand for handling codes 'E' and 'V'. */
367 rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx
, int idx
)
372 fprintf (m_outfile
, "\n%s%*s",
373 print_rtx_head
, m_indent
* 2, "");
376 if (GET_CODE (in_rtx
) == CONST_VECTOR
377 && !GET_MODE_NUNITS (GET_MODE (in_rtx
)).is_constant ()
378 && CONST_VECTOR_DUPLICATE_P (in_rtx
))
379 fprintf (m_outfile
, " repeat");
380 fputs (" [", m_outfile
);
381 if (XVEC (in_rtx
, idx
) != NULL
)
384 if (XVECLEN (in_rtx
, idx
))
387 int barrier
= XVECLEN (in_rtx
, idx
);
388 if (GET_CODE (in_rtx
) == CONST_VECTOR
389 && !GET_MODE_NUNITS (GET_MODE (in_rtx
)).is_constant ())
390 barrier
= CONST_VECTOR_NPATTERNS (in_rtx
);
392 for (int j
= 0; j
< XVECLEN (in_rtx
, idx
); j
++)
398 fprintf (m_outfile
, "\n%s%*s",
399 print_rtx_head
, m_indent
* 2, "");
400 if (!CONST_VECTOR_STEPPED_P (in_rtx
))
401 fprintf (m_outfile
, "repeat [");
402 else if (CONST_VECTOR_NPATTERNS (in_rtx
) == 1)
403 fprintf (m_outfile
, "stepped [");
405 fprintf (m_outfile
, "stepped (interleave %d) [",
406 CONST_VECTOR_NPATTERNS (in_rtx
));
410 print_rtx (XVECEXP (in_rtx
, idx
, j
));
411 int limit
= MIN (barrier
, XVECLEN (in_rtx
, idx
));
412 for (j1
= j
+ 1; j1
< limit
; j1
++)
413 if (XVECEXP (in_rtx
, idx
, j
) != XVECEXP (in_rtx
, idx
, j1
))
418 fprintf (m_outfile
, " repeated x%i", j1
- j
);
423 if (barrier
< XVECLEN (in_rtx
, idx
))
426 fprintf (m_outfile
, "\n%s%*s]", print_rtx_head
, m_indent
* 2, "");
432 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
434 fputs ("]", m_outfile
);
439 /* Subroutine of print_rtx_operand for handling code 'i'. */
442 rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx
, int idx
)
444 if (idx
== 4 && INSN_P (in_rtx
))
446 #ifndef GENERATOR_FILE
447 const rtx_insn
*in_insn
= as_a
<const rtx_insn
*> (in_rtx
);
449 /* Pretty-print insn locations. Ignore scoping as it is mostly
450 redundant with line number information and do not print anything
451 when there is no location information available. */
452 if (INSN_HAS_LOCATION (in_insn
))
454 expanded_location xloc
= insn_location (in_insn
);
455 fprintf (m_outfile
, " \"%s\":%i:%i", xloc
.file
, xloc
.line
,
457 int discriminator
= insn_discriminator (in_insn
);
459 fprintf (m_outfile
, " discrim %d", discriminator
);
464 else if (idx
== 6 && GET_CODE (in_rtx
) == ASM_OPERANDS
)
466 #ifndef GENERATOR_FILE
467 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
468 fprintf (m_outfile
, " %s:%i",
469 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)),
470 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)));
473 else if (idx
== 1 && GET_CODE (in_rtx
) == ASM_INPUT
)
475 #ifndef GENERATOR_FILE
476 if (ASM_INPUT_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
477 fprintf (m_outfile
, " %s:%i",
478 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)),
479 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)));
482 else if (idx
== 5 && NOTE_P (in_rtx
))
484 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
485 other times often contains garbage from INSN->NOTE death. */
486 if (NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_LABEL
487 || NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_DEBUG_LABEL
)
488 fprintf (m_outfile
, " %d", XINT (in_rtx
, idx
));
490 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
492 && GET_CODE (in_rtx
) == UNSPEC_VOLATILE
493 && XINT (in_rtx
, 1) >= 0
494 && XINT (in_rtx
, 1) < NUM_UNSPECV_VALUES
)
495 fprintf (m_outfile
, " %s", unspecv_strings
[XINT (in_rtx
, 1)]);
497 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
499 && (GET_CODE (in_rtx
) == UNSPEC
500 || GET_CODE (in_rtx
) == UNSPEC_VOLATILE
)
501 && XINT (in_rtx
, 1) >= 0
502 && XINT (in_rtx
, 1) < NUM_UNSPEC_VALUES
)
503 fprintf (m_outfile
, " %s", unspec_strings
[XINT (in_rtx
, 1)]);
507 int value
= XINT (in_rtx
, idx
);
509 int is_insn
= INSN_P (in_rtx
);
511 /* Don't print INSN_CODEs in compact mode. */
512 if (m_compact
&& is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
))
518 if (flag_dump_unnumbered
519 && (is_insn
|| NOTE_P (in_rtx
)))
520 fputc ('#', m_outfile
);
522 fprintf (m_outfile
, " %d", value
);
524 if (is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
)
525 && XINT (in_rtx
, idx
) >= 0
526 && (name
= get_insn_name (XINT (in_rtx
, idx
))) != NULL
)
527 fprintf (m_outfile
, " {%s}", name
);
532 /* Subroutine of print_rtx_operand for handling code 'r'. */
535 rtx_writer::print_rtx_operand_code_r (const_rtx in_rtx
)
537 int is_insn
= INSN_P (in_rtx
);
538 unsigned int regno
= REGNO (in_rtx
);
540 #ifndef GENERATOR_FILE
541 /* For hard registers and virtuals, always print the
542 regno, except in compact mode. */
543 if (regno
<= LAST_VIRTUAL_REGISTER
&& !m_compact
)
544 fprintf (m_outfile
, " %d", regno
);
545 if (regno
< FIRST_PSEUDO_REGISTER
)
546 fprintf (m_outfile
, " %s", reg_names
[regno
]);
547 else if (regno
<= LAST_VIRTUAL_REGISTER
)
549 if (regno
== VIRTUAL_INCOMING_ARGS_REGNUM
)
550 fprintf (m_outfile
, " virtual-incoming-args");
551 else if (regno
== VIRTUAL_STACK_VARS_REGNUM
)
552 fprintf (m_outfile
, " virtual-stack-vars");
553 else if (regno
== VIRTUAL_STACK_DYNAMIC_REGNUM
)
554 fprintf (m_outfile
, " virtual-stack-dynamic");
555 else if (regno
== VIRTUAL_OUTGOING_ARGS_REGNUM
)
556 fprintf (m_outfile
, " virtual-outgoing-args");
557 else if (regno
== VIRTUAL_CFA_REGNUM
)
558 fprintf (m_outfile
, " virtual-cfa");
559 else if (regno
== VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM
)
560 fprintf (m_outfile
, " virtual-preferred-stack-boundary");
562 fprintf (m_outfile
, " virtual-reg-%d", regno
-FIRST_VIRTUAL_REGISTER
);
566 if (flag_dump_unnumbered
&& is_insn
)
567 fputc ('#', m_outfile
);
570 /* In compact mode, print pseudos with '< and '>' wrapping the regno,
571 offseting it by (LAST_VIRTUAL_REGISTER + 1), so that the
572 first non-virtual pseudo is dumped as "<0>". */
573 gcc_assert (regno
> LAST_VIRTUAL_REGISTER
);
574 fprintf (m_outfile
, " <%d>", regno
- (LAST_VIRTUAL_REGISTER
+ 1));
577 fprintf (m_outfile
, " %d", regno
);
579 #ifndef GENERATOR_FILE
580 if (REG_ATTRS (in_rtx
))
582 fputs (" [", m_outfile
);
583 if (regno
!= ORIGINAL_REGNO (in_rtx
))
584 fprintf (m_outfile
, "orig:%i", ORIGINAL_REGNO (in_rtx
));
585 if (REG_EXPR (in_rtx
))
586 print_mem_expr (m_outfile
, REG_EXPR (in_rtx
));
588 if (maybe_ne (REG_OFFSET (in_rtx
), 0))
590 fprintf (m_outfile
, "+");
591 print_poly_int (m_outfile
, REG_OFFSET (in_rtx
));
593 fputs (" ]", m_outfile
);
595 if (regno
!= ORIGINAL_REGNO (in_rtx
))
596 fprintf (m_outfile
, " [%d]", ORIGINAL_REGNO (in_rtx
));
600 /* Subroutine of print_rtx_operand for handling code 'u'. */
603 rtx_writer::print_rtx_operand_code_u (const_rtx in_rtx
, int idx
)
605 /* Don't print insn UIDs for PREV/NEXT_INSN in compact mode. */
606 if (m_compact
&& INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)) && idx
< 2)
609 if (XEXP (in_rtx
, idx
) != NULL
)
611 rtx sub
= XEXP (in_rtx
, idx
);
612 enum rtx_code subc
= GET_CODE (sub
);
614 if (GET_CODE (in_rtx
) == LABEL_REF
)
617 && NOTE_KIND (sub
) == NOTE_INSN_DELETED_LABEL
)
619 if (flag_dump_unnumbered
)
620 fprintf (m_outfile
, " [# deleted]");
622 fprintf (m_outfile
, " [%d deleted]", INSN_UID (sub
));
627 if (subc
!= CODE_LABEL
)
629 print_rtx_operand_code_e (in_rtx
, idx
);
634 if (flag_dump_unnumbered
635 || (flag_dump_unnumbered_links
&& idx
<= 1
636 && (INSN_P (in_rtx
) || NOTE_P (in_rtx
)
637 || LABEL_P (in_rtx
) || BARRIER_P (in_rtx
))))
638 fputs (" #", m_outfile
);
640 fprintf (m_outfile
, " %d", INSN_UID (sub
));
643 fputs (" 0", m_outfile
);
647 /* Subroutine of print_rtx. Print operand IDX of IN_RTX. */
650 rtx_writer::print_rtx_operand (const_rtx in_rtx
, int idx
)
652 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
654 switch (format_ptr
[idx
])
659 str
= XTMPL (in_rtx
, idx
);
664 str
= XSTR (in_rtx
, idx
);
668 fputs (" (nil)", m_outfile
);
670 fprintf (m_outfile
, " (\"%s\")", str
);
675 print_rtx_operand_code_0 (in_rtx
, idx
);
679 print_rtx_operand_code_e (in_rtx
, idx
);
684 print_rtx_operand_codes_E_and_V (in_rtx
, idx
);
689 fprintf (m_outfile
, " ");
690 fprintf (m_outfile
, HOST_WIDE_INT_PRINT_DEC
, XWINT (in_rtx
, idx
));
691 if (! m_simple
&& !m_compact
)
692 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_HEX
"]",
693 (unsigned HOST_WIDE_INT
) XWINT (in_rtx
, idx
));
697 print_rtx_operand_code_i (in_rtx
, idx
);
701 fprintf (m_outfile
, " ");
702 print_poly_int (m_outfile
, SUBREG_BYTE (in_rtx
));
706 print_rtx_operand_code_r (in_rtx
);
709 /* Print NOTE_INSN names rather than integer codes. */
712 fprintf (m_outfile
, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx
, idx
)));
717 print_rtx_operand_code_u (in_rtx
, idx
);
721 #ifndef GENERATOR_FILE
722 if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_IMPLICIT_PTR
)
723 print_mem_expr (m_outfile
, DEBUG_IMPLICIT_PTR_DECL (in_rtx
));
724 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_PARAMETER_REF
)
725 print_mem_expr (m_outfile
, DEBUG_PARAMETER_REF_DECL (in_rtx
));
727 dump_addr (m_outfile
, " ", XTREE (in_rtx
, idx
));
732 fputs (" Unknown", m_outfile
);
737 /* Don't print basic block ids in compact mode. */
740 #ifndef GENERATOR_FILE
741 if (XBBDEF (in_rtx
, idx
))
742 fprintf (m_outfile
, " %i", XBBDEF (in_rtx
, idx
)->index
);
751 /* Subroutine of rtx_writer::print_rtx.
752 In compact mode, determine if operand IDX of IN_RTX is interesting
753 to dump, or (if in a trailing position) it can be omitted. */
756 rtx_writer::operand_has_default_value_p (const_rtx in_rtx
, int idx
)
758 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
760 switch (format_ptr
[idx
])
764 return XEXP (in_rtx
, idx
) == NULL_RTX
;
767 return XSTR (in_rtx
, idx
) == NULL
;
770 switch (GET_CODE (in_rtx
))
773 /* JUMP_LABELs are always omitted in compact mode, so treat
774 any value here as omittable, so that earlier operands can
775 potentially be omitted also. */
788 /* Print IN_RTX onto m_outfile. This is the recursive part of printing. */
791 rtx_writer::print_rtx (const_rtx in_rtx
)
798 fputc (' ', m_outfile
);
800 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
806 fputs ("(nil)", m_outfile
);
810 else if (GET_CODE (in_rtx
) > NUM_RTX_CODE
)
812 fprintf (m_outfile
, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx
),
813 print_rtx_head
, m_indent
* 2, "");
818 fputc ('(', m_outfile
);
820 /* Print name of expression code. */
823 #ifndef GENERATOR_FILE
824 if (m_rtx_reuse_manager
)
827 if (m_rtx_reuse_manager
->has_reuse_id (in_rtx
, &reuse_id
))
829 /* Have we already seen the defn of this rtx? */
830 if (m_rtx_reuse_manager
->seen_def_p (reuse_id
))
832 fprintf (m_outfile
, "reuse_rtx %i)", reuse_id
);
838 /* First time we've seen this reused-rtx. */
839 fprintf (m_outfile
, "%i|", reuse_id
);
840 m_rtx_reuse_manager
->set_seen_def (reuse_id
);
844 #endif /* #ifndef GENERATOR_FILE */
846 /* In compact mode, prefix the code of insns with "c",
847 giving "cinsn", "cnote" etc. */
848 if (m_compact
&& is_a
<const rtx_insn
*, const struct rtx_def
> (in_rtx
))
850 /* "ccode_label" is slightly awkward, so special-case it as
852 rtx_code code
= GET_CODE (in_rtx
);
853 if (code
== CODE_LABEL
)
854 fprintf (m_outfile
, "clabel");
856 fprintf (m_outfile
, "c%s", GET_RTX_NAME (code
));
858 else if (m_simple
&& CONST_INT_P (in_rtx
))
861 fprintf (m_outfile
, "%s", GET_RTX_NAME (GET_CODE (in_rtx
)));
865 if (RTX_FLAG (in_rtx
, in_struct
))
866 fputs ("/s", m_outfile
);
868 if (RTX_FLAG (in_rtx
, volatil
))
869 fputs ("/v", m_outfile
);
871 if (RTX_FLAG (in_rtx
, unchanging
))
872 fputs ("/u", m_outfile
);
874 if (RTX_FLAG (in_rtx
, frame_related
))
875 fputs ("/f", m_outfile
);
877 if (RTX_FLAG (in_rtx
, jump
))
878 fputs ("/j", m_outfile
);
880 if (RTX_FLAG (in_rtx
, call
))
881 fputs ("/c", m_outfile
);
883 if (RTX_FLAG (in_rtx
, return_val
))
884 fputs ("/i", m_outfile
);
886 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
887 if ((GET_CODE (in_rtx
) == EXPR_LIST
888 || GET_CODE (in_rtx
) == INSN_LIST
889 || GET_CODE (in_rtx
) == INT_LIST
)
890 && (int)GET_MODE (in_rtx
) < REG_NOTE_MAX
891 && !m_in_call_function_usage
)
892 fprintf (m_outfile
, ":%s",
893 GET_REG_NOTE_NAME (GET_MODE (in_rtx
)));
895 /* For other rtl, print the mode if it's not VOID. */
896 else if (GET_MODE (in_rtx
) != VOIDmode
)
897 fprintf (m_outfile
, ":%s", GET_MODE_NAME (GET_MODE (in_rtx
)));
899 #ifndef GENERATOR_FILE
900 if (GET_CODE (in_rtx
) == VAR_LOCATION
)
902 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx
)) == STRING_CST
)
903 fputs (" <debug string placeholder>", m_outfile
);
905 print_mem_expr (m_outfile
, PAT_VAR_LOCATION_DECL (in_rtx
));
906 fputc (' ', m_outfile
);
907 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx
));
908 if (PAT_VAR_LOCATION_STATUS (in_rtx
)
909 == VAR_INIT_STATUS_UNINITIALIZED
)
910 fprintf (m_outfile
, " [uninit]");
912 idx
= GET_RTX_LENGTH (VAR_LOCATION
);
917 #ifndef GENERATOR_FILE
918 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx
))
922 /* For insns, print the INSN_UID. */
923 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)))
925 if (flag_dump_unnumbered
)
926 fprintf (m_outfile
, " #");
928 fprintf (m_outfile
, " %d", INSN_UID (in_rtx
));
931 /* Determine which is the final operand to print.
932 In compact mode, skip trailing operands that have the default values
933 e.g. trailing "(nil)" values. */
934 int limit
= GET_RTX_LENGTH (GET_CODE (in_rtx
));
936 while (limit
> idx
&& operand_has_default_value_p (in_rtx
, limit
- 1))
939 /* Get the format string and skip the first elements if we have handled
942 for (; idx
< limit
; idx
++)
943 print_rtx_operand (in_rtx
, idx
);
945 switch (GET_CODE (in_rtx
))
947 #ifndef GENERATOR_FILE
949 if (UNLIKELY (final_insns_dump_p
))
950 fprintf (m_outfile
, " [");
952 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_DEC
,
953 (HOST_WIDE_INT
) MEM_ALIAS_SET (in_rtx
));
955 if (MEM_EXPR (in_rtx
))
956 print_mem_expr (m_outfile
, MEM_EXPR (in_rtx
));
958 fputc (' ', m_outfile
);
960 if (MEM_OFFSET_KNOWN_P (in_rtx
))
962 fprintf (m_outfile
, "+");
963 print_poly_int (m_outfile
, MEM_OFFSET (in_rtx
));
966 if (MEM_SIZE_KNOWN_P (in_rtx
))
968 fprintf (m_outfile
, " S");
969 print_poly_int (m_outfile
, MEM_SIZE (in_rtx
));
972 if (MEM_ALIGN (in_rtx
) != 1)
973 fprintf (m_outfile
, " A%u", MEM_ALIGN (in_rtx
));
975 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx
)))
976 fprintf (m_outfile
, " AS%u", MEM_ADDR_SPACE (in_rtx
));
978 fputc (']', m_outfile
);
982 if (FLOAT_MODE_P (GET_MODE (in_rtx
)))
986 real_to_decimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
988 fprintf (m_outfile
, " %s", s
);
990 real_to_hexadecimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
992 fprintf (m_outfile
, " [%s]", s
);
997 fprintf (m_outfile
, " ");
998 cwi_output_hex (m_outfile
, in_rtx
);
1001 case CONST_POLY_INT
:
1002 fprintf (m_outfile
, " [");
1003 print_dec (CONST_POLY_INT_COEFFS (in_rtx
)[0], m_outfile
, SIGNED
);
1004 for (unsigned int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
1006 fprintf (m_outfile
, ", ");
1007 print_dec (CONST_POLY_INT_COEFFS (in_rtx
)[i
], m_outfile
, SIGNED
);
1009 fprintf (m_outfile
, "]");
1015 fprintf (m_outfile
, " [%d uses]", LABEL_NUSES (in_rtx
));
1016 switch (LABEL_KIND (in_rtx
))
1018 case LABEL_NORMAL
: break;
1019 case LABEL_STATIC_ENTRY
: fputs (" [entry]", m_outfile
); break;
1020 case LABEL_GLOBAL_ENTRY
: fputs (" [global entry]", m_outfile
); break;
1021 case LABEL_WEAK_ENTRY
: fputs (" [weak entry]", m_outfile
); break;
1022 default: gcc_unreachable ();
1030 fputc (')', m_outfile
);
1034 /* Emit a closing parenthesis and newline. */
1037 rtx_writer::finish_directive ()
1039 fprintf (m_outfile
, ")\n");
1043 /* Print an rtx on the current line of FILE. Initially indent IND
1047 print_inline_rtx (FILE *outf
, const_rtx x
, int ind
)
1049 rtx_writer
w (outf
, ind
, false, false, NULL
);
1053 /* Call this function from the debugger to see what X looks like. */
1056 debug_rtx (const_rtx x
)
1058 rtx_writer
w (stderr
, 0, false, false, NULL
);
1060 fprintf (stderr
, "\n");
1066 debug (const rtx_def
&ref
)
1072 debug (const rtx_def
*ptr
)
1077 fprintf (stderr
, "<nil>\n");
1080 /* Like debug_rtx but with no newline, as debug_helper will add one.
1082 Note: No debug_slim(rtx_insn *) variant implemented, as this
1083 function can serve for both rtx and rtx_insn. */
1086 debug_slim (const_rtx x
)
1088 rtx_writer
w (stderr
, 0, false, false, NULL
);
1092 DEFINE_DEBUG_VEC (rtx_def
*)
1093 DEFINE_DEBUG_VEC (rtx_insn
*)
1094 DEFINE_DEBUG_HASH_SET (rtx_def
*)
1095 DEFINE_DEBUG_HASH_SET (rtx_insn
*)
1097 /* Count of rtx's to print with debug_rtx_list.
1098 This global exists because gdb user defined commands have no arguments. */
1100 DEBUG_VARIABLE
int debug_rtx_count
= 0; /* 0 is treated as equivalent to 1 */
1102 /* Call this function to print list from X on.
1104 N is a count of the rtx's to print. Positive values print from the specified
1105 rtx_insn on. Negative values print a window around the rtx_insn.
1106 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
1110 debug_rtx_list (const rtx_insn
*x
, int n
)
1113 const rtx_insn
*insn
;
1115 count
= n
== 0 ? 1 : n
< 0 ? -n
: n
;
1117 /* If we are printing a window, back up to the start. */
1120 for (i
= count
/ 2; i
> 0; i
--)
1122 if (PREV_INSN (x
) == 0)
1127 for (i
= count
, insn
= x
; i
> 0 && insn
!= 0; i
--, insn
= NEXT_INSN (insn
))
1130 fprintf (stderr
, "\n");
1134 /* Call this function to print an rtx_insn list from START to END
1138 debug_rtx_range (const rtx_insn
*start
, const rtx_insn
*end
)
1143 fprintf (stderr
, "\n");
1144 if (!start
|| start
== end
)
1146 start
= NEXT_INSN (start
);
1150 /* Call this function to search an rtx_insn list to find one with insn uid UID,
1151 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
1152 The found insn is returned to enable further debugging analysis. */
1154 DEBUG_FUNCTION
const rtx_insn
*
1155 debug_rtx_find (const rtx_insn
*x
, int uid
)
1157 while (x
!= 0 && INSN_UID (x
) != uid
)
1161 debug_rtx_list (x
, debug_rtx_count
);
1166 fprintf (stderr
, "insn uid %d not found\n", uid
);
1171 /* External entry point for printing a chain of insns
1172 starting with RTX_FIRST.
1173 A blank line separates insns.
1175 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1178 rtx_writer::print_rtl (const_rtx rtx_first
)
1180 const rtx_insn
*tmp_rtx
;
1184 fputs (print_rtx_head
, m_outfile
);
1185 fputs ("(nil)\n", m_outfile
);
1188 switch (GET_CODE (rtx_first
))
1195 case JUMP_TABLE_DATA
:
1197 for (tmp_rtx
= as_a
<const rtx_insn
*> (rtx_first
);
1199 tmp_rtx
= NEXT_INSN (tmp_rtx
))
1201 fputs (print_rtx_head
, m_outfile
);
1202 print_rtx (tmp_rtx
);
1203 fprintf (m_outfile
, "\n");
1208 fputs (print_rtx_head
, m_outfile
);
1209 print_rtx (rtx_first
);
1213 /* External entry point for printing a chain of insns
1214 starting with RTX_FIRST onto file OUTF.
1215 A blank line separates insns.
1217 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1220 print_rtl (FILE *outf
, const_rtx rtx_first
)
1222 rtx_writer
w (outf
, 0, false, false, NULL
);
1223 w
.print_rtl (rtx_first
);
1226 /* Like print_rtx, except specify a file. */
1229 print_rtl_single (FILE *outf
, const_rtx x
)
1231 rtx_writer
w (outf
, 0, false, false, NULL
);
1232 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
;
1255 /* Like print_rtl except without all the detail; for example,
1256 if RTX is a CONST_INT then print in decimal format. */
1259 print_simple_rtl (FILE *outf
, const_rtx x
)
1261 rtx_writer
w (outf
, 0, true, false, NULL
);
1265 /* Print the elements of VEC to FILE. */
1268 print_rtx_insn_vec (FILE *file
, const vec
<rtx_insn
*> &vec
)
1272 unsigned int len
= vec
.length ();
1273 for (unsigned int i
= 0; i
< len
; i
++)
1275 print_rtl_single (file
, vec
[i
]);
1283 #ifndef GENERATOR_FILE
1284 /* The functions below try to print RTL in a form resembling assembler
1285 mnemonics. Because this form is more concise than the "traditional" form
1286 of RTL printing in Lisp-style, the form printed by this file is called
1287 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
1288 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
1289 always printed in slim form.
1291 The normal interface to the functionality provided in this pretty-printer
1292 is through the dump_*_slim functions to print to a stream, or via the
1293 print_*_slim functions to print into a user's pretty-printer.
1295 It is also possible to obtain a string for a single pattern as a string
1296 pointer, via str_pattern_slim, but this usage is discouraged. */
1298 /* This recognizes rtx'en classified as expressions. These are always
1299 represent some action on values or results of other expression, that
1300 may be stored in objects representing values. */
1303 print_exp (pretty_printer
*pp
, const_rtx x
, int verbose
)
1311 for (i
= 0; i
< 4; i
++)
1317 switch (GET_CODE (x
))
1320 op
[0] = XEXP (x
, 0);
1321 if (CONST_INT_P (XEXP (x
, 1))
1322 && INTVAL (XEXP (x
, 1)) < 0)
1325 op
[1] = GEN_INT (-INTVAL (XEXP (x
, 1)));
1330 op
[1] = XEXP (x
, 1);
1334 op
[0] = XEXP (x
, 0);
1336 op
[1] = XEXP (x
, 1);
1340 op
[0] = XEXP (x
, 0);
1342 op
[1] = XEXP (x
, 1);
1346 op
[0] = XEXP (x
, 0);
1347 op
[1] = XEXP (x
, 1);
1351 op
[0] = XEXP (x
, 0);
1355 op
[0] = XEXP (x
, 0);
1357 op
[1] = XEXP (x
, 1);
1359 op
[2] = XEXP (x
, 2);
1363 op
[0] = XEXP (x
, 0);
1365 op
[1] = XEXP (x
, 1);
1368 op
[0] = XEXP (x
, 0);
1370 op
[1] = XEXP (x
, 1);
1374 op
[0] = XEXP (x
, 0);
1375 op
[1] = XEXP (x
, 1);
1378 op
[0] = XEXP (x
, 0);
1380 op
[1] = XEXP (x
, 1);
1384 op
[0] = XEXP (x
, 0);
1385 op
[1] = XEXP (x
, 1);
1389 op
[0] = XEXP (x
, 0);
1390 op
[1] = XEXP (x
, 1);
1394 op
[0] = XEXP (x
, 0);
1395 op
[1] = XEXP (x
, 1);
1399 op
[0] = XEXP (x
, 0);
1400 op
[1] = XEXP (x
, 1);
1404 op
[0] = XEXP (x
, 0);
1405 op
[1] = XEXP (x
, 1);
1409 op
[0] = XEXP (x
, 0);
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 op
[0] = XEXP (x
, 0);
1449 op
[1] = XEXP (x
, 1);
1452 op
[0] = XEXP (x
, 0);
1454 op
[1] = XEXP (x
, 1);
1457 op
[0] = XEXP (x
, 0);
1459 op
[1] = XEXP (x
, 1);
1462 op
[0] = XEXP (x
, 0);
1464 op
[1] = XEXP (x
, 1);
1467 op
[0] = XEXP (x
, 0);
1469 op
[1] = XEXP (x
, 1);
1472 op
[0] = XEXP (x
, 0);
1474 op
[1] = XEXP (x
, 1);
1477 op
[0] = XEXP (x
, 0);
1479 op
[1] = XEXP (x
, 1);
1482 fun
= (verbose
) ? "sign_extract" : "sxt";
1483 op
[0] = XEXP (x
, 0);
1484 op
[1] = XEXP (x
, 1);
1485 op
[2] = XEXP (x
, 2);
1488 fun
= (verbose
) ? "zero_extract" : "zxt";
1489 op
[0] = XEXP (x
, 0);
1490 op
[1] = XEXP (x
, 1);
1491 op
[2] = XEXP (x
, 2);
1494 fun
= (verbose
) ? "sign_extend" : "sxn";
1495 op
[0] = XEXP (x
, 0);
1498 fun
= (verbose
) ? "zero_extend" : "zxn";
1499 op
[0] = XEXP (x
, 0);
1502 fun
= (verbose
) ? "float_extend" : "fxn";
1503 op
[0] = XEXP (x
, 0);
1506 fun
= (verbose
) ? "trunc" : "trn";
1507 op
[0] = XEXP (x
, 0);
1509 case FLOAT_TRUNCATE
:
1510 fun
= (verbose
) ? "float_trunc" : "ftr";
1511 op
[0] = XEXP (x
, 0);
1514 fun
= (verbose
) ? "float" : "flt";
1515 op
[0] = XEXP (x
, 0);
1517 case UNSIGNED_FLOAT
:
1518 fun
= (verbose
) ? "uns_float" : "ufl";
1519 op
[0] = XEXP (x
, 0);
1523 op
[0] = XEXP (x
, 0);
1526 fun
= (verbose
) ? "uns_fix" : "ufx";
1527 op
[0] = XEXP (x
, 0);
1531 op
[0] = XEXP (x
, 0);
1535 op
[0] = XEXP (x
, 0);
1538 op
[0] = XEXP (x
, 0);
1542 op
[0] = XEXP (x
, 0);
1547 op
[0] = XEXP (XEXP (x
, 1), 0);
1549 op
[1] = XEXP (XEXP (x
, 1), 1);
1553 op
[0] = XEXP (XEXP (x
, 1), 0);
1555 op
[1] = XEXP (XEXP (x
, 1), 1);
1559 op
[0] = XEXP (x
, 0);
1563 op
[1] = XEXP (x
, 1);
1568 op
[0] = XEXP (x
, 0);
1570 op
[1] = XEXP (x
, 1);
1572 op
[2] = XEXP (x
, 2);
1577 op
[0] = TRAP_CONDITION (x
);
1581 op
[0] = XEXP (x
, 0);
1582 op
[1] = XEXP (x
, 1);
1583 op
[2] = XEXP (x
, 2);
1586 case UNSPEC_VOLATILE
:
1588 pp_string (pp
, "unspec");
1589 if (GET_CODE (x
) == UNSPEC_VOLATILE
)
1590 pp_string (pp
, "/v");
1591 pp_left_bracket (pp
);
1592 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1596 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1598 pp_string (pp
, "] ");
1599 pp_decimal_int (pp
, XINT (x
, 1));
1604 /* Most unhandled codes can be printed as pseudo-functions. */
1605 if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_UNARY
)
1607 fun
= GET_RTX_NAME (GET_CODE (x
));
1608 op
[0] = XEXP (x
, 0);
1610 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMPARE
1611 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_COMPARE
1612 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_BIN_ARITH
1613 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_ARITH
)
1615 fun
= GET_RTX_NAME (GET_CODE (x
));
1616 op
[0] = XEXP (x
, 0);
1617 op
[1] = XEXP (x
, 1);
1619 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_TERNARY
)
1621 fun
= GET_RTX_NAME (GET_CODE (x
));
1622 op
[0] = XEXP (x
, 0);
1623 op
[1] = XEXP (x
, 1);
1624 op
[2] = XEXP (x
, 2);
1627 /* Give up, just print the RTX name. */
1628 st
[0] = GET_RTX_NAME (GET_CODE (x
));
1633 /* Print this as a function? */
1636 pp_string (pp
, fun
);
1640 for (i
= 0; i
< 4; i
++)
1643 pp_string (pp
, st
[i
]);
1649 print_value (pp
, op
[i
], verbose
);
1654 pp_right_paren (pp
);
1657 /* Prints rtxes, I customarily classified as values. They're constants,
1658 registers, labels, symbols and memory accesses. */
1661 print_value (pretty_printer
*pp
, const_rtx x
, int verbose
)
1667 pp_string (pp
, "(nil)");
1670 switch (GET_CODE (x
))
1673 pp_scalar (pp
, HOST_WIDE_INT_PRINT_HEX
,
1674 (unsigned HOST_WIDE_INT
) INTVAL (x
));
1677 case CONST_WIDE_INT
:
1679 const char *sep
= "<";
1681 for (i
= CONST_WIDE_INT_NUNITS (x
) - 1; i
>= 0; i
--)
1683 pp_string (pp
, sep
);
1685 sprintf (tmp
, HOST_WIDE_INT_PRINT_HEX
,
1686 (unsigned HOST_WIDE_INT
) CONST_WIDE_INT_ELT (x
, i
));
1687 pp_string (pp
, tmp
);
1693 case CONST_POLY_INT
:
1694 pp_left_bracket (pp
);
1695 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[0], SIGNED
);
1696 for (unsigned int i
= 1; i
< NUM_POLY_INT_COEFFS
; ++i
)
1698 pp_string (pp
, ", ");
1699 pp_wide_int (pp
, CONST_POLY_INT_COEFFS (x
)[i
], SIGNED
);
1701 pp_right_bracket (pp
);
1705 if (FLOAT_MODE_P (GET_MODE (x
)))
1707 real_to_decimal (tmp
, CONST_DOUBLE_REAL_VALUE (x
),
1708 sizeof (tmp
), 0, 1);
1709 pp_string (pp
, tmp
);
1712 pp_printf (pp
, "<%wx,%wx>",
1713 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (x
),
1714 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_HIGH (x
));
1717 fixed_to_decimal (tmp
, CONST_FIXED_VALUE (x
), sizeof (tmp
));
1718 pp_string (pp
, tmp
);
1721 pp_string (pp
, "\"");
1722 pretty_print_string (pp
, XSTR (x
, 0), strlen (XSTR (x
, 0)));
1723 pp_string (pp
, "\"");
1726 pp_printf (pp
, "`%s'", XSTR (x
, 0));
1729 pp_printf (pp
, "L%d", INSN_UID (label_ref_label (x
)));
1733 case STRICT_LOW_PART
:
1734 pp_printf (pp
, "%s(", GET_RTX_NAME (GET_CODE (x
)));
1735 print_value (pp
, XEXP (x
, 0), verbose
);
1736 pp_right_paren (pp
);
1739 if (REGNO (x
) < FIRST_PSEUDO_REGISTER
)
1741 if (ISDIGIT (reg_names
[REGNO (x
)][0]))
1743 pp_string (pp
, reg_names
[REGNO (x
)]);
1746 pp_printf (pp
, "r%d", REGNO (x
));
1748 pp_printf (pp
, ":%s", GET_MODE_NAME (GET_MODE (x
)));
1751 print_value (pp
, SUBREG_REG (x
), verbose
);
1752 pp_printf (pp
, "#");
1753 pp_wide_integer (pp
, SUBREG_BYTE (x
));
1757 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1760 pp_left_bracket (pp
);
1761 print_value (pp
, XEXP (x
, 0), verbose
);
1762 pp_right_bracket (pp
);
1765 pp_printf (pp
, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x
)));
1768 print_exp (pp
, x
, verbose
);
1773 /* The next step in insn detalization, its pattern recognition. */
1776 print_pattern (pretty_printer
*pp
, const_rtx x
, int verbose
)
1780 pp_string (pp
, "(nil)");
1784 switch (GET_CODE (x
))
1787 print_value (pp
, SET_DEST (x
), verbose
);
1789 print_value (pp
, SET_SRC (x
), verbose
);
1794 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1797 print_exp (pp
, x
, verbose
);
1801 pp_printf (pp
, "%s ", GET_RTX_NAME (GET_CODE (x
)));
1802 print_value (pp
, XEXP (x
, 0), verbose
);
1805 pp_string (pp
, "loc ");
1806 print_value (pp
, PAT_VAR_LOCATION_LOC (x
), verbose
);
1810 if (GET_CODE (COND_EXEC_TEST (x
)) == NE
1811 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1812 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1813 else if (GET_CODE (COND_EXEC_TEST (x
)) == EQ
1814 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1816 pp_exclamation (pp
);
1817 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1820 print_value (pp
, COND_EXEC_TEST (x
), verbose
);
1821 pp_string (pp
, ") ");
1822 print_pattern (pp
, COND_EXEC_CODE (x
), verbose
);
1829 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1831 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1834 pp_right_brace (pp
);
1839 const rtx_sequence
*seq
= as_a
<const rtx_sequence
*> (x
);
1840 pp_string (pp
, "sequence{");
1841 if (INSN_P (seq
->element (0)))
1843 /* Print the sequence insns indented. */
1844 const char * save_print_rtx_head
= print_rtx_head
;
1845 char indented_print_rtx_head
[32];
1848 gcc_assert (strlen (print_rtx_head
) < sizeof (indented_print_rtx_head
) - 4);
1849 snprintf (indented_print_rtx_head
,
1850 sizeof (indented_print_rtx_head
),
1851 "%s ", print_rtx_head
);
1852 print_rtx_head
= indented_print_rtx_head
;
1853 for (int i
= 0; i
< seq
->len (); i
++)
1854 print_insn_with_notes (pp
, seq
->insn (i
));
1855 pp_printf (pp
, "%s ", save_print_rtx_head
);
1856 print_rtx_head
= save_print_rtx_head
;
1860 for (int i
= 0; i
< seq
->len (); i
++)
1862 print_pattern (pp
, seq
->element (i
), verbose
);
1866 pp_right_brace (pp
);
1870 pp_printf (pp
, "asm {%s}", XSTR (x
, 0));
1873 for (int i
= 0; i
< XVECLEN (x
, 0); i
++)
1875 print_value (pp
, XVECEXP (x
, 0, i
), verbose
);
1880 for (int i
= 0; i
< XVECLEN (x
, 1); i
++)
1882 print_value (pp
, XVECEXP (x
, 1, i
), verbose
);
1887 pp_string (pp
, "trap_if ");
1888 print_value (pp
, TRAP_CONDITION (x
), verbose
);
1891 case UNSPEC_VOLATILE
:
1892 /* Fallthru -- leave UNSPECs to print_exp. */
1894 print_value (pp
, x
, verbose
);
1896 } /* print_pattern */
1898 /* This is the main function in slim rtl visualization mechanism.
1900 X is an insn, to be printed into PP.
1902 This function tries to print it properly in human-readable form,
1903 resembling assembler mnemonics (instead of the older Lisp-style
1906 If VERBOSE is TRUE, insns are printed with more complete (but
1907 longer) pattern names and with extra information, and prefixed
1908 with their INSN_UIDs. */
1911 print_insn (pretty_printer
*pp
, const rtx_insn
*x
, int verbose
)
1915 /* Blech, pretty-print can't print integers with a specified width. */
1916 char uid_prefix
[32];
1917 snprintf (uid_prefix
, sizeof uid_prefix
, " %4d: ", INSN_UID (x
));
1918 pp_string (pp
, uid_prefix
);
1921 switch (GET_CODE (x
))
1924 print_pattern (pp
, PATTERN (x
), verbose
);
1929 if (DEBUG_MARKER_INSN_P (x
))
1931 switch (INSN_DEBUG_MARKER_KIND (x
))
1933 case NOTE_INSN_BEGIN_STMT
:
1934 pp_string (pp
, "debug begin stmt marker");
1937 case NOTE_INSN_INLINE_ENTRY
:
1938 pp_string (pp
, "debug inline entry marker");
1947 const char *name
= "?";
1950 if (DECL_P (INSN_VAR_LOCATION_DECL (x
)))
1952 tree id
= DECL_NAME (INSN_VAR_LOCATION_DECL (x
));
1954 name
= IDENTIFIER_POINTER (id
);
1955 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x
))
1958 sprintf (idbuf
, "D#%i",
1959 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x
)));
1964 sprintf (idbuf
, "D.%i",
1965 DECL_UID (INSN_VAR_LOCATION_DECL (x
)));
1969 pp_printf (pp
, "debug %s => ", name
);
1970 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x
)))
1971 pp_string (pp
, "optimized away");
1973 print_pattern (pp
, INSN_VAR_LOCATION_LOC (x
), verbose
);
1978 print_pattern (pp
, PATTERN (x
), verbose
);
1981 if (GET_CODE (PATTERN (x
)) == PARALLEL
)
1982 print_pattern (pp
, XVECEXP (PATTERN (x
), 0, 0), verbose
);
1984 print_pattern (pp
, PATTERN (x
), verbose
);
1987 pp_printf (pp
, "L%d:", INSN_UID (x
));
1989 case JUMP_TABLE_DATA
:
1990 pp_string (pp
, "jump_table_data{\n");
1991 print_pattern (pp
, PATTERN (x
), verbose
);
1992 pp_right_brace (pp
);
1995 pp_string (pp
, "barrier");
1999 pp_string (pp
, GET_NOTE_INSN_NAME (NOTE_KIND (x
)));
2000 switch (NOTE_KIND (x
))
2002 case NOTE_INSN_EH_REGION_BEG
:
2003 case NOTE_INSN_EH_REGION_END
:
2004 pp_printf (pp
, " %d", NOTE_EH_HANDLER (x
));
2007 case NOTE_INSN_BLOCK_BEG
:
2008 case NOTE_INSN_BLOCK_END
:
2009 pp_printf (pp
, " %d", BLOCK_NUMBER (NOTE_BLOCK (x
)));
2012 case NOTE_INSN_BASIC_BLOCK
:
2013 pp_printf (pp
, " %d", NOTE_BASIC_BLOCK (x
)->index
);
2016 case NOTE_INSN_DELETED_LABEL
:
2017 case NOTE_INSN_DELETED_DEBUG_LABEL
:
2019 const char *label
= NOTE_DELETED_LABEL_NAME (x
);
2022 pp_printf (pp
, " (\"%s\")", label
);
2026 case NOTE_INSN_VAR_LOCATION
:
2028 print_pattern (pp
, NOTE_VAR_LOCATION (x
), verbose
);
2029 pp_right_brace (pp
);
2042 /* Pretty-print a slim dump of X (an insn) to PP, including any register
2043 note attached to the instruction. */
2046 print_insn_with_notes (pretty_printer
*pp
, const rtx_insn
*x
)
2048 pp_string (pp
, print_rtx_head
);
2049 print_insn (pp
, x
, 1);
2051 if (INSN_P (x
) && REG_NOTES (x
))
2052 for (rtx note
= REG_NOTES (x
); note
; note
= XEXP (note
, 1))
2054 pp_printf (pp
, "%s %s ", print_rtx_head
,
2055 GET_REG_NOTE_NAME (REG_NOTE_KIND (note
)));
2056 if (GET_CODE (note
) == INT_LIST
)
2057 pp_printf (pp
, "%d", XINT (note
, 0));
2059 print_pattern (pp
, XEXP (note
, 0), 1);
2064 /* Print X, an RTL value node, to file F in slim format. Include
2065 additional information if VERBOSE is nonzero.
2067 Value nodes are constants, registers, labels, symbols and
2071 dump_value_slim (FILE *f
, const_rtx x
, int verbose
)
2073 pretty_printer rtl_slim_pp
;
2074 rtl_slim_pp
.set_output_stream (f
);
2075 print_value (&rtl_slim_pp
, x
, verbose
);
2076 pp_flush (&rtl_slim_pp
);
2079 /* Emit a slim dump of X (an insn) to the file F, including any register
2080 note attached to the instruction. */
2082 dump_insn_slim (FILE *f
, const rtx_insn
*x
)
2084 pretty_printer rtl_slim_pp
;
2085 rtl_slim_pp
.set_output_stream (f
);
2086 print_insn_with_notes (&rtl_slim_pp
, x
);
2087 pp_flush (&rtl_slim_pp
);
2090 /* Same as above, but stop at LAST or when COUNT == 0.
2091 If COUNT < 0 it will stop only at LAST or NULL rtx. */
2094 dump_rtl_slim (FILE *f
, const rtx_insn
*first
, const rtx_insn
*last
,
2095 int count
, int flags ATTRIBUTE_UNUSED
)
2097 const rtx_insn
*insn
, *tail
;
2098 pretty_printer rtl_slim_pp
;
2099 rtl_slim_pp
.set_output_stream (f
);
2101 tail
= last
? NEXT_INSN (last
) : NULL
;
2103 (insn
!= NULL
) && (insn
!= tail
) && (count
!= 0);
2104 insn
= NEXT_INSN (insn
))
2106 print_insn_with_notes (&rtl_slim_pp
, insn
);
2111 pp_flush (&rtl_slim_pp
);
2114 /* Dumps basic block BB to pretty-printer PP in slim form and without and
2115 no indentation, for use as a label of a DOT graph record-node. */
2118 rtl_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
2123 /* TODO: inter-bb stuff. */
2124 FOR_BB_INSNS (bb
, insn
)
2129 pp_write_text_to_stream (pp
);
2132 print_insn_with_notes (pp
, insn
);
2133 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2137 /* Pretty-print pattern X of some insn in non-verbose mode.
2138 Return a string pointer to the pretty-printer buffer.
2140 This function is only exported exists only to accommodate some older users
2141 of the slim RTL pretty printers. Please do not use it for new code. */
2144 str_pattern_slim (const_rtx x
)
2146 pretty_printer rtl_slim_pp
;
2147 print_pattern (&rtl_slim_pp
, x
, 0);
2148 return ggc_strdup (pp_formatted_text (&rtl_slim_pp
));
2151 /* Emit a slim dump of X (an insn) to stderr. */
2152 extern void debug_insn_slim (const rtx_insn
*);
2154 debug_insn_slim (const rtx_insn
*x
)
2156 dump_insn_slim (stderr
, x
);
2159 /* Same as above, but using dump_rtl_slim. */
2160 extern void debug_rtl_slim (FILE *, const rtx_insn
*, const rtx_insn
*,
2163 debug_rtl_slim (const rtx_insn
*first
, const rtx_insn
*last
, int count
,
2166 dump_rtl_slim (stderr
, first
, last
, count
, flags
);
2169 extern void debug_bb_slim (basic_block
);
2171 debug_bb_slim (basic_block bb
)
2173 debug_bb (bb
, TDF_SLIM
| TDF_BLOCKS
);
2176 extern void debug_bb_n_slim (int);
2178 debug_bb_n_slim (int n
)
2180 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, n
);
2187 # pragma GCC diagnostic pop