Add -static-libasan option to the GCC driver
[gcc.git] / gcc / sched-vis.c
1 /* Instruction scheduling pass.
2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
4 Free Software Foundation, Inc.
5 Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
6 and currently maintained by, Jim Wilson (wilson@cygnus.com)
7
8 This file is part of GCC.
9
10 GCC is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 3, or (at your option) any later
13 version.
14
15 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3. If not see
22 <http://www.gnu.org/licenses/>. */
23 \f
24 #include "config.h"
25 #include "system.h"
26 #include "coretypes.h"
27 #include "tm.h"
28 #include "rtl.h"
29 #include "tree.h" /* FIXME: To dump INSN_VAR_LOCATION_DECL. */
30 #include "obstack.h"
31 #include "hard-reg-set.h"
32 #include "basic-block.h"
33 #include "insn-attr.h"
34 #include "sched-int.h"
35 #include "dumpfile.h" /* for the TDF_* flags */
36
37 static char *safe_concat (char *, char *, const char *);
38
39 #define BUF_LEN 2048
40
41 static char *
42 safe_concat (char *buf, char *cur, const char *str)
43 {
44 char *end = buf + BUF_LEN - 2; /* Leave room for null. */
45 int c;
46
47 if (cur > end)
48 {
49 *end = '\0';
50 return end;
51 }
52
53 while (cur < end && (c = *str++) != '\0')
54 *cur++ = c;
55
56 *cur = '\0';
57 return cur;
58 }
59
60 /* This recognizes rtx, I 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. */
63
64 static void
65 print_exp (char *buf, const_rtx x, int verbose)
66 {
67 char tmp[BUF_LEN];
68 const char *st[4];
69 char *cur = buf;
70 const char *fun = (char *) 0;
71 const char *sep;
72 rtx op[4];
73 int i;
74
75 for (i = 0; i < 4; i++)
76 {
77 st[i] = (char *) 0;
78 op[i] = NULL_RTX;
79 }
80
81 switch (GET_CODE (x))
82 {
83 case PLUS:
84 op[0] = XEXP (x, 0);
85 if (CONST_INT_P (XEXP (x, 1))
86 && INTVAL (XEXP (x, 1)) < 0)
87 {
88 st[1] = "-";
89 op[1] = GEN_INT (-INTVAL (XEXP (x, 1)));
90 }
91 else
92 {
93 st[1] = "+";
94 op[1] = XEXP (x, 1);
95 }
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)
325 {
326 st[1] = " argc:";
327 op[1] = XEXP (x, 1);
328 }
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:
351 {
352 cur = safe_concat (buf, cur, "unspec");
353 if (GET_CODE (x) == UNSPEC_VOLATILE)
354 cur = safe_concat (buf, cur, "/v");
355 cur = safe_concat (buf, cur, "[");
356 sep = "";
357 for (i = 0; i < XVECLEN (x, 0); i++)
358 {
359 print_pattern (tmp, XVECEXP (x, 0, i), verbose);
360 cur = safe_concat (buf, cur, sep);
361 cur = safe_concat (buf, cur, tmp);
362 sep = ",";
363 }
364 cur = safe_concat (buf, cur, "] ");
365 sprintf (tmp, "%d", XINT (x, 1));
366 cur = safe_concat (buf, cur, tmp);
367 }
368 break;
369 default:
370 {
371 /* Most unhandled codes can be printed as pseudo-functions. */
372 if (GET_RTX_CLASS (GET_CODE (x)) == RTX_UNARY)
373 {
374 fun = GET_RTX_NAME (GET_CODE (x));
375 op[0] = XEXP (x, 0);
376 }
377 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_COMPARE
378 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_COMPARE
379 || GET_RTX_CLASS (GET_CODE (x)) == RTX_BIN_ARITH
380 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_ARITH)
381 {
382 fun = GET_RTX_NAME (GET_CODE (x));
383 op[0] = XEXP (x, 0);
384 op[1] = XEXP (x, 1);
385 }
386 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_TERNARY)
387 {
388 fun = GET_RTX_NAME (GET_CODE (x));
389 op[0] = XEXP (x, 0);
390 op[1] = XEXP (x, 1);
391 op[2] = XEXP (x, 2);
392 }
393 else
394 /* Give up, just print the RTX name. */
395 st[0] = GET_RTX_NAME (GET_CODE (x));
396 }
397 break;
398 }
399
400 /* Print this as a function? */
401 if (fun)
402 {
403 cur = safe_concat (buf, cur, fun);
404 cur = safe_concat (buf, cur, "(");
405 }
406
407 for (i = 0; i < 4; i++)
408 {
409 if (st[i])
410 cur = safe_concat (buf, cur, st[i]);
411
412 if (op[i])
413 {
414 if (fun && i != 0)
415 cur = safe_concat (buf, cur, ",");
416
417 print_value (tmp, op[i], verbose);
418 cur = safe_concat (buf, cur, tmp);
419 }
420 }
421
422 if (fun)
423 cur = safe_concat (buf, cur, ")");
424 } /* print_exp */
425
426 /* Prints rtxes, I customarily classified as values. They're constants,
427 registers, labels, symbols and memory accesses. */
428
429 void
430 print_value (char *buf, const_rtx x, int verbose)
431 {
432 char t[BUF_LEN];
433 char *cur = buf;
434
435 if (!x)
436 {
437 safe_concat (buf, buf, "(nil)");
438 return;
439 }
440 switch (GET_CODE (x))
441 {
442 case CONST_INT:
443 sprintf (t, HOST_WIDE_INT_PRINT_HEX,
444 (unsigned HOST_WIDE_INT) INTVAL (x));
445 cur = safe_concat (buf, cur, t);
446 break;
447 case CONST_DOUBLE:
448 if (FLOAT_MODE_P (GET_MODE (x)))
449 real_to_decimal (t, CONST_DOUBLE_REAL_VALUE (x), sizeof (t), 0, 1);
450 else
451 sprintf (t,
452 "<" HOST_WIDE_INT_PRINT_HEX "," HOST_WIDE_INT_PRINT_HEX ">",
453 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x),
454 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x));
455 cur = safe_concat (buf, cur, t);
456 break;
457 case CONST_FIXED:
458 fixed_to_decimal (t, CONST_FIXED_VALUE (x), sizeof (t));
459 cur = safe_concat (buf, cur, t);
460 break;
461 case CONST_STRING:
462 cur = safe_concat (buf, cur, "\"");
463 cur = safe_concat (buf, cur, XSTR (x, 0));
464 cur = safe_concat (buf, cur, "\"");
465 break;
466 case SYMBOL_REF:
467 cur = safe_concat (buf, cur, "`");
468 cur = safe_concat (buf, cur, XSTR (x, 0));
469 cur = safe_concat (buf, cur, "'");
470 break;
471 case LABEL_REF:
472 sprintf (t, "L%d", INSN_UID (XEXP (x, 0)));
473 cur = safe_concat (buf, cur, t);
474 break;
475 case CONST:
476 print_value (t, XEXP (x, 0), verbose);
477 cur = safe_concat (buf, cur, "const(");
478 cur = safe_concat (buf, cur, t);
479 cur = safe_concat (buf, cur, ")");
480 break;
481 case HIGH:
482 print_value (t, XEXP (x, 0), verbose);
483 cur = safe_concat (buf, cur, "high(");
484 cur = safe_concat (buf, cur, t);
485 cur = safe_concat (buf, cur, ")");
486 break;
487 case REG:
488 if (REGNO (x) < FIRST_PSEUDO_REGISTER)
489 {
490 int c = reg_names[REGNO (x)][0];
491 if (ISDIGIT (c))
492 cur = safe_concat (buf, cur, "%");
493
494 cur = safe_concat (buf, cur, reg_names[REGNO (x)]);
495 }
496 else
497 {
498 sprintf (t, "r%d", REGNO (x));
499 cur = safe_concat (buf, cur, t);
500 }
501 if (verbose
502 #ifdef INSN_SCHEDULING
503 && !current_sched_info
504 #endif
505 )
506 {
507 sprintf (t, ":%s", GET_MODE_NAME (GET_MODE (x)));
508 cur = safe_concat (buf, cur, t);
509 }
510 break;
511 case SUBREG:
512 print_value (t, SUBREG_REG (x), verbose);
513 cur = safe_concat (buf, cur, t);
514 sprintf (t, "#%d", SUBREG_BYTE (x));
515 cur = safe_concat (buf, cur, t);
516 break;
517 case STRICT_LOW_PART:
518 print_value (t, XEXP (x, 0), verbose);
519 cur = safe_concat (buf, cur, "strict_low_part(");
520 cur = safe_concat (buf, cur, t);
521 cur = safe_concat (buf, cur, ")");
522 break;
523 case SCRATCH:
524 cur = safe_concat (buf, cur, "scratch");
525 break;
526 case CC0:
527 cur = safe_concat (buf, cur, "cc0");
528 break;
529 case PC:
530 cur = safe_concat (buf, cur, "pc");
531 break;
532 case MEM:
533 print_value (t, XEXP (x, 0), verbose);
534 cur = safe_concat (buf, cur, "[");
535 cur = safe_concat (buf, cur, t);
536 cur = safe_concat (buf, cur, "]");
537 break;
538 case DEBUG_EXPR:
539 sprintf (t, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x)));
540 cur = safe_concat (buf, cur, t);
541 break;
542 default:
543 print_exp (t, x, verbose);
544 cur = safe_concat (buf, cur, t);
545 break;
546 }
547 } /* print_value */
548
549 /* Print X, an RTL value node, to file F in slim format. Include
550 additional information if VERBOSE is nonzero.
551
552 Value nodes are constants, registers, labels, symbols and
553 memory. */
554
555 void
556 print_value_slim (FILE *f, const_rtx x, int verbose)
557 {
558 char buf[BUF_LEN];
559
560 print_value (buf, x, verbose);
561 fprintf (f, "%s", buf);
562 }
563
564 /* The next step in insn detalization, its pattern recognition. */
565
566 void
567 print_pattern (char *buf, const_rtx x, int verbose)
568 {
569 char t1[BUF_LEN], t2[BUF_LEN], t3[BUF_LEN];
570
571 if (! x)
572 {
573 sprintf (buf, "(nil)");
574 return;
575 }
576
577 switch (GET_CODE (x))
578 {
579 case SET:
580 print_value (t1, SET_DEST (x), verbose);
581 print_value (t2, SET_SRC (x), verbose);
582 sprintf (buf, "%s=%s", t1, t2);
583 break;
584 case RETURN:
585 case SIMPLE_RETURN:
586 case EH_RETURN:
587 sprintf (buf, GET_RTX_NAME (GET_CODE (x)));
588 break;
589 case CALL:
590 print_exp (buf, x, verbose);
591 break;
592 case CLOBBER:
593 print_value (t1, XEXP (x, 0), verbose);
594 sprintf (buf, "clobber %s", t1);
595 break;
596 case USE:
597 print_value (t1, XEXP (x, 0), verbose);
598 sprintf (buf, "use %s", t1);
599 break;
600 case VAR_LOCATION:
601 print_value (t1, PAT_VAR_LOCATION_LOC (x), verbose);
602 sprintf (buf, "loc %s", t1);
603 break;
604 case COND_EXEC:
605 if (GET_CODE (COND_EXEC_TEST (x)) == NE
606 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
607 print_value (t1, XEXP (COND_EXEC_TEST (x), 0), verbose);
608 else if (GET_CODE (COND_EXEC_TEST (x)) == EQ
609 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
610 {
611 t1[0] = '!';
612 print_value (t1 + 1, XEXP (COND_EXEC_TEST (x), 0), verbose);
613 }
614 else
615 print_value (t1, COND_EXEC_TEST (x), verbose);
616 print_pattern (t2, COND_EXEC_CODE (x), verbose);
617 sprintf (buf, "(%s) %s", t1, t2);
618 break;
619 case PARALLEL:
620 {
621 int i;
622
623 sprintf (t1, "{");
624 for (i = 0; i < XVECLEN (x, 0); i++)
625 {
626 print_pattern (t2, XVECEXP (x, 0, i), verbose);
627 sprintf (t3, "%s%s;", t1, t2);
628 strcpy (t1, t3);
629 }
630 sprintf (buf, "%s}", t1);
631 }
632 break;
633 case SEQUENCE:
634 {
635 int i;
636
637 sprintf (t1, "sequence{");
638 for (i = 0; i < XVECLEN (x, 0); i++)
639 {
640 print_pattern (t2, XVECEXP (x, 0, i), verbose);
641 sprintf (t3, "%s%s;", t1, t2);
642 strcpy (t1, t3);
643 }
644 sprintf (buf, "%s}", t1);
645 }
646 break;
647 case ASM_INPUT:
648 sprintf (buf, "asm {%s}", XSTR (x, 0));
649 break;
650 case ADDR_VEC:
651 /* Fall through. */
652 case ADDR_DIFF_VEC:
653 print_value (buf, XEXP (x, 0), verbose);
654 break;
655 case TRAP_IF:
656 print_value (t1, TRAP_CONDITION (x), verbose);
657 sprintf (buf, "trap_if %s", t1);
658 break;
659 case UNSPEC:
660 {
661 int i;
662
663 sprintf (t1, "unspec{");
664 for (i = 0; i < XVECLEN (x, 0); i++)
665 {
666 print_pattern (t2, XVECEXP (x, 0, i), verbose);
667 sprintf (t3, "%s%s;", t1, t2);
668 strcpy (t1, t3);
669 }
670 sprintf (buf, "%s}", t1);
671 }
672 break;
673 case UNSPEC_VOLATILE:
674 {
675 int i;
676
677 sprintf (t1, "unspec/v{");
678 for (i = 0; i < XVECLEN (x, 0); i++)
679 {
680 print_pattern (t2, XVECEXP (x, 0, i), verbose);
681 sprintf (t3, "%s%s;", t1, t2);
682 strcpy (t1, t3);
683 }
684 sprintf (buf, "%s}", t1);
685 }
686 break;
687 default:
688 print_value (buf, x, verbose);
689 }
690 } /* print_pattern */
691
692 /* This is the main function in rtl visualization mechanism. It
693 accepts an rtx and tries to recognize it as an insn, then prints it
694 properly in human readable form, resembling assembler mnemonics.
695 For every insn it prints its UID and BB the insn belongs too.
696 (Probably the last "option" should be extended somehow, since it
697 depends now on sched.c inner variables ...) */
698
699 void
700 print_insn (char *buf, const_rtx x, int verbose)
701 {
702 char t[BUF_LEN];
703 const_rtx insn = x;
704
705 switch (GET_CODE (x))
706 {
707 case INSN:
708 print_pattern (t, PATTERN (x), verbose);
709 #ifdef INSN_SCHEDULING
710 if (verbose && current_sched_info)
711 sprintf (buf, "%s: %s", (*current_sched_info->print_insn) (x, 1),
712 t);
713 else
714 #endif
715 sprintf (buf, " %4d %s", INSN_UID (x), t);
716 break;
717
718 case DEBUG_INSN:
719 {
720 const char *name = "?";
721
722 if (DECL_P (INSN_VAR_LOCATION_DECL (insn)))
723 {
724 tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (insn));
725 char idbuf[32];
726 if (id)
727 name = IDENTIFIER_POINTER (id);
728 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (insn))
729 == DEBUG_EXPR_DECL)
730 {
731 sprintf (idbuf, "D#%i",
732 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (insn)));
733 name = idbuf;
734 }
735 else
736 {
737 sprintf (idbuf, "D.%i",
738 DECL_UID (INSN_VAR_LOCATION_DECL (insn)));
739 name = idbuf;
740 }
741 }
742 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn)))
743 sprintf (buf, " %4d: debug %s optimized away", INSN_UID (insn), name);
744 else
745 {
746 print_pattern (t, INSN_VAR_LOCATION_LOC (insn), verbose);
747 sprintf (buf, " %4d: debug %s => %s", INSN_UID (insn), name, t);
748 }
749 }
750 break;
751
752 case JUMP_INSN:
753 print_pattern (t, PATTERN (x), verbose);
754 #ifdef INSN_SCHEDULING
755 if (verbose && current_sched_info)
756 sprintf (buf, "%s: jump %s", (*current_sched_info->print_insn) (x, 1),
757 t);
758 else
759 #endif
760 sprintf (buf, " %4d %s", INSN_UID (x), t);
761 break;
762 case CALL_INSN:
763 x = PATTERN (insn);
764 if (GET_CODE (x) == PARALLEL)
765 {
766 x = XVECEXP (x, 0, 0);
767 print_pattern (t, x, verbose);
768 }
769 else
770 strcpy (t, "call <...>");
771 #ifdef INSN_SCHEDULING
772 if (verbose && current_sched_info)
773 sprintf (buf, "%s: %s", (*current_sched_info->print_insn) (insn, 1), t);
774 else
775 #endif
776 sprintf (buf, " %4d %s", INSN_UID (insn), t);
777 break;
778 case CODE_LABEL:
779 sprintf (buf, "L%d:", INSN_UID (x));
780 break;
781 case BARRIER:
782 sprintf (buf, "i%4d: barrier", INSN_UID (x));
783 break;
784 case NOTE:
785 sprintf (buf, " %4d %s", INSN_UID (x),
786 GET_NOTE_INSN_NAME (NOTE_KIND (x)));
787 break;
788 default:
789 sprintf (buf, "i%4d <What %s?>", INSN_UID (x),
790 GET_RTX_NAME (GET_CODE (x)));
791 }
792 } /* print_insn */
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 char t[BUF_LEN + 32];
800 rtx note;
801
802 print_insn (t, x, 1);
803 fputs (print_rtx_head, f);
804 fputs (t, f);
805 putc ('\n', f);
806 if (INSN_P (x) && REG_NOTES (x))
807 for (note = REG_NOTES (x); note; note = XEXP (note, 1))
808 {
809 fputs (print_rtx_head, f);
810 print_pattern (t, XEXP (note, 0), 1);
811 fprintf (f, " %s: %s\n",
812 GET_REG_NOTE_NAME (REG_NOTE_KIND (note)), t);
813 }
814 }
815
816 /* Emit a slim dump of X (an insn) to stderr. */
817 extern void debug_insn_slim (const_rtx);
818 DEBUG_FUNCTION void
819 debug_insn_slim (const_rtx x)
820 {
821 dump_insn_slim (stderr, x);
822 }
823
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. */
826 extern void debug_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
827 DEBUG_FUNCTION void
828 debug_rtl_slim (FILE *f, const_rtx first, const_rtx last,
829 int count, int flags ATTRIBUTE_UNUSED)
830 {
831 const_rtx insn, tail;
832
833 tail = last ? NEXT_INSN (last) : NULL_RTX;
834 for (insn = first;
835 (insn != NULL) && (insn != tail) && (count != 0);
836 insn = NEXT_INSN (insn))
837 {
838 dump_insn_slim (f, insn);
839 if (count > 0)
840 count--;
841 }
842 }
843
844 extern void debug_bb_slim (basic_block);
845 DEBUG_FUNCTION void
846 debug_bb_slim (basic_block bb)
847 {
848 dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
849 }
850
851 extern void debug_bb_n_slim (int);
852 DEBUG_FUNCTION void
853 debug_bb_n_slim (int n)
854 {
855 basic_block bb = BASIC_BLOCK (n);
856 debug_bb_slim (bb);
857 }
858