Merge trunk version 195164 into gupc branch.
[official-gcc.git] / gcc / rtl.c
blob38c46fa91104caba1e816ec12ae61cdce1924a43
1 /* RTL utility routines.
2 Copyright (C) 1987-2013 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* This file is compiled twice: once for the generator programs
21 once for the compiler. */
22 #ifdef GENERATOR_FILE
23 #include "bconfig.h"
24 #else
25 #include "config.h"
26 #endif
28 #include "system.h"
29 #include "coretypes.h"
30 #include "tm.h"
31 #include "rtl.h"
32 #include "ggc.h"
33 #ifdef GENERATOR_FILE
34 # include "errors.h"
35 #else
36 # include "diagnostic-core.h"
37 #endif
40 /* Indexed by rtx code, gives number of operands for an rtx with that code.
41 Does NOT include rtx header data (code and links). */
43 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) sizeof FORMAT - 1 ,
45 const unsigned char rtx_length[NUM_RTX_CODE] = {
46 #include "rtl.def"
49 #undef DEF_RTL_EXPR
51 /* Indexed by rtx code, gives the name of that kind of rtx, as a C string. */
53 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) NAME ,
55 const char * const rtx_name[NUM_RTX_CODE] = {
56 #include "rtl.def" /* rtl expressions are documented here */
59 #undef DEF_RTL_EXPR
61 /* Indexed by rtx code, gives a sequence of operand-types for
62 rtx's of that code. The sequence is a C string in which
63 each character describes one operand. */
65 const char * const rtx_format[NUM_RTX_CODE] = {
66 /* "*" undefined.
67 can cause a warning message
68 "0" field is unused (or used in a phase-dependent manner)
69 prints nothing
70 "i" an integer
71 prints the integer
72 "n" like "i", but prints entries from `note_insn_name'
73 "w" an integer of width HOST_BITS_PER_WIDE_INT
74 prints the integer
75 "s" a pointer to a string
76 prints the string
77 "S" like "s", but optional:
78 the containing rtx may end before this operand
79 "T" like "s", but treated specially by the RTL reader;
80 only found in machine description patterns.
81 "e" a pointer to an rtl expression
82 prints the expression
83 "E" a pointer to a vector that points to a number of rtl expressions
84 prints a list of the rtl expressions
85 "V" like "E", but optional:
86 the containing rtx may end before this operand
87 "u" a pointer to another insn
88 prints the uid of the insn.
89 "b" is a pointer to a bitmap header.
90 "B" is a basic block pointer.
91 "t" is a tree pointer. */
93 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) FORMAT ,
94 #include "rtl.def" /* rtl expressions are defined here */
95 #undef DEF_RTL_EXPR
98 /* Indexed by rtx code, gives a character representing the "class" of
99 that rtx code. See rtl.def for documentation on the defined classes. */
101 const enum rtx_class rtx_class[NUM_RTX_CODE] = {
102 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS,
103 #include "rtl.def" /* rtl expressions are defined here */
104 #undef DEF_RTL_EXPR
107 /* Indexed by rtx code, gives the size of the rtx in bytes. */
109 const unsigned char rtx_code_size[NUM_RTX_CODE] = {
110 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \
111 (((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE \
112 || (ENUM) == CONST_FIXED) \
113 ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \
114 : RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (rtunion)),
116 #include "rtl.def"
117 #undef DEF_RTL_EXPR
120 /* Names for kinds of NOTEs and REG_NOTEs. */
122 const char * const note_insn_name[NOTE_INSN_MAX] =
124 #define DEF_INSN_NOTE(NAME) #NAME,
125 #include "insn-notes.def"
126 #undef DEF_INSN_NOTE
129 const char * const reg_note_name[REG_NOTE_MAX] =
131 #define DEF_REG_NOTE(NAME) #NAME,
132 #include "reg-notes.def"
133 #undef DEF_REG_NOTE
136 static int rtx_alloc_counts[(int) LAST_AND_UNUSED_RTX_CODE];
137 static int rtx_alloc_sizes[(int) LAST_AND_UNUSED_RTX_CODE];
138 static int rtvec_alloc_counts;
139 static int rtvec_alloc_sizes;
142 /* Allocate an rtx vector of N elements.
143 Store the length, and initialize all elements to zero. */
145 rtvec
146 rtvec_alloc (int n)
148 rtvec rt;
150 rt = ggc_alloc_rtvec_sized (n);
151 /* Clear out the vector. */
152 memset (&rt->elem[0], 0, n * sizeof (rtx));
154 PUT_NUM_ELEM (rt, n);
156 if (GATHER_STATISTICS)
158 rtvec_alloc_counts++;
159 rtvec_alloc_sizes += n * sizeof (rtx);
162 return rt;
165 /* Create a bitwise copy of VEC. */
167 rtvec
168 shallow_copy_rtvec (rtvec vec)
170 rtvec newvec;
171 int n;
173 n = GET_NUM_ELEM (vec);
174 newvec = rtvec_alloc (n);
175 memcpy (&newvec->elem[0], &vec->elem[0], sizeof (rtx) * n);
176 return newvec;
179 /* Return the number of bytes occupied by rtx value X. */
181 unsigned int
182 rtx_size (const_rtx x)
184 if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_HAS_BLOCK_INFO_P (x))
185 return RTX_HDR_SIZE + sizeof (struct block_symbol);
186 return RTX_CODE_SIZE (GET_CODE (x));
189 /* Allocate an rtx of code CODE. The CODE is stored in the rtx;
190 all the rest is initialized to zero. */
193 rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
195 rtx rt = ggc_alloc_zone_rtx_def_stat (&rtl_zone, RTX_CODE_SIZE (code)
196 PASS_MEM_STAT);
198 /* We want to clear everything up to the FLD array. Normally, this
199 is one int, but we don't want to assume that and it isn't very
200 portable anyway; this is. */
202 memset (rt, 0, RTX_HDR_SIZE);
203 PUT_CODE (rt, code);
205 if (GATHER_STATISTICS)
207 rtx_alloc_counts[code]++;
208 rtx_alloc_sizes[code] += RTX_CODE_SIZE (code);
211 return rt;
215 /* Return true if ORIG is a sharable CONST. */
217 bool
218 shared_const_p (const_rtx orig)
220 gcc_assert (GET_CODE (orig) == CONST);
222 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
223 a LABEL_REF, it isn't sharable. */
224 return (GET_CODE (XEXP (orig, 0)) == PLUS
225 && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
226 && CONST_INT_P(XEXP (XEXP (orig, 0), 1)));
230 /* Create a new copy of an rtx.
231 Recursively copies the operands of the rtx,
232 except for those few rtx codes that are sharable. */
235 copy_rtx (rtx orig)
237 rtx copy;
238 int i, j;
239 RTX_CODE code;
240 const char *format_ptr;
242 code = GET_CODE (orig);
244 switch (code)
246 case REG:
247 case DEBUG_EXPR:
248 case VALUE:
249 CASE_CONST_ANY:
250 case SYMBOL_REF:
251 case CODE_LABEL:
252 case PC:
253 case CC0:
254 case RETURN:
255 case SIMPLE_RETURN:
256 case SCRATCH:
257 /* SCRATCH must be shared because they represent distinct values. */
258 return orig;
259 case CLOBBER:
260 if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER)
261 return orig;
262 break;
264 case CONST:
265 if (shared_const_p (orig))
266 return orig;
267 break;
269 /* A MEM with a constant address is not sharable. The problem is that
270 the constant address may need to be reloaded. If the mem is shared,
271 then reloading one copy of this mem will cause all copies to appear
272 to have been reloaded. */
274 default:
275 break;
278 /* Copy the various flags, fields, and other information. We assume
279 that all fields need copying, and then clear the fields that should
280 not be copied. That is the sensible default behavior, and forces
281 us to explicitly document why we are *not* copying a flag. */
282 copy = shallow_copy_rtx (orig);
284 /* We do not copy the USED flag, which is used as a mark bit during
285 walks over the RTL. */
286 RTX_FLAG (copy, used) = 0;
288 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
290 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
291 switch (*format_ptr++)
293 case 'e':
294 if (XEXP (orig, i) != NULL)
295 XEXP (copy, i) = copy_rtx (XEXP (orig, i));
296 break;
298 case 'E':
299 case 'V':
300 if (XVEC (orig, i) != NULL)
302 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
303 for (j = 0; j < XVECLEN (copy, i); j++)
304 XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
306 break;
308 case 't':
309 case 'w':
310 case 'i':
311 case 's':
312 case 'S':
313 case 'T':
314 case 'u':
315 case 'B':
316 case '0':
317 /* These are left unchanged. */
318 break;
320 default:
321 gcc_unreachable ();
323 return copy;
326 /* Create a new copy of an rtx. Only copy just one level. */
329 shallow_copy_rtx_stat (const_rtx orig MEM_STAT_DECL)
331 const unsigned int size = rtx_size (orig);
332 rtx const copy = ggc_alloc_zone_rtx_def_stat (&rtl_zone, size PASS_MEM_STAT);
333 return (rtx) memcpy (copy, orig, size);
336 /* Nonzero when we are generating CONCATs. */
337 int generating_concat_p;
339 /* Nonzero when we are expanding trees to RTL. */
340 int currently_expanding_to_rtl;
344 /* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL.
345 When the callback returns true, we continue with the new pair.
346 Whenever changing this function check if rtx_equal_p below doesn't need
347 changing as well. */
350 rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
352 int i;
353 int j;
354 enum rtx_code code;
355 const char *fmt;
356 rtx nx, ny;
358 if (x == y)
359 return 1;
360 if (x == 0 || y == 0)
361 return 0;
363 /* Invoke the callback first. */
364 if (cb != NULL
365 && ((*cb) (&x, &y, &nx, &ny)))
366 return rtx_equal_p_cb (nx, ny, cb);
368 code = GET_CODE (x);
369 /* Rtx's of different codes cannot be equal. */
370 if (code != GET_CODE (y))
371 return 0;
373 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
374 (REG:SI x) and (REG:HI x) are NOT equivalent. */
376 if (GET_MODE (x) != GET_MODE (y))
377 return 0;
379 /* MEMs referring to different address space are not equivalent. */
380 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
381 return 0;
383 /* Some RTL can be compared nonrecursively. */
384 switch (code)
386 case REG:
387 return (REGNO (x) == REGNO (y));
389 case LABEL_REF:
390 return XEXP (x, 0) == XEXP (y, 0);
392 case SYMBOL_REF:
393 return XSTR (x, 0) == XSTR (y, 0);
395 case DEBUG_EXPR:
396 case VALUE:
397 case SCRATCH:
398 CASE_CONST_UNIQUE:
399 return 0;
401 case DEBUG_IMPLICIT_PTR:
402 return DEBUG_IMPLICIT_PTR_DECL (x)
403 == DEBUG_IMPLICIT_PTR_DECL (y);
405 case DEBUG_PARAMETER_REF:
406 return DEBUG_PARAMETER_REF_DECL (x)
407 == DEBUG_PARAMETER_REF_DECL (x);
409 case ENTRY_VALUE:
410 return rtx_equal_p_cb (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y), cb);
412 default:
413 break;
416 /* Compare the elements. If any pair of corresponding elements
417 fail to match, return 0 for the whole thing. */
419 fmt = GET_RTX_FORMAT (code);
420 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
422 switch (fmt[i])
424 case 'w':
425 if (XWINT (x, i) != XWINT (y, i))
426 return 0;
427 break;
429 case 'n':
430 case 'i':
431 if (XINT (x, i) != XINT (y, i))
433 #ifndef GENERATOR_FILE
434 if (((code == ASM_OPERANDS && i == 6)
435 || (code == ASM_INPUT && i == 1))
436 && XINT (x, i) == XINT (y, i))
437 break;
438 #endif
439 return 0;
441 break;
443 case 'V':
444 case 'E':
445 /* Two vectors must have the same length. */
446 if (XVECLEN (x, i) != XVECLEN (y, i))
447 return 0;
449 /* And the corresponding elements must match. */
450 for (j = 0; j < XVECLEN (x, i); j++)
451 if (rtx_equal_p_cb (XVECEXP (x, i, j),
452 XVECEXP (y, i, j), cb) == 0)
453 return 0;
454 break;
456 case 'e':
457 if (rtx_equal_p_cb (XEXP (x, i), XEXP (y, i), cb) == 0)
458 return 0;
459 break;
461 case 'S':
462 case 's':
463 if ((XSTR (x, i) || XSTR (y, i))
464 && (! XSTR (x, i) || ! XSTR (y, i)
465 || strcmp (XSTR (x, i), XSTR (y, i))))
466 return 0;
467 break;
469 case 'u':
470 /* These are just backpointers, so they don't matter. */
471 break;
473 case '0':
474 case 't':
475 break;
477 /* It is believed that rtx's at this level will never
478 contain anything but integers and other rtx's,
479 except for within LABEL_REFs and SYMBOL_REFs. */
480 default:
481 gcc_unreachable ();
484 return 1;
487 /* Return 1 if X and Y are identical-looking rtx's.
488 This is the Lisp function EQUAL for rtx arguments.
489 Whenever changing this function check if rtx_equal_p_cb above doesn't need
490 changing as well. */
493 rtx_equal_p (const_rtx x, const_rtx y)
495 int i;
496 int j;
497 enum rtx_code code;
498 const char *fmt;
500 if (x == y)
501 return 1;
502 if (x == 0 || y == 0)
503 return 0;
505 code = GET_CODE (x);
506 /* Rtx's of different codes cannot be equal. */
507 if (code != GET_CODE (y))
508 return 0;
510 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
511 (REG:SI x) and (REG:HI x) are NOT equivalent. */
513 if (GET_MODE (x) != GET_MODE (y))
514 return 0;
516 /* MEMs referring to different address space are not equivalent. */
517 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
518 return 0;
520 /* Some RTL can be compared nonrecursively. */
521 switch (code)
523 case REG:
524 return (REGNO (x) == REGNO (y));
526 case LABEL_REF:
527 return XEXP (x, 0) == XEXP (y, 0);
529 case SYMBOL_REF:
530 return XSTR (x, 0) == XSTR (y, 0);
532 case DEBUG_EXPR:
533 case VALUE:
534 case SCRATCH:
535 CASE_CONST_UNIQUE:
536 return 0;
538 case DEBUG_IMPLICIT_PTR:
539 return DEBUG_IMPLICIT_PTR_DECL (x)
540 == DEBUG_IMPLICIT_PTR_DECL (y);
542 case DEBUG_PARAMETER_REF:
543 return DEBUG_PARAMETER_REF_DECL (x)
544 == DEBUG_PARAMETER_REF_DECL (y);
546 case ENTRY_VALUE:
547 return rtx_equal_p (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
549 default:
550 break;
553 /* Compare the elements. If any pair of corresponding elements
554 fail to match, return 0 for the whole thing. */
556 fmt = GET_RTX_FORMAT (code);
557 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
559 switch (fmt[i])
561 case 'w':
562 if (XWINT (x, i) != XWINT (y, i))
563 return 0;
564 break;
566 case 'n':
567 case 'i':
568 if (XINT (x, i) != XINT (y, i))
570 #ifndef GENERATOR_FILE
571 if (((code == ASM_OPERANDS && i == 6)
572 || (code == ASM_INPUT && i == 1))
573 && XINT (x, i) == XINT (y, i))
574 break;
575 #endif
576 return 0;
578 break;
580 case 'V':
581 case 'E':
582 /* Two vectors must have the same length. */
583 if (XVECLEN (x, i) != XVECLEN (y, i))
584 return 0;
586 /* And the corresponding elements must match. */
587 for (j = 0; j < XVECLEN (x, i); j++)
588 if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
589 return 0;
590 break;
592 case 'e':
593 if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
594 return 0;
595 break;
597 case 'S':
598 case 's':
599 if ((XSTR (x, i) || XSTR (y, i))
600 && (! XSTR (x, i) || ! XSTR (y, i)
601 || strcmp (XSTR (x, i), XSTR (y, i))))
602 return 0;
603 break;
605 case 'u':
606 /* These are just backpointers, so they don't matter. */
607 break;
609 case '0':
610 case 't':
611 break;
613 /* It is believed that rtx's at this level will never
614 contain anything but integers and other rtx's,
615 except for within LABEL_REFs and SYMBOL_REFs. */
616 default:
617 gcc_unreachable ();
620 return 1;
623 /* Iteratively hash rtx X. */
625 hashval_t
626 iterative_hash_rtx (const_rtx x, hashval_t hash)
628 enum rtx_code code;
629 enum machine_mode mode;
630 int i, j;
631 const char *fmt;
633 if (x == NULL_RTX)
634 return hash;
635 code = GET_CODE (x);
636 hash = iterative_hash_object (code, hash);
637 mode = GET_MODE (x);
638 hash = iterative_hash_object (mode, hash);
639 switch (code)
641 case REG:
642 i = REGNO (x);
643 return iterative_hash_object (i, hash);
644 case CONST_INT:
645 return iterative_hash_object (INTVAL (x), hash);
646 case SYMBOL_REF:
647 if (XSTR (x, 0))
648 return iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
649 hash);
650 return hash;
651 case LABEL_REF:
652 case DEBUG_EXPR:
653 case VALUE:
654 case SCRATCH:
655 case CONST_DOUBLE:
656 case CONST_FIXED:
657 case DEBUG_IMPLICIT_PTR:
658 case DEBUG_PARAMETER_REF:
659 return hash;
660 default:
661 break;
664 fmt = GET_RTX_FORMAT (code);
665 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
666 switch (fmt[i])
668 case 'w':
669 hash = iterative_hash_object (XWINT (x, i), hash);
670 break;
671 case 'n':
672 case 'i':
673 hash = iterative_hash_object (XINT (x, i), hash);
674 break;
675 case 'V':
676 case 'E':
677 j = XVECLEN (x, i);
678 hash = iterative_hash_object (j, hash);
679 for (j = 0; j < XVECLEN (x, i); j++)
680 hash = iterative_hash_rtx (XVECEXP (x, i, j), hash);
681 break;
682 case 'e':
683 hash = iterative_hash_rtx (XEXP (x, i), hash);
684 break;
685 case 'S':
686 case 's':
687 if (XSTR (x, i))
688 hash = iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
689 hash);
690 break;
691 default:
692 break;
694 return hash;
697 void
698 dump_rtx_statistics (void)
700 int i;
701 int total_counts = 0;
702 int total_sizes = 0;
704 if (! GATHER_STATISTICS)
706 fprintf (stderr, "No RTX statistics\n");
707 return;
710 fprintf (stderr, "\nRTX Kind Count Bytes\n");
711 fprintf (stderr, "---------------------------------------\n");
712 for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
713 if (rtx_alloc_counts[i])
715 fprintf (stderr, "%-20s %7d %10d\n", GET_RTX_NAME (i),
716 rtx_alloc_counts[i], rtx_alloc_sizes[i]);
717 total_counts += rtx_alloc_counts[i];
718 total_sizes += rtx_alloc_sizes[i];
720 if (rtvec_alloc_counts)
722 fprintf (stderr, "%-20s %7d %10d\n", "rtvec",
723 rtvec_alloc_counts, rtvec_alloc_sizes);
724 total_counts += rtvec_alloc_counts;
725 total_sizes += rtvec_alloc_sizes;
727 fprintf (stderr, "---------------------------------------\n");
728 fprintf (stderr, "%-20s %7d %10d\n",
729 "Total", total_counts, total_sizes);
730 fprintf (stderr, "---------------------------------------\n");
733 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
734 void
735 rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line,
736 const char *func)
738 internal_error
739 ("RTL check: access of elt %d of '%s' with last elt %d in %s, at %s:%d",
740 n, GET_RTX_NAME (GET_CODE (r)), GET_RTX_LENGTH (GET_CODE (r)) - 1,
741 func, trim_filename (file), line);
744 void
745 rtl_check_failed_type1 (const_rtx r, int n, int c1, const char *file, int line,
746 const char *func)
748 internal_error
749 ("RTL check: expected elt %d type '%c', have '%c' (rtx %s) in %s, at %s:%d",
750 n, c1, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
751 func, trim_filename (file), line);
754 void
755 rtl_check_failed_type2 (const_rtx r, int n, int c1, int c2, const char *file,
756 int line, const char *func)
758 internal_error
759 ("RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s) in %s, at %s:%d",
760 n, c1, c2, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
761 func, trim_filename (file), line);
764 void
765 rtl_check_failed_code1 (const_rtx r, enum rtx_code code, const char *file,
766 int line, const char *func)
768 internal_error ("RTL check: expected code '%s', have '%s' in %s, at %s:%d",
769 GET_RTX_NAME (code), GET_RTX_NAME (GET_CODE (r)), func,
770 trim_filename (file), line);
773 void
774 rtl_check_failed_code2 (const_rtx r, enum rtx_code code1, enum rtx_code code2,
775 const char *file, int line, const char *func)
777 internal_error
778 ("RTL check: expected code '%s' or '%s', have '%s' in %s, at %s:%d",
779 GET_RTX_NAME (code1), GET_RTX_NAME (code2), GET_RTX_NAME (GET_CODE (r)),
780 func, trim_filename (file), line);
783 void
784 rtl_check_failed_code_mode (const_rtx r, enum rtx_code code, enum machine_mode mode,
785 bool not_mode, const char *file, int line,
786 const char *func)
788 internal_error ((not_mode
789 ? ("RTL check: expected code '%s' and not mode '%s', "
790 "have code '%s' and mode '%s' in %s, at %s:%d")
791 : ("RTL check: expected code '%s' and mode '%s', "
792 "have code '%s' and mode '%s' in %s, at %s:%d")),
793 GET_RTX_NAME (code), GET_MODE_NAME (mode),
794 GET_RTX_NAME (GET_CODE (r)), GET_MODE_NAME (GET_MODE (r)),
795 func, trim_filename (file), line);
798 /* Report that line LINE of FILE tried to access the block symbol fields
799 of a non-block symbol. FUNC is the function that contains the line. */
801 void
802 rtl_check_failed_block_symbol (const char *file, int line, const char *func)
804 internal_error
805 ("RTL check: attempt to treat non-block symbol as a block symbol "
806 "in %s, at %s:%d", func, trim_filename (file), line);
809 /* XXX Maybe print the vector? */
810 void
811 rtvec_check_failed_bounds (const_rtvec r, int n, const char *file, int line,
812 const char *func)
814 internal_error
815 ("RTL check: access of elt %d of vector with last elt %d in %s, at %s:%d",
816 n, GET_NUM_ELEM (r) - 1, func, trim_filename (file), line);
818 #endif /* ENABLE_RTL_CHECKING */
820 #if defined ENABLE_RTL_FLAG_CHECKING
821 void
822 rtl_check_failed_flag (const char *name, const_rtx r, const char *file,
823 int line, const char *func)
825 internal_error
826 ("RTL flag check: %s used with unexpected rtx code '%s' in %s, at %s:%d",
827 name, GET_RTX_NAME (GET_CODE (r)), func, trim_filename (file), line);
829 #endif /* ENABLE_RTL_FLAG_CHECKING */