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