PR other/54324
[official-gcc.git] / gcc / sched-vis.c
blobbdb166e53859696538f7064f60ee62dff38743e9
1 /* Printing of RTL in "slim", mnemonic like form.
2 Copyright (C) 1992-2012
3 Free Software Foundation, Inc.
4 Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
5 and currently maintained by, Jim Wilson (wilson@cygnus.com)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
12 version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 /* Historically this form of RTL dumping was introduced along with
24 the Haifa instruction scheduling pass, hence the name of this file.
25 But there is nothing in this file left that is scheduler-specific. */
27 #include "config.h"
28 #include "system.h"
29 #include "coretypes.h"
30 #include "tm.h"
31 #include "rtl.h"
32 #include "tree.h" /* FIXME: To dump INSN_VAR_LOCATION_DECL. */
33 #include "basic-block.h"
34 #include "dumpfile.h" /* for the TDF_* flags */
35 #include "pretty-print.h"
37 /* The functions in this file try to print RTL in a form resembling assembler
38 mnemonics. Because this form is more concise than the "traditional" form
39 of RTL printing in Lisp-style, the form printed by this file is called
40 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
41 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
42 always printed in slim form.
44 The normal interface to the functionality provided in this pretty-printer
45 is through the dump_*_slim functions to print to a stream, or via the
46 print_*_slim functions to print into a user's pretty-printer.
48 It is also possible to obtain a string for a single pattern as a string
49 pointer, via str_pattern_slim, but this usage is discouraged. */
51 /* A pretty-printer for slim rtl printing. */
52 static bool rtl_slim_pp_initialized = false;
53 static pretty_printer rtl_slim_pp;
55 /* This recognizes rtx'en classified as expressions. These are always
56 represent some action on values or results of other expression, that
57 may be stored in objects representing values. */
59 static void
60 print_exp (pretty_printer *pp, const_rtx x, int verbose)
62 const char *st[4];
63 const char *fun;
64 rtx op[4];
65 int i;
67 fun = (char *) 0;
68 for (i = 0; i < 4; i++)
70 st[i] = (char *) 0;
71 op[i] = NULL_RTX;
74 switch (GET_CODE (x))
76 case PLUS:
77 op[0] = XEXP (x, 0);
78 if (CONST_INT_P (XEXP (x, 1))
79 && INTVAL (XEXP (x, 1)) < 0)
81 st[1] = "-";
82 op[1] = GEN_INT (-INTVAL (XEXP (x, 1)));
84 else
86 st[1] = "+";
87 op[1] = XEXP (x, 1);
89 break;
90 case LO_SUM:
91 op[0] = XEXP (x, 0);
92 st[1] = "+low(";
93 op[1] = XEXP (x, 1);
94 st[2] = ")";
95 break;
96 case MINUS:
97 op[0] = XEXP (x, 0);
98 st[1] = "-";
99 op[1] = XEXP (x, 1);
100 break;
101 case COMPARE:
102 fun = "cmp";
103 op[0] = XEXP (x, 0);
104 op[1] = XEXP (x, 1);
105 break;
106 case NEG:
107 st[0] = "-";
108 op[0] = XEXP (x, 0);
109 break;
110 case FMA:
111 st[0] = "{";
112 op[0] = XEXP (x, 0);
113 st[1] = "*";
114 op[1] = XEXP (x, 1);
115 st[2] = "+";
116 op[2] = XEXP (x, 2);
117 st[3] = "}";
118 break;
119 case MULT:
120 op[0] = XEXP (x, 0);
121 st[1] = "*";
122 op[1] = XEXP (x, 1);
123 break;
124 case DIV:
125 op[0] = XEXP (x, 0);
126 st[1] = "/";
127 op[1] = XEXP (x, 1);
128 break;
129 case UDIV:
130 fun = "udiv";
131 op[0] = XEXP (x, 0);
132 op[1] = XEXP (x, 1);
133 break;
134 case MOD:
135 op[0] = XEXP (x, 0);
136 st[1] = "%";
137 op[1] = XEXP (x, 1);
138 break;
139 case UMOD:
140 fun = "umod";
141 op[0] = XEXP (x, 0);
142 op[1] = XEXP (x, 1);
143 break;
144 case SMIN:
145 fun = "smin";
146 op[0] = XEXP (x, 0);
147 op[1] = XEXP (x, 1);
148 break;
149 case SMAX:
150 fun = "smax";
151 op[0] = XEXP (x, 0);
152 op[1] = XEXP (x, 1);
153 break;
154 case UMIN:
155 fun = "umin";
156 op[0] = XEXP (x, 0);
157 op[1] = XEXP (x, 1);
158 break;
159 case UMAX:
160 fun = "umax";
161 op[0] = XEXP (x, 0);
162 op[1] = XEXP (x, 1);
163 break;
164 case NOT:
165 st[0] = "!";
166 op[0] = XEXP (x, 0);
167 break;
168 case AND:
169 op[0] = XEXP (x, 0);
170 st[1] = "&";
171 op[1] = XEXP (x, 1);
172 break;
173 case IOR:
174 op[0] = XEXP (x, 0);
175 st[1] = "|";
176 op[1] = XEXP (x, 1);
177 break;
178 case XOR:
179 op[0] = XEXP (x, 0);
180 st[1] = "^";
181 op[1] = XEXP (x, 1);
182 break;
183 case ASHIFT:
184 op[0] = XEXP (x, 0);
185 st[1] = "<<";
186 op[1] = XEXP (x, 1);
187 break;
188 case LSHIFTRT:
189 op[0] = XEXP (x, 0);
190 st[1] = " 0>>";
191 op[1] = XEXP (x, 1);
192 break;
193 case ASHIFTRT:
194 op[0] = XEXP (x, 0);
195 st[1] = ">>";
196 op[1] = XEXP (x, 1);
197 break;
198 case ROTATE:
199 op[0] = XEXP (x, 0);
200 st[1] = "<-<";
201 op[1] = XEXP (x, 1);
202 break;
203 case ROTATERT:
204 op[0] = XEXP (x, 0);
205 st[1] = ">->";
206 op[1] = XEXP (x, 1);
207 break;
208 case NE:
209 op[0] = XEXP (x, 0);
210 st[1] = "!=";
211 op[1] = XEXP (x, 1);
212 break;
213 case EQ:
214 op[0] = XEXP (x, 0);
215 st[1] = "==";
216 op[1] = XEXP (x, 1);
217 break;
218 case GE:
219 op[0] = XEXP (x, 0);
220 st[1] = ">=";
221 op[1] = XEXP (x, 1);
222 break;
223 case GT:
224 op[0] = XEXP (x, 0);
225 st[1] = ">";
226 op[1] = XEXP (x, 1);
227 break;
228 case LE:
229 op[0] = XEXP (x, 0);
230 st[1] = "<=";
231 op[1] = XEXP (x, 1);
232 break;
233 case LT:
234 op[0] = XEXP (x, 0);
235 st[1] = "<";
236 op[1] = XEXP (x, 1);
237 break;
238 case SIGN_EXTRACT:
239 fun = (verbose) ? "sign_extract" : "sxt";
240 op[0] = XEXP (x, 0);
241 op[1] = XEXP (x, 1);
242 op[2] = XEXP (x, 2);
243 break;
244 case ZERO_EXTRACT:
245 fun = (verbose) ? "zero_extract" : "zxt";
246 op[0] = XEXP (x, 0);
247 op[1] = XEXP (x, 1);
248 op[2] = XEXP (x, 2);
249 break;
250 case SIGN_EXTEND:
251 fun = (verbose) ? "sign_extend" : "sxn";
252 op[0] = XEXP (x, 0);
253 break;
254 case ZERO_EXTEND:
255 fun = (verbose) ? "zero_extend" : "zxn";
256 op[0] = XEXP (x, 0);
257 break;
258 case FLOAT_EXTEND:
259 fun = (verbose) ? "float_extend" : "fxn";
260 op[0] = XEXP (x, 0);
261 break;
262 case TRUNCATE:
263 fun = (verbose) ? "trunc" : "trn";
264 op[0] = XEXP (x, 0);
265 break;
266 case FLOAT_TRUNCATE:
267 fun = (verbose) ? "float_trunc" : "ftr";
268 op[0] = XEXP (x, 0);
269 break;
270 case FLOAT:
271 fun = (verbose) ? "float" : "flt";
272 op[0] = XEXP (x, 0);
273 break;
274 case UNSIGNED_FLOAT:
275 fun = (verbose) ? "uns_float" : "ufl";
276 op[0] = XEXP (x, 0);
277 break;
278 case FIX:
279 fun = "fix";
280 op[0] = XEXP (x, 0);
281 break;
282 case UNSIGNED_FIX:
283 fun = (verbose) ? "uns_fix" : "ufx";
284 op[0] = XEXP (x, 0);
285 break;
286 case PRE_DEC:
287 st[0] = "--";
288 op[0] = XEXP (x, 0);
289 break;
290 case PRE_INC:
291 st[0] = "++";
292 op[0] = XEXP (x, 0);
293 break;
294 case POST_DEC:
295 op[0] = XEXP (x, 0);
296 st[1] = "--";
297 break;
298 case POST_INC:
299 op[0] = XEXP (x, 0);
300 st[1] = "++";
301 break;
302 case PRE_MODIFY:
303 st[0] = "pre ";
304 op[0] = XEXP (XEXP (x, 1), 0);
305 st[1] = "+=";
306 op[1] = XEXP (XEXP (x, 1), 1);
307 break;
308 case POST_MODIFY:
309 st[0] = "post ";
310 op[0] = XEXP (XEXP (x, 1), 0);
311 st[1] = "+=";
312 op[1] = XEXP (XEXP (x, 1), 1);
313 break;
314 case CALL:
315 st[0] = "call ";
316 op[0] = XEXP (x, 0);
317 if (verbose)
319 st[1] = " argc:";
320 op[1] = XEXP (x, 1);
322 break;
323 case IF_THEN_ELSE:
324 st[0] = "{(";
325 op[0] = XEXP (x, 0);
326 st[1] = ")?";
327 op[1] = XEXP (x, 1);
328 st[2] = ":";
329 op[2] = XEXP (x, 2);
330 st[3] = "}";
331 break;
332 case TRAP_IF:
333 fun = "trap_if";
334 op[0] = TRAP_CONDITION (x);
335 break;
336 case PREFETCH:
337 fun = "prefetch";
338 op[0] = XEXP (x, 0);
339 op[1] = XEXP (x, 1);
340 op[2] = XEXP (x, 2);
341 break;
342 case UNSPEC:
343 case UNSPEC_VOLATILE:
345 pp_string (pp, "unspec");
346 if (GET_CODE (x) == UNSPEC_VOLATILE)
347 pp_string (pp, "/v");
348 pp_character (pp, '[');
349 for (i = 0; i < XVECLEN (x, 0); i++)
351 if (i != 0)
352 pp_character (pp, ',');
353 print_pattern (pp, XVECEXP (x, 0, i), verbose);
355 pp_string (pp, "] ");
356 pp_decimal_int (pp, XINT (x, 1));
358 break;
359 default:
361 /* Most unhandled codes can be printed as pseudo-functions. */
362 if (GET_RTX_CLASS (GET_CODE (x)) == RTX_UNARY)
364 fun = GET_RTX_NAME (GET_CODE (x));
365 op[0] = XEXP (x, 0);
367 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_COMPARE
368 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_COMPARE
369 || GET_RTX_CLASS (GET_CODE (x)) == RTX_BIN_ARITH
370 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_ARITH)
372 fun = GET_RTX_NAME (GET_CODE (x));
373 op[0] = XEXP (x, 0);
374 op[1] = XEXP (x, 1);
376 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_TERNARY)
378 fun = GET_RTX_NAME (GET_CODE (x));
379 op[0] = XEXP (x, 0);
380 op[1] = XEXP (x, 1);
381 op[2] = XEXP (x, 2);
383 else
384 /* Give up, just print the RTX name. */
385 st[0] = GET_RTX_NAME (GET_CODE (x));
387 break;
390 /* Print this as a function? */
391 if (fun)
393 pp_string (pp, fun);
394 pp_character (pp, '(');
397 for (i = 0; i < 4; i++)
399 if (st[i])
400 pp_string (pp, st[i]);
402 if (op[i])
404 if (fun && i != 0)
405 pp_character (pp, ',');
406 print_value (pp, op[i], verbose);
410 if (fun)
411 pp_character (pp, ')');
412 } /* print_exp */
414 /* Prints rtxes, I customarily classified as values. They're constants,
415 registers, labels, symbols and memory accesses. */
417 void
418 print_value (pretty_printer *pp, const_rtx x, int verbose)
420 char tmp[1024];
422 if (!x)
424 pp_string (pp, "(nil)");
425 return;
427 switch (GET_CODE (x))
429 case CONST_INT:
430 pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
431 (unsigned HOST_WIDE_INT) INTVAL (x));
432 break;
433 case CONST_DOUBLE:
434 if (FLOAT_MODE_P (GET_MODE (x)))
436 real_to_decimal (tmp, CONST_DOUBLE_REAL_VALUE (x),
437 sizeof (tmp), 0, 1);
438 pp_string (pp, tmp);
440 else
441 pp_printf (pp, "<%wx,%wx>",
442 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x),
443 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x));
444 break;
445 case CONST_FIXED:
446 fixed_to_decimal (tmp, CONST_FIXED_VALUE (x), sizeof (tmp));
447 pp_string (pp, tmp);
448 break;
449 case CONST_STRING:
450 pp_printf (pp, "\"%s\"", XSTR (x, 0));
451 break;
452 case SYMBOL_REF:
453 pp_printf (pp, "`%s'", XSTR (x, 0));
454 break;
455 case LABEL_REF:
456 pp_printf (pp, "L%d", INSN_UID (XEXP (x, 0)));
457 break;
458 case CONST:
459 case HIGH:
460 case STRICT_LOW_PART:
461 pp_printf (pp, "%s(", GET_RTX_NAME (GET_CODE (x)));
462 print_value (pp, XEXP (x, 0), verbose);
463 pp_character (pp, ')');
464 break;
465 case REG:
466 if (REGNO (x) < FIRST_PSEUDO_REGISTER)
468 if (ISDIGIT (reg_names[REGNO (x)][0]))
469 pp_character (pp, '%');
470 pp_string (pp, reg_names[REGNO (x)]);
472 else
473 pp_printf (pp, "r%d", REGNO (x));
474 if (verbose)
475 pp_printf (pp, ":%s", GET_MODE_NAME (GET_MODE (x)));
476 break;
477 case SUBREG:
478 print_value (pp, SUBREG_REG (x), verbose);
479 pp_printf (pp, "#%d", SUBREG_BYTE (x));
480 break;
481 case SCRATCH:
482 case CC0:
483 case PC:
484 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
485 break;
486 case MEM:
487 pp_character (pp, '[');
488 print_value (pp, XEXP (x, 0), verbose);
489 pp_character (pp, ']');
490 break;
491 case DEBUG_EXPR:
492 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x)));
493 break;
494 default:
495 print_exp (pp, x, verbose);
496 break;
498 } /* print_value */
500 /* The next step in insn detalization, its pattern recognition. */
502 void
503 print_pattern (pretty_printer *pp, const_rtx x, int verbose)
505 if (! x)
507 pp_string (pp, "(nil)");
508 return;
511 switch (GET_CODE (x))
513 case SET:
514 print_value (pp, SET_DEST (x), verbose);
515 pp_character (pp, '=');
516 print_value (pp, SET_SRC (x), verbose);
517 break;
518 case RETURN:
519 case SIMPLE_RETURN:
520 case EH_RETURN:
521 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
522 break;
523 case CALL:
524 print_exp (pp, x, verbose);
525 break;
526 case CLOBBER:
527 case USE:
528 pp_printf (pp, "%s ", GET_RTX_NAME (GET_CODE (x)));
529 print_value (pp, XEXP (x, 0), verbose);
530 break;
531 case VAR_LOCATION:
532 pp_string (pp, "loc ");
533 print_value (pp, PAT_VAR_LOCATION_LOC (x), verbose);
534 break;
535 case COND_EXEC:
536 pp_character (pp, '(');
537 if (GET_CODE (COND_EXEC_TEST (x)) == NE
538 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
539 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
540 else if (GET_CODE (COND_EXEC_TEST (x)) == EQ
541 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
543 pp_character (pp, '!');
544 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
546 else
547 print_value (pp, COND_EXEC_TEST (x), verbose);
548 pp_string (pp, ") ");
549 print_pattern (pp, COND_EXEC_CODE (x), verbose);
550 break;
551 case PARALLEL:
553 int i;
555 pp_character (pp, '{');
556 for (i = 0; i < XVECLEN (x, 0); i++)
558 print_pattern (pp, XVECEXP (x, 0, i), verbose);
559 pp_character (pp, ';');
561 pp_character (pp, '}');
563 break;
564 case SEQUENCE:
566 int i;
568 pp_string (pp, "sequence{");
569 for (i = 0; i < XVECLEN (x, 0); i++)
571 print_pattern (pp, XVECEXP (x, 0, i), verbose);
572 pp_character (pp, ';');
574 pp_character (pp, '}');
576 break;
577 case ASM_INPUT:
578 pp_printf (pp, "asm {%s}", XSTR (x, 0));
579 break;
580 case ADDR_VEC:
581 /* Fall through. */
582 case ADDR_DIFF_VEC:
583 print_value (pp, XEXP (x, 0), verbose);
584 break;
585 case TRAP_IF:
586 pp_string (pp, "trap_if ");
587 print_value (pp, TRAP_CONDITION (x), verbose);
588 break;
589 case UNSPEC:
590 case UNSPEC_VOLATILE:
591 /* Fallthru -- leave UNSPECs to print_exp. */
592 default:
593 print_value (pp, x, verbose);
595 } /* print_pattern */
597 /* This is the main function in slim rtl visualization mechanism.
599 X is an insn, to be printed into PP.
601 This function tries to print it properly in human-readable form,
602 resembling assembler mnemonics (instead of the older Lisp-style
603 form).
605 If VERBOSE is TRUE, insns are printed with more complete (but
606 longer) pattern names and with extra information, and prefixed
607 with their INSN_UIDs. */
609 void
610 print_insn (pretty_printer *pp, const_rtx x, int verbose)
612 if (verbose)
614 /* Blech, pretty-print can't print integers with a specified width. */
615 char uid_prefix[32];
616 snprintf (uid_prefix, sizeof uid_prefix, " %4d: ", INSN_UID (x));
617 pp_string (pp, uid_prefix);
620 switch (GET_CODE (x))
622 case INSN:
623 print_pattern (pp, PATTERN (x), verbose);
624 break;
626 case DEBUG_INSN:
628 const char *name = "?";
630 if (DECL_P (INSN_VAR_LOCATION_DECL (x)))
632 tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x));
633 char idbuf[32];
634 if (id)
635 name = IDENTIFIER_POINTER (id);
636 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x))
637 == DEBUG_EXPR_DECL)
639 sprintf (idbuf, "D#%i",
640 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x)));
641 name = idbuf;
643 else
645 sprintf (idbuf, "D.%i",
646 DECL_UID (INSN_VAR_LOCATION_DECL (x)));
647 name = idbuf;
650 pp_printf (pp, "debug %s => ", name);
651 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x)))
652 pp_string (pp, "optimized away");
653 else
654 print_pattern (pp, INSN_VAR_LOCATION_LOC (x), verbose);
656 break;
658 case JUMP_INSN:
659 print_pattern (pp, PATTERN (x), verbose);
660 break;
661 case CALL_INSN:
662 if (GET_CODE (PATTERN (x)) == PARALLEL)
663 print_pattern (pp, XVECEXP (PATTERN (x), 0, 0), verbose);
664 else
665 print_pattern (pp, PATTERN (x), verbose);
666 break;
667 case CODE_LABEL:
668 pp_printf (pp, "L%d:", INSN_UID (x));
669 break;
670 case BARRIER:
671 pp_string (pp, "barrier");
672 break;
673 case NOTE:
675 pp_string (pp, GET_NOTE_INSN_NAME (NOTE_KIND (x)));
676 switch (NOTE_KIND (x))
678 case NOTE_INSN_EH_REGION_BEG:
679 case NOTE_INSN_EH_REGION_END:
680 pp_printf (pp, " %d", NOTE_EH_HANDLER (x));
681 break;
683 case NOTE_INSN_BLOCK_BEG:
684 case NOTE_INSN_BLOCK_END:
685 pp_printf (pp, " %d", BLOCK_NUMBER (NOTE_BLOCK (x)));
686 break;
688 case NOTE_INSN_BASIC_BLOCK:
689 pp_printf (pp, " %d", NOTE_BASIC_BLOCK (x)->index);
690 break;
692 case NOTE_INSN_DELETED_LABEL:
693 case NOTE_INSN_DELETED_DEBUG_LABEL:
695 const char *label = NOTE_DELETED_LABEL_NAME (x);
696 if (label == NULL)
697 label = "";
698 pp_printf (pp, " (\"%s\")", label);
700 break;
702 case NOTE_INSN_VAR_LOCATION:
703 case NOTE_INSN_CALL_ARG_LOCATION:
704 pp_character (pp, '{');
705 print_pattern (pp, NOTE_VAR_LOCATION (x), verbose);
706 pp_character (pp, '}');
707 break;
709 default:
710 break;
712 break;
714 default:
715 gcc_unreachable ();
717 } /* print_insn */
719 /* Pretty-print a slim dump of X (an insn) to PP, including any register
720 note attached to the instruction. */
722 static void
723 print_insn_with_notes (pretty_printer *pp, const_rtx x)
725 pp_string (pp, print_rtx_head);
726 print_insn (pp, x, 1);
727 pp_newline (pp);
728 if (INSN_P (x) && REG_NOTES (x))
729 for (rtx note = REG_NOTES (x); note; note = XEXP (note, 1))
731 pp_printf (pp, "%s %s ", print_rtx_head,
732 GET_REG_NOTE_NAME (REG_NOTE_KIND (note)));
733 print_pattern (pp, XEXP (note, 0), 1);
734 pp_newline (pp);
738 /* Return a pretty-print buffer set up to print to file F. */
740 static pretty_printer *
741 init_rtl_slim_pretty_print (FILE *f)
743 if (! rtl_slim_pp_initialized)
745 pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
746 rtl_slim_pp_initialized = true;
748 else
749 /* Clean out any data that str_insn_slim may have left here. */
750 pp_clear_output_area (&rtl_slim_pp);
752 rtl_slim_pp.buffer->stream = f;
753 return &rtl_slim_pp;
756 /* Print X, an RTL value node, to file F in slim format. Include
757 additional information if VERBOSE is nonzero.
759 Value nodes are constants, registers, labels, symbols and
760 memory. */
762 void
763 dump_value_slim (FILE *f, const_rtx x, int verbose)
765 pretty_printer *pp = init_rtl_slim_pretty_print (f);
766 print_value (pp, x, verbose);
767 pp_flush (pp);
770 /* Emit a slim dump of X (an insn) to the file F, including any register
771 note attached to the instruction. */
772 void
773 dump_insn_slim (FILE *f, const_rtx x)
775 pretty_printer *pp = init_rtl_slim_pretty_print (f);
776 print_insn_with_notes (pp, x);
777 pp_flush (pp);
780 /* Same as above, but stop at LAST or when COUNT == 0.
781 If COUNT < 0 it will stop only at LAST or NULL rtx. */
783 void
784 dump_rtl_slim (FILE *f, const_rtx first, const_rtx last,
785 int count, int flags ATTRIBUTE_UNUSED)
787 const_rtx insn, tail;
788 pretty_printer *pp = init_rtl_slim_pretty_print (f);
790 tail = last ? NEXT_INSN (last) : NULL_RTX;
791 for (insn = first;
792 (insn != NULL) && (insn != tail) && (count != 0);
793 insn = NEXT_INSN (insn))
795 print_insn_with_notes (pp, insn);
796 if (count > 0)
797 count--;
800 pp_flush (pp);
803 /* Dumps basic block BB to pretty-printer PP in slim form and without and
804 no indentation, for use as a label of a DOT graph record-node. */
806 void
807 rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
809 rtx insn;
810 bool first = true;
812 /* TODO: inter-bb stuff. */
813 FOR_BB_INSNS (bb, insn)
815 if (! first)
817 pp_character (pp, '|');
818 pp_write_text_to_stream (pp);
820 first = false;
821 print_insn_with_notes (pp, insn);
822 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
826 /* Pretty-print pattern X of some insn in non-verbose mode.
827 Return a string pointer to the pretty-printer buffer.
829 This function is only exported exists only to accommodate some older users
830 of the slim RTL pretty printers. Please do not use it for new code. */
832 const char *
833 str_pattern_slim (const_rtx x)
835 pretty_printer *pp = init_rtl_slim_pretty_print (NULL);
836 print_pattern (pp, x, 0);
837 return pp_base_formatted_text (pp);
840 /* Emit a slim dump of X (an insn) to stderr. */
841 extern void debug_insn_slim (const_rtx);
842 DEBUG_FUNCTION void
843 debug_insn_slim (const_rtx x)
845 dump_insn_slim (stderr, x);
848 /* Same as above, but using dump_rtl_slim. */
849 extern void debug_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
850 DEBUG_FUNCTION void
851 debug_rtl_slim (const_rtx first, const_rtx last, int count, int flags)
853 dump_rtl_slim (stderr, first, last, count, flags);
856 extern void debug_bb_slim (basic_block);
857 DEBUG_FUNCTION void
858 debug_bb_slim (basic_block bb)
860 dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
863 extern void debug_bb_n_slim (int);
864 DEBUG_FUNCTION void
865 debug_bb_n_slim (int n)
867 basic_block bb = BASIC_BLOCK (n);
868 debug_bb_slim (bb);