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