PR target/63620
[official-gcc.git] / gcc / sched-vis.c
blob0ea923be436be1ecdabd38f2345ab82a8918c5e1
1 /* Printing of RTL in "slim", mnemonic like form.
2 Copyright (C) 1992-2014 Free Software Foundation, Inc.
3 Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
4 and currently maintained by, Jim Wilson (wilson@cygnus.com)
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /* Historically this form of RTL dumping was introduced along with
23 the Haifa instruction scheduling pass, hence the name of this file.
24 But there is nothing in this file left that is scheduler-specific. */
26 #include "config.h"
27 #include "system.h"
28 #include "coretypes.h"
29 #include "tm.h"
30 #include "rtl.h"
31 #include "tree.h" /* FIXME: To dump INSN_VAR_LOCATION_DECL. */
32 #include "predict.h"
33 #include "vec.h"
34 #include "hashtab.h"
35 #include "hash-set.h"
36 #include "machmode.h"
37 #include "hard-reg-set.h"
38 #include "input.h"
39 #include "function.h"
40 #include "dominance.h"
41 #include "cfg.h"
42 #include "basic-block.h"
43 #include "dumpfile.h" /* for the TDF_* flags */
44 #include "pretty-print.h"
46 /* The functions in this file try to print RTL in a form resembling assembler
47 mnemonics. Because this form is more concise than the "traditional" form
48 of RTL printing in Lisp-style, the form printed by this file is called
49 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
50 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
51 always printed in slim form.
53 The normal interface to the functionality provided in this pretty-printer
54 is through the dump_*_slim functions to print to a stream, or via the
55 print_*_slim functions to print into a user's pretty-printer.
57 It is also possible to obtain a string for a single pattern as a string
58 pointer, via str_pattern_slim, but this usage is discouraged. */
60 /* For insns we print patterns, and for some patterns we print insns... */
61 static void print_insn_with_notes (pretty_printer *, const_rtx);
63 /* This recognizes rtx'en classified as expressions. These are always
64 represent some action on values or results of other expression, that
65 may be stored in objects representing values. */
67 static void
68 print_exp (pretty_printer *pp, const_rtx x, int verbose)
70 const char *st[4];
71 const char *fun;
72 rtx op[4];
73 int i;
75 fun = (char *) 0;
76 for (i = 0; i < 4; i++)
78 st[i] = (char *) 0;
79 op[i] = NULL_RTX;
82 switch (GET_CODE (x))
84 case PLUS:
85 op[0] = XEXP (x, 0);
86 if (CONST_INT_P (XEXP (x, 1))
87 && INTVAL (XEXP (x, 1)) < 0)
89 st[1] = "-";
90 op[1] = GEN_INT (-INTVAL (XEXP (x, 1)));
92 else
94 st[1] = "+";
95 op[1] = XEXP (x, 1);
97 break;
98 case LO_SUM:
99 op[0] = XEXP (x, 0);
100 st[1] = "+low(";
101 op[1] = XEXP (x, 1);
102 st[2] = ")";
103 break;
104 case MINUS:
105 op[0] = XEXP (x, 0);
106 st[1] = "-";
107 op[1] = XEXP (x, 1);
108 break;
109 case COMPARE:
110 fun = "cmp";
111 op[0] = XEXP (x, 0);
112 op[1] = XEXP (x, 1);
113 break;
114 case NEG:
115 st[0] = "-";
116 op[0] = XEXP (x, 0);
117 break;
118 case FMA:
119 st[0] = "{";
120 op[0] = XEXP (x, 0);
121 st[1] = "*";
122 op[1] = XEXP (x, 1);
123 st[2] = "+";
124 op[2] = XEXP (x, 2);
125 st[3] = "}";
126 break;
127 case MULT:
128 op[0] = XEXP (x, 0);
129 st[1] = "*";
130 op[1] = XEXP (x, 1);
131 break;
132 case DIV:
133 op[0] = XEXP (x, 0);
134 st[1] = "/";
135 op[1] = XEXP (x, 1);
136 break;
137 case UDIV:
138 fun = "udiv";
139 op[0] = XEXP (x, 0);
140 op[1] = XEXP (x, 1);
141 break;
142 case MOD:
143 op[0] = XEXP (x, 0);
144 st[1] = "%";
145 op[1] = XEXP (x, 1);
146 break;
147 case UMOD:
148 fun = "umod";
149 op[0] = XEXP (x, 0);
150 op[1] = XEXP (x, 1);
151 break;
152 case SMIN:
153 fun = "smin";
154 op[0] = XEXP (x, 0);
155 op[1] = XEXP (x, 1);
156 break;
157 case SMAX:
158 fun = "smax";
159 op[0] = XEXP (x, 0);
160 op[1] = XEXP (x, 1);
161 break;
162 case UMIN:
163 fun = "umin";
164 op[0] = XEXP (x, 0);
165 op[1] = XEXP (x, 1);
166 break;
167 case UMAX:
168 fun = "umax";
169 op[0] = XEXP (x, 0);
170 op[1] = XEXP (x, 1);
171 break;
172 case NOT:
173 st[0] = "!";
174 op[0] = XEXP (x, 0);
175 break;
176 case AND:
177 op[0] = XEXP (x, 0);
178 st[1] = "&";
179 op[1] = XEXP (x, 1);
180 break;
181 case IOR:
182 op[0] = XEXP (x, 0);
183 st[1] = "|";
184 op[1] = XEXP (x, 1);
185 break;
186 case XOR:
187 op[0] = XEXP (x, 0);
188 st[1] = "^";
189 op[1] = XEXP (x, 1);
190 break;
191 case ASHIFT:
192 op[0] = XEXP (x, 0);
193 st[1] = "<<";
194 op[1] = XEXP (x, 1);
195 break;
196 case LSHIFTRT:
197 op[0] = XEXP (x, 0);
198 st[1] = " 0>>";
199 op[1] = XEXP (x, 1);
200 break;
201 case ASHIFTRT:
202 op[0] = XEXP (x, 0);
203 st[1] = ">>";
204 op[1] = XEXP (x, 1);
205 break;
206 case ROTATE:
207 op[0] = XEXP (x, 0);
208 st[1] = "<-<";
209 op[1] = XEXP (x, 1);
210 break;
211 case ROTATERT:
212 op[0] = XEXP (x, 0);
213 st[1] = ">->";
214 op[1] = XEXP (x, 1);
215 break;
216 case NE:
217 op[0] = XEXP (x, 0);
218 st[1] = "!=";
219 op[1] = XEXP (x, 1);
220 break;
221 case EQ:
222 op[0] = XEXP (x, 0);
223 st[1] = "==";
224 op[1] = XEXP (x, 1);
225 break;
226 case GE:
227 op[0] = XEXP (x, 0);
228 st[1] = ">=";
229 op[1] = XEXP (x, 1);
230 break;
231 case GT:
232 op[0] = XEXP (x, 0);
233 st[1] = ">";
234 op[1] = XEXP (x, 1);
235 break;
236 case LE:
237 op[0] = XEXP (x, 0);
238 st[1] = "<=";
239 op[1] = XEXP (x, 1);
240 break;
241 case LT:
242 op[0] = XEXP (x, 0);
243 st[1] = "<";
244 op[1] = XEXP (x, 1);
245 break;
246 case SIGN_EXTRACT:
247 fun = (verbose) ? "sign_extract" : "sxt";
248 op[0] = XEXP (x, 0);
249 op[1] = XEXP (x, 1);
250 op[2] = XEXP (x, 2);
251 break;
252 case ZERO_EXTRACT:
253 fun = (verbose) ? "zero_extract" : "zxt";
254 op[0] = XEXP (x, 0);
255 op[1] = XEXP (x, 1);
256 op[2] = XEXP (x, 2);
257 break;
258 case SIGN_EXTEND:
259 fun = (verbose) ? "sign_extend" : "sxn";
260 op[0] = XEXP (x, 0);
261 break;
262 case ZERO_EXTEND:
263 fun = (verbose) ? "zero_extend" : "zxn";
264 op[0] = XEXP (x, 0);
265 break;
266 case FLOAT_EXTEND:
267 fun = (verbose) ? "float_extend" : "fxn";
268 op[0] = XEXP (x, 0);
269 break;
270 case TRUNCATE:
271 fun = (verbose) ? "trunc" : "trn";
272 op[0] = XEXP (x, 0);
273 break;
274 case FLOAT_TRUNCATE:
275 fun = (verbose) ? "float_trunc" : "ftr";
276 op[0] = XEXP (x, 0);
277 break;
278 case FLOAT:
279 fun = (verbose) ? "float" : "flt";
280 op[0] = XEXP (x, 0);
281 break;
282 case UNSIGNED_FLOAT:
283 fun = (verbose) ? "uns_float" : "ufl";
284 op[0] = XEXP (x, 0);
285 break;
286 case FIX:
287 fun = "fix";
288 op[0] = XEXP (x, 0);
289 break;
290 case UNSIGNED_FIX:
291 fun = (verbose) ? "uns_fix" : "ufx";
292 op[0] = XEXP (x, 0);
293 break;
294 case PRE_DEC:
295 st[0] = "--";
296 op[0] = XEXP (x, 0);
297 break;
298 case PRE_INC:
299 st[0] = "++";
300 op[0] = XEXP (x, 0);
301 break;
302 case POST_DEC:
303 op[0] = XEXP (x, 0);
304 st[1] = "--";
305 break;
306 case POST_INC:
307 op[0] = XEXP (x, 0);
308 st[1] = "++";
309 break;
310 case PRE_MODIFY:
311 st[0] = "pre ";
312 op[0] = XEXP (XEXP (x, 1), 0);
313 st[1] = "+=";
314 op[1] = XEXP (XEXP (x, 1), 1);
315 break;
316 case POST_MODIFY:
317 st[0] = "post ";
318 op[0] = XEXP (XEXP (x, 1), 0);
319 st[1] = "+=";
320 op[1] = XEXP (XEXP (x, 1), 1);
321 break;
322 case CALL:
323 st[0] = "call ";
324 op[0] = XEXP (x, 0);
325 if (verbose)
327 st[1] = " argc:";
328 op[1] = XEXP (x, 1);
330 break;
331 case IF_THEN_ELSE:
332 st[0] = "{(";
333 op[0] = XEXP (x, 0);
334 st[1] = ")?";
335 op[1] = XEXP (x, 1);
336 st[2] = ":";
337 op[2] = XEXP (x, 2);
338 st[3] = "}";
339 break;
340 case TRAP_IF:
341 fun = "trap_if";
342 op[0] = TRAP_CONDITION (x);
343 break;
344 case PREFETCH:
345 fun = "prefetch";
346 op[0] = XEXP (x, 0);
347 op[1] = XEXP (x, 1);
348 op[2] = XEXP (x, 2);
349 break;
350 case UNSPEC:
351 case UNSPEC_VOLATILE:
353 pp_string (pp, "unspec");
354 if (GET_CODE (x) == UNSPEC_VOLATILE)
355 pp_string (pp, "/v");
356 pp_left_bracket (pp);
357 for (i = 0; i < XVECLEN (x, 0); i++)
359 if (i != 0)
360 pp_comma (pp);
361 print_pattern (pp, XVECEXP (x, 0, i), verbose);
363 pp_string (pp, "] ");
364 pp_decimal_int (pp, XINT (x, 1));
366 break;
367 default:
369 /* Most unhandled codes can be printed as pseudo-functions. */
370 if (GET_RTX_CLASS (GET_CODE (x)) == RTX_UNARY)
372 fun = GET_RTX_NAME (GET_CODE (x));
373 op[0] = XEXP (x, 0);
375 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_COMPARE
376 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_COMPARE
377 || GET_RTX_CLASS (GET_CODE (x)) == RTX_BIN_ARITH
378 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_ARITH)
380 fun = GET_RTX_NAME (GET_CODE (x));
381 op[0] = XEXP (x, 0);
382 op[1] = XEXP (x, 1);
384 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_TERNARY)
386 fun = GET_RTX_NAME (GET_CODE (x));
387 op[0] = XEXP (x, 0);
388 op[1] = XEXP (x, 1);
389 op[2] = XEXP (x, 2);
391 else
392 /* Give up, just print the RTX name. */
393 st[0] = GET_RTX_NAME (GET_CODE (x));
395 break;
398 /* Print this as a function? */
399 if (fun)
401 pp_string (pp, fun);
402 pp_left_paren (pp);
405 for (i = 0; i < 4; i++)
407 if (st[i])
408 pp_string (pp, st[i]);
410 if (op[i])
412 if (fun && i != 0)
413 pp_comma (pp);
414 print_value (pp, op[i], verbose);
418 if (fun)
419 pp_right_paren (pp);
420 } /* print_exp */
422 /* Prints rtxes, I customarily classified as values. They're constants,
423 registers, labels, symbols and memory accesses. */
425 void
426 print_value (pretty_printer *pp, const_rtx x, int verbose)
428 char tmp[1024];
430 if (!x)
432 pp_string (pp, "(nil)");
433 return;
435 switch (GET_CODE (x))
437 case CONST_INT:
438 pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
439 (unsigned HOST_WIDE_INT) INTVAL (x));
440 break;
442 case CONST_WIDE_INT:
444 const char *sep = "<";
445 int i;
446 for (i = CONST_WIDE_INT_NUNITS (x) - 1; i >= 0; i--)
448 pp_string (pp, sep);
449 sep = ",";
450 sprintf (tmp, HOST_WIDE_INT_PRINT_HEX,
451 (unsigned HOST_WIDE_INT) CONST_WIDE_INT_ELT (x, i));
452 pp_string (pp, tmp);
454 pp_greater (pp);
456 break;
458 case CONST_DOUBLE:
459 if (FLOAT_MODE_P (GET_MODE (x)))
461 real_to_decimal (tmp, CONST_DOUBLE_REAL_VALUE (x),
462 sizeof (tmp), 0, 1);
463 pp_string (pp, tmp);
465 else
466 pp_printf (pp, "<%wx,%wx>",
467 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x),
468 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x));
469 break;
470 case CONST_FIXED:
471 fixed_to_decimal (tmp, CONST_FIXED_VALUE (x), sizeof (tmp));
472 pp_string (pp, tmp);
473 break;
474 case CONST_STRING:
475 pp_printf (pp, "\"%s\"", XSTR (x, 0));
476 break;
477 case SYMBOL_REF:
478 pp_printf (pp, "`%s'", XSTR (x, 0));
479 break;
480 case LABEL_REF:
481 pp_printf (pp, "L%d", INSN_UID (LABEL_REF_LABEL (x)));
482 break;
483 case CONST:
484 case HIGH:
485 case STRICT_LOW_PART:
486 pp_printf (pp, "%s(", GET_RTX_NAME (GET_CODE (x)));
487 print_value (pp, XEXP (x, 0), verbose);
488 pp_right_paren (pp);
489 break;
490 case REG:
491 if (REGNO (x) < FIRST_PSEUDO_REGISTER)
493 if (ISDIGIT (reg_names[REGNO (x)][0]))
494 pp_modulo (pp);
495 pp_string (pp, reg_names[REGNO (x)]);
497 else
498 pp_printf (pp, "r%d", REGNO (x));
499 if (verbose)
500 pp_printf (pp, ":%s", GET_MODE_NAME (GET_MODE (x)));
501 break;
502 case SUBREG:
503 print_value (pp, SUBREG_REG (x), verbose);
504 pp_printf (pp, "#%d", SUBREG_BYTE (x));
505 break;
506 case SCRATCH:
507 case CC0:
508 case PC:
509 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
510 break;
511 case MEM:
512 pp_left_bracket (pp);
513 print_value (pp, XEXP (x, 0), verbose);
514 pp_right_bracket (pp);
515 break;
516 case DEBUG_EXPR:
517 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x)));
518 break;
519 default:
520 print_exp (pp, x, verbose);
521 break;
523 } /* print_value */
525 /* The next step in insn detalization, its pattern recognition. */
527 void
528 print_pattern (pretty_printer *pp, const_rtx x, int verbose)
530 if (! x)
532 pp_string (pp, "(nil)");
533 return;
536 switch (GET_CODE (x))
538 case SET:
539 print_value (pp, SET_DEST (x), verbose);
540 pp_equal (pp);
541 print_value (pp, SET_SRC (x), verbose);
542 break;
543 case RETURN:
544 case SIMPLE_RETURN:
545 case EH_RETURN:
546 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
547 break;
548 case CALL:
549 print_exp (pp, x, verbose);
550 break;
551 case CLOBBER:
552 case USE:
553 pp_printf (pp, "%s ", GET_RTX_NAME (GET_CODE (x)));
554 print_value (pp, XEXP (x, 0), verbose);
555 break;
556 case VAR_LOCATION:
557 pp_string (pp, "loc ");
558 print_value (pp, PAT_VAR_LOCATION_LOC (x), verbose);
559 break;
560 case COND_EXEC:
561 pp_left_paren (pp);
562 if (GET_CODE (COND_EXEC_TEST (x)) == NE
563 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
564 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
565 else if (GET_CODE (COND_EXEC_TEST (x)) == EQ
566 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
568 pp_exclamation (pp);
569 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
571 else
572 print_value (pp, COND_EXEC_TEST (x), verbose);
573 pp_string (pp, ") ");
574 print_pattern (pp, COND_EXEC_CODE (x), verbose);
575 break;
576 case PARALLEL:
578 int i;
580 pp_left_brace (pp);
581 for (i = 0; i < XVECLEN (x, 0); i++)
583 print_pattern (pp, XVECEXP (x, 0, i), verbose);
584 pp_semicolon (pp);
586 pp_right_brace (pp);
588 break;
589 case SEQUENCE:
591 const rtx_sequence *seq = as_a <const rtx_sequence *> (x);
592 pp_string (pp, "sequence{");
593 if (INSN_P (seq->element (0)))
595 /* Print the sequence insns indented. */
596 const char * save_print_rtx_head = print_rtx_head;
597 char indented_print_rtx_head[32];
599 pp_newline (pp);
600 gcc_assert (strlen (print_rtx_head) < sizeof (indented_print_rtx_head) - 4);
601 snprintf (indented_print_rtx_head,
602 sizeof (indented_print_rtx_head),
603 "%s ", print_rtx_head);
604 print_rtx_head = indented_print_rtx_head;
605 for (int i = 0; i < seq->len (); i++)
606 print_insn_with_notes (pp, seq->insn (i));
607 pp_printf (pp, "%s ", save_print_rtx_head);
608 print_rtx_head = save_print_rtx_head;
610 else
612 for (int i = 0; i < seq->len (); i++)
614 print_pattern (pp, seq->element (i), verbose);
615 pp_semicolon (pp);
618 pp_right_brace (pp);
620 break;
621 case ASM_INPUT:
622 pp_printf (pp, "asm {%s}", XSTR (x, 0));
623 break;
624 case ADDR_VEC:
625 for (int i = 0; i < XVECLEN (x, 0); i++)
627 print_value (pp, XVECEXP (x, 0, i), verbose);
628 pp_semicolon (pp);
630 break;
631 case ADDR_DIFF_VEC:
632 for (int i = 0; i < XVECLEN (x, 1); i++)
634 print_value (pp, XVECEXP (x, 1, i), verbose);
635 pp_semicolon (pp);
637 break;
638 case TRAP_IF:
639 pp_string (pp, "trap_if ");
640 print_value (pp, TRAP_CONDITION (x), verbose);
641 break;
642 case UNSPEC:
643 case UNSPEC_VOLATILE:
644 /* Fallthru -- leave UNSPECs to print_exp. */
645 default:
646 print_value (pp, x, verbose);
648 } /* print_pattern */
650 /* This is the main function in slim rtl visualization mechanism.
652 X is an insn, to be printed into PP.
654 This function tries to print it properly in human-readable form,
655 resembling assembler mnemonics (instead of the older Lisp-style
656 form).
658 If VERBOSE is TRUE, insns are printed with more complete (but
659 longer) pattern names and with extra information, and prefixed
660 with their INSN_UIDs. */
662 void
663 print_insn (pretty_printer *pp, const_rtx x, int verbose)
665 if (verbose)
667 /* Blech, pretty-print can't print integers with a specified width. */
668 char uid_prefix[32];
669 snprintf (uid_prefix, sizeof uid_prefix, " %4d: ", INSN_UID (x));
670 pp_string (pp, uid_prefix);
673 switch (GET_CODE (x))
675 case INSN:
676 print_pattern (pp, PATTERN (x), verbose);
677 break;
679 case DEBUG_INSN:
681 const char *name = "?";
683 if (DECL_P (INSN_VAR_LOCATION_DECL (x)))
685 tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x));
686 char idbuf[32];
687 if (id)
688 name = IDENTIFIER_POINTER (id);
689 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x))
690 == DEBUG_EXPR_DECL)
692 sprintf (idbuf, "D#%i",
693 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x)));
694 name = idbuf;
696 else
698 sprintf (idbuf, "D.%i",
699 DECL_UID (INSN_VAR_LOCATION_DECL (x)));
700 name = idbuf;
703 pp_printf (pp, "debug %s => ", name);
704 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x)))
705 pp_string (pp, "optimized away");
706 else
707 print_pattern (pp, INSN_VAR_LOCATION_LOC (x), verbose);
709 break;
711 case JUMP_INSN:
712 print_pattern (pp, PATTERN (x), verbose);
713 break;
714 case CALL_INSN:
715 if (GET_CODE (PATTERN (x)) == PARALLEL)
716 print_pattern (pp, XVECEXP (PATTERN (x), 0, 0), verbose);
717 else
718 print_pattern (pp, PATTERN (x), verbose);
719 break;
720 case CODE_LABEL:
721 pp_printf (pp, "L%d:", INSN_UID (x));
722 break;
723 case JUMP_TABLE_DATA:
724 pp_string (pp, "jump_table_data{\n");
725 print_pattern (pp, PATTERN (x), verbose);
726 pp_right_brace (pp);
727 break;
728 case BARRIER:
729 pp_string (pp, "barrier");
730 break;
731 case NOTE:
733 pp_string (pp, GET_NOTE_INSN_NAME (NOTE_KIND (x)));
734 switch (NOTE_KIND (x))
736 case NOTE_INSN_EH_REGION_BEG:
737 case NOTE_INSN_EH_REGION_END:
738 pp_printf (pp, " %d", NOTE_EH_HANDLER (x));
739 break;
741 case NOTE_INSN_BLOCK_BEG:
742 case NOTE_INSN_BLOCK_END:
743 pp_printf (pp, " %d", BLOCK_NUMBER (NOTE_BLOCK (x)));
744 break;
746 case NOTE_INSN_BASIC_BLOCK:
747 pp_printf (pp, " %d", NOTE_BASIC_BLOCK (x)->index);
748 break;
750 case NOTE_INSN_DELETED_LABEL:
751 case NOTE_INSN_DELETED_DEBUG_LABEL:
753 const char *label = NOTE_DELETED_LABEL_NAME (x);
754 if (label == NULL)
755 label = "";
756 pp_printf (pp, " (\"%s\")", label);
758 break;
760 case NOTE_INSN_VAR_LOCATION:
761 case NOTE_INSN_CALL_ARG_LOCATION:
762 pp_left_brace (pp);
763 print_pattern (pp, NOTE_VAR_LOCATION (x), verbose);
764 pp_right_brace (pp);
765 break;
767 default:
768 break;
770 break;
772 default:
773 gcc_unreachable ();
775 } /* print_insn */
777 /* Pretty-print a slim dump of X (an insn) to PP, including any register
778 note attached to the instruction. */
780 static void
781 print_insn_with_notes (pretty_printer *pp, const_rtx x)
783 pp_string (pp, print_rtx_head);
784 print_insn (pp, x, 1);
785 pp_newline (pp);
786 if (INSN_P (x) && REG_NOTES (x))
787 for (rtx note = REG_NOTES (x); note; note = XEXP (note, 1))
789 pp_printf (pp, "%s %s ", print_rtx_head,
790 GET_REG_NOTE_NAME (REG_NOTE_KIND (note)));
791 if (GET_CODE (note) == INT_LIST)
792 pp_printf (pp, "%d", XINT (note, 0));
793 else
794 print_pattern (pp, XEXP (note, 0), 1);
795 pp_newline (pp);
799 /* Print X, an RTL value node, to file F in slim format. Include
800 additional information if VERBOSE is nonzero.
802 Value nodes are constants, registers, labels, symbols and
803 memory. */
805 void
806 dump_value_slim (FILE *f, const_rtx x, int verbose)
808 pretty_printer rtl_slim_pp;
809 rtl_slim_pp.buffer->stream = f;
810 print_value (&rtl_slim_pp, x, verbose);
811 pp_flush (&rtl_slim_pp);
814 /* Emit a slim dump of X (an insn) to the file F, including any register
815 note attached to the instruction. */
816 void
817 dump_insn_slim (FILE *f, const_rtx x)
819 pretty_printer rtl_slim_pp;
820 rtl_slim_pp.buffer->stream = f;
821 print_insn_with_notes (&rtl_slim_pp, x);
822 pp_flush (&rtl_slim_pp);
825 /* Same as above, but stop at LAST or when COUNT == 0.
826 If COUNT < 0 it will stop only at LAST or NULL rtx. */
828 void
829 dump_rtl_slim (FILE *f, const rtx_insn *first, const rtx_insn *last,
830 int count, int flags ATTRIBUTE_UNUSED)
832 const rtx_insn *insn, *tail;
833 pretty_printer rtl_slim_pp;
834 rtl_slim_pp.buffer->stream = f;
836 tail = last ? NEXT_INSN (last) : NULL;
837 for (insn = first;
838 (insn != NULL) && (insn != tail) && (count != 0);
839 insn = NEXT_INSN (insn))
841 print_insn_with_notes (&rtl_slim_pp, insn);
842 if (count > 0)
843 count--;
846 pp_flush (&rtl_slim_pp);
849 /* Dumps basic block BB to pretty-printer PP in slim form and without and
850 no indentation, for use as a label of a DOT graph record-node. */
852 void
853 rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
855 rtx_insn *insn;
856 bool first = true;
858 /* TODO: inter-bb stuff. */
859 FOR_BB_INSNS (bb, insn)
861 if (! first)
863 pp_bar (pp);
864 pp_write_text_to_stream (pp);
866 first = false;
867 print_insn_with_notes (pp, insn);
868 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
872 /* Pretty-print pattern X of some insn in non-verbose mode.
873 Return a string pointer to the pretty-printer buffer.
875 This function is only exported exists only to accommodate some older users
876 of the slim RTL pretty printers. Please do not use it for new code. */
878 const char *
879 str_pattern_slim (const_rtx x)
881 pretty_printer rtl_slim_pp;
882 print_pattern (&rtl_slim_pp, x, 0);
883 return ggc_strdup (pp_formatted_text (&rtl_slim_pp));
886 /* Emit a slim dump of X (an insn) to stderr. */
887 extern void debug_insn_slim (const_rtx);
888 DEBUG_FUNCTION void
889 debug_insn_slim (const_rtx x)
891 dump_insn_slim (stderr, x);
894 /* Same as above, but using dump_rtl_slim. */
895 extern void debug_rtl_slim (FILE *, const rtx_insn *, const rtx_insn *,
896 int, int);
897 DEBUG_FUNCTION void
898 debug_rtl_slim (const rtx_insn *first, const rtx_insn *last, int count,
899 int flags)
901 dump_rtl_slim (stderr, first, last, count, flags);
904 extern void debug_bb_slim (basic_block);
905 DEBUG_FUNCTION void
906 debug_bb_slim (basic_block bb)
908 dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
911 extern void debug_bb_n_slim (int);
912 DEBUG_FUNCTION void
913 debug_bb_n_slim (int n)
915 basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
916 debug_bb_slim (bb);