]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rtl.c
Remove zone allocator.
[thirdparty/gcc.git] / gcc / rtl.c
1 /* RTL utility routines.
2 Copyright (C) 1987-2013 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
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.
10
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.
15
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/>. */
19
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
27
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
38
39 \f
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). */
42
43 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) sizeof FORMAT - 1 ,
44
45 const unsigned char rtx_length[NUM_RTX_CODE] = {
46 #include "rtl.def"
47 };
48
49 #undef DEF_RTL_EXPR
50
51 /* Indexed by rtx code, gives the name of that kind of rtx, as a C string. */
52
53 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) NAME ,
54
55 const char * const rtx_name[NUM_RTX_CODE] = {
56 #include "rtl.def" /* rtl expressions are documented here */
57 };
58
59 #undef DEF_RTL_EXPR
60
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. */
64
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. */
92
93 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) FORMAT ,
94 #include "rtl.def" /* rtl expressions are defined here */
95 #undef DEF_RTL_EXPR
96 };
97
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. */
100
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
105 };
106
107 /* Indexed by rtx code, gives the size of the rtx in bytes. */
108
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)),
115
116 #include "rtl.def"
117 #undef DEF_RTL_EXPR
118 };
119
120 /* Names for kinds of NOTEs and REG_NOTEs. */
121
122 const char * const note_insn_name[NOTE_INSN_MAX] =
123 {
124 #define DEF_INSN_NOTE(NAME) #NAME,
125 #include "insn-notes.def"
126 #undef DEF_INSN_NOTE
127 };
128
129 const char * const reg_note_name[REG_NOTE_MAX] =
130 {
131 #define DEF_REG_NOTE(NAME) #NAME,
132 #include "reg-notes.def"
133 #undef DEF_REG_NOTE
134 };
135
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;
140
141 \f
142 /* Allocate an rtx vector of N elements.
143 Store the length, and initialize all elements to zero. */
144
145 rtvec
146 rtvec_alloc (int n)
147 {
148 rtvec rt;
149
150 rt = ggc_alloc_rtvec_sized (n);
151 /* Clear out the vector. */
152 memset (&rt->elem[0], 0, n * sizeof (rtx));
153
154 PUT_NUM_ELEM (rt, n);
155
156 if (GATHER_STATISTICS)
157 {
158 rtvec_alloc_counts++;
159 rtvec_alloc_sizes += n * sizeof (rtx);
160 }
161
162 return rt;
163 }
164
165 /* Create a bitwise copy of VEC. */
166
167 rtvec
168 shallow_copy_rtvec (rtvec vec)
169 {
170 rtvec newvec;
171 int n;
172
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;
177 }
178
179 /* Return the number of bytes occupied by rtx value X. */
180
181 unsigned int
182 rtx_size (const_rtx x)
183 {
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));
187 }
188
189 /* Allocate an rtx of code CODE. The CODE is stored in the rtx;
190 all the rest is initialized to zero. */
191
192 rtx
193 rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
194 {
195 rtx rt = ggc_alloc_rtx_def_stat (RTX_CODE_SIZE (code) PASS_MEM_STAT);
196
197 /* We want to clear everything up to the FLD array. Normally, this
198 is one int, but we don't want to assume that and it isn't very
199 portable anyway; this is. */
200
201 memset (rt, 0, RTX_HDR_SIZE);
202 PUT_CODE (rt, code);
203
204 if (GATHER_STATISTICS)
205 {
206 rtx_alloc_counts[code]++;
207 rtx_alloc_sizes[code] += RTX_CODE_SIZE (code);
208 }
209
210 return rt;
211 }
212
213 \f
214 /* Return true if ORIG is a sharable CONST. */
215
216 bool
217 shared_const_p (const_rtx orig)
218 {
219 gcc_assert (GET_CODE (orig) == CONST);
220
221 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
222 a LABEL_REF, it isn't sharable. */
223 return (GET_CODE (XEXP (orig, 0)) == PLUS
224 && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
225 && CONST_INT_P(XEXP (XEXP (orig, 0), 1)));
226 }
227
228
229 /* Create a new copy of an rtx.
230 Recursively copies the operands of the rtx,
231 except for those few rtx codes that are sharable. */
232
233 rtx
234 copy_rtx (rtx orig)
235 {
236 rtx copy;
237 int i, j;
238 RTX_CODE code;
239 const char *format_ptr;
240
241 code = GET_CODE (orig);
242
243 switch (code)
244 {
245 case REG:
246 case DEBUG_EXPR:
247 case VALUE:
248 CASE_CONST_ANY:
249 case SYMBOL_REF:
250 case CODE_LABEL:
251 case PC:
252 case CC0:
253 case RETURN:
254 case SIMPLE_RETURN:
255 case SCRATCH:
256 /* SCRATCH must be shared because they represent distinct values. */
257 return orig;
258 case CLOBBER:
259 if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER)
260 return orig;
261 break;
262
263 case CONST:
264 if (shared_const_p (orig))
265 return orig;
266 break;
267
268 /* A MEM with a constant address is not sharable. The problem is that
269 the constant address may need to be reloaded. If the mem is shared,
270 then reloading one copy of this mem will cause all copies to appear
271 to have been reloaded. */
272
273 default:
274 break;
275 }
276
277 /* Copy the various flags, fields, and other information. We assume
278 that all fields need copying, and then clear the fields that should
279 not be copied. That is the sensible default behavior, and forces
280 us to explicitly document why we are *not* copying a flag. */
281 copy = shallow_copy_rtx (orig);
282
283 /* We do not copy the USED flag, which is used as a mark bit during
284 walks over the RTL. */
285 RTX_FLAG (copy, used) = 0;
286
287 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
288
289 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
290 switch (*format_ptr++)
291 {
292 case 'e':
293 if (XEXP (orig, i) != NULL)
294 XEXP (copy, i) = copy_rtx (XEXP (orig, i));
295 break;
296
297 case 'E':
298 case 'V':
299 if (XVEC (orig, i) != NULL)
300 {
301 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
302 for (j = 0; j < XVECLEN (copy, i); j++)
303 XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
304 }
305 break;
306
307 case 't':
308 case 'w':
309 case 'i':
310 case 's':
311 case 'S':
312 case 'T':
313 case 'u':
314 case 'B':
315 case '0':
316 /* These are left unchanged. */
317 break;
318
319 default:
320 gcc_unreachable ();
321 }
322 return copy;
323 }
324
325 /* Create a new copy of an rtx. Only copy just one level. */
326
327 rtx
328 shallow_copy_rtx_stat (const_rtx orig MEM_STAT_DECL)
329 {
330 const unsigned int size = rtx_size (orig);
331 rtx const copy = ggc_alloc_rtx_def_stat (size PASS_MEM_STAT);
332 return (rtx) memcpy (copy, orig, size);
333 }
334 \f
335 /* Nonzero when we are generating CONCATs. */
336 int generating_concat_p;
337
338 /* Nonzero when we are expanding trees to RTL. */
339 int currently_expanding_to_rtl;
340
341 \f
342
343 /* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL.
344 When the callback returns true, we continue with the new pair.
345 Whenever changing this function check if rtx_equal_p below doesn't need
346 changing as well. */
347
348 int
349 rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
350 {
351 int i;
352 int j;
353 enum rtx_code code;
354 const char *fmt;
355 rtx nx, ny;
356
357 if (x == y)
358 return 1;
359 if (x == 0 || y == 0)
360 return 0;
361
362 /* Invoke the callback first. */
363 if (cb != NULL
364 && ((*cb) (&x, &y, &nx, &ny)))
365 return rtx_equal_p_cb (nx, ny, cb);
366
367 code = GET_CODE (x);
368 /* Rtx's of different codes cannot be equal. */
369 if (code != GET_CODE (y))
370 return 0;
371
372 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
373 (REG:SI x) and (REG:HI x) are NOT equivalent. */
374
375 if (GET_MODE (x) != GET_MODE (y))
376 return 0;
377
378 /* MEMs referring to different address space are not equivalent. */
379 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
380 return 0;
381
382 /* Some RTL can be compared nonrecursively. */
383 switch (code)
384 {
385 case REG:
386 return (REGNO (x) == REGNO (y));
387
388 case LABEL_REF:
389 return XEXP (x, 0) == XEXP (y, 0);
390
391 case SYMBOL_REF:
392 return XSTR (x, 0) == XSTR (y, 0);
393
394 case DEBUG_EXPR:
395 case VALUE:
396 case SCRATCH:
397 CASE_CONST_UNIQUE:
398 return 0;
399
400 case DEBUG_IMPLICIT_PTR:
401 return DEBUG_IMPLICIT_PTR_DECL (x)
402 == DEBUG_IMPLICIT_PTR_DECL (y);
403
404 case DEBUG_PARAMETER_REF:
405 return DEBUG_PARAMETER_REF_DECL (x)
406 == DEBUG_PARAMETER_REF_DECL (x);
407
408 case ENTRY_VALUE:
409 return rtx_equal_p_cb (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y), cb);
410
411 default:
412 break;
413 }
414
415 /* Compare the elements. If any pair of corresponding elements
416 fail to match, return 0 for the whole thing. */
417
418 fmt = GET_RTX_FORMAT (code);
419 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
420 {
421 switch (fmt[i])
422 {
423 case 'w':
424 if (XWINT (x, i) != XWINT (y, i))
425 return 0;
426 break;
427
428 case 'n':
429 case 'i':
430 if (XINT (x, i) != XINT (y, i))
431 {
432 #ifndef GENERATOR_FILE
433 if (((code == ASM_OPERANDS && i == 6)
434 || (code == ASM_INPUT && i == 1))
435 && XINT (x, i) == XINT (y, i))
436 break;
437 #endif
438 return 0;
439 }
440 break;
441
442 case 'V':
443 case 'E':
444 /* Two vectors must have the same length. */
445 if (XVECLEN (x, i) != XVECLEN (y, i))
446 return 0;
447
448 /* And the corresponding elements must match. */
449 for (j = 0; j < XVECLEN (x, i); j++)
450 if (rtx_equal_p_cb (XVECEXP (x, i, j),
451 XVECEXP (y, i, j), cb) == 0)
452 return 0;
453 break;
454
455 case 'e':
456 if (rtx_equal_p_cb (XEXP (x, i), XEXP (y, i), cb) == 0)
457 return 0;
458 break;
459
460 case 'S':
461 case 's':
462 if ((XSTR (x, i) || XSTR (y, i))
463 && (! XSTR (x, i) || ! XSTR (y, i)
464 || strcmp (XSTR (x, i), XSTR (y, i))))
465 return 0;
466 break;
467
468 case 'u':
469 /* These are just backpointers, so they don't matter. */
470 break;
471
472 case '0':
473 case 't':
474 break;
475
476 /* It is believed that rtx's at this level will never
477 contain anything but integers and other rtx's,
478 except for within LABEL_REFs and SYMBOL_REFs. */
479 default:
480 gcc_unreachable ();
481 }
482 }
483 return 1;
484 }
485
486 /* Return 1 if X and Y are identical-looking rtx's.
487 This is the Lisp function EQUAL for rtx arguments.
488 Whenever changing this function check if rtx_equal_p_cb above doesn't need
489 changing as well. */
490
491 int
492 rtx_equal_p (const_rtx x, const_rtx y)
493 {
494 int i;
495 int j;
496 enum rtx_code code;
497 const char *fmt;
498
499 if (x == y)
500 return 1;
501 if (x == 0 || y == 0)
502 return 0;
503
504 code = GET_CODE (x);
505 /* Rtx's of different codes cannot be equal. */
506 if (code != GET_CODE (y))
507 return 0;
508
509 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
510 (REG:SI x) and (REG:HI x) are NOT equivalent. */
511
512 if (GET_MODE (x) != GET_MODE (y))
513 return 0;
514
515 /* MEMs referring to different address space are not equivalent. */
516 if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
517 return 0;
518
519 /* Some RTL can be compared nonrecursively. */
520 switch (code)
521 {
522 case REG:
523 return (REGNO (x) == REGNO (y));
524
525 case LABEL_REF:
526 return XEXP (x, 0) == XEXP (y, 0);
527
528 case SYMBOL_REF:
529 return XSTR (x, 0) == XSTR (y, 0);
530
531 case DEBUG_EXPR:
532 case VALUE:
533 case SCRATCH:
534 CASE_CONST_UNIQUE:
535 return 0;
536
537 case DEBUG_IMPLICIT_PTR:
538 return DEBUG_IMPLICIT_PTR_DECL (x)
539 == DEBUG_IMPLICIT_PTR_DECL (y);
540
541 case DEBUG_PARAMETER_REF:
542 return DEBUG_PARAMETER_REF_DECL (x)
543 == DEBUG_PARAMETER_REF_DECL (y);
544
545 case ENTRY_VALUE:
546 return rtx_equal_p (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
547
548 default:
549 break;
550 }
551
552 /* Compare the elements. If any pair of corresponding elements
553 fail to match, return 0 for the whole thing. */
554
555 fmt = GET_RTX_FORMAT (code);
556 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
557 {
558 switch (fmt[i])
559 {
560 case 'w':
561 if (XWINT (x, i) != XWINT (y, i))
562 return 0;
563 break;
564
565 case 'n':
566 case 'i':
567 if (XINT (x, i) != XINT (y, i))
568 {
569 #ifndef GENERATOR_FILE
570 if (((code == ASM_OPERANDS && i == 6)
571 || (code == ASM_INPUT && i == 1))
572 && XINT (x, i) == XINT (y, i))
573 break;
574 #endif
575 return 0;
576 }
577 break;
578
579 case 'V':
580 case 'E':
581 /* Two vectors must have the same length. */
582 if (XVECLEN (x, i) != XVECLEN (y, i))
583 return 0;
584
585 /* And the corresponding elements must match. */
586 for (j = 0; j < XVECLEN (x, i); j++)
587 if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
588 return 0;
589 break;
590
591 case 'e':
592 if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
593 return 0;
594 break;
595
596 case 'S':
597 case 's':
598 if ((XSTR (x, i) || XSTR (y, i))
599 && (! XSTR (x, i) || ! XSTR (y, i)
600 || strcmp (XSTR (x, i), XSTR (y, i))))
601 return 0;
602 break;
603
604 case 'u':
605 /* These are just backpointers, so they don't matter. */
606 break;
607
608 case '0':
609 case 't':
610 break;
611
612 /* It is believed that rtx's at this level will never
613 contain anything but integers and other rtx's,
614 except for within LABEL_REFs and SYMBOL_REFs. */
615 default:
616 gcc_unreachable ();
617 }
618 }
619 return 1;
620 }
621
622 /* Iteratively hash rtx X. */
623
624 hashval_t
625 iterative_hash_rtx (const_rtx x, hashval_t hash)
626 {
627 enum rtx_code code;
628 enum machine_mode mode;
629 int i, j;
630 const char *fmt;
631
632 if (x == NULL_RTX)
633 return hash;
634 code = GET_CODE (x);
635 hash = iterative_hash_object (code, hash);
636 mode = GET_MODE (x);
637 hash = iterative_hash_object (mode, hash);
638 switch (code)
639 {
640 case REG:
641 i = REGNO (x);
642 return iterative_hash_object (i, hash);
643 case CONST_INT:
644 return iterative_hash_object (INTVAL (x), hash);
645 case SYMBOL_REF:
646 if (XSTR (x, 0))
647 return iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
648 hash);
649 return hash;
650 case LABEL_REF:
651 case DEBUG_EXPR:
652 case VALUE:
653 case SCRATCH:
654 case CONST_DOUBLE:
655 case CONST_FIXED:
656 case DEBUG_IMPLICIT_PTR:
657 case DEBUG_PARAMETER_REF:
658 return hash;
659 default:
660 break;
661 }
662
663 fmt = GET_RTX_FORMAT (code);
664 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
665 switch (fmt[i])
666 {
667 case 'w':
668 hash = iterative_hash_object (XWINT (x, i), hash);
669 break;
670 case 'n':
671 case 'i':
672 hash = iterative_hash_object (XINT (x, i), hash);
673 break;
674 case 'V':
675 case 'E':
676 j = XVECLEN (x, i);
677 hash = iterative_hash_object (j, hash);
678 for (j = 0; j < XVECLEN (x, i); j++)
679 hash = iterative_hash_rtx (XVECEXP (x, i, j), hash);
680 break;
681 case 'e':
682 hash = iterative_hash_rtx (XEXP (x, i), hash);
683 break;
684 case 'S':
685 case 's':
686 if (XSTR (x, i))
687 hash = iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
688 hash);
689 break;
690 default:
691 break;
692 }
693 return hash;
694 }
695
696 void
697 dump_rtx_statistics (void)
698 {
699 int i;
700 int total_counts = 0;
701 int total_sizes = 0;
702
703 if (! GATHER_STATISTICS)
704 {
705 fprintf (stderr, "No RTX statistics\n");
706 return;
707 }
708
709 fprintf (stderr, "\nRTX Kind Count Bytes\n");
710 fprintf (stderr, "---------------------------------------\n");
711 for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
712 if (rtx_alloc_counts[i])
713 {
714 fprintf (stderr, "%-20s %7d %10d\n", GET_RTX_NAME (i),
715 rtx_alloc_counts[i], rtx_alloc_sizes[i]);
716 total_counts += rtx_alloc_counts[i];
717 total_sizes += rtx_alloc_sizes[i];
718 }
719 if (rtvec_alloc_counts)
720 {
721 fprintf (stderr, "%-20s %7d %10d\n", "rtvec",
722 rtvec_alloc_counts, rtvec_alloc_sizes);
723 total_counts += rtvec_alloc_counts;
724 total_sizes += rtvec_alloc_sizes;
725 }
726 fprintf (stderr, "---------------------------------------\n");
727 fprintf (stderr, "%-20s %7d %10d\n",
728 "Total", total_counts, total_sizes);
729 fprintf (stderr, "---------------------------------------\n");
730 }
731 \f
732 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
733 void
734 rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line,
735 const char *func)
736 {
737 internal_error
738 ("RTL check: access of elt %d of '%s' with last elt %d in %s, at %s:%d",
739 n, GET_RTX_NAME (GET_CODE (r)), GET_RTX_LENGTH (GET_CODE (r)) - 1,
740 func, trim_filename (file), line);
741 }
742
743 void
744 rtl_check_failed_type1 (const_rtx r, int n, int c1, const char *file, int line,
745 const char *func)
746 {
747 internal_error
748 ("RTL check: expected elt %d type '%c', have '%c' (rtx %s) in %s, at %s:%d",
749 n, c1, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
750 func, trim_filename (file), line);
751 }
752
753 void
754 rtl_check_failed_type2 (const_rtx r, int n, int c1, int c2, const char *file,
755 int line, const char *func)
756 {
757 internal_error
758 ("RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s) in %s, at %s:%d",
759 n, c1, c2, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
760 func, trim_filename (file), line);
761 }
762
763 void
764 rtl_check_failed_code1 (const_rtx r, enum rtx_code code, const char *file,
765 int line, const char *func)
766 {
767 internal_error ("RTL check: expected code '%s', have '%s' in %s, at %s:%d",
768 GET_RTX_NAME (code), GET_RTX_NAME (GET_CODE (r)), func,
769 trim_filename (file), line);
770 }
771
772 void
773 rtl_check_failed_code2 (const_rtx r, enum rtx_code code1, enum rtx_code code2,
774 const char *file, int line, const char *func)
775 {
776 internal_error
777 ("RTL check: expected code '%s' or '%s', have '%s' in %s, at %s:%d",
778 GET_RTX_NAME (code1), GET_RTX_NAME (code2), GET_RTX_NAME (GET_CODE (r)),
779 func, trim_filename (file), line);
780 }
781
782 void
783 rtl_check_failed_code_mode (const_rtx r, enum rtx_code code, enum machine_mode mode,
784 bool not_mode, const char *file, int line,
785 const char *func)
786 {
787 internal_error ((not_mode
788 ? ("RTL check: expected code '%s' and not mode '%s', "
789 "have code '%s' and mode '%s' in %s, at %s:%d")
790 : ("RTL check: expected code '%s' and mode '%s', "
791 "have code '%s' and mode '%s' in %s, at %s:%d")),
792 GET_RTX_NAME (code), GET_MODE_NAME (mode),
793 GET_RTX_NAME (GET_CODE (r)), GET_MODE_NAME (GET_MODE (r)),
794 func, trim_filename (file), line);
795 }
796
797 /* Report that line LINE of FILE tried to access the block symbol fields
798 of a non-block symbol. FUNC is the function that contains the line. */
799
800 void
801 rtl_check_failed_block_symbol (const char *file, int line, const char *func)
802 {
803 internal_error
804 ("RTL check: attempt to treat non-block symbol as a block symbol "
805 "in %s, at %s:%d", func, trim_filename (file), line);
806 }
807
808 /* XXX Maybe print the vector? */
809 void
810 rtvec_check_failed_bounds (const_rtvec r, int n, const char *file, int line,
811 const char *func)
812 {
813 internal_error
814 ("RTL check: access of elt %d of vector with last elt %d in %s, at %s:%d",
815 n, GET_NUM_ELEM (r) - 1, func, trim_filename (file), line);
816 }
817 #endif /* ENABLE_RTL_CHECKING */
818
819 #if defined ENABLE_RTL_FLAG_CHECKING
820 void
821 rtl_check_failed_flag (const char *name, const_rtx r, const char *file,
822 int line, const char *func)
823 {
824 internal_error
825 ("RTL flag check: %s used with unexpected rtx code '%s' in %s, at %s:%d",
826 name, GET_RTX_NAME (GET_CODE (r)), func, trim_filename (file), line);
827 }
828 #endif /* ENABLE_RTL_FLAG_CHECKING */