2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* This file is compiled twice: once for the generator programs,
21 once for the compiler. */
29 #include "coretypes.h"
33 /* These headers all define things which are not available in
34 generator programs. */
35 #ifndef GENERATOR_FILE
39 #include "print-tree.h"
43 #include "basic-block.h"
44 #include "diagnostic.h"
45 #include "tree-pretty-print.h"
46 #include "alloc-pool.h"
48 #include "dumpfile.h" /* for dump_flags */
49 #include "dwarf2out.h"
50 #include "pretty-print.h"
53 #include "print-rtl.h"
56 /* String printed at beginning of each RTL when it is dumped.
57 This string is set to ASM_COMMENT_START when the RTL is dumped in
58 the assembly output file. */
59 const char *print_rtx_head
= "";
62 /* These are defined from the .opt file when not used in generator
65 /* Nonzero means suppress output of instruction numbers
67 This must be defined here so that programs like gencodes can be linked. */
68 int flag_dump_unnumbered
= 0;
70 /* Nonzero means suppress output of instruction numbers for previous
71 and next insns in debugging dumps.
72 This must be defined here so that programs like gencodes can be linked. */
73 int flag_dump_unnumbered_links
= 0;
76 /* Constructor for rtx_writer. */
78 rtx_writer::rtx_writer (FILE *outf
, int ind
, bool simple
, bool compact
,
79 rtx_reuse_manager
*reuse_manager
)
80 : m_outfile (outf
), m_sawclose (0), m_indent (ind
),
81 m_in_call_function_usage (false), m_simple (simple
), m_compact (compact
),
82 m_rtx_reuse_manager (reuse_manager
)
86 #ifndef GENERATOR_FILE
88 /* rtx_reuse_manager's ctor. */
90 rtx_reuse_manager::rtx_reuse_manager ()
95 /* Determine if X is of a kind suitable for dumping via reuse_rtx. */
98 uses_rtx_reuse_p (const_rtx x
)
103 switch (GET_CODE (x
))
110 /* We don't use reuse_rtx for consts. */
117 /* Traverse X and its descendents, determining if we see any rtx more than
118 once. Any rtx suitable for "reuse_rtx" that is seen more than once is
122 rtx_reuse_manager::preprocess (const_rtx x
)
124 subrtx_iterator::array_type array
;
125 FOR_EACH_SUBRTX (iter
, array
, x
, NONCONST
)
126 if (uses_rtx_reuse_p (*iter
))
128 if (int *count
= m_rtx_occurrence_count
.get (*iter
))
131 m_rtx_reuse_ids
.put (*iter
, m_next_id
++);
134 m_rtx_occurrence_count
.put (*iter
, 1);
138 /* Return true iff X has been assigned a reuse ID. If it has,
139 and OUT is non-NULL, then write the reuse ID to *OUT. */
142 rtx_reuse_manager::has_reuse_id (const_rtx x
, int *out
)
144 int *id
= m_rtx_reuse_ids
.get (x
);
155 /* Determine if set_seen_def has been called for the given reuse ID. */
158 rtx_reuse_manager::seen_def_p (int reuse_id
)
160 return bitmap_bit_p (m_defs_seen
, reuse_id
);
163 /* Record that the definition of the given reuse ID has been seen. */
166 rtx_reuse_manager::set_seen_def (int reuse_id
)
168 bitmap_set_bit (m_defs_seen
, reuse_id
);
171 #endif /* #ifndef GENERATOR_FILE */
173 #ifndef GENERATOR_FILE
175 print_mem_expr (FILE *outfile
, const_tree expr
)
177 fputc (' ', outfile
);
178 print_generic_expr (outfile
, CONST_CAST_TREE (expr
), dump_flags
);
182 /* Subroutine of print_rtx_operand for handling code '0'.
183 0 indicates a field for internal use that should not be printed.
184 However there are various special cases, such as the third field
185 of a NOTE, where it indicates that the field has several different
189 rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED
,
190 int idx ATTRIBUTE_UNUSED
)
192 #ifndef GENERATOR_FILE
193 if (idx
== 1 && GET_CODE (in_rtx
) == SYMBOL_REF
)
195 int flags
= SYMBOL_REF_FLAGS (in_rtx
);
197 fprintf (m_outfile
, " [flags %#x]", flags
);
198 tree decl
= SYMBOL_REF_DECL (in_rtx
);
200 print_node_brief (m_outfile
, "", decl
, dump_flags
);
202 else if (idx
== 3 && NOTE_P (in_rtx
))
204 switch (NOTE_KIND (in_rtx
))
206 case NOTE_INSN_EH_REGION_BEG
:
207 case NOTE_INSN_EH_REGION_END
:
208 if (flag_dump_unnumbered
)
209 fprintf (m_outfile
, " #");
211 fprintf (m_outfile
, " %d", NOTE_EH_HANDLER (in_rtx
));
215 case NOTE_INSN_BLOCK_BEG
:
216 case NOTE_INSN_BLOCK_END
:
217 dump_addr (m_outfile
, " ", NOTE_BLOCK (in_rtx
));
221 case NOTE_INSN_BASIC_BLOCK
:
223 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
225 fprintf (m_outfile
, " [bb %d]", bb
->index
);
229 case NOTE_INSN_DELETED_LABEL
:
230 case NOTE_INSN_DELETED_DEBUG_LABEL
:
232 const char *label
= NOTE_DELETED_LABEL_NAME (in_rtx
);
234 fprintf (m_outfile
, " (\"%s\")", label
);
236 fprintf (m_outfile
, " \"\"");
240 case NOTE_INSN_SWITCH_TEXT_SECTIONS
:
242 basic_block bb
= NOTE_BASIC_BLOCK (in_rtx
);
244 fprintf (m_outfile
, " [bb %d]", bb
->index
);
248 case NOTE_INSN_VAR_LOCATION
:
249 case NOTE_INSN_CALL_ARG_LOCATION
:
250 fputc (' ', m_outfile
);
251 print_rtx (NOTE_VAR_LOCATION (in_rtx
));
255 fputc ('\n', m_outfile
);
256 output_cfi_directive (m_outfile
, NOTE_CFI (in_rtx
));
257 fputc ('\t', m_outfile
);
264 else if (idx
== 7 && JUMP_P (in_rtx
) && JUMP_LABEL (in_rtx
) != NULL
267 /* Output the JUMP_LABEL reference. */
268 fprintf (m_outfile
, "\n%s%*s -> ", print_rtx_head
, m_indent
* 2, "");
269 if (GET_CODE (JUMP_LABEL (in_rtx
)) == RETURN
)
270 fprintf (m_outfile
, "return");
271 else if (GET_CODE (JUMP_LABEL (in_rtx
)) == SIMPLE_RETURN
)
272 fprintf (m_outfile
, "simple_return");
274 fprintf (m_outfile
, "%d", INSN_UID (JUMP_LABEL (in_rtx
)));
276 else if (idx
== 0 && GET_CODE (in_rtx
) == VALUE
)
278 cselib_val
*val
= CSELIB_VAL_PTR (in_rtx
);
280 fprintf (m_outfile
, " %u:%u", val
->uid
, val
->hash
);
281 dump_addr (m_outfile
, " @", in_rtx
);
282 dump_addr (m_outfile
, "/", (void*)val
);
284 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_EXPR
)
286 fprintf (m_outfile
, " D#%i",
287 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx
)));
289 else if (idx
== 0 && GET_CODE (in_rtx
) == ENTRY_VALUE
)
293 fprintf (m_outfile
, " ");
294 print_rtx (ENTRY_VALUE_EXP (in_rtx
));
300 /* Subroutine of print_rtx_operand for handling code 'e'.
301 Also called by print_rtx_operand_code_u for handling code 'u'
302 for LABEL_REFs when they don't reference a CODE_LABEL. */
305 rtx_writer::print_rtx_operand_code_e (const_rtx in_rtx
, int idx
)
308 if (idx
== 6 && INSN_P (in_rtx
))
309 /* Put REG_NOTES on their own line. */
310 fprintf (m_outfile
, "\n%s%*s",
311 print_rtx_head
, m_indent
* 2, "");
313 fprintf (m_outfile
, " ");
314 if (idx
== 7 && CALL_P (in_rtx
))
316 m_in_call_function_usage
= true;
317 print_rtx (XEXP (in_rtx
, idx
));
318 m_in_call_function_usage
= false;
321 print_rtx (XEXP (in_rtx
, idx
));
325 /* Subroutine of print_rtx_operand for handling codes 'E' and 'V'. */
328 rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx
, int idx
)
333 fprintf (m_outfile
, "\n%s%*s",
334 print_rtx_head
, m_indent
* 2, "");
337 fputs (" [", m_outfile
);
338 if (NULL
!= XVEC (in_rtx
, idx
))
341 if (XVECLEN (in_rtx
, idx
))
344 for (int j
= 0; j
< XVECLEN (in_rtx
, idx
); j
++)
345 print_rtx (XVECEXP (in_rtx
, idx
, j
));
350 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
352 fputs ("]", m_outfile
);
357 /* Subroutine of print_rtx_operand for handling code 'i'. */
360 rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx
, int idx
)
362 if (idx
== 4 && INSN_P (in_rtx
))
364 #ifndef GENERATOR_FILE
365 const rtx_insn
*in_insn
= as_a
<const rtx_insn
*> (in_rtx
);
367 /* Pretty-print insn locations. Ignore scoping as it is mostly
368 redundant with line number information and do not print anything
369 when there is no location information available. */
370 if (INSN_HAS_LOCATION (in_insn
))
372 expanded_location xloc
= insn_location (in_insn
);
373 fprintf (m_outfile
, " \"%s\":%i", xloc
.file
, xloc
.line
);
377 else if (idx
== 6 && GET_CODE (in_rtx
) == ASM_OPERANDS
)
379 #ifndef GENERATOR_FILE
380 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
381 fprintf (m_outfile
, " %s:%i",
382 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)),
383 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx
)));
386 else if (idx
== 1 && GET_CODE (in_rtx
) == ASM_INPUT
)
388 #ifndef GENERATOR_FILE
389 if (ASM_INPUT_SOURCE_LOCATION (in_rtx
) != UNKNOWN_LOCATION
)
390 fprintf (m_outfile
, " %s:%i",
391 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)),
392 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx
)));
395 else if (idx
== 5 && NOTE_P (in_rtx
))
397 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
398 other times often contains garbage from INSN->NOTE death. */
399 if (NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_LABEL
400 || NOTE_KIND (in_rtx
) == NOTE_INSN_DELETED_DEBUG_LABEL
)
401 fprintf (m_outfile
, " %d", XINT (in_rtx
, idx
));
403 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
405 && GET_CODE (in_rtx
) == UNSPEC_VOLATILE
406 && XINT (in_rtx
, 1) >= 0
407 && XINT (in_rtx
, 1) < NUM_UNSPECV_VALUES
)
408 fprintf (m_outfile
, " %s", unspecv_strings
[XINT (in_rtx
, 1)]);
410 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
412 && (GET_CODE (in_rtx
) == UNSPEC
413 || GET_CODE (in_rtx
) == UNSPEC_VOLATILE
)
414 && XINT (in_rtx
, 1) >= 0
415 && XINT (in_rtx
, 1) < NUM_UNSPEC_VALUES
)
416 fprintf (m_outfile
, " %s", unspec_strings
[XINT (in_rtx
, 1)]);
420 int value
= XINT (in_rtx
, idx
);
422 int is_insn
= INSN_P (in_rtx
);
424 /* Don't print INSN_CODEs in compact mode. */
425 if (m_compact
&& is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
))
431 if (flag_dump_unnumbered
432 && (is_insn
|| NOTE_P (in_rtx
)))
433 fputc ('#', m_outfile
);
435 fprintf (m_outfile
, " %d", value
);
437 if (is_insn
&& &INSN_CODE (in_rtx
) == &XINT (in_rtx
, idx
)
438 && XINT (in_rtx
, idx
) >= 0
439 && (name
= get_insn_name (XINT (in_rtx
, idx
))) != NULL
)
440 fprintf (m_outfile
, " {%s}", name
);
445 /* Subroutine of print_rtx_operand for handling code 'r'. */
448 rtx_writer::print_rtx_operand_code_r (const_rtx in_rtx
)
450 int is_insn
= INSN_P (in_rtx
);
451 unsigned int regno
= REGNO (in_rtx
);
453 #ifndef GENERATOR_FILE
454 /* For hard registers and virtuals, always print the
455 regno, except in compact mode. */
456 if (regno
<= LAST_VIRTUAL_REGISTER
&& !m_compact
)
457 fprintf (m_outfile
, " %d", regno
);
458 if (regno
< FIRST_PSEUDO_REGISTER
)
459 fprintf (m_outfile
, " %s", reg_names
[regno
]);
460 else if (regno
<= LAST_VIRTUAL_REGISTER
)
462 if (regno
== VIRTUAL_INCOMING_ARGS_REGNUM
)
463 fprintf (m_outfile
, " virtual-incoming-args");
464 else if (regno
== VIRTUAL_STACK_VARS_REGNUM
)
465 fprintf (m_outfile
, " virtual-stack-vars");
466 else if (regno
== VIRTUAL_STACK_DYNAMIC_REGNUM
)
467 fprintf (m_outfile
, " virtual-stack-dynamic");
468 else if (regno
== VIRTUAL_OUTGOING_ARGS_REGNUM
)
469 fprintf (m_outfile
, " virtual-outgoing-args");
470 else if (regno
== VIRTUAL_CFA_REGNUM
)
471 fprintf (m_outfile
, " virtual-cfa");
472 else if (regno
== VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM
)
473 fprintf (m_outfile
, " virtual-preferred-stack-boundary");
475 fprintf (m_outfile
, " virtual-reg-%d", regno
-FIRST_VIRTUAL_REGISTER
);
479 if (flag_dump_unnumbered
&& is_insn
)
480 fputc ('#', m_outfile
);
483 /* In compact mode, print pseudos with '< and '>' wrapping the regno,
484 offseting it by (LAST_VIRTUAL_REGISTER + 1), so that the
485 first non-virtual pseudo is dumped as "<0>". */
486 gcc_assert (regno
> LAST_VIRTUAL_REGISTER
);
487 fprintf (m_outfile
, " <%d>", regno
- (LAST_VIRTUAL_REGISTER
+ 1));
490 fprintf (m_outfile
, " %d", regno
);
492 #ifndef GENERATOR_FILE
493 if (REG_ATTRS (in_rtx
))
495 fputs (" [", m_outfile
);
496 if (regno
!= ORIGINAL_REGNO (in_rtx
))
497 fprintf (m_outfile
, "orig:%i", ORIGINAL_REGNO (in_rtx
));
498 if (REG_EXPR (in_rtx
))
499 print_mem_expr (m_outfile
, REG_EXPR (in_rtx
));
501 if (REG_OFFSET (in_rtx
))
502 fprintf (m_outfile
, "+" HOST_WIDE_INT_PRINT_DEC
,
503 REG_OFFSET (in_rtx
));
504 fputs (" ]", m_outfile
);
506 if (regno
!= ORIGINAL_REGNO (in_rtx
))
507 fprintf (m_outfile
, " [%d]", ORIGINAL_REGNO (in_rtx
));
511 /* Subroutine of print_rtx_operand for handling code 'u'. */
514 rtx_writer::print_rtx_operand_code_u (const_rtx in_rtx
, int idx
)
516 /* Don't print insn UIDs for PREV/NEXT_INSN in compact mode. */
517 if (m_compact
&& INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)) && idx
< 2)
520 if (XEXP (in_rtx
, idx
) != NULL
)
522 rtx sub
= XEXP (in_rtx
, idx
);
523 enum rtx_code subc
= GET_CODE (sub
);
525 if (GET_CODE (in_rtx
) == LABEL_REF
)
528 && NOTE_KIND (sub
) == NOTE_INSN_DELETED_LABEL
)
530 if (flag_dump_unnumbered
)
531 fprintf (m_outfile
, " [# deleted]");
533 fprintf (m_outfile
, " [%d deleted]", INSN_UID (sub
));
538 if (subc
!= CODE_LABEL
)
540 print_rtx_operand_code_e (in_rtx
, idx
);
545 if (flag_dump_unnumbered
546 || (flag_dump_unnumbered_links
&& idx
<= 1
547 && (INSN_P (in_rtx
) || NOTE_P (in_rtx
)
548 || LABEL_P (in_rtx
) || BARRIER_P (in_rtx
))))
549 fputs (" #", m_outfile
);
551 fprintf (m_outfile
, " %d", INSN_UID (sub
));
554 fputs (" 0", m_outfile
);
558 /* Subroutine of print_rtx. Print operand IDX of IN_RTX. */
561 rtx_writer::print_rtx_operand (const_rtx in_rtx
, int idx
)
563 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
565 switch (format_ptr
[idx
])
570 str
= XTMPL (in_rtx
, idx
);
575 str
= XSTR (in_rtx
, idx
);
579 fputs (" (nil)", m_outfile
);
581 fprintf (m_outfile
, " (\"%s\")", str
);
586 print_rtx_operand_code_0 (in_rtx
, idx
);
590 print_rtx_operand_code_e (in_rtx
, idx
);
595 print_rtx_operand_codes_E_and_V (in_rtx
, idx
);
600 fprintf (m_outfile
, " ");
601 fprintf (m_outfile
, HOST_WIDE_INT_PRINT_DEC
, XWINT (in_rtx
, idx
));
602 if (! m_simple
&& !m_compact
)
603 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_HEX
"]",
604 (unsigned HOST_WIDE_INT
) XWINT (in_rtx
, idx
));
608 print_rtx_operand_code_i (in_rtx
, idx
);
612 print_rtx_operand_code_r (in_rtx
);
615 /* Print NOTE_INSN names rather than integer codes. */
618 fprintf (m_outfile
, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx
, idx
)));
623 print_rtx_operand_code_u (in_rtx
, idx
);
627 #ifndef GENERATOR_FILE
628 if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_IMPLICIT_PTR
)
629 print_mem_expr (m_outfile
, DEBUG_IMPLICIT_PTR_DECL (in_rtx
));
630 else if (idx
== 0 && GET_CODE (in_rtx
) == DEBUG_PARAMETER_REF
)
631 print_mem_expr (m_outfile
, DEBUG_PARAMETER_REF_DECL (in_rtx
));
633 dump_addr (m_outfile
, " ", XTREE (in_rtx
, idx
));
638 fputs (" Unknown", m_outfile
);
643 /* Don't print basic block ids in compact mode. */
646 #ifndef GENERATOR_FILE
647 if (XBBDEF (in_rtx
, idx
))
648 fprintf (m_outfile
, " %i", XBBDEF (in_rtx
, idx
)->index
);
657 /* Subroutine of rtx_writer::print_rtx.
658 In compact mode, determine if operand IDX of IN_RTX is interesting
659 to dump, or (if in a trailing position) it can be omitted. */
662 rtx_writer::operand_has_default_value_p (const_rtx in_rtx
, int idx
)
664 const char *format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
666 switch (format_ptr
[idx
])
670 return XEXP (in_rtx
, idx
) == NULL_RTX
;
673 return XSTR (in_rtx
, idx
) == NULL
;
676 switch (GET_CODE (in_rtx
))
679 /* JUMP_LABELs are always omitted in compact mode, so treat
680 any value here as omittable, so that earlier operands can
681 potentially be omitted also. */
694 /* Print IN_RTX onto m_outfile. This is the recursive part of printing. */
697 rtx_writer::print_rtx (const_rtx in_rtx
)
704 fputc (' ', m_outfile
);
706 fprintf (m_outfile
, "\n%s%*s", print_rtx_head
, m_indent
* 2, "");
712 fputs ("(nil)", m_outfile
);
716 else if (GET_CODE (in_rtx
) > NUM_RTX_CODE
)
718 fprintf (m_outfile
, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx
),
719 print_rtx_head
, m_indent
* 2, "");
724 fputc ('(', m_outfile
);
726 /* Print name of expression code. */
729 #ifndef GENERATOR_FILE
730 if (m_rtx_reuse_manager
)
733 if (m_rtx_reuse_manager
->has_reuse_id (in_rtx
, &reuse_id
))
735 /* Have we already seen the defn of this rtx? */
736 if (m_rtx_reuse_manager
->seen_def_p (reuse_id
))
738 fprintf (m_outfile
, "reuse_rtx %i)", reuse_id
);
744 /* First time we've seen this reused-rtx. */
745 fprintf (m_outfile
, "%i|", reuse_id
);
746 m_rtx_reuse_manager
->set_seen_def (reuse_id
);
750 #endif /* #ifndef GENERATOR_FILE */
752 /* In compact mode, prefix the code of insns with "c",
753 giving "cinsn", "cnote" etc. */
754 if (m_compact
&& is_a
<const rtx_insn
*, const struct rtx_def
> (in_rtx
))
756 /* "ccode_label" is slightly awkward, so special-case it as
758 rtx_code code
= GET_CODE (in_rtx
);
759 if (code
== CODE_LABEL
)
760 fprintf (m_outfile
, "clabel");
762 fprintf (m_outfile
, "c%s", GET_RTX_NAME (code
));
764 else if (m_simple
&& CONST_INT_P (in_rtx
))
767 fprintf (m_outfile
, "%s", GET_RTX_NAME (GET_CODE (in_rtx
)));
771 if (RTX_FLAG (in_rtx
, in_struct
))
772 fputs ("/s", m_outfile
);
774 if (RTX_FLAG (in_rtx
, volatil
))
775 fputs ("/v", m_outfile
);
777 if (RTX_FLAG (in_rtx
, unchanging
))
778 fputs ("/u", m_outfile
);
780 if (RTX_FLAG (in_rtx
, frame_related
))
781 fputs ("/f", m_outfile
);
783 if (RTX_FLAG (in_rtx
, jump
))
784 fputs ("/j", m_outfile
);
786 if (RTX_FLAG (in_rtx
, call
))
787 fputs ("/c", m_outfile
);
789 if (RTX_FLAG (in_rtx
, return_val
))
790 fputs ("/i", m_outfile
);
792 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
793 if ((GET_CODE (in_rtx
) == EXPR_LIST
794 || GET_CODE (in_rtx
) == INSN_LIST
795 || GET_CODE (in_rtx
) == INT_LIST
)
796 && (int)GET_MODE (in_rtx
) < REG_NOTE_MAX
797 && !m_in_call_function_usage
)
798 fprintf (m_outfile
, ":%s",
799 GET_REG_NOTE_NAME (GET_MODE (in_rtx
)));
801 /* For other rtl, print the mode if it's not VOID. */
802 else if (GET_MODE (in_rtx
) != VOIDmode
)
803 fprintf (m_outfile
, ":%s", GET_MODE_NAME (GET_MODE (in_rtx
)));
805 #ifndef GENERATOR_FILE
806 if (GET_CODE (in_rtx
) == VAR_LOCATION
)
808 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx
)) == STRING_CST
)
809 fputs (" <debug string placeholder>", m_outfile
);
811 print_mem_expr (m_outfile
, PAT_VAR_LOCATION_DECL (in_rtx
));
812 fputc (' ', m_outfile
);
813 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx
));
814 if (PAT_VAR_LOCATION_STATUS (in_rtx
)
815 == VAR_INIT_STATUS_UNINITIALIZED
)
816 fprintf (m_outfile
, " [uninit]");
818 idx
= GET_RTX_LENGTH (VAR_LOCATION
);
823 #ifndef GENERATOR_FILE
824 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx
))
828 /* For insns, print the INSN_UID. */
829 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx
)))
831 if (flag_dump_unnumbered
)
832 fprintf (m_outfile
, " #");
834 fprintf (m_outfile
, " %d", INSN_UID (in_rtx
));
837 /* Determine which is the final operand to print.
838 In compact mode, skip trailing operands that have the default values
839 e.g. trailing "(nil)" values. */
840 int limit
= GET_RTX_LENGTH (GET_CODE (in_rtx
));
842 while (limit
> idx
&& operand_has_default_value_p (in_rtx
, limit
- 1))
845 /* Get the format string and skip the first elements if we have handled
848 for (; idx
< limit
; idx
++)
849 print_rtx_operand (in_rtx
, idx
);
851 switch (GET_CODE (in_rtx
))
853 #ifndef GENERATOR_FILE
855 if (__builtin_expect (final_insns_dump_p
, false))
856 fprintf (m_outfile
, " [");
858 fprintf (m_outfile
, " [" HOST_WIDE_INT_PRINT_DEC
,
859 (HOST_WIDE_INT
) MEM_ALIAS_SET (in_rtx
));
861 if (MEM_EXPR (in_rtx
))
862 print_mem_expr (m_outfile
, MEM_EXPR (in_rtx
));
864 fputc (' ', m_outfile
);
866 if (MEM_OFFSET_KNOWN_P (in_rtx
))
867 fprintf (m_outfile
, "+" HOST_WIDE_INT_PRINT_DEC
, MEM_OFFSET (in_rtx
));
869 if (MEM_SIZE_KNOWN_P (in_rtx
))
870 fprintf (m_outfile
, " S" HOST_WIDE_INT_PRINT_DEC
, MEM_SIZE (in_rtx
));
872 if (MEM_ALIGN (in_rtx
) != 1)
873 fprintf (m_outfile
, " A%u", MEM_ALIGN (in_rtx
));
875 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx
)))
876 fprintf (m_outfile
, " AS%u", MEM_ADDR_SPACE (in_rtx
));
878 fputc (']', m_outfile
);
882 if (FLOAT_MODE_P (GET_MODE (in_rtx
)))
886 real_to_decimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
888 fprintf (m_outfile
, " %s", s
);
890 real_to_hexadecimal (s
, CONST_DOUBLE_REAL_VALUE (in_rtx
),
892 fprintf (m_outfile
, " [%s]", s
);
897 fprintf (m_outfile
, " ");
898 cwi_output_hex (m_outfile
, in_rtx
);
904 fprintf (m_outfile
, " [%d uses]", LABEL_NUSES (in_rtx
));
905 switch (LABEL_KIND (in_rtx
))
907 case LABEL_NORMAL
: break;
908 case LABEL_STATIC_ENTRY
: fputs (" [entry]", m_outfile
); break;
909 case LABEL_GLOBAL_ENTRY
: fputs (" [global entry]", m_outfile
); break;
910 case LABEL_WEAK_ENTRY
: fputs (" [weak entry]", m_outfile
); break;
911 default: gcc_unreachable ();
919 fputc (')', m_outfile
);
923 /* Emit a closing parenthesis and newline. */
926 rtx_writer::finish_directive ()
928 fprintf (m_outfile
, ")\n");
932 /* Print an rtx on the current line of FILE. Initially indent IND
936 print_inline_rtx (FILE *outf
, const_rtx x
, int ind
)
938 rtx_writer
w (outf
, ind
, false, false, NULL
);
942 /* Call this function from the debugger to see what X looks like. */
945 debug_rtx (const_rtx x
)
947 rtx_writer
w (stderr
, 0, false, false, NULL
);
949 fprintf (stderr
, "\n");
955 debug (const rtx_def
&ref
)
961 debug (const rtx_def
*ptr
)
966 fprintf (stderr
, "<nil>\n");
969 /* Count of rtx's to print with debug_rtx_list.
970 This global exists because gdb user defined commands have no arguments. */
972 DEBUG_VARIABLE
int debug_rtx_count
= 0; /* 0 is treated as equivalent to 1 */
974 /* Call this function to print list from X on.
976 N is a count of the rtx's to print. Positive values print from the specified
977 rtx_insn on. Negative values print a window around the rtx_insn.
978 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
982 debug_rtx_list (const rtx_insn
*x
, int n
)
985 const rtx_insn
*insn
;
987 count
= n
== 0 ? 1 : n
< 0 ? -n
: n
;
989 /* If we are printing a window, back up to the start. */
992 for (i
= count
/ 2; i
> 0; i
--)
994 if (PREV_INSN (x
) == 0)
999 for (i
= count
, insn
= x
; i
> 0 && insn
!= 0; i
--, insn
= NEXT_INSN (insn
))
1002 fprintf (stderr
, "\n");
1006 /* Call this function to print an rtx_insn list from START to END
1010 debug_rtx_range (const rtx_insn
*start
, const rtx_insn
*end
)
1015 fprintf (stderr
, "\n");
1016 if (!start
|| start
== end
)
1018 start
= NEXT_INSN (start
);
1022 /* Call this function to search an rtx_insn list to find one with insn uid UID,
1023 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
1024 The found insn is returned to enable further debugging analysis. */
1026 DEBUG_FUNCTION
const rtx_insn
*
1027 debug_rtx_find (const rtx_insn
*x
, int uid
)
1029 while (x
!= 0 && INSN_UID (x
) != uid
)
1033 debug_rtx_list (x
, debug_rtx_count
);
1038 fprintf (stderr
, "insn uid %d not found\n", uid
);
1043 /* External entry point for printing a chain of insns
1044 starting with RTX_FIRST.
1045 A blank line separates insns.
1047 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1050 rtx_writer::print_rtl (const_rtx rtx_first
)
1052 const rtx_insn
*tmp_rtx
;
1056 fputs (print_rtx_head
, m_outfile
);
1057 fputs ("(nil)\n", m_outfile
);
1060 switch (GET_CODE (rtx_first
))
1067 case JUMP_TABLE_DATA
:
1069 for (tmp_rtx
= as_a
<const rtx_insn
*> (rtx_first
);
1071 tmp_rtx
= NEXT_INSN (tmp_rtx
))
1073 fputs (print_rtx_head
, m_outfile
);
1074 print_rtx (tmp_rtx
);
1075 fprintf (m_outfile
, "\n");
1080 fputs (print_rtx_head
, m_outfile
);
1081 print_rtx (rtx_first
);
1085 /* External entry point for printing a chain of insns
1086 starting with RTX_FIRST onto file OUTF.
1087 A blank line separates insns.
1089 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
1092 print_rtl (FILE *outf
, const_rtx rtx_first
)
1094 rtx_writer
w (outf
, 0, false, false, NULL
);
1095 w
.print_rtl (rtx_first
);
1098 /* Like print_rtx, except specify a file. */
1099 /* Return nonzero if we actually printed anything. */
1102 print_rtl_single (FILE *outf
, const_rtx x
)
1104 rtx_writer
w (outf
, 0, false, false, NULL
);
1105 return w
.print_rtl_single_with_indent (x
, 0);
1108 /* Like print_rtl_single, except specify an indentation. */
1111 rtx_writer::print_rtl_single_with_indent (const_rtx x
, int ind
)
1113 char *s_indent
= (char *) alloca ((size_t) ind
+ 1);
1114 memset ((void *) s_indent
, ' ', (size_t) ind
);
1115 s_indent
[ind
] = '\0';
1116 fputs (s_indent
, m_outfile
);
1117 fputs (print_rtx_head
, m_outfile
);
1119 int old_indent
= m_indent
;
1123 putc ('\n', m_outfile
);
1124 m_indent
= old_indent
;
1129 /* Like print_rtl except without all the detail; for example,
1130 if RTX is a CONST_INT then print in decimal format. */
1133 print_simple_rtl (FILE *outf
, const_rtx x
)
1135 rtx_writer
w (outf
, 0, true, false, NULL
);
1139 /* Print the elements of VEC to FILE. */
1142 print_rtx_insn_vec (FILE *file
, const vec
<rtx_insn
*> &vec
)
1146 unsigned int len
= vec
.length ();
1147 for (unsigned int i
= 0; i
< len
; i
++)
1149 print_rtl (file
, vec
[i
]);
1157 #ifndef GENERATOR_FILE
1158 /* The functions below try to print RTL in a form resembling assembler
1159 mnemonics. Because this form is more concise than the "traditional" form
1160 of RTL printing in Lisp-style, the form printed by this file is called
1161 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
1162 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
1163 always printed in slim form.
1165 The normal interface to the functionality provided in this pretty-printer
1166 is through the dump_*_slim functions to print to a stream, or via the
1167 print_*_slim functions to print into a user's pretty-printer.
1169 It is also possible to obtain a string for a single pattern as a string
1170 pointer, via str_pattern_slim, but this usage is discouraged. */
1172 /* For insns we print patterns, and for some patterns we print insns... */
1173 static void print_insn_with_notes (pretty_printer
*, const rtx_insn
*);
1175 /* This recognizes rtx'en classified as expressions. These are always
1176 represent some action on values or results of other expression, that
1177 may be stored in objects representing values. */
1180 print_exp (pretty_printer
*pp
, const_rtx x
, int verbose
)
1188 for (i
= 0; i
< 4; i
++)
1194 switch (GET_CODE (x
))
1197 op
[0] = XEXP (x
, 0);
1198 if (CONST_INT_P (XEXP (x
, 1))
1199 && INTVAL (XEXP (x
, 1)) < 0)
1202 op
[1] = GEN_INT (-INTVAL (XEXP (x
, 1)));
1207 op
[1] = XEXP (x
, 1);
1211 op
[0] = XEXP (x
, 0);
1213 op
[1] = XEXP (x
, 1);
1217 op
[0] = XEXP (x
, 0);
1219 op
[1] = XEXP (x
, 1);
1223 op
[0] = XEXP (x
, 0);
1224 op
[1] = XEXP (x
, 1);
1228 op
[0] = XEXP (x
, 0);
1232 op
[0] = XEXP (x
, 0);
1234 op
[1] = XEXP (x
, 1);
1236 op
[2] = XEXP (x
, 2);
1240 op
[0] = XEXP (x
, 0);
1242 op
[1] = XEXP (x
, 1);
1245 op
[0] = XEXP (x
, 0);
1247 op
[1] = XEXP (x
, 1);
1251 op
[0] = XEXP (x
, 0);
1252 op
[1] = XEXP (x
, 1);
1255 op
[0] = XEXP (x
, 0);
1257 op
[1] = XEXP (x
, 1);
1261 op
[0] = XEXP (x
, 0);
1262 op
[1] = XEXP (x
, 1);
1266 op
[0] = XEXP (x
, 0);
1267 op
[1] = XEXP (x
, 1);
1271 op
[0] = XEXP (x
, 0);
1272 op
[1] = XEXP (x
, 1);
1276 op
[0] = XEXP (x
, 0);
1277 op
[1] = XEXP (x
, 1);
1281 op
[0] = XEXP (x
, 0);
1282 op
[1] = XEXP (x
, 1);
1286 op
[0] = XEXP (x
, 0);
1289 op
[0] = XEXP (x
, 0);
1291 op
[1] = XEXP (x
, 1);
1294 op
[0] = XEXP (x
, 0);
1296 op
[1] = XEXP (x
, 1);
1299 op
[0] = XEXP (x
, 0);
1301 op
[1] = XEXP (x
, 1);
1304 op
[0] = XEXP (x
, 0);
1306 op
[1] = XEXP (x
, 1);
1309 op
[0] = XEXP (x
, 0);
1311 op
[1] = XEXP (x
, 1);
1314 op
[0] = XEXP (x
, 0);
1316 op
[1] = XEXP (x
, 1);
1319 op
[0] = XEXP (x
, 0);
1321 op
[1] = XEXP (x
, 1);
1324 op
[0] = XEXP (x
, 0);
1326 op
[1] = XEXP (x
, 1);
1329 op
[0] = XEXP (x
, 0);
1331 op
[1] = XEXP (x
, 1);
1334 op
[0] = XEXP (x
, 0);
1336 op
[1] = XEXP (x
, 1);
1339 op
[0] = XEXP (x
, 0);
1341 op
[1] = XEXP (x
, 1);
1344 op
[0] = XEXP (x
, 0);
1346 op
[1] = XEXP (x
, 1);
1349 op
[0] = XEXP (x
, 0);
1351 op
[1] = XEXP (x
, 1);
1354 op
[0] = XEXP (x
, 0);
1356 op
[1] = XEXP (x
, 1);
1359 fun
= (verbose
) ? "sign_extract" : "sxt";
1360 op
[0] = XEXP (x
, 0);
1361 op
[1] = XEXP (x
, 1);
1362 op
[2] = XEXP (x
, 2);
1365 fun
= (verbose
) ? "zero_extract" : "zxt";
1366 op
[0] = XEXP (x
, 0);
1367 op
[1] = XEXP (x
, 1);
1368 op
[2] = XEXP (x
, 2);
1371 fun
= (verbose
) ? "sign_extend" : "sxn";
1372 op
[0] = XEXP (x
, 0);
1375 fun
= (verbose
) ? "zero_extend" : "zxn";
1376 op
[0] = XEXP (x
, 0);
1379 fun
= (verbose
) ? "float_extend" : "fxn";
1380 op
[0] = XEXP (x
, 0);
1383 fun
= (verbose
) ? "trunc" : "trn";
1384 op
[0] = XEXP (x
, 0);
1386 case FLOAT_TRUNCATE
:
1387 fun
= (verbose
) ? "float_trunc" : "ftr";
1388 op
[0] = XEXP (x
, 0);
1391 fun
= (verbose
) ? "float" : "flt";
1392 op
[0] = XEXP (x
, 0);
1394 case UNSIGNED_FLOAT
:
1395 fun
= (verbose
) ? "uns_float" : "ufl";
1396 op
[0] = XEXP (x
, 0);
1400 op
[0] = XEXP (x
, 0);
1403 fun
= (verbose
) ? "uns_fix" : "ufx";
1404 op
[0] = XEXP (x
, 0);
1408 op
[0] = XEXP (x
, 0);
1412 op
[0] = XEXP (x
, 0);
1415 op
[0] = XEXP (x
, 0);
1419 op
[0] = XEXP (x
, 0);
1424 op
[0] = XEXP (XEXP (x
, 1), 0);
1426 op
[1] = XEXP (XEXP (x
, 1), 1);
1430 op
[0] = XEXP (XEXP (x
, 1), 0);
1432 op
[1] = XEXP (XEXP (x
, 1), 1);
1436 op
[0] = XEXP (x
, 0);
1440 op
[1] = XEXP (x
, 1);
1445 op
[0] = XEXP (x
, 0);
1447 op
[1] = XEXP (x
, 1);
1449 op
[2] = XEXP (x
, 2);
1454 op
[0] = TRAP_CONDITION (x
);
1458 op
[0] = XEXP (x
, 0);
1459 op
[1] = XEXP (x
, 1);
1460 op
[2] = XEXP (x
, 2);
1463 case UNSPEC_VOLATILE
:
1465 pp_string (pp
, "unspec");
1466 if (GET_CODE (x
) == UNSPEC_VOLATILE
)
1467 pp_string (pp
, "/v");
1468 pp_left_bracket (pp
);
1469 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1473 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1475 pp_string (pp
, "] ");
1476 pp_decimal_int (pp
, XINT (x
, 1));
1481 /* Most unhandled codes can be printed as pseudo-functions. */
1482 if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_UNARY
)
1484 fun
= GET_RTX_NAME (GET_CODE (x
));
1485 op
[0] = XEXP (x
, 0);
1487 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMPARE
1488 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_COMPARE
1489 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_BIN_ARITH
1490 || GET_RTX_CLASS (GET_CODE (x
)) == RTX_COMM_ARITH
)
1492 fun
= GET_RTX_NAME (GET_CODE (x
));
1493 op
[0] = XEXP (x
, 0);
1494 op
[1] = XEXP (x
, 1);
1496 else if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_TERNARY
)
1498 fun
= GET_RTX_NAME (GET_CODE (x
));
1499 op
[0] = XEXP (x
, 0);
1500 op
[1] = XEXP (x
, 1);
1501 op
[2] = XEXP (x
, 2);
1504 /* Give up, just print the RTX name. */
1505 st
[0] = GET_RTX_NAME (GET_CODE (x
));
1510 /* Print this as a function? */
1513 pp_string (pp
, fun
);
1517 for (i
= 0; i
< 4; i
++)
1520 pp_string (pp
, st
[i
]);
1526 print_value (pp
, op
[i
], verbose
);
1531 pp_right_paren (pp
);
1534 /* Prints rtxes, I customarily classified as values. They're constants,
1535 registers, labels, symbols and memory accesses. */
1538 print_value (pretty_printer
*pp
, const_rtx x
, int verbose
)
1544 pp_string (pp
, "(nil)");
1547 switch (GET_CODE (x
))
1550 pp_scalar (pp
, HOST_WIDE_INT_PRINT_HEX
,
1551 (unsigned HOST_WIDE_INT
) INTVAL (x
));
1554 case CONST_WIDE_INT
:
1556 const char *sep
= "<";
1558 for (i
= CONST_WIDE_INT_NUNITS (x
) - 1; i
>= 0; i
--)
1560 pp_string (pp
, sep
);
1562 sprintf (tmp
, HOST_WIDE_INT_PRINT_HEX
,
1563 (unsigned HOST_WIDE_INT
) CONST_WIDE_INT_ELT (x
, i
));
1564 pp_string (pp
, tmp
);
1571 if (FLOAT_MODE_P (GET_MODE (x
)))
1573 real_to_decimal (tmp
, CONST_DOUBLE_REAL_VALUE (x
),
1574 sizeof (tmp
), 0, 1);
1575 pp_string (pp
, tmp
);
1578 pp_printf (pp
, "<%wx,%wx>",
1579 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (x
),
1580 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_HIGH (x
));
1583 fixed_to_decimal (tmp
, CONST_FIXED_VALUE (x
), sizeof (tmp
));
1584 pp_string (pp
, tmp
);
1587 pp_printf (pp
, "\"%s\"", XSTR (x
, 0));
1590 pp_printf (pp
, "`%s'", XSTR (x
, 0));
1593 pp_printf (pp
, "L%d", INSN_UID (label_ref_label (x
)));
1597 case STRICT_LOW_PART
:
1598 pp_printf (pp
, "%s(", GET_RTX_NAME (GET_CODE (x
)));
1599 print_value (pp
, XEXP (x
, 0), verbose
);
1600 pp_right_paren (pp
);
1603 if (REGNO (x
) < FIRST_PSEUDO_REGISTER
)
1605 if (ISDIGIT (reg_names
[REGNO (x
)][0]))
1607 pp_string (pp
, reg_names
[REGNO (x
)]);
1610 pp_printf (pp
, "r%d", REGNO (x
));
1612 pp_printf (pp
, ":%s", GET_MODE_NAME (GET_MODE (x
)));
1615 print_value (pp
, SUBREG_REG (x
), verbose
);
1616 pp_printf (pp
, "#%d", SUBREG_BYTE (x
));
1621 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1624 pp_left_bracket (pp
);
1625 print_value (pp
, XEXP (x
, 0), verbose
);
1626 pp_right_bracket (pp
);
1629 pp_printf (pp
, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x
)));
1632 print_exp (pp
, x
, verbose
);
1637 /* The next step in insn detalization, its pattern recognition. */
1640 print_pattern (pretty_printer
*pp
, const_rtx x
, int verbose
)
1644 pp_string (pp
, "(nil)");
1648 switch (GET_CODE (x
))
1651 print_value (pp
, SET_DEST (x
), verbose
);
1653 print_value (pp
, SET_SRC (x
), verbose
);
1658 pp_string (pp
, GET_RTX_NAME (GET_CODE (x
)));
1661 print_exp (pp
, x
, verbose
);
1665 pp_printf (pp
, "%s ", GET_RTX_NAME (GET_CODE (x
)));
1666 print_value (pp
, XEXP (x
, 0), verbose
);
1669 pp_string (pp
, "loc ");
1670 print_value (pp
, PAT_VAR_LOCATION_LOC (x
), verbose
);
1674 if (GET_CODE (COND_EXEC_TEST (x
)) == NE
1675 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1676 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1677 else if (GET_CODE (COND_EXEC_TEST (x
)) == EQ
1678 && XEXP (COND_EXEC_TEST (x
), 1) == const0_rtx
)
1680 pp_exclamation (pp
);
1681 print_value (pp
, XEXP (COND_EXEC_TEST (x
), 0), verbose
);
1684 print_value (pp
, COND_EXEC_TEST (x
), verbose
);
1685 pp_string (pp
, ") ");
1686 print_pattern (pp
, COND_EXEC_CODE (x
), verbose
);
1693 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
1695 print_pattern (pp
, XVECEXP (x
, 0, i
), verbose
);
1698 pp_right_brace (pp
);
1703 const rtx_sequence
*seq
= as_a
<const rtx_sequence
*> (x
);
1704 pp_string (pp
, "sequence{");
1705 if (INSN_P (seq
->element (0)))
1707 /* Print the sequence insns indented. */
1708 const char * save_print_rtx_head
= print_rtx_head
;
1709 char indented_print_rtx_head
[32];
1712 gcc_assert (strlen (print_rtx_head
) < sizeof (indented_print_rtx_head
) - 4);
1713 snprintf (indented_print_rtx_head
,
1714 sizeof (indented_print_rtx_head
),
1715 "%s ", print_rtx_head
);
1716 print_rtx_head
= indented_print_rtx_head
;
1717 for (int i
= 0; i
< seq
->len (); i
++)
1718 print_insn_with_notes (pp
, seq
->insn (i
));
1719 pp_printf (pp
, "%s ", save_print_rtx_head
);
1720 print_rtx_head
= save_print_rtx_head
;
1724 for (int i
= 0; i
< seq
->len (); i
++)
1726 print_pattern (pp
, seq
->element (i
), verbose
);
1730 pp_right_brace (pp
);
1734 pp_printf (pp
, "asm {%s}", XSTR (x
, 0));
1737 for (int i
= 0; i
< XVECLEN (x
, 0); i
++)
1739 print_value (pp
, XVECEXP (x
, 0, i
), verbose
);
1744 for (int i
= 0; i
< XVECLEN (x
, 1); i
++)
1746 print_value (pp
, XVECEXP (x
, 1, i
), verbose
);
1751 pp_string (pp
, "trap_if ");
1752 print_value (pp
, TRAP_CONDITION (x
), verbose
);
1755 case UNSPEC_VOLATILE
:
1756 /* Fallthru -- leave UNSPECs to print_exp. */
1758 print_value (pp
, x
, verbose
);
1760 } /* print_pattern */
1762 /* This is the main function in slim rtl visualization mechanism.
1764 X is an insn, to be printed into PP.
1766 This function tries to print it properly in human-readable form,
1767 resembling assembler mnemonics (instead of the older Lisp-style
1770 If VERBOSE is TRUE, insns are printed with more complete (but
1771 longer) pattern names and with extra information, and prefixed
1772 with their INSN_UIDs. */
1775 print_insn (pretty_printer
*pp
, const rtx_insn
*x
, int verbose
)
1779 /* Blech, pretty-print can't print integers with a specified width. */
1780 char uid_prefix
[32];
1781 snprintf (uid_prefix
, sizeof uid_prefix
, " %4d: ", INSN_UID (x
));
1782 pp_string (pp
, uid_prefix
);
1785 switch (GET_CODE (x
))
1788 print_pattern (pp
, PATTERN (x
), verbose
);
1793 const char *name
= "?";
1795 if (DECL_P (INSN_VAR_LOCATION_DECL (x
)))
1797 tree id
= DECL_NAME (INSN_VAR_LOCATION_DECL (x
));
1800 name
= IDENTIFIER_POINTER (id
);
1801 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x
))
1804 sprintf (idbuf
, "D#%i",
1805 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x
)));
1810 sprintf (idbuf
, "D.%i",
1811 DECL_UID (INSN_VAR_LOCATION_DECL (x
)));
1815 pp_printf (pp
, "debug %s => ", name
);
1816 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x
)))
1817 pp_string (pp
, "optimized away");
1819 print_pattern (pp
, INSN_VAR_LOCATION_LOC (x
), verbose
);
1824 print_pattern (pp
, PATTERN (x
), verbose
);
1827 if (GET_CODE (PATTERN (x
)) == PARALLEL
)
1828 print_pattern (pp
, XVECEXP (PATTERN (x
), 0, 0), verbose
);
1830 print_pattern (pp
, PATTERN (x
), verbose
);
1833 pp_printf (pp
, "L%d:", INSN_UID (x
));
1835 case JUMP_TABLE_DATA
:
1836 pp_string (pp
, "jump_table_data{\n");
1837 print_pattern (pp
, PATTERN (x
), verbose
);
1838 pp_right_brace (pp
);
1841 pp_string (pp
, "barrier");
1845 pp_string (pp
, GET_NOTE_INSN_NAME (NOTE_KIND (x
)));
1846 switch (NOTE_KIND (x
))
1848 case NOTE_INSN_EH_REGION_BEG
:
1849 case NOTE_INSN_EH_REGION_END
:
1850 pp_printf (pp
, " %d", NOTE_EH_HANDLER (x
));
1853 case NOTE_INSN_BLOCK_BEG
:
1854 case NOTE_INSN_BLOCK_END
:
1855 pp_printf (pp
, " %d", BLOCK_NUMBER (NOTE_BLOCK (x
)));
1858 case NOTE_INSN_BASIC_BLOCK
:
1859 pp_printf (pp
, " %d", NOTE_BASIC_BLOCK (x
)->index
);
1862 case NOTE_INSN_DELETED_LABEL
:
1863 case NOTE_INSN_DELETED_DEBUG_LABEL
:
1865 const char *label
= NOTE_DELETED_LABEL_NAME (x
);
1868 pp_printf (pp
, " (\"%s\")", label
);
1872 case NOTE_INSN_VAR_LOCATION
:
1873 case NOTE_INSN_CALL_ARG_LOCATION
:
1875 print_pattern (pp
, NOTE_VAR_LOCATION (x
), verbose
);
1876 pp_right_brace (pp
);
1889 /* Pretty-print a slim dump of X (an insn) to PP, including any register
1890 note attached to the instruction. */
1893 print_insn_with_notes (pretty_printer
*pp
, const rtx_insn
*x
)
1895 pp_string (pp
, print_rtx_head
);
1896 print_insn (pp
, x
, 1);
1898 if (INSN_P (x
) && REG_NOTES (x
))
1899 for (rtx note
= REG_NOTES (x
); note
; note
= XEXP (note
, 1))
1901 pp_printf (pp
, "%s %s ", print_rtx_head
,
1902 GET_REG_NOTE_NAME (REG_NOTE_KIND (note
)));
1903 if (GET_CODE (note
) == INT_LIST
)
1904 pp_printf (pp
, "%d", XINT (note
, 0));
1906 print_pattern (pp
, XEXP (note
, 0), 1);
1911 /* Print X, an RTL value node, to file F in slim format. Include
1912 additional information if VERBOSE is nonzero.
1914 Value nodes are constants, registers, labels, symbols and
1918 dump_value_slim (FILE *f
, const_rtx x
, int verbose
)
1920 pretty_printer rtl_slim_pp
;
1921 rtl_slim_pp
.buffer
->stream
= f
;
1922 print_value (&rtl_slim_pp
, x
, verbose
);
1923 pp_flush (&rtl_slim_pp
);
1926 /* Emit a slim dump of X (an insn) to the file F, including any register
1927 note attached to the instruction. */
1929 dump_insn_slim (FILE *f
, const rtx_insn
*x
)
1931 pretty_printer rtl_slim_pp
;
1932 rtl_slim_pp
.buffer
->stream
= f
;
1933 print_insn_with_notes (&rtl_slim_pp
, x
);
1934 pp_flush (&rtl_slim_pp
);
1937 /* Same as above, but stop at LAST or when COUNT == 0.
1938 If COUNT < 0 it will stop only at LAST or NULL rtx. */
1941 dump_rtl_slim (FILE *f
, const rtx_insn
*first
, const rtx_insn
*last
,
1942 int count
, int flags ATTRIBUTE_UNUSED
)
1944 const rtx_insn
*insn
, *tail
;
1945 pretty_printer rtl_slim_pp
;
1946 rtl_slim_pp
.buffer
->stream
= f
;
1948 tail
= last
? NEXT_INSN (last
) : NULL
;
1950 (insn
!= NULL
) && (insn
!= tail
) && (count
!= 0);
1951 insn
= NEXT_INSN (insn
))
1953 print_insn_with_notes (&rtl_slim_pp
, insn
);
1958 pp_flush (&rtl_slim_pp
);
1961 /* Dumps basic block BB to pretty-printer PP in slim form and without and
1962 no indentation, for use as a label of a DOT graph record-node. */
1965 rtl_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
1970 /* TODO: inter-bb stuff. */
1971 FOR_BB_INSNS (bb
, insn
)
1976 pp_write_text_to_stream (pp
);
1979 print_insn_with_notes (pp
, insn
);
1980 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
1984 /* Pretty-print pattern X of some insn in non-verbose mode.
1985 Return a string pointer to the pretty-printer buffer.
1987 This function is only exported exists only to accommodate some older users
1988 of the slim RTL pretty printers. Please do not use it for new code. */
1991 str_pattern_slim (const_rtx x
)
1993 pretty_printer rtl_slim_pp
;
1994 print_pattern (&rtl_slim_pp
, x
, 0);
1995 return ggc_strdup (pp_formatted_text (&rtl_slim_pp
));
1998 /* Emit a slim dump of X (an insn) to stderr. */
1999 extern void debug_insn_slim (const rtx_insn
*);
2001 debug_insn_slim (const rtx_insn
*x
)
2003 dump_insn_slim (stderr
, x
);
2006 /* Same as above, but using dump_rtl_slim. */
2007 extern void debug_rtl_slim (FILE *, const rtx_insn
*, const rtx_insn
*,
2010 debug_rtl_slim (const rtx_insn
*first
, const rtx_insn
*last
, int count
,
2013 dump_rtl_slim (stderr
, first
, last
, count
, flags
);
2016 extern void debug_bb_slim (basic_block
);
2018 debug_bb_slim (basic_block bb
)
2020 dump_bb (stderr
, bb
, 0, TDF_SLIM
| TDF_BLOCKS
);
2023 extern void debug_bb_n_slim (int);
2025 debug_bb_n_slim (int n
)
2027 basic_block bb
= BASIC_BLOCK_FOR_FN (cfun
, n
);