gcc/testsuite/
[official-gcc.git] / gcc / rtl.c
blob520f9a8eb7f110df293e4aa10c1c4a26f751e229
1 /* RTL utility routines.
2 Copyright (C) 1987-2014 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 "ggc.h"
32 #include "rtl.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 || (ENUM) == CONST_WIDE_INT) \
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 (CONST_WIDE_INT_P (x))
185 return (RTX_HDR_SIZE
186 + sizeof (struct hwivec_def)
187 + ((CONST_WIDE_INT_NUNITS (x) - 1)
188 * sizeof (HOST_WIDE_INT)));
189 if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_HAS_BLOCK_INFO_P (x))
190 return RTX_HDR_SIZE + sizeof (struct block_symbol);
191 return RTX_CODE_SIZE (GET_CODE (x));
194 /* Allocate an rtx of code CODE with EXTRA bytes in it. The CODE is
195 stored in the rtx; all the rest is initialized to zero. */
198 rtx_alloc_stat_v (RTX_CODE code MEM_STAT_DECL, int extra)
200 rtx rt = ggc_alloc_rtx_def_stat (RTX_CODE_SIZE (code) + extra
201 PASS_MEM_STAT);
203 /* We want to clear everything up to the FLD array. Normally, this
204 is one int, but we don't want to assume that and it isn't very
205 portable anyway; this is. */
207 memset (rt, 0, RTX_HDR_SIZE);
208 PUT_CODE (rt, code);
210 if (GATHER_STATISTICS)
212 rtx_alloc_counts[code]++;
213 rtx_alloc_sizes[code] += RTX_CODE_SIZE (code);
216 return rt;
219 /* Allocate an rtx of code CODE. The CODE is stored in the rtx;
220 all the rest is initialized to zero. */
223 rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
225 return rtx_alloc_stat_v (code PASS_MEM_STAT, 0);
228 /* Write the wide constant X to OUTFILE. */
230 void
231 cwi_output_hex (FILE *outfile, const_rtx x)
233 int i = CWI_GET_NUM_ELEM (x);
234 gcc_assert (i > 0);
235 if (CWI_ELT (x, i - 1) == 0)
236 /* The HOST_WIDE_INT_PRINT_HEX prepends a 0x only if the val is
237 non zero. We want all numbers to have a 0x prefix. */
238 fprintf (outfile, "0x");
239 fprintf (outfile, HOST_WIDE_INT_PRINT_HEX, CWI_ELT (x, --i));
240 while (--i >= 0)
241 fprintf (outfile, HOST_WIDE_INT_PRINT_PADDED_HEX, CWI_ELT (x, i));
245 /* Return true if ORIG is a sharable CONST. */
247 bool
248 shared_const_p (const_rtx orig)
250 gcc_assert (GET_CODE (orig) == CONST);
252 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
253 a LABEL_REF, it isn't sharable. */
254 return (GET_CODE (XEXP (orig, 0)) == PLUS
255 && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
256 && CONST_INT_P (XEXP (XEXP (orig, 0), 1)));
260 /* Create a new copy of an rtx.
261 Recursively copies the operands of the rtx,
262 except for those few rtx codes that are sharable. */
265 copy_rtx (rtx orig)
267 rtx copy;
268 int i, j;
269 RTX_CODE code;
270 const char *format_ptr;
272 code = GET_CODE (orig);
274 switch (code)
276 case REG:
277 case DEBUG_EXPR:
278 case VALUE:
279 CASE_CONST_ANY:
280 case SYMBOL_REF:
281 case CODE_LABEL:
282 case PC:
283 case CC0:
284 case RETURN:
285 case SIMPLE_RETURN:
286 case SCRATCH:
287 /* SCRATCH must be shared because they represent distinct values. */
288 return orig;
289 case CLOBBER:
290 /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
291 clobbers or clobbers of hard registers that originated as pseudos.
292 This is needed to allow safe register renaming. */
293 if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER
294 && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0)))
295 return orig;
296 break;
298 case CONST:
299 if (shared_const_p (orig))
300 return orig;
301 break;
303 /* A MEM with a constant address is not sharable. The problem is that
304 the constant address may need to be reloaded. If the mem is shared,
305 then reloading one copy of this mem will cause all copies to appear
306 to have been reloaded. */
308 default:
309 break;
312 /* Copy the various flags, fields, and other information. We assume
313 that all fields need copying, and then clear the fields that should
314 not be copied. That is the sensible default behavior, and forces
315 us to explicitly document why we are *not* copying a flag. */
316 copy = shallow_copy_rtx (orig);
318 /* We do not copy the USED flag, which is used as a mark bit during
319 walks over the RTL. */
320 RTX_FLAG (copy, used) = 0;
322 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
324 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
325 switch (*format_ptr++)
327 case 'e':
328 if (XEXP (orig, i) != NULL)
329 XEXP (copy, i) = copy_rtx (XEXP (orig, i));
330 break;
332 case 'E':
333 case 'V':
334 if (XVEC (orig, i) != NULL)
336 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
337 for (j = 0; j < XVECLEN (copy, i); j++)
338 XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
340 break;
342 case 't':
343 case 'w':
344 case 'i':
345 case 's':
346 case 'S':
347 case 'T':
348 case 'u':
349 case 'B':
350 case '0':
351 /* These are left unchanged. */
352 break;
354 default:
355 gcc_unreachable ();
357 return copy;
360 /* Create a new copy of an rtx. Only copy just one level. */
363 shallow_copy_rtx_stat (const_rtx orig MEM_STAT_DECL)
365 const unsigned int size = rtx_size (orig);
366 rtx const copy = ggc_alloc_rtx_def_stat (size PASS_MEM_STAT);
367 return (rtx) memcpy (copy, orig, size);
370 /* Nonzero when we are generating CONCATs. */
371 int generating_concat_p;
373 /* Nonzero when we are expanding trees to RTL. */
374 int currently_expanding_to_rtl;
378 /* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL.
379 When the callback returns true, we continue with the new pair.
380 Whenever changing this function check if rtx_equal_p below doesn't need
381 changing as well. */
384 rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
386 int i;
387 int j;
388 enum rtx_code code;
389 const char *fmt;
390 rtx nx, ny;
392 if (x == y)
393 return 1;
394 if (x == 0 || y == 0)
395 return 0;
397 /* Invoke the callback first. */
398 if (cb != NULL
399 && ((*cb) (&x, &y, &nx, &ny)))
400 return rtx_equal_p_cb (nx, ny, cb);
402 code = GET_CODE (x);
403 /* Rtx's of different codes cannot be equal. */
404 if (code != GET_CODE (y))
405 return 0;
407 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
408 (REG:SI x) and (REG:HI x) are NOT equivalent. */
410 if (GET_MODE (x) != GET_MODE (y))
411 return 0;
413 /* MEMs referring to different address space are not equivalent. */
414 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
415 return 0;
417 /* Some RTL can be compared nonrecursively. */
418 switch (code)
420 case REG:
421 return (REGNO (x) == REGNO (y));
423 case LABEL_REF:
424 return XEXP (x, 0) == XEXP (y, 0);
426 case SYMBOL_REF:
427 return XSTR (x, 0) == XSTR (y, 0);
429 case DEBUG_EXPR:
430 case VALUE:
431 case SCRATCH:
432 CASE_CONST_UNIQUE:
433 return 0;
435 case DEBUG_IMPLICIT_PTR:
436 return DEBUG_IMPLICIT_PTR_DECL (x)
437 == DEBUG_IMPLICIT_PTR_DECL (y);
439 case DEBUG_PARAMETER_REF:
440 return DEBUG_PARAMETER_REF_DECL (x)
441 == DEBUG_PARAMETER_REF_DECL (x);
443 case ENTRY_VALUE:
444 return rtx_equal_p_cb (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y), cb);
446 default:
447 break;
450 /* Compare the elements. If any pair of corresponding elements
451 fail to match, return 0 for the whole thing. */
453 fmt = GET_RTX_FORMAT (code);
454 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
456 switch (fmt[i])
458 case 'w':
459 if (XWINT (x, i) != XWINT (y, i))
460 return 0;
461 break;
463 case 'n':
464 case 'i':
465 if (XINT (x, i) != XINT (y, i))
467 #ifndef GENERATOR_FILE
468 if (((code == ASM_OPERANDS && i == 6)
469 || (code == ASM_INPUT && i == 1))
470 && XINT (x, i) == XINT (y, i))
471 break;
472 #endif
473 return 0;
475 break;
477 case 'V':
478 case 'E':
479 /* Two vectors must have the same length. */
480 if (XVECLEN (x, i) != XVECLEN (y, i))
481 return 0;
483 /* And the corresponding elements must match. */
484 for (j = 0; j < XVECLEN (x, i); j++)
485 if (rtx_equal_p_cb (XVECEXP (x, i, j),
486 XVECEXP (y, i, j), cb) == 0)
487 return 0;
488 break;
490 case 'e':
491 if (rtx_equal_p_cb (XEXP (x, i), XEXP (y, i), cb) == 0)
492 return 0;
493 break;
495 case 'S':
496 case 's':
497 if ((XSTR (x, i) || XSTR (y, i))
498 && (! XSTR (x, i) || ! XSTR (y, i)
499 || strcmp (XSTR (x, i), XSTR (y, i))))
500 return 0;
501 break;
503 case 'u':
504 /* These are just backpointers, so they don't matter. */
505 break;
507 case '0':
508 case 't':
509 break;
511 /* It is believed that rtx's at this level will never
512 contain anything but integers and other rtx's,
513 except for within LABEL_REFs and SYMBOL_REFs. */
514 default:
515 gcc_unreachable ();
518 return 1;
521 /* Return 1 if X and Y are identical-looking rtx's.
522 This is the Lisp function EQUAL for rtx arguments.
523 Whenever changing this function check if rtx_equal_p_cb above doesn't need
524 changing as well. */
527 rtx_equal_p (const_rtx x, const_rtx y)
529 int i;
530 int j;
531 enum rtx_code code;
532 const char *fmt;
534 if (x == y)
535 return 1;
536 if (x == 0 || y == 0)
537 return 0;
539 code = GET_CODE (x);
540 /* Rtx's of different codes cannot be equal. */
541 if (code != GET_CODE (y))
542 return 0;
544 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
545 (REG:SI x) and (REG:HI x) are NOT equivalent. */
547 if (GET_MODE (x) != GET_MODE (y))
548 return 0;
550 /* MEMs referring to different address space are not equivalent. */
551 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
552 return 0;
554 /* Some RTL can be compared nonrecursively. */
555 switch (code)
557 case REG:
558 return (REGNO (x) == REGNO (y));
560 case LABEL_REF:
561 return XEXP (x, 0) == XEXP (y, 0);
563 case SYMBOL_REF:
564 return XSTR (x, 0) == XSTR (y, 0);
566 case DEBUG_EXPR:
567 case VALUE:
568 case SCRATCH:
569 CASE_CONST_UNIQUE:
570 return 0;
572 case DEBUG_IMPLICIT_PTR:
573 return DEBUG_IMPLICIT_PTR_DECL (x)
574 == DEBUG_IMPLICIT_PTR_DECL (y);
576 case DEBUG_PARAMETER_REF:
577 return DEBUG_PARAMETER_REF_DECL (x)
578 == DEBUG_PARAMETER_REF_DECL (y);
580 case ENTRY_VALUE:
581 return rtx_equal_p (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
583 default:
584 break;
587 /* Compare the elements. If any pair of corresponding elements
588 fail to match, return 0 for the whole thing. */
590 fmt = GET_RTX_FORMAT (code);
591 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
593 switch (fmt[i])
595 case 'w':
596 if (XWINT (x, i) != XWINT (y, i))
597 return 0;
598 break;
600 case 'n':
601 case 'i':
602 if (XINT (x, i) != XINT (y, i))
604 #ifndef GENERATOR_FILE
605 if (((code == ASM_OPERANDS && i == 6)
606 || (code == ASM_INPUT && i == 1))
607 && XINT (x, i) == XINT (y, i))
608 break;
609 #endif
610 return 0;
612 break;
614 case 'V':
615 case 'E':
616 /* Two vectors must have the same length. */
617 if (XVECLEN (x, i) != XVECLEN (y, i))
618 return 0;
620 /* And the corresponding elements must match. */
621 for (j = 0; j < XVECLEN (x, i); j++)
622 if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
623 return 0;
624 break;
626 case 'e':
627 if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
628 return 0;
629 break;
631 case 'S':
632 case 's':
633 if ((XSTR (x, i) || XSTR (y, i))
634 && (! XSTR (x, i) || ! XSTR (y, i)
635 || strcmp (XSTR (x, i), XSTR (y, i))))
636 return 0;
637 break;
639 case 'u':
640 /* These are just backpointers, so they don't matter. */
641 break;
643 case '0':
644 case 't':
645 break;
647 /* It is believed that rtx's at this level will never
648 contain anything but integers and other rtx's,
649 except for within LABEL_REFs and SYMBOL_REFs. */
650 default:
651 gcc_unreachable ();
654 return 1;
657 /* Iteratively hash rtx X. */
659 hashval_t
660 iterative_hash_rtx (const_rtx x, hashval_t hash)
662 enum rtx_code code;
663 enum machine_mode mode;
664 int i, j;
665 const char *fmt;
667 if (x == NULL_RTX)
668 return hash;
669 code = GET_CODE (x);
670 hash = iterative_hash_object (code, hash);
671 mode = GET_MODE (x);
672 hash = iterative_hash_object (mode, hash);
673 switch (code)
675 case REG:
676 i = REGNO (x);
677 return iterative_hash_object (i, hash);
678 case CONST_INT:
679 return iterative_hash_object (INTVAL (x), hash);
680 case CONST_WIDE_INT:
681 for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
682 hash = iterative_hash_object (CONST_WIDE_INT_ELT (x, i), hash);
683 return hash;
684 case SYMBOL_REF:
685 if (XSTR (x, 0))
686 return iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
687 hash);
688 return hash;
689 case LABEL_REF:
690 case DEBUG_EXPR:
691 case VALUE:
692 case SCRATCH:
693 case CONST_DOUBLE:
694 case CONST_FIXED:
695 case DEBUG_IMPLICIT_PTR:
696 case DEBUG_PARAMETER_REF:
697 return hash;
698 default:
699 break;
702 fmt = GET_RTX_FORMAT (code);
703 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
704 switch (fmt[i])
706 case 'w':
707 hash = iterative_hash_object (XWINT (x, i), hash);
708 break;
709 case 'n':
710 case 'i':
711 hash = iterative_hash_object (XINT (x, i), hash);
712 break;
713 case 'V':
714 case 'E':
715 j = XVECLEN (x, i);
716 hash = iterative_hash_object (j, hash);
717 for (j = 0; j < XVECLEN (x, i); j++)
718 hash = iterative_hash_rtx (XVECEXP (x, i, j), hash);
719 break;
720 case 'e':
721 hash = iterative_hash_rtx (XEXP (x, i), hash);
722 break;
723 case 'S':
724 case 's':
725 if (XSTR (x, i))
726 hash = iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
727 hash);
728 break;
729 default:
730 break;
732 return hash;
735 void
736 dump_rtx_statistics (void)
738 int i;
739 int total_counts = 0;
740 int total_sizes = 0;
742 if (! GATHER_STATISTICS)
744 fprintf (stderr, "No RTX statistics\n");
745 return;
748 fprintf (stderr, "\nRTX Kind Count Bytes\n");
749 fprintf (stderr, "---------------------------------------\n");
750 for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
751 if (rtx_alloc_counts[i])
753 fprintf (stderr, "%-20s %7d %10d\n", GET_RTX_NAME (i),
754 rtx_alloc_counts[i], rtx_alloc_sizes[i]);
755 total_counts += rtx_alloc_counts[i];
756 total_sizes += rtx_alloc_sizes[i];
758 if (rtvec_alloc_counts)
760 fprintf (stderr, "%-20s %7d %10d\n", "rtvec",
761 rtvec_alloc_counts, rtvec_alloc_sizes);
762 total_counts += rtvec_alloc_counts;
763 total_sizes += rtvec_alloc_sizes;
765 fprintf (stderr, "---------------------------------------\n");
766 fprintf (stderr, "%-20s %7d %10d\n",
767 "Total", total_counts, total_sizes);
768 fprintf (stderr, "---------------------------------------\n");
771 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
772 void
773 rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line,
774 const char *func)
776 internal_error
777 ("RTL check: access of elt %d of '%s' with last elt %d in %s, at %s:%d",
778 n, GET_RTX_NAME (GET_CODE (r)), GET_RTX_LENGTH (GET_CODE (r)) - 1,
779 func, trim_filename (file), line);
782 void
783 rtl_check_failed_type1 (const_rtx r, int n, int c1, const char *file, int line,
784 const char *func)
786 internal_error
787 ("RTL check: expected elt %d type '%c', have '%c' (rtx %s) in %s, at %s:%d",
788 n, c1, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
789 func, trim_filename (file), line);
792 void
793 rtl_check_failed_type2 (const_rtx r, int n, int c1, int c2, const char *file,
794 int line, const char *func)
796 internal_error
797 ("RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s) in %s, at %s:%d",
798 n, c1, c2, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
799 func, trim_filename (file), line);
802 void
803 rtl_check_failed_code1 (const_rtx r, enum rtx_code code, const char *file,
804 int line, const char *func)
806 internal_error ("RTL check: expected code '%s', have '%s' in %s, at %s:%d",
807 GET_RTX_NAME (code), GET_RTX_NAME (GET_CODE (r)), func,
808 trim_filename (file), line);
811 void
812 rtl_check_failed_code2 (const_rtx r, enum rtx_code code1, enum rtx_code code2,
813 const char *file, int line, const char *func)
815 internal_error
816 ("RTL check: expected code '%s' or '%s', have '%s' in %s, at %s:%d",
817 GET_RTX_NAME (code1), GET_RTX_NAME (code2), GET_RTX_NAME (GET_CODE (r)),
818 func, trim_filename (file), line);
821 void
822 rtl_check_failed_code_mode (const_rtx r, enum rtx_code code, enum machine_mode mode,
823 bool not_mode, const char *file, int line,
824 const char *func)
826 internal_error ((not_mode
827 ? ("RTL check: expected code '%s' and not mode '%s', "
828 "have code '%s' and mode '%s' in %s, at %s:%d")
829 : ("RTL check: expected code '%s' and mode '%s', "
830 "have code '%s' and mode '%s' in %s, at %s:%d")),
831 GET_RTX_NAME (code), GET_MODE_NAME (mode),
832 GET_RTX_NAME (GET_CODE (r)), GET_MODE_NAME (GET_MODE (r)),
833 func, trim_filename (file), line);
836 /* Report that line LINE of FILE tried to access the block symbol fields
837 of a non-block symbol. FUNC is the function that contains the line. */
839 void
840 rtl_check_failed_block_symbol (const char *file, int line, const char *func)
842 internal_error
843 ("RTL check: attempt to treat non-block symbol as a block symbol "
844 "in %s, at %s:%d", func, trim_filename (file), line);
847 /* XXX Maybe print the vector? */
848 void
849 cwi_check_failed_bounds (const_rtx x, int n, const char *file, int line,
850 const char *func)
852 internal_error
853 ("RTL check: access of hwi elt %d of vector with last elt %d in %s, at %s:%d",
854 n, CWI_GET_NUM_ELEM (x) - 1, func, trim_filename (file), line);
857 /* XXX Maybe print the vector? */
858 void
859 rtvec_check_failed_bounds (const_rtvec r, int n, const char *file, int line,
860 const char *func)
862 internal_error
863 ("RTL check: access of elt %d of vector with last elt %d in %s, at %s:%d",
864 n, GET_NUM_ELEM (r) - 1, func, trim_filename (file), line);
866 #endif /* ENABLE_RTL_CHECKING */
868 #if defined ENABLE_RTL_FLAG_CHECKING
869 void
870 rtl_check_failed_flag (const char *name, const_rtx r, const char *file,
871 int line, const char *func)
873 internal_error
874 ("RTL flag check: %s used with unexpected rtx code '%s' in %s, at %s:%d",
875 name, GET_RTX_NAME (GET_CODE (r)), func, trim_filename (file), line);
877 #endif /* ENABLE_RTL_FLAG_CHECKING */