2015-06-11 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / sched-vis.c
blobd7124e3ca009ec0639d029d0d2f23c6747ef142c
1 /* Printing of RTL in "slim", mnemonic like form.
2 Copyright (C) 1992-2015 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 "input.h"
32 #include "alias.h"
33 #include "symtab.h"
34 #include "tree.h" /* FIXME: To dump INSN_VAR_LOCATION_DECL. */
35 #include "predict.h"
36 #include "hard-reg-set.h"
37 #include "input.h"
38 #include "function.h"
39 #include "dominance.h"
40 #include "cfg.h"
41 #include "basic-block.h"
42 #include "dumpfile.h" /* for the TDF_* flags */
43 #include "pretty-print.h"
45 /* The functions in this file try to print RTL in a form resembling assembler
46 mnemonics. Because this form is more concise than the "traditional" form
47 of RTL printing in Lisp-style, the form printed by this file is called
48 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
49 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
50 always printed in slim form.
52 The normal interface to the functionality provided in this pretty-printer
53 is through the dump_*_slim functions to print to a stream, or via the
54 print_*_slim functions to print into a user's pretty-printer.
56 It is also possible to obtain a string for a single pattern as a string
57 pointer, via str_pattern_slim, but this usage is discouraged. */
59 /* For insns we print patterns, and for some patterns we print insns... */
60 static void print_insn_with_notes (pretty_printer *, const rtx_insn *);
62 /* This recognizes rtx'en classified as expressions. These are always
63 represent some action on values or results of other expression, that
64 may be stored in objects representing values. */
66 static void
67 print_exp (pretty_printer *pp, const_rtx x, int verbose)
69 const char *st[4];
70 const char *fun;
71 rtx op[4];
72 int i;
74 fun = (char *) 0;
75 for (i = 0; i < 4; i++)
77 st[i] = (char *) 0;
78 op[i] = NULL_RTX;
81 switch (GET_CODE (x))
83 case PLUS:
84 op[0] = XEXP (x, 0);
85 if (CONST_INT_P (XEXP (x, 1))
86 && INTVAL (XEXP (x, 1)) < 0)
88 st[1] = "-";
89 op[1] = GEN_INT (-INTVAL (XEXP (x, 1)));
91 else
93 st[1] = "+";
94 op[1] = XEXP (x, 1);
96 break;
97 case LO_SUM:
98 op[0] = XEXP (x, 0);
99 st[1] = "+low(";
100 op[1] = XEXP (x, 1);
101 st[2] = ")";
102 break;
103 case MINUS:
104 op[0] = XEXP (x, 0);
105 st[1] = "-";
106 op[1] = XEXP (x, 1);
107 break;
108 case COMPARE:
109 fun = "cmp";
110 op[0] = XEXP (x, 0);
111 op[1] = XEXP (x, 1);
112 break;
113 case NEG:
114 st[0] = "-";
115 op[0] = XEXP (x, 0);
116 break;
117 case FMA:
118 st[0] = "{";
119 op[0] = XEXP (x, 0);
120 st[1] = "*";
121 op[1] = XEXP (x, 1);
122 st[2] = "+";
123 op[2] = XEXP (x, 2);
124 st[3] = "}";
125 break;
126 case MULT:
127 op[0] = XEXP (x, 0);
128 st[1] = "*";
129 op[1] = XEXP (x, 1);
130 break;
131 case DIV:
132 op[0] = XEXP (x, 0);
133 st[1] = "/";
134 op[1] = XEXP (x, 1);
135 break;
136 case UDIV:
137 fun = "udiv";
138 op[0] = XEXP (x, 0);
139 op[1] = XEXP (x, 1);
140 break;
141 case MOD:
142 op[0] = XEXP (x, 0);
143 st[1] = "%";
144 op[1] = XEXP (x, 1);
145 break;
146 case UMOD:
147 fun = "umod";
148 op[0] = XEXP (x, 0);
149 op[1] = XEXP (x, 1);
150 break;
151 case SMIN:
152 fun = "smin";
153 op[0] = XEXP (x, 0);
154 op[1] = XEXP (x, 1);
155 break;
156 case SMAX:
157 fun = "smax";
158 op[0] = XEXP (x, 0);
159 op[1] = XEXP (x, 1);
160 break;
161 case UMIN:
162 fun = "umin";
163 op[0] = XEXP (x, 0);
164 op[1] = XEXP (x, 1);
165 break;
166 case UMAX:
167 fun = "umax";
168 op[0] = XEXP (x, 0);
169 op[1] = XEXP (x, 1);
170 break;
171 case NOT:
172 st[0] = "!";
173 op[0] = XEXP (x, 0);
174 break;
175 case AND:
176 op[0] = XEXP (x, 0);
177 st[1] = "&";
178 op[1] = XEXP (x, 1);
179 break;
180 case IOR:
181 op[0] = XEXP (x, 0);
182 st[1] = "|";
183 op[1] = XEXP (x, 1);
184 break;
185 case XOR:
186 op[0] = XEXP (x, 0);
187 st[1] = "^";
188 op[1] = XEXP (x, 1);
189 break;
190 case ASHIFT:
191 op[0] = XEXP (x, 0);
192 st[1] = "<<";
193 op[1] = XEXP (x, 1);
194 break;
195 case LSHIFTRT:
196 op[0] = XEXP (x, 0);
197 st[1] = " 0>>";
198 op[1] = XEXP (x, 1);
199 break;
200 case ASHIFTRT:
201 op[0] = XEXP (x, 0);
202 st[1] = ">>";
203 op[1] = XEXP (x, 1);
204 break;
205 case ROTATE:
206 op[0] = XEXP (x, 0);
207 st[1] = "<-<";
208 op[1] = XEXP (x, 1);
209 break;
210 case ROTATERT:
211 op[0] = XEXP (x, 0);
212 st[1] = ">->";
213 op[1] = XEXP (x, 1);
214 break;
215 case NE:
216 op[0] = XEXP (x, 0);
217 st[1] = "!=";
218 op[1] = XEXP (x, 1);
219 break;
220 case EQ:
221 op[0] = XEXP (x, 0);
222 st[1] = "==";
223 op[1] = XEXP (x, 1);
224 break;
225 case GE:
226 op[0] = XEXP (x, 0);
227 st[1] = ">=";
228 op[1] = XEXP (x, 1);
229 break;
230 case GT:
231 op[0] = XEXP (x, 0);
232 st[1] = ">";
233 op[1] = XEXP (x, 1);
234 break;
235 case LE:
236 op[0] = XEXP (x, 0);
237 st[1] = "<=";
238 op[1] = XEXP (x, 1);
239 break;
240 case LT:
241 op[0] = XEXP (x, 0);
242 st[1] = "<";
243 op[1] = XEXP (x, 1);
244 break;
245 case SIGN_EXTRACT:
246 fun = (verbose) ? "sign_extract" : "sxt";
247 op[0] = XEXP (x, 0);
248 op[1] = XEXP (x, 1);
249 op[2] = XEXP (x, 2);
250 break;
251 case ZERO_EXTRACT:
252 fun = (verbose) ? "zero_extract" : "zxt";
253 op[0] = XEXP (x, 0);
254 op[1] = XEXP (x, 1);
255 op[2] = XEXP (x, 2);
256 break;
257 case SIGN_EXTEND:
258 fun = (verbose) ? "sign_extend" : "sxn";
259 op[0] = XEXP (x, 0);
260 break;
261 case ZERO_EXTEND:
262 fun = (verbose) ? "zero_extend" : "zxn";
263 op[0] = XEXP (x, 0);
264 break;
265 case FLOAT_EXTEND:
266 fun = (verbose) ? "float_extend" : "fxn";
267 op[0] = XEXP (x, 0);
268 break;
269 case TRUNCATE:
270 fun = (verbose) ? "trunc" : "trn";
271 op[0] = XEXP (x, 0);
272 break;
273 case FLOAT_TRUNCATE:
274 fun = (verbose) ? "float_trunc" : "ftr";
275 op[0] = XEXP (x, 0);
276 break;
277 case FLOAT:
278 fun = (verbose) ? "float" : "flt";
279 op[0] = XEXP (x, 0);
280 break;
281 case UNSIGNED_FLOAT:
282 fun = (verbose) ? "uns_float" : "ufl";
283 op[0] = XEXP (x, 0);
284 break;
285 case FIX:
286 fun = "fix";
287 op[0] = XEXP (x, 0);
288 break;
289 case UNSIGNED_FIX:
290 fun = (verbose) ? "uns_fix" : "ufx";
291 op[0] = XEXP (x, 0);
292 break;
293 case PRE_DEC:
294 st[0] = "--";
295 op[0] = XEXP (x, 0);
296 break;
297 case PRE_INC:
298 st[0] = "++";
299 op[0] = XEXP (x, 0);
300 break;
301 case POST_DEC:
302 op[0] = XEXP (x, 0);
303 st[1] = "--";
304 break;
305 case POST_INC:
306 op[0] = XEXP (x, 0);
307 st[1] = "++";
308 break;
309 case PRE_MODIFY:
310 st[0] = "pre ";
311 op[0] = XEXP (XEXP (x, 1), 0);
312 st[1] = "+=";
313 op[1] = XEXP (XEXP (x, 1), 1);
314 break;
315 case POST_MODIFY:
316 st[0] = "post ";
317 op[0] = XEXP (XEXP (x, 1), 0);
318 st[1] = "+=";
319 op[1] = XEXP (XEXP (x, 1), 1);
320 break;
321 case CALL:
322 st[0] = "call ";
323 op[0] = XEXP (x, 0);
324 if (verbose)
326 st[1] = " argc:";
327 op[1] = XEXP (x, 1);
329 break;
330 case IF_THEN_ELSE:
331 st[0] = "{(";
332 op[0] = XEXP (x, 0);
333 st[1] = ")?";
334 op[1] = XEXP (x, 1);
335 st[2] = ":";
336 op[2] = XEXP (x, 2);
337 st[3] = "}";
338 break;
339 case TRAP_IF:
340 fun = "trap_if";
341 op[0] = TRAP_CONDITION (x);
342 break;
343 case PREFETCH:
344 fun = "prefetch";
345 op[0] = XEXP (x, 0);
346 op[1] = XEXP (x, 1);
347 op[2] = XEXP (x, 2);
348 break;
349 case UNSPEC:
350 case UNSPEC_VOLATILE:
352 pp_string (pp, "unspec");
353 if (GET_CODE (x) == UNSPEC_VOLATILE)
354 pp_string (pp, "/v");
355 pp_left_bracket (pp);
356 for (i = 0; i < XVECLEN (x, 0); i++)
358 if (i != 0)
359 pp_comma (pp);
360 print_pattern (pp, XVECEXP (x, 0, i), verbose);
362 pp_string (pp, "] ");
363 pp_decimal_int (pp, XINT (x, 1));
365 break;
366 default:
368 /* Most unhandled codes can be printed as pseudo-functions. */
369 if (GET_RTX_CLASS (GET_CODE (x)) == RTX_UNARY)
371 fun = GET_RTX_NAME (GET_CODE (x));
372 op[0] = XEXP (x, 0);
374 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_COMPARE
375 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_COMPARE
376 || GET_RTX_CLASS (GET_CODE (x)) == RTX_BIN_ARITH
377 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_ARITH)
379 fun = GET_RTX_NAME (GET_CODE (x));
380 op[0] = XEXP (x, 0);
381 op[1] = XEXP (x, 1);
383 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_TERNARY)
385 fun = GET_RTX_NAME (GET_CODE (x));
386 op[0] = XEXP (x, 0);
387 op[1] = XEXP (x, 1);
388 op[2] = XEXP (x, 2);
390 else
391 /* Give up, just print the RTX name. */
392 st[0] = GET_RTX_NAME (GET_CODE (x));
394 break;
397 /* Print this as a function? */
398 if (fun)
400 pp_string (pp, fun);
401 pp_left_paren (pp);
404 for (i = 0; i < 4; i++)
406 if (st[i])
407 pp_string (pp, st[i]);
409 if (op[i])
411 if (fun && i != 0)
412 pp_comma (pp);
413 print_value (pp, op[i], verbose);
417 if (fun)
418 pp_right_paren (pp);
419 } /* print_exp */
421 /* Prints rtxes, I customarily classified as values. They're constants,
422 registers, labels, symbols and memory accesses. */
424 void
425 print_value (pretty_printer *pp, const_rtx x, int verbose)
427 char tmp[1024];
429 if (!x)
431 pp_string (pp, "(nil)");
432 return;
434 switch (GET_CODE (x))
436 case CONST_INT:
437 pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
438 (unsigned HOST_WIDE_INT) INTVAL (x));
439 break;
441 case CONST_WIDE_INT:
443 const char *sep = "<";
444 int i;
445 for (i = CONST_WIDE_INT_NUNITS (x) - 1; i >= 0; i--)
447 pp_string (pp, sep);
448 sep = ",";
449 sprintf (tmp, HOST_WIDE_INT_PRINT_HEX,
450 (unsigned HOST_WIDE_INT) CONST_WIDE_INT_ELT (x, i));
451 pp_string (pp, tmp);
453 pp_greater (pp);
455 break;
457 case CONST_DOUBLE:
458 if (FLOAT_MODE_P (GET_MODE (x)))
460 real_to_decimal (tmp, CONST_DOUBLE_REAL_VALUE (x),
461 sizeof (tmp), 0, 1);
462 pp_string (pp, tmp);
464 else
465 pp_printf (pp, "<%wx,%wx>",
466 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x),
467 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x));
468 break;
469 case CONST_FIXED:
470 fixed_to_decimal (tmp, CONST_FIXED_VALUE (x), sizeof (tmp));
471 pp_string (pp, tmp);
472 break;
473 case CONST_STRING:
474 pp_printf (pp, "\"%s\"", XSTR (x, 0));
475 break;
476 case SYMBOL_REF:
477 pp_printf (pp, "`%s'", XSTR (x, 0));
478 break;
479 case LABEL_REF:
480 pp_printf (pp, "L%d", INSN_UID (LABEL_REF_LABEL (x)));
481 break;
482 case CONST:
483 case HIGH:
484 case STRICT_LOW_PART:
485 pp_printf (pp, "%s(", GET_RTX_NAME (GET_CODE (x)));
486 print_value (pp, XEXP (x, 0), verbose);
487 pp_right_paren (pp);
488 break;
489 case REG:
490 if (REGNO (x) < FIRST_PSEUDO_REGISTER)
492 if (ISDIGIT (reg_names[REGNO (x)][0]))
493 pp_modulo (pp);
494 pp_string (pp, reg_names[REGNO (x)]);
496 else
497 pp_printf (pp, "r%d", REGNO (x));
498 if (verbose)
499 pp_printf (pp, ":%s", GET_MODE_NAME (GET_MODE (x)));
500 break;
501 case SUBREG:
502 print_value (pp, SUBREG_REG (x), verbose);
503 pp_printf (pp, "#%d", SUBREG_BYTE (x));
504 break;
505 case SCRATCH:
506 case CC0:
507 case PC:
508 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
509 break;
510 case MEM:
511 pp_left_bracket (pp);
512 print_value (pp, XEXP (x, 0), verbose);
513 pp_right_bracket (pp);
514 break;
515 case DEBUG_EXPR:
516 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x)));
517 break;
518 default:
519 print_exp (pp, x, verbose);
520 break;
522 } /* print_value */
524 /* The next step in insn detalization, its pattern recognition. */
526 void
527 print_pattern (pretty_printer *pp, const_rtx x, int verbose)
529 if (! x)
531 pp_string (pp, "(nil)");
532 return;
535 switch (GET_CODE (x))
537 case SET:
538 print_value (pp, SET_DEST (x), verbose);
539 pp_equal (pp);
540 print_value (pp, SET_SRC (x), verbose);
541 break;
542 case RETURN:
543 case SIMPLE_RETURN:
544 case EH_RETURN:
545 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
546 break;
547 case CALL:
548 print_exp (pp, x, verbose);
549 break;
550 case CLOBBER:
551 case USE:
552 pp_printf (pp, "%s ", GET_RTX_NAME (GET_CODE (x)));
553 print_value (pp, XEXP (x, 0), verbose);
554 break;
555 case VAR_LOCATION:
556 pp_string (pp, "loc ");
557 print_value (pp, PAT_VAR_LOCATION_LOC (x), verbose);
558 break;
559 case COND_EXEC:
560 pp_left_paren (pp);
561 if (GET_CODE (COND_EXEC_TEST (x)) == NE
562 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
563 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
564 else if (GET_CODE (COND_EXEC_TEST (x)) == EQ
565 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
567 pp_exclamation (pp);
568 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
570 else
571 print_value (pp, COND_EXEC_TEST (x), verbose);
572 pp_string (pp, ") ");
573 print_pattern (pp, COND_EXEC_CODE (x), verbose);
574 break;
575 case PARALLEL:
577 int i;
579 pp_left_brace (pp);
580 for (i = 0; i < XVECLEN (x, 0); i++)
582 print_pattern (pp, XVECEXP (x, 0, i), verbose);
583 pp_semicolon (pp);
585 pp_right_brace (pp);
587 break;
588 case SEQUENCE:
590 const rtx_sequence *seq = as_a <const rtx_sequence *> (x);
591 pp_string (pp, "sequence{");
592 if (INSN_P (seq->element (0)))
594 /* Print the sequence insns indented. */
595 const char * save_print_rtx_head = print_rtx_head;
596 char indented_print_rtx_head[32];
598 pp_newline (pp);
599 gcc_assert (strlen (print_rtx_head) < sizeof (indented_print_rtx_head) - 4);
600 snprintf (indented_print_rtx_head,
601 sizeof (indented_print_rtx_head),
602 "%s ", print_rtx_head);
603 print_rtx_head = indented_print_rtx_head;
604 for (int i = 0; i < seq->len (); i++)
605 print_insn_with_notes (pp, seq->insn (i));
606 pp_printf (pp, "%s ", save_print_rtx_head);
607 print_rtx_head = save_print_rtx_head;
609 else
611 for (int i = 0; i < seq->len (); i++)
613 print_pattern (pp, seq->element (i), verbose);
614 pp_semicolon (pp);
617 pp_right_brace (pp);
619 break;
620 case ASM_INPUT:
621 pp_printf (pp, "asm {%s}", XSTR (x, 0));
622 break;
623 case ADDR_VEC:
624 for (int i = 0; i < XVECLEN (x, 0); i++)
626 print_value (pp, XVECEXP (x, 0, i), verbose);
627 pp_semicolon (pp);
629 break;
630 case ADDR_DIFF_VEC:
631 for (int i = 0; i < XVECLEN (x, 1); i++)
633 print_value (pp, XVECEXP (x, 1, i), verbose);
634 pp_semicolon (pp);
636 break;
637 case TRAP_IF:
638 pp_string (pp, "trap_if ");
639 print_value (pp, TRAP_CONDITION (x), verbose);
640 break;
641 case UNSPEC:
642 case UNSPEC_VOLATILE:
643 /* Fallthru -- leave UNSPECs to print_exp. */
644 default:
645 print_value (pp, x, verbose);
647 } /* print_pattern */
649 /* This is the main function in slim rtl visualization mechanism.
651 X is an insn, to be printed into PP.
653 This function tries to print it properly in human-readable form,
654 resembling assembler mnemonics (instead of the older Lisp-style
655 form).
657 If VERBOSE is TRUE, insns are printed with more complete (but
658 longer) pattern names and with extra information, and prefixed
659 with their INSN_UIDs. */
661 void
662 print_insn (pretty_printer *pp, const rtx_insn *x, int verbose)
664 if (verbose)
666 /* Blech, pretty-print can't print integers with a specified width. */
667 char uid_prefix[32];
668 snprintf (uid_prefix, sizeof uid_prefix, " %4d: ", INSN_UID (x));
669 pp_string (pp, uid_prefix);
672 switch (GET_CODE (x))
674 case INSN:
675 print_pattern (pp, PATTERN (x), verbose);
676 break;
678 case DEBUG_INSN:
680 const char *name = "?";
682 if (DECL_P (INSN_VAR_LOCATION_DECL (x)))
684 tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x));
685 char idbuf[32];
686 if (id)
687 name = IDENTIFIER_POINTER (id);
688 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x))
689 == DEBUG_EXPR_DECL)
691 sprintf (idbuf, "D#%i",
692 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x)));
693 name = idbuf;
695 else
697 sprintf (idbuf, "D.%i",
698 DECL_UID (INSN_VAR_LOCATION_DECL (x)));
699 name = idbuf;
702 pp_printf (pp, "debug %s => ", name);
703 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x)))
704 pp_string (pp, "optimized away");
705 else
706 print_pattern (pp, INSN_VAR_LOCATION_LOC (x), verbose);
708 break;
710 case JUMP_INSN:
711 print_pattern (pp, PATTERN (x), verbose);
712 break;
713 case CALL_INSN:
714 if (GET_CODE (PATTERN (x)) == PARALLEL)
715 print_pattern (pp, XVECEXP (PATTERN (x), 0, 0), verbose);
716 else
717 print_pattern (pp, PATTERN (x), verbose);
718 break;
719 case CODE_LABEL:
720 pp_printf (pp, "L%d:", INSN_UID (x));
721 break;
722 case JUMP_TABLE_DATA:
723 pp_string (pp, "jump_table_data{\n");
724 print_pattern (pp, PATTERN (x), verbose);
725 pp_right_brace (pp);
726 break;
727 case BARRIER:
728 pp_string (pp, "barrier");
729 break;
730 case NOTE:
732 pp_string (pp, GET_NOTE_INSN_NAME (NOTE_KIND (x)));
733 switch (NOTE_KIND (x))
735 case NOTE_INSN_EH_REGION_BEG:
736 case NOTE_INSN_EH_REGION_END:
737 pp_printf (pp, " %d", NOTE_EH_HANDLER (x));
738 break;
740 case NOTE_INSN_BLOCK_BEG:
741 case NOTE_INSN_BLOCK_END:
742 pp_printf (pp, " %d", BLOCK_NUMBER (NOTE_BLOCK (x)));
743 break;
745 case NOTE_INSN_BASIC_BLOCK:
746 pp_printf (pp, " %d", NOTE_BASIC_BLOCK (x)->index);
747 break;
749 case NOTE_INSN_DELETED_LABEL:
750 case NOTE_INSN_DELETED_DEBUG_LABEL:
752 const char *label = NOTE_DELETED_LABEL_NAME (x);
753 if (label == NULL)
754 label = "";
755 pp_printf (pp, " (\"%s\")", label);
757 break;
759 case NOTE_INSN_VAR_LOCATION:
760 case NOTE_INSN_CALL_ARG_LOCATION:
761 pp_left_brace (pp);
762 print_pattern (pp, NOTE_VAR_LOCATION (x), verbose);
763 pp_right_brace (pp);
764 break;
766 default:
767 break;
769 break;
771 default:
772 gcc_unreachable ();
774 } /* print_insn */
776 /* Pretty-print a slim dump of X (an insn) to PP, including any register
777 note attached to the instruction. */
779 static void
780 print_insn_with_notes (pretty_printer *pp, const rtx_insn *x)
782 pp_string (pp, print_rtx_head);
783 print_insn (pp, x, 1);
784 pp_newline (pp);
785 if (INSN_P (x) && REG_NOTES (x))
786 for (rtx note = REG_NOTES (x); note; note = XEXP (note, 1))
788 pp_printf (pp, "%s %s ", print_rtx_head,
789 GET_REG_NOTE_NAME (REG_NOTE_KIND (note)));
790 if (GET_CODE (note) == INT_LIST)
791 pp_printf (pp, "%d", XINT (note, 0));
792 else
793 print_pattern (pp, XEXP (note, 0), 1);
794 pp_newline (pp);
798 /* Print X, an RTL value node, to file F in slim format. Include
799 additional information if VERBOSE is nonzero.
801 Value nodes are constants, registers, labels, symbols and
802 memory. */
804 void
805 dump_value_slim (FILE *f, const_rtx x, int verbose)
807 pretty_printer rtl_slim_pp;
808 rtl_slim_pp.buffer->stream = f;
809 print_value (&rtl_slim_pp, x, verbose);
810 pp_flush (&rtl_slim_pp);
813 /* Emit a slim dump of X (an insn) to the file F, including any register
814 note attached to the instruction. */
815 void
816 dump_insn_slim (FILE *f, const rtx_insn *x)
818 pretty_printer rtl_slim_pp;
819 rtl_slim_pp.buffer->stream = f;
820 print_insn_with_notes (&rtl_slim_pp, x);
821 pp_flush (&rtl_slim_pp);
824 /* Same as above, but stop at LAST or when COUNT == 0.
825 If COUNT < 0 it will stop only at LAST or NULL rtx. */
827 void
828 dump_rtl_slim (FILE *f, const rtx_insn *first, const rtx_insn *last,
829 int count, int flags ATTRIBUTE_UNUSED)
831 const rtx_insn *insn, *tail;
832 pretty_printer rtl_slim_pp;
833 rtl_slim_pp.buffer->stream = f;
835 tail = last ? NEXT_INSN (last) : NULL;
836 for (insn = first;
837 (insn != NULL) && (insn != tail) && (count != 0);
838 insn = NEXT_INSN (insn))
840 print_insn_with_notes (&rtl_slim_pp, insn);
841 if (count > 0)
842 count--;
845 pp_flush (&rtl_slim_pp);
848 /* Dumps basic block BB to pretty-printer PP in slim form and without and
849 no indentation, for use as a label of a DOT graph record-node. */
851 void
852 rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
854 rtx_insn *insn;
855 bool first = true;
857 /* TODO: inter-bb stuff. */
858 FOR_BB_INSNS (bb, insn)
860 if (! first)
862 pp_bar (pp);
863 pp_write_text_to_stream (pp);
865 first = false;
866 print_insn_with_notes (pp, insn);
867 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
871 /* Pretty-print pattern X of some insn in non-verbose mode.
872 Return a string pointer to the pretty-printer buffer.
874 This function is only exported exists only to accommodate some older users
875 of the slim RTL pretty printers. Please do not use it for new code. */
877 const char *
878 str_pattern_slim (const_rtx x)
880 pretty_printer rtl_slim_pp;
881 print_pattern (&rtl_slim_pp, x, 0);
882 return ggc_strdup (pp_formatted_text (&rtl_slim_pp));
885 /* Emit a slim dump of X (an insn) to stderr. */
886 extern void debug_insn_slim (const rtx_insn *);
887 DEBUG_FUNCTION void
888 debug_insn_slim (const rtx_insn *x)
890 dump_insn_slim (stderr, x);
893 /* Same as above, but using dump_rtl_slim. */
894 extern void debug_rtl_slim (FILE *, const rtx_insn *, const rtx_insn *,
895 int, int);
896 DEBUG_FUNCTION void
897 debug_rtl_slim (const rtx_insn *first, const rtx_insn *last, int count,
898 int flags)
900 dump_rtl_slim (stderr, first, last, count, flags);
903 extern void debug_bb_slim (basic_block);
904 DEBUG_FUNCTION void
905 debug_bb_slim (basic_block bb)
907 dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
910 extern void debug_bb_n_slim (int);
911 DEBUG_FUNCTION void
912 debug_bb_n_slim (int n)
914 basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
915 debug_bb_slim (bb);