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