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