1*38fd1498Szrj /* RTL utility routines.
2*38fd1498Szrj Copyright (C) 1987-2018 Free Software Foundation, Inc.
3*38fd1498Szrj
4*38fd1498Szrj This file is part of GCC.
5*38fd1498Szrj
6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
7*38fd1498Szrj the terms of the GNU General Public License as published by the Free
8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
9*38fd1498Szrj version.
10*38fd1498Szrj
11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14*38fd1498Szrj for more details.
15*38fd1498Szrj
16*38fd1498Szrj You should have received a copy of the GNU General Public License
17*38fd1498Szrj along with GCC; see the file COPYING3. If not see
18*38fd1498Szrj <http://www.gnu.org/licenses/>. */
19*38fd1498Szrj
20*38fd1498Szrj /* This file is compiled twice: once for the generator programs
21*38fd1498Szrj once for the compiler. */
22*38fd1498Szrj #ifdef GENERATOR_FILE
23*38fd1498Szrj #include "bconfig.h"
24*38fd1498Szrj #else
25*38fd1498Szrj #include "config.h"
26*38fd1498Szrj #endif
27*38fd1498Szrj
28*38fd1498Szrj #include "system.h"
29*38fd1498Szrj #include "coretypes.h"
30*38fd1498Szrj #include "tm.h"
31*38fd1498Szrj #include "rtl.h"
32*38fd1498Szrj #ifdef GENERATOR_FILE
33*38fd1498Szrj # include "errors.h"
34*38fd1498Szrj #else
35*38fd1498Szrj # include "rtlhash.h"
36*38fd1498Szrj # include "diagnostic-core.h"
37*38fd1498Szrj #endif
38*38fd1498Szrj
39*38fd1498Szrj
40*38fd1498Szrj /* Indexed by rtx code, gives number of operands for an rtx with that code.
41*38fd1498Szrj Does NOT include rtx header data (code and links). */
42*38fd1498Szrj
43*38fd1498Szrj #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) sizeof FORMAT - 1 ,
44*38fd1498Szrj
45*38fd1498Szrj const unsigned char rtx_length[NUM_RTX_CODE] = {
46*38fd1498Szrj #include "rtl.def"
47*38fd1498Szrj };
48*38fd1498Szrj
49*38fd1498Szrj #undef DEF_RTL_EXPR
50*38fd1498Szrj
51*38fd1498Szrj /* Indexed by rtx code, gives the name of that kind of rtx, as a C string. */
52*38fd1498Szrj
53*38fd1498Szrj #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) NAME ,
54*38fd1498Szrj
55*38fd1498Szrj const char * const rtx_name[NUM_RTX_CODE] = {
56*38fd1498Szrj #include "rtl.def" /* rtl expressions are documented here */
57*38fd1498Szrj };
58*38fd1498Szrj
59*38fd1498Szrj #undef DEF_RTL_EXPR
60*38fd1498Szrj
61*38fd1498Szrj /* Indexed by rtx code, gives a sequence of operand-types for
62*38fd1498Szrj rtx's of that code. The sequence is a C string in which
63*38fd1498Szrj each character describes one operand. */
64*38fd1498Szrj
65*38fd1498Szrj const char * const rtx_format[NUM_RTX_CODE] = {
66*38fd1498Szrj /* "*" undefined.
67*38fd1498Szrj can cause a warning message
68*38fd1498Szrj "0" field is unused (or used in a phase-dependent manner)
69*38fd1498Szrj prints nothing
70*38fd1498Szrj "i" an integer
71*38fd1498Szrj prints the integer
72*38fd1498Szrj "n" like "i", but prints entries from `note_insn_name'
73*38fd1498Szrj "w" an integer of width HOST_BITS_PER_WIDE_INT
74*38fd1498Szrj prints the integer
75*38fd1498Szrj "s" a pointer to a string
76*38fd1498Szrj prints the string
77*38fd1498Szrj "S" like "s", but optional:
78*38fd1498Szrj the containing rtx may end before this operand
79*38fd1498Szrj "T" like "s", but treated specially by the RTL reader;
80*38fd1498Szrj only found in machine description patterns.
81*38fd1498Szrj "e" a pointer to an rtl expression
82*38fd1498Szrj prints the expression
83*38fd1498Szrj "E" a pointer to a vector that points to a number of rtl expressions
84*38fd1498Szrj prints a list of the rtl expressions
85*38fd1498Szrj "V" like "E", but optional:
86*38fd1498Szrj the containing rtx may end before this operand
87*38fd1498Szrj "u" a pointer to another insn
88*38fd1498Szrj prints the uid of the insn.
89*38fd1498Szrj "b" is a pointer to a bitmap header.
90*38fd1498Szrj "B" is a basic block pointer.
91*38fd1498Szrj "t" is a tree pointer.
92*38fd1498Szrj "r" a register.
93*38fd1498Szrj "p" is a poly_uint16 offset. */
94*38fd1498Szrj
95*38fd1498Szrj #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) FORMAT ,
96*38fd1498Szrj #include "rtl.def" /* rtl expressions are defined here */
97*38fd1498Szrj #undef DEF_RTL_EXPR
98*38fd1498Szrj };
99*38fd1498Szrj
100*38fd1498Szrj /* Indexed by rtx code, gives a character representing the "class" of
101*38fd1498Szrj that rtx code. See rtl.def for documentation on the defined classes. */
102*38fd1498Szrj
103*38fd1498Szrj const enum rtx_class rtx_class[NUM_RTX_CODE] = {
104*38fd1498Szrj #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS,
105*38fd1498Szrj #include "rtl.def" /* rtl expressions are defined here */
106*38fd1498Szrj #undef DEF_RTL_EXPR
107*38fd1498Szrj };
108*38fd1498Szrj
109*38fd1498Szrj /* Indexed by rtx code, gives the size of the rtx in bytes. */
110*38fd1498Szrj
111*38fd1498Szrj const unsigned char rtx_code_size[NUM_RTX_CODE] = {
112*38fd1498Szrj #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \
113*38fd1498Szrj (((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE \
114*38fd1498Szrj || (ENUM) == CONST_FIXED || (ENUM) == CONST_WIDE_INT) \
115*38fd1498Szrj ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \
116*38fd1498Szrj : (ENUM) == REG \
117*38fd1498Szrj ? RTX_HDR_SIZE + sizeof (reg_info) \
118*38fd1498Szrj : RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (rtunion)),
119*38fd1498Szrj
120*38fd1498Szrj #include "rtl.def"
121*38fd1498Szrj #undef DEF_RTL_EXPR
122*38fd1498Szrj };
123*38fd1498Szrj
124*38fd1498Szrj /* Names for kinds of NOTEs and REG_NOTEs. */
125*38fd1498Szrj
126*38fd1498Szrj const char * const note_insn_name[NOTE_INSN_MAX] =
127*38fd1498Szrj {
128*38fd1498Szrj #define DEF_INSN_NOTE(NAME) #NAME,
129*38fd1498Szrj #include "insn-notes.def"
130*38fd1498Szrj #undef DEF_INSN_NOTE
131*38fd1498Szrj };
132*38fd1498Szrj
133*38fd1498Szrj const char * const reg_note_name[REG_NOTE_MAX] =
134*38fd1498Szrj {
135*38fd1498Szrj #define DEF_REG_NOTE(NAME) #NAME,
136*38fd1498Szrj #include "reg-notes.def"
137*38fd1498Szrj #undef DEF_REG_NOTE
138*38fd1498Szrj };
139*38fd1498Szrj
140*38fd1498Szrj static int rtx_alloc_counts[(int) LAST_AND_UNUSED_RTX_CODE];
141*38fd1498Szrj static int rtx_alloc_sizes[(int) LAST_AND_UNUSED_RTX_CODE];
142*38fd1498Szrj static int rtvec_alloc_counts;
143*38fd1498Szrj static int rtvec_alloc_sizes;
144*38fd1498Szrj
145*38fd1498Szrj
146*38fd1498Szrj /* Allocate an rtx vector of N elements.
147*38fd1498Szrj Store the length, and initialize all elements to zero. */
148*38fd1498Szrj
149*38fd1498Szrj rtvec
rtvec_alloc(int n)150*38fd1498Szrj rtvec_alloc (int n)
151*38fd1498Szrj {
152*38fd1498Szrj rtvec rt;
153*38fd1498Szrj
154*38fd1498Szrj rt = ggc_alloc_rtvec_sized (n);
155*38fd1498Szrj /* Clear out the vector. */
156*38fd1498Szrj memset (&rt->elem[0], 0, n * sizeof (rtx));
157*38fd1498Szrj
158*38fd1498Szrj PUT_NUM_ELEM (rt, n);
159*38fd1498Szrj
160*38fd1498Szrj if (GATHER_STATISTICS)
161*38fd1498Szrj {
162*38fd1498Szrj rtvec_alloc_counts++;
163*38fd1498Szrj rtvec_alloc_sizes += n * sizeof (rtx);
164*38fd1498Szrj }
165*38fd1498Szrj
166*38fd1498Szrj return rt;
167*38fd1498Szrj }
168*38fd1498Szrj
169*38fd1498Szrj /* Create a bitwise copy of VEC. */
170*38fd1498Szrj
171*38fd1498Szrj rtvec
shallow_copy_rtvec(rtvec vec)172*38fd1498Szrj shallow_copy_rtvec (rtvec vec)
173*38fd1498Szrj {
174*38fd1498Szrj rtvec newvec;
175*38fd1498Szrj int n;
176*38fd1498Szrj
177*38fd1498Szrj n = GET_NUM_ELEM (vec);
178*38fd1498Szrj newvec = rtvec_alloc (n);
179*38fd1498Szrj memcpy (&newvec->elem[0], &vec->elem[0], sizeof (rtx) * n);
180*38fd1498Szrj return newvec;
181*38fd1498Szrj }
182*38fd1498Szrj
183*38fd1498Szrj /* Return the number of bytes occupied by rtx value X. */
184*38fd1498Szrj
185*38fd1498Szrj unsigned int
rtx_size(const_rtx x)186*38fd1498Szrj rtx_size (const_rtx x)
187*38fd1498Szrj {
188*38fd1498Szrj if (CONST_WIDE_INT_P (x))
189*38fd1498Szrj return (RTX_HDR_SIZE
190*38fd1498Szrj + sizeof (struct hwivec_def)
191*38fd1498Szrj + ((CONST_WIDE_INT_NUNITS (x) - 1)
192*38fd1498Szrj * sizeof (HOST_WIDE_INT)));
193*38fd1498Szrj if (CONST_POLY_INT_P (x))
194*38fd1498Szrj return (RTX_HDR_SIZE
195*38fd1498Szrj + sizeof (struct const_poly_int_def)
196*38fd1498Szrj + CONST_POLY_INT_COEFFS (x).extra_size ());
197*38fd1498Szrj if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_HAS_BLOCK_INFO_P (x))
198*38fd1498Szrj return RTX_HDR_SIZE + sizeof (struct block_symbol);
199*38fd1498Szrj return RTX_CODE_SIZE (GET_CODE (x));
200*38fd1498Szrj }
201*38fd1498Szrj
202*38fd1498Szrj /* Allocate an rtx of code CODE with EXTRA bytes in it. The CODE is
203*38fd1498Szrj stored in the rtx; all the rest is initialized to zero. */
204*38fd1498Szrj
205*38fd1498Szrj rtx
rtx_alloc_stat_v(RTX_CODE code MEM_STAT_DECL,int extra)206*38fd1498Szrj rtx_alloc_stat_v (RTX_CODE code MEM_STAT_DECL, int extra)
207*38fd1498Szrj {
208*38fd1498Szrj rtx rt = ggc_alloc_rtx_def_stat (RTX_CODE_SIZE (code) + extra
209*38fd1498Szrj PASS_MEM_STAT);
210*38fd1498Szrj
211*38fd1498Szrj /* We want to clear everything up to the FLD array. Normally, this
212*38fd1498Szrj is one int, but we don't want to assume that and it isn't very
213*38fd1498Szrj portable anyway; this is. */
214*38fd1498Szrj
215*38fd1498Szrj memset (rt, 0, RTX_HDR_SIZE);
216*38fd1498Szrj PUT_CODE (rt, code);
217*38fd1498Szrj
218*38fd1498Szrj if (GATHER_STATISTICS)
219*38fd1498Szrj {
220*38fd1498Szrj rtx_alloc_counts[code]++;
221*38fd1498Szrj rtx_alloc_sizes[code] += RTX_CODE_SIZE (code);
222*38fd1498Szrj }
223*38fd1498Szrj
224*38fd1498Szrj return rt;
225*38fd1498Szrj }
226*38fd1498Szrj
227*38fd1498Szrj /* Allocate an rtx of code CODE. The CODE is stored in the rtx;
228*38fd1498Szrj all the rest is initialized to zero. */
229*38fd1498Szrj
230*38fd1498Szrj rtx
rtx_alloc(RTX_CODE code MEM_STAT_DECL)231*38fd1498Szrj rtx_alloc (RTX_CODE code MEM_STAT_DECL)
232*38fd1498Szrj {
233*38fd1498Szrj return rtx_alloc_stat_v (code PASS_MEM_STAT, 0);
234*38fd1498Szrj }
235*38fd1498Szrj
236*38fd1498Szrj /* Write the wide constant X to OUTFILE. */
237*38fd1498Szrj
238*38fd1498Szrj void
cwi_output_hex(FILE * outfile,const_rtx x)239*38fd1498Szrj cwi_output_hex (FILE *outfile, const_rtx x)
240*38fd1498Szrj {
241*38fd1498Szrj int i = CWI_GET_NUM_ELEM (x);
242*38fd1498Szrj gcc_assert (i > 0);
243*38fd1498Szrj if (CWI_ELT (x, i - 1) == 0)
244*38fd1498Szrj /* The HOST_WIDE_INT_PRINT_HEX prepends a 0x only if the val is
245*38fd1498Szrj non zero. We want all numbers to have a 0x prefix. */
246*38fd1498Szrj fprintf (outfile, "0x");
247*38fd1498Szrj fprintf (outfile, HOST_WIDE_INT_PRINT_HEX, CWI_ELT (x, --i));
248*38fd1498Szrj while (--i >= 0)
249*38fd1498Szrj fprintf (outfile, HOST_WIDE_INT_PRINT_PADDED_HEX, CWI_ELT (x, i));
250*38fd1498Szrj }
251*38fd1498Szrj
252*38fd1498Szrj
253*38fd1498Szrj /* Return true if ORIG is a sharable CONST. */
254*38fd1498Szrj
255*38fd1498Szrj bool
shared_const_p(const_rtx orig)256*38fd1498Szrj shared_const_p (const_rtx orig)
257*38fd1498Szrj {
258*38fd1498Szrj gcc_assert (GET_CODE (orig) == CONST);
259*38fd1498Szrj
260*38fd1498Szrj /* CONST can be shared if it contains a SYMBOL_REF. If it contains
261*38fd1498Szrj a LABEL_REF, it isn't sharable. */
262*38fd1498Szrj poly_int64 offset;
263*38fd1498Szrj return (GET_CODE (XEXP (orig, 0)) == PLUS
264*38fd1498Szrj && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
265*38fd1498Szrj && poly_int_rtx_p (XEXP (XEXP (orig, 0), 1), &offset));
266*38fd1498Szrj }
267*38fd1498Szrj
268*38fd1498Szrj
269*38fd1498Szrj /* Create a new copy of an rtx.
270*38fd1498Szrj Recursively copies the operands of the rtx,
271*38fd1498Szrj except for those few rtx codes that are sharable. */
272*38fd1498Szrj
273*38fd1498Szrj rtx
copy_rtx(rtx orig)274*38fd1498Szrj copy_rtx (rtx orig)
275*38fd1498Szrj {
276*38fd1498Szrj rtx copy;
277*38fd1498Szrj int i, j;
278*38fd1498Szrj RTX_CODE code;
279*38fd1498Szrj const char *format_ptr;
280*38fd1498Szrj
281*38fd1498Szrj code = GET_CODE (orig);
282*38fd1498Szrj
283*38fd1498Szrj switch (code)
284*38fd1498Szrj {
285*38fd1498Szrj case REG:
286*38fd1498Szrj case DEBUG_EXPR:
287*38fd1498Szrj case VALUE:
288*38fd1498Szrj CASE_CONST_ANY:
289*38fd1498Szrj case SYMBOL_REF:
290*38fd1498Szrj case CODE_LABEL:
291*38fd1498Szrj case PC:
292*38fd1498Szrj case CC0:
293*38fd1498Szrj case RETURN:
294*38fd1498Szrj case SIMPLE_RETURN:
295*38fd1498Szrj case SCRATCH:
296*38fd1498Szrj /* SCRATCH must be shared because they represent distinct values. */
297*38fd1498Szrj return orig;
298*38fd1498Szrj case CLOBBER:
299*38fd1498Szrj /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
300*38fd1498Szrj clobbers or clobbers of hard registers that originated as pseudos.
301*38fd1498Szrj This is needed to allow safe register renaming. */
302*38fd1498Szrj if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER
303*38fd1498Szrj && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0)))
304*38fd1498Szrj return orig;
305*38fd1498Szrj break;
306*38fd1498Szrj
307*38fd1498Szrj case CONST:
308*38fd1498Szrj if (shared_const_p (orig))
309*38fd1498Szrj return orig;
310*38fd1498Szrj break;
311*38fd1498Szrj
312*38fd1498Szrj /* A MEM with a constant address is not sharable. The problem is that
313*38fd1498Szrj the constant address may need to be reloaded. If the mem is shared,
314*38fd1498Szrj then reloading one copy of this mem will cause all copies to appear
315*38fd1498Szrj to have been reloaded. */
316*38fd1498Szrj
317*38fd1498Szrj default:
318*38fd1498Szrj break;
319*38fd1498Szrj }
320*38fd1498Szrj
321*38fd1498Szrj /* Copy the various flags, fields, and other information. We assume
322*38fd1498Szrj that all fields need copying, and then clear the fields that should
323*38fd1498Szrj not be copied. That is the sensible default behavior, and forces
324*38fd1498Szrj us to explicitly document why we are *not* copying a flag. */
325*38fd1498Szrj copy = shallow_copy_rtx (orig);
326*38fd1498Szrj
327*38fd1498Szrj format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
328*38fd1498Szrj
329*38fd1498Szrj for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
330*38fd1498Szrj switch (*format_ptr++)
331*38fd1498Szrj {
332*38fd1498Szrj case 'e':
333*38fd1498Szrj if (XEXP (orig, i) != NULL)
334*38fd1498Szrj XEXP (copy, i) = copy_rtx (XEXP (orig, i));
335*38fd1498Szrj break;
336*38fd1498Szrj
337*38fd1498Szrj case 'E':
338*38fd1498Szrj case 'V':
339*38fd1498Szrj if (XVEC (orig, i) != NULL)
340*38fd1498Szrj {
341*38fd1498Szrj XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
342*38fd1498Szrj for (j = 0; j < XVECLEN (copy, i); j++)
343*38fd1498Szrj XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
344*38fd1498Szrj }
345*38fd1498Szrj break;
346*38fd1498Szrj
347*38fd1498Szrj case 't':
348*38fd1498Szrj case 'w':
349*38fd1498Szrj case 'i':
350*38fd1498Szrj case 'p':
351*38fd1498Szrj case 's':
352*38fd1498Szrj case 'S':
353*38fd1498Szrj case 'T':
354*38fd1498Szrj case 'u':
355*38fd1498Szrj case 'B':
356*38fd1498Szrj case '0':
357*38fd1498Szrj /* These are left unchanged. */
358*38fd1498Szrj break;
359*38fd1498Szrj
360*38fd1498Szrj default:
361*38fd1498Szrj gcc_unreachable ();
362*38fd1498Szrj }
363*38fd1498Szrj return copy;
364*38fd1498Szrj }
365*38fd1498Szrj
366*38fd1498Szrj /* Create a new copy of an rtx. Only copy just one level. */
367*38fd1498Szrj
368*38fd1498Szrj rtx
shallow_copy_rtx(const_rtx orig MEM_STAT_DECL)369*38fd1498Szrj shallow_copy_rtx (const_rtx orig MEM_STAT_DECL)
370*38fd1498Szrj {
371*38fd1498Szrj const unsigned int size = rtx_size (orig);
372*38fd1498Szrj rtx const copy = ggc_alloc_rtx_def_stat (size PASS_MEM_STAT);
373*38fd1498Szrj memcpy (copy, orig, size);
374*38fd1498Szrj switch (GET_CODE (orig))
375*38fd1498Szrj {
376*38fd1498Szrj /* RTX codes copy_rtx_if_shared_1 considers are shareable,
377*38fd1498Szrj the used flag is often used for other purposes. */
378*38fd1498Szrj case REG:
379*38fd1498Szrj case DEBUG_EXPR:
380*38fd1498Szrj case VALUE:
381*38fd1498Szrj CASE_CONST_ANY:
382*38fd1498Szrj case SYMBOL_REF:
383*38fd1498Szrj case CODE_LABEL:
384*38fd1498Szrj case PC:
385*38fd1498Szrj case CC0:
386*38fd1498Szrj case RETURN:
387*38fd1498Szrj case SIMPLE_RETURN:
388*38fd1498Szrj case SCRATCH:
389*38fd1498Szrj break;
390*38fd1498Szrj default:
391*38fd1498Szrj /* For all other RTXes clear the used flag on the copy. */
392*38fd1498Szrj RTX_FLAG (copy, used) = 0;
393*38fd1498Szrj break;
394*38fd1498Szrj }
395*38fd1498Szrj return copy;
396*38fd1498Szrj }
397*38fd1498Szrj
398*38fd1498Szrj /* Nonzero when we are generating CONCATs. */
399*38fd1498Szrj int generating_concat_p;
400*38fd1498Szrj
401*38fd1498Szrj /* Nonzero when we are expanding trees to RTL. */
402*38fd1498Szrj int currently_expanding_to_rtl;
403*38fd1498Szrj
404*38fd1498Szrj
405*38fd1498Szrj
406*38fd1498Szrj /* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL.
407*38fd1498Szrj When the callback returns true, we continue with the new pair.
408*38fd1498Szrj Whenever changing this function check if rtx_equal_p below doesn't need
409*38fd1498Szrj changing as well. */
410*38fd1498Szrj
411*38fd1498Szrj int
rtx_equal_p_cb(const_rtx x,const_rtx y,rtx_equal_p_callback_function cb)412*38fd1498Szrj rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
413*38fd1498Szrj {
414*38fd1498Szrj int i;
415*38fd1498Szrj int j;
416*38fd1498Szrj enum rtx_code code;
417*38fd1498Szrj const char *fmt;
418*38fd1498Szrj rtx nx, ny;
419*38fd1498Szrj
420*38fd1498Szrj if (x == y)
421*38fd1498Szrj return 1;
422*38fd1498Szrj if (x == 0 || y == 0)
423*38fd1498Szrj return 0;
424*38fd1498Szrj
425*38fd1498Szrj /* Invoke the callback first. */
426*38fd1498Szrj if (cb != NULL
427*38fd1498Szrj && ((*cb) (&x, &y, &nx, &ny)))
428*38fd1498Szrj return rtx_equal_p_cb (nx, ny, cb);
429*38fd1498Szrj
430*38fd1498Szrj code = GET_CODE (x);
431*38fd1498Szrj /* Rtx's of different codes cannot be equal. */
432*38fd1498Szrj if (code != GET_CODE (y))
433*38fd1498Szrj return 0;
434*38fd1498Szrj
435*38fd1498Szrj /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
436*38fd1498Szrj (REG:SI x) and (REG:HI x) are NOT equivalent. */
437*38fd1498Szrj
438*38fd1498Szrj if (GET_MODE (x) != GET_MODE (y))
439*38fd1498Szrj return 0;
440*38fd1498Szrj
441*38fd1498Szrj /* MEMs referring to different address space are not equivalent. */
442*38fd1498Szrj if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
443*38fd1498Szrj return 0;
444*38fd1498Szrj
445*38fd1498Szrj /* Some RTL can be compared nonrecursively. */
446*38fd1498Szrj switch (code)
447*38fd1498Szrj {
448*38fd1498Szrj case REG:
449*38fd1498Szrj return (REGNO (x) == REGNO (y));
450*38fd1498Szrj
451*38fd1498Szrj case LABEL_REF:
452*38fd1498Szrj return label_ref_label (x) == label_ref_label (y);
453*38fd1498Szrj
454*38fd1498Szrj case SYMBOL_REF:
455*38fd1498Szrj return XSTR (x, 0) == XSTR (y, 0);
456*38fd1498Szrj
457*38fd1498Szrj case DEBUG_EXPR:
458*38fd1498Szrj case VALUE:
459*38fd1498Szrj case SCRATCH:
460*38fd1498Szrj CASE_CONST_UNIQUE:
461*38fd1498Szrj return 0;
462*38fd1498Szrj
463*38fd1498Szrj case DEBUG_IMPLICIT_PTR:
464*38fd1498Szrj return DEBUG_IMPLICIT_PTR_DECL (x)
465*38fd1498Szrj == DEBUG_IMPLICIT_PTR_DECL (y);
466*38fd1498Szrj
467*38fd1498Szrj case DEBUG_PARAMETER_REF:
468*38fd1498Szrj return DEBUG_PARAMETER_REF_DECL (x)
469*38fd1498Szrj == DEBUG_PARAMETER_REF_DECL (y);
470*38fd1498Szrj
471*38fd1498Szrj case ENTRY_VALUE:
472*38fd1498Szrj return rtx_equal_p_cb (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y), cb);
473*38fd1498Szrj
474*38fd1498Szrj default:
475*38fd1498Szrj break;
476*38fd1498Szrj }
477*38fd1498Szrj
478*38fd1498Szrj /* Compare the elements. If any pair of corresponding elements
479*38fd1498Szrj fail to match, return 0 for the whole thing. */
480*38fd1498Szrj
481*38fd1498Szrj fmt = GET_RTX_FORMAT (code);
482*38fd1498Szrj for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
483*38fd1498Szrj {
484*38fd1498Szrj switch (fmt[i])
485*38fd1498Szrj {
486*38fd1498Szrj case 'w':
487*38fd1498Szrj if (XWINT (x, i) != XWINT (y, i))
488*38fd1498Szrj return 0;
489*38fd1498Szrj break;
490*38fd1498Szrj
491*38fd1498Szrj case 'n':
492*38fd1498Szrj case 'i':
493*38fd1498Szrj if (XINT (x, i) != XINT (y, i))
494*38fd1498Szrj {
495*38fd1498Szrj #ifndef GENERATOR_FILE
496*38fd1498Szrj if (((code == ASM_OPERANDS && i == 6)
497*38fd1498Szrj || (code == ASM_INPUT && i == 1))
498*38fd1498Szrj && XINT (x, i) == XINT (y, i))
499*38fd1498Szrj break;
500*38fd1498Szrj #endif
501*38fd1498Szrj return 0;
502*38fd1498Szrj }
503*38fd1498Szrj break;
504*38fd1498Szrj
505*38fd1498Szrj case 'p':
506*38fd1498Szrj if (maybe_ne (SUBREG_BYTE (x), SUBREG_BYTE (y)))
507*38fd1498Szrj return 0;
508*38fd1498Szrj break;
509*38fd1498Szrj
510*38fd1498Szrj case 'V':
511*38fd1498Szrj case 'E':
512*38fd1498Szrj /* Two vectors must have the same length. */
513*38fd1498Szrj if (XVECLEN (x, i) != XVECLEN (y, i))
514*38fd1498Szrj return 0;
515*38fd1498Szrj
516*38fd1498Szrj /* And the corresponding elements must match. */
517*38fd1498Szrj for (j = 0; j < XVECLEN (x, i); j++)
518*38fd1498Szrj if (rtx_equal_p_cb (XVECEXP (x, i, j),
519*38fd1498Szrj XVECEXP (y, i, j), cb) == 0)
520*38fd1498Szrj return 0;
521*38fd1498Szrj break;
522*38fd1498Szrj
523*38fd1498Szrj case 'e':
524*38fd1498Szrj if (rtx_equal_p_cb (XEXP (x, i), XEXP (y, i), cb) == 0)
525*38fd1498Szrj return 0;
526*38fd1498Szrj break;
527*38fd1498Szrj
528*38fd1498Szrj case 'S':
529*38fd1498Szrj case 's':
530*38fd1498Szrj if ((XSTR (x, i) || XSTR (y, i))
531*38fd1498Szrj && (! XSTR (x, i) || ! XSTR (y, i)
532*38fd1498Szrj || strcmp (XSTR (x, i), XSTR (y, i))))
533*38fd1498Szrj return 0;
534*38fd1498Szrj break;
535*38fd1498Szrj
536*38fd1498Szrj case 'u':
537*38fd1498Szrj /* These are just backpointers, so they don't matter. */
538*38fd1498Szrj break;
539*38fd1498Szrj
540*38fd1498Szrj case '0':
541*38fd1498Szrj case 't':
542*38fd1498Szrj break;
543*38fd1498Szrj
544*38fd1498Szrj /* It is believed that rtx's at this level will never
545*38fd1498Szrj contain anything but integers and other rtx's,
546*38fd1498Szrj except for within LABEL_REFs and SYMBOL_REFs. */
547*38fd1498Szrj default:
548*38fd1498Szrj gcc_unreachable ();
549*38fd1498Szrj }
550*38fd1498Szrj }
551*38fd1498Szrj return 1;
552*38fd1498Szrj }
553*38fd1498Szrj
554*38fd1498Szrj /* Return 1 if X and Y are identical-looking rtx's.
555*38fd1498Szrj This is the Lisp function EQUAL for rtx arguments.
556*38fd1498Szrj Whenever changing this function check if rtx_equal_p_cb above doesn't need
557*38fd1498Szrj changing as well. */
558*38fd1498Szrj
559*38fd1498Szrj int
rtx_equal_p(const_rtx x,const_rtx y)560*38fd1498Szrj rtx_equal_p (const_rtx x, const_rtx y)
561*38fd1498Szrj {
562*38fd1498Szrj int i;
563*38fd1498Szrj int j;
564*38fd1498Szrj enum rtx_code code;
565*38fd1498Szrj const char *fmt;
566*38fd1498Szrj
567*38fd1498Szrj if (x == y)
568*38fd1498Szrj return 1;
569*38fd1498Szrj if (x == 0 || y == 0)
570*38fd1498Szrj return 0;
571*38fd1498Szrj
572*38fd1498Szrj code = GET_CODE (x);
573*38fd1498Szrj /* Rtx's of different codes cannot be equal. */
574*38fd1498Szrj if (code != GET_CODE (y))
575*38fd1498Szrj return 0;
576*38fd1498Szrj
577*38fd1498Szrj /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
578*38fd1498Szrj (REG:SI x) and (REG:HI x) are NOT equivalent. */
579*38fd1498Szrj
580*38fd1498Szrj if (GET_MODE (x) != GET_MODE (y))
581*38fd1498Szrj return 0;
582*38fd1498Szrj
583*38fd1498Szrj /* MEMs referring to different address space are not equivalent. */
584*38fd1498Szrj if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
585*38fd1498Szrj return 0;
586*38fd1498Szrj
587*38fd1498Szrj /* Some RTL can be compared nonrecursively. */
588*38fd1498Szrj switch (code)
589*38fd1498Szrj {
590*38fd1498Szrj case REG:
591*38fd1498Szrj return (REGNO (x) == REGNO (y));
592*38fd1498Szrj
593*38fd1498Szrj case LABEL_REF:
594*38fd1498Szrj return label_ref_label (x) == label_ref_label (y);
595*38fd1498Szrj
596*38fd1498Szrj case SYMBOL_REF:
597*38fd1498Szrj return XSTR (x, 0) == XSTR (y, 0);
598*38fd1498Szrj
599*38fd1498Szrj case DEBUG_EXPR:
600*38fd1498Szrj case VALUE:
601*38fd1498Szrj case SCRATCH:
602*38fd1498Szrj CASE_CONST_UNIQUE:
603*38fd1498Szrj return 0;
604*38fd1498Szrj
605*38fd1498Szrj case DEBUG_IMPLICIT_PTR:
606*38fd1498Szrj return DEBUG_IMPLICIT_PTR_DECL (x)
607*38fd1498Szrj == DEBUG_IMPLICIT_PTR_DECL (y);
608*38fd1498Szrj
609*38fd1498Szrj case DEBUG_PARAMETER_REF:
610*38fd1498Szrj return DEBUG_PARAMETER_REF_DECL (x)
611*38fd1498Szrj == DEBUG_PARAMETER_REF_DECL (y);
612*38fd1498Szrj
613*38fd1498Szrj case ENTRY_VALUE:
614*38fd1498Szrj return rtx_equal_p (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
615*38fd1498Szrj
616*38fd1498Szrj default:
617*38fd1498Szrj break;
618*38fd1498Szrj }
619*38fd1498Szrj
620*38fd1498Szrj /* Compare the elements. If any pair of corresponding elements
621*38fd1498Szrj fail to match, return 0 for the whole thing. */
622*38fd1498Szrj
623*38fd1498Szrj fmt = GET_RTX_FORMAT (code);
624*38fd1498Szrj for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
625*38fd1498Szrj {
626*38fd1498Szrj switch (fmt[i])
627*38fd1498Szrj {
628*38fd1498Szrj case 'w':
629*38fd1498Szrj if (XWINT (x, i) != XWINT (y, i))
630*38fd1498Szrj return 0;
631*38fd1498Szrj break;
632*38fd1498Szrj
633*38fd1498Szrj case 'n':
634*38fd1498Szrj case 'i':
635*38fd1498Szrj if (XINT (x, i) != XINT (y, i))
636*38fd1498Szrj {
637*38fd1498Szrj #ifndef GENERATOR_FILE
638*38fd1498Szrj if (((code == ASM_OPERANDS && i == 6)
639*38fd1498Szrj || (code == ASM_INPUT && i == 1))
640*38fd1498Szrj && XINT (x, i) == XINT (y, i))
641*38fd1498Szrj break;
642*38fd1498Szrj #endif
643*38fd1498Szrj return 0;
644*38fd1498Szrj }
645*38fd1498Szrj break;
646*38fd1498Szrj
647*38fd1498Szrj case 'p':
648*38fd1498Szrj if (maybe_ne (SUBREG_BYTE (x), SUBREG_BYTE (y)))
649*38fd1498Szrj return 0;
650*38fd1498Szrj break;
651*38fd1498Szrj
652*38fd1498Szrj case 'V':
653*38fd1498Szrj case 'E':
654*38fd1498Szrj /* Two vectors must have the same length. */
655*38fd1498Szrj if (XVECLEN (x, i) != XVECLEN (y, i))
656*38fd1498Szrj return 0;
657*38fd1498Szrj
658*38fd1498Szrj /* And the corresponding elements must match. */
659*38fd1498Szrj for (j = 0; j < XVECLEN (x, i); j++)
660*38fd1498Szrj if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
661*38fd1498Szrj return 0;
662*38fd1498Szrj break;
663*38fd1498Szrj
664*38fd1498Szrj case 'e':
665*38fd1498Szrj if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
666*38fd1498Szrj return 0;
667*38fd1498Szrj break;
668*38fd1498Szrj
669*38fd1498Szrj case 'S':
670*38fd1498Szrj case 's':
671*38fd1498Szrj if ((XSTR (x, i) || XSTR (y, i))
672*38fd1498Szrj && (! XSTR (x, i) || ! XSTR (y, i)
673*38fd1498Szrj || strcmp (XSTR (x, i), XSTR (y, i))))
674*38fd1498Szrj return 0;
675*38fd1498Szrj break;
676*38fd1498Szrj
677*38fd1498Szrj case 'u':
678*38fd1498Szrj /* These are just backpointers, so they don't matter. */
679*38fd1498Szrj break;
680*38fd1498Szrj
681*38fd1498Szrj case '0':
682*38fd1498Szrj case 't':
683*38fd1498Szrj break;
684*38fd1498Szrj
685*38fd1498Szrj /* It is believed that rtx's at this level will never
686*38fd1498Szrj contain anything but integers and other rtx's,
687*38fd1498Szrj except for within LABEL_REFs and SYMBOL_REFs. */
688*38fd1498Szrj default:
689*38fd1498Szrj gcc_unreachable ();
690*38fd1498Szrj }
691*38fd1498Szrj }
692*38fd1498Szrj return 1;
693*38fd1498Szrj }
694*38fd1498Szrj
695*38fd1498Szrj /* Return true if all elements of VEC are equal. */
696*38fd1498Szrj
697*38fd1498Szrj bool
rtvec_all_equal_p(const_rtvec vec)698*38fd1498Szrj rtvec_all_equal_p (const_rtvec vec)
699*38fd1498Szrj {
700*38fd1498Szrj const_rtx first = RTVEC_ELT (vec, 0);
701*38fd1498Szrj /* Optimize the important special case of a vector of constants.
702*38fd1498Szrj The main use of this function is to detect whether every element
703*38fd1498Szrj of CONST_VECTOR is the same. */
704*38fd1498Szrj switch (GET_CODE (first))
705*38fd1498Szrj {
706*38fd1498Szrj CASE_CONST_UNIQUE:
707*38fd1498Szrj for (int i = 1, n = GET_NUM_ELEM (vec); i < n; ++i)
708*38fd1498Szrj if (first != RTVEC_ELT (vec, i))
709*38fd1498Szrj return false;
710*38fd1498Szrj return true;
711*38fd1498Szrj
712*38fd1498Szrj default:
713*38fd1498Szrj for (int i = 1, n = GET_NUM_ELEM (vec); i < n; ++i)
714*38fd1498Szrj if (!rtx_equal_p (first, RTVEC_ELT (vec, i)))
715*38fd1498Szrj return false;
716*38fd1498Szrj return true;
717*38fd1498Szrj }
718*38fd1498Szrj }
719*38fd1498Szrj
720*38fd1498Szrj /* Return an indication of which type of insn should have X as a body.
721*38fd1498Szrj In generator files, this can be UNKNOWN if the answer is only known
722*38fd1498Szrj at (GCC) runtime. Otherwise the value is CODE_LABEL, INSN, CALL_INSN
723*38fd1498Szrj or JUMP_INSN. */
724*38fd1498Szrj
725*38fd1498Szrj enum rtx_code
classify_insn(rtx x)726*38fd1498Szrj classify_insn (rtx x)
727*38fd1498Szrj {
728*38fd1498Szrj if (LABEL_P (x))
729*38fd1498Szrj return CODE_LABEL;
730*38fd1498Szrj if (GET_CODE (x) == CALL)
731*38fd1498Szrj return CALL_INSN;
732*38fd1498Szrj if (ANY_RETURN_P (x))
733*38fd1498Szrj return JUMP_INSN;
734*38fd1498Szrj if (GET_CODE (x) == SET)
735*38fd1498Szrj {
736*38fd1498Szrj if (GET_CODE (SET_DEST (x)) == PC)
737*38fd1498Szrj return JUMP_INSN;
738*38fd1498Szrj else if (GET_CODE (SET_SRC (x)) == CALL)
739*38fd1498Szrj return CALL_INSN;
740*38fd1498Szrj else
741*38fd1498Szrj return INSN;
742*38fd1498Szrj }
743*38fd1498Szrj if (GET_CODE (x) == PARALLEL)
744*38fd1498Szrj {
745*38fd1498Szrj int j;
746*38fd1498Szrj bool has_return_p = false;
747*38fd1498Szrj for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
748*38fd1498Szrj if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
749*38fd1498Szrj return CALL_INSN;
750*38fd1498Szrj else if (ANY_RETURN_P (XVECEXP (x, 0, j)))
751*38fd1498Szrj has_return_p = true;
752*38fd1498Szrj else if (GET_CODE (XVECEXP (x, 0, j)) == SET
753*38fd1498Szrj && GET_CODE (SET_DEST (XVECEXP (x, 0, j))) == PC)
754*38fd1498Szrj return JUMP_INSN;
755*38fd1498Szrj else if (GET_CODE (XVECEXP (x, 0, j)) == SET
756*38fd1498Szrj && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL)
757*38fd1498Szrj return CALL_INSN;
758*38fd1498Szrj if (has_return_p)
759*38fd1498Szrj return JUMP_INSN;
760*38fd1498Szrj }
761*38fd1498Szrj #ifdef GENERATOR_FILE
762*38fd1498Szrj if (GET_CODE (x) == MATCH_OPERAND
763*38fd1498Szrj || GET_CODE (x) == MATCH_OPERATOR
764*38fd1498Szrj || GET_CODE (x) == MATCH_PARALLEL
765*38fd1498Szrj || GET_CODE (x) == MATCH_OP_DUP
766*38fd1498Szrj || GET_CODE (x) == MATCH_DUP
767*38fd1498Szrj || GET_CODE (x) == PARALLEL)
768*38fd1498Szrj return UNKNOWN;
769*38fd1498Szrj #endif
770*38fd1498Szrj return INSN;
771*38fd1498Szrj }
772*38fd1498Szrj
773*38fd1498Szrj void
dump_rtx_statistics(void)774*38fd1498Szrj dump_rtx_statistics (void)
775*38fd1498Szrj {
776*38fd1498Szrj int i;
777*38fd1498Szrj int total_counts = 0;
778*38fd1498Szrj int total_sizes = 0;
779*38fd1498Szrj
780*38fd1498Szrj if (! GATHER_STATISTICS)
781*38fd1498Szrj {
782*38fd1498Szrj fprintf (stderr, "No RTX statistics\n");
783*38fd1498Szrj return;
784*38fd1498Szrj }
785*38fd1498Szrj
786*38fd1498Szrj fprintf (stderr, "\nRTX Kind Count Bytes\n");
787*38fd1498Szrj fprintf (stderr, "---------------------------------------\n");
788*38fd1498Szrj for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
789*38fd1498Szrj if (rtx_alloc_counts[i])
790*38fd1498Szrj {
791*38fd1498Szrj fprintf (stderr, "%-20s %7d %10d\n", GET_RTX_NAME (i),
792*38fd1498Szrj rtx_alloc_counts[i], rtx_alloc_sizes[i]);
793*38fd1498Szrj total_counts += rtx_alloc_counts[i];
794*38fd1498Szrj total_sizes += rtx_alloc_sizes[i];
795*38fd1498Szrj }
796*38fd1498Szrj if (rtvec_alloc_counts)
797*38fd1498Szrj {
798*38fd1498Szrj fprintf (stderr, "%-20s %7d %10d\n", "rtvec",
799*38fd1498Szrj rtvec_alloc_counts, rtvec_alloc_sizes);
800*38fd1498Szrj total_counts += rtvec_alloc_counts;
801*38fd1498Szrj total_sizes += rtvec_alloc_sizes;
802*38fd1498Szrj }
803*38fd1498Szrj fprintf (stderr, "---------------------------------------\n");
804*38fd1498Szrj fprintf (stderr, "%-20s %7d %10d\n",
805*38fd1498Szrj "Total", total_counts, total_sizes);
806*38fd1498Szrj fprintf (stderr, "---------------------------------------\n");
807*38fd1498Szrj }
808*38fd1498Szrj
809*38fd1498Szrj #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
810*38fd1498Szrj void
rtl_check_failed_bounds(const_rtx r,int n,const char * file,int line,const char * func)811*38fd1498Szrj rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line,
812*38fd1498Szrj const char *func)
813*38fd1498Szrj {
814*38fd1498Szrj internal_error
815*38fd1498Szrj ("RTL check: access of elt %d of '%s' with last elt %d in %s, at %s:%d",
816*38fd1498Szrj n, GET_RTX_NAME (GET_CODE (r)), GET_RTX_LENGTH (GET_CODE (r)) - 1,
817*38fd1498Szrj func, trim_filename (file), line);
818*38fd1498Szrj }
819*38fd1498Szrj
820*38fd1498Szrj void
rtl_check_failed_type1(const_rtx r,int n,int c1,const char * file,int line,const char * func)821*38fd1498Szrj rtl_check_failed_type1 (const_rtx r, int n, int c1, const char *file, int line,
822*38fd1498Szrj const char *func)
823*38fd1498Szrj {
824*38fd1498Szrj internal_error
825*38fd1498Szrj ("RTL check: expected elt %d type '%c', have '%c' (rtx %s) in %s, at %s:%d",
826*38fd1498Szrj n, c1, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
827*38fd1498Szrj func, trim_filename (file), line);
828*38fd1498Szrj }
829*38fd1498Szrj
830*38fd1498Szrj void
rtl_check_failed_type2(const_rtx r,int n,int c1,int c2,const char * file,int line,const char * func)831*38fd1498Szrj rtl_check_failed_type2 (const_rtx r, int n, int c1, int c2, const char *file,
832*38fd1498Szrj int line, const char *func)
833*38fd1498Szrj {
834*38fd1498Szrj internal_error
835*38fd1498Szrj ("RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s) in %s, at %s:%d",
836*38fd1498Szrj n, c1, c2, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
837*38fd1498Szrj func, trim_filename (file), line);
838*38fd1498Szrj }
839*38fd1498Szrj
840*38fd1498Szrj void
rtl_check_failed_code1(const_rtx r,enum rtx_code code,const char * file,int line,const char * func)841*38fd1498Szrj rtl_check_failed_code1 (const_rtx r, enum rtx_code code, const char *file,
842*38fd1498Szrj int line, const char *func)
843*38fd1498Szrj {
844*38fd1498Szrj internal_error ("RTL check: expected code '%s', have '%s' in %s, at %s:%d",
845*38fd1498Szrj GET_RTX_NAME (code), GET_RTX_NAME (GET_CODE (r)), func,
846*38fd1498Szrj trim_filename (file), line);
847*38fd1498Szrj }
848*38fd1498Szrj
849*38fd1498Szrj void
rtl_check_failed_code2(const_rtx r,enum rtx_code code1,enum rtx_code code2,const char * file,int line,const char * func)850*38fd1498Szrj rtl_check_failed_code2 (const_rtx r, enum rtx_code code1, enum rtx_code code2,
851*38fd1498Szrj const char *file, int line, const char *func)
852*38fd1498Szrj {
853*38fd1498Szrj internal_error
854*38fd1498Szrj ("RTL check: expected code '%s' or '%s', have '%s' in %s, at %s:%d",
855*38fd1498Szrj GET_RTX_NAME (code1), GET_RTX_NAME (code2), GET_RTX_NAME (GET_CODE (r)),
856*38fd1498Szrj func, trim_filename (file), line);
857*38fd1498Szrj }
858*38fd1498Szrj
859*38fd1498Szrj void
rtl_check_failed_code_mode(const_rtx r,enum rtx_code code,machine_mode mode,bool not_mode,const char * file,int line,const char * func)860*38fd1498Szrj rtl_check_failed_code_mode (const_rtx r, enum rtx_code code, machine_mode mode,
861*38fd1498Szrj bool not_mode, const char *file, int line,
862*38fd1498Szrj const char *func)
863*38fd1498Szrj {
864*38fd1498Szrj internal_error ((not_mode
865*38fd1498Szrj ? ("RTL check: expected code '%s' and not mode '%s', "
866*38fd1498Szrj "have code '%s' and mode '%s' in %s, at %s:%d")
867*38fd1498Szrj : ("RTL check: expected code '%s' and mode '%s', "
868*38fd1498Szrj "have code '%s' and mode '%s' in %s, at %s:%d")),
869*38fd1498Szrj GET_RTX_NAME (code), GET_MODE_NAME (mode),
870*38fd1498Szrj GET_RTX_NAME (GET_CODE (r)), GET_MODE_NAME (GET_MODE (r)),
871*38fd1498Szrj func, trim_filename (file), line);
872*38fd1498Szrj }
873*38fd1498Szrj
874*38fd1498Szrj /* Report that line LINE of FILE tried to access the block symbol fields
875*38fd1498Szrj of a non-block symbol. FUNC is the function that contains the line. */
876*38fd1498Szrj
877*38fd1498Szrj void
rtl_check_failed_block_symbol(const char * file,int line,const char * func)878*38fd1498Szrj rtl_check_failed_block_symbol (const char *file, int line, const char *func)
879*38fd1498Szrj {
880*38fd1498Szrj internal_error
881*38fd1498Szrj ("RTL check: attempt to treat non-block symbol as a block symbol "
882*38fd1498Szrj "in %s, at %s:%d", func, trim_filename (file), line);
883*38fd1498Szrj }
884*38fd1498Szrj
885*38fd1498Szrj /* XXX Maybe print the vector? */
886*38fd1498Szrj void
cwi_check_failed_bounds(const_rtx x,int n,const char * file,int line,const char * func)887*38fd1498Szrj cwi_check_failed_bounds (const_rtx x, int n, const char *file, int line,
888*38fd1498Szrj const char *func)
889*38fd1498Szrj {
890*38fd1498Szrj internal_error
891*38fd1498Szrj ("RTL check: access of hwi elt %d of vector with last elt %d in %s, at %s:%d",
892*38fd1498Szrj n, CWI_GET_NUM_ELEM (x) - 1, func, trim_filename (file), line);
893*38fd1498Szrj }
894*38fd1498Szrj
895*38fd1498Szrj /* XXX Maybe print the vector? */
896*38fd1498Szrj void
rtvec_check_failed_bounds(const_rtvec r,int n,const char * file,int line,const char * func)897*38fd1498Szrj rtvec_check_failed_bounds (const_rtvec r, int n, const char *file, int line,
898*38fd1498Szrj const char *func)
899*38fd1498Szrj {
900*38fd1498Szrj internal_error
901*38fd1498Szrj ("RTL check: access of elt %d of vector with last elt %d in %s, at %s:%d",
902*38fd1498Szrj n, GET_NUM_ELEM (r) - 1, func, trim_filename (file), line);
903*38fd1498Szrj }
904*38fd1498Szrj #endif /* ENABLE_RTL_CHECKING */
905*38fd1498Szrj
906*38fd1498Szrj #if defined ENABLE_RTL_FLAG_CHECKING
907*38fd1498Szrj void
rtl_check_failed_flag(const char * name,const_rtx r,const char * file,int line,const char * func)908*38fd1498Szrj rtl_check_failed_flag (const char *name, const_rtx r, const char *file,
909*38fd1498Szrj int line, const char *func)
910*38fd1498Szrj {
911*38fd1498Szrj internal_error
912*38fd1498Szrj ("RTL flag check: %s used with unexpected rtx code '%s' in %s, at %s:%d",
913*38fd1498Szrj name, GET_RTX_NAME (GET_CODE (r)), func, trim_filename (file), line);
914*38fd1498Szrj }
915*38fd1498Szrj #endif /* ENABLE_RTL_FLAG_CHECKING */
916