]>
Commit | Line | Data |
---|---|---|
6f29feb1 | 1 | /* Allocate and read RTL for GNU C Compiler. |
9311a396 | 2 | Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000 |
c5c76735 | 3 | Free Software Foundation, Inc. |
6f29feb1 JW |
4 | |
5 | This file is part of GNU CC. | |
6 | ||
7 | GNU CC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GNU CC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU CC; see the file COPYING. If not, write to | |
e99215a3 RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
6f29feb1 JW |
21 | |
22 | ||
23 | #include "config.h" | |
670ee920 | 24 | #include "system.h" |
6f29feb1 | 25 | #include "rtl.h" |
a19a1b5d | 26 | #include "real.h" |
0dfa1860 | 27 | #include "bitmap.h" |
a3770a81 | 28 | #include "ggc.h" |
6f29feb1 | 29 | #include "obstack.h" |
17074a35 | 30 | #include "toplev.h" |
49886fe1 | 31 | |
6f29feb1 JW |
32 | #define obstack_chunk_alloc xmalloc |
33 | #define obstack_chunk_free free | |
6f29feb1 JW |
34 | |
35 | /* Obstack used for allocating RTL objects. | |
36 | Between functions, this is the permanent_obstack. | |
37 | While parsing and expanding a function, this is maybepermanent_obstack | |
38 | so we can save it if it is an inline function. | |
39 | During optimization and output, this is function_obstack. */ | |
40 | ||
41 | extern struct obstack *rtl_obstack; | |
6f29feb1 | 42 | \f |
aa0b4465 ZW |
43 | /* Calculate the format for CONST_DOUBLE. This depends on the relative |
44 | widths of HOST_WIDE_INT and REAL_VALUE_TYPE. | |
b6b4c6c6 RH |
45 | |
46 | We need to go out to e0wwwww, since REAL_ARITHMETIC assumes 16-bits | |
47 | per element in REAL_VALUE_TYPE. | |
48 | ||
aa0b4465 | 49 | This is duplicated in gengenrtl.c. |
b6b4c6c6 | 50 | |
aa0b4465 ZW |
51 | A number of places assume that there are always at least two 'w' |
52 | slots in a CONST_DOUBLE, so we provide them even if one would suffice. */ | |
b6b4c6c6 RH |
53 | |
54 | #ifdef REAL_ARITHMETIC | |
4710d3eb | 55 | #if MAX_LONG_DOUBLE_TYPE_SIZE == 96 |
b6b4c6c6 | 56 | #define REAL_WIDTH (11*8 + HOST_BITS_PER_WIDE_INT)/HOST_BITS_PER_WIDE_INT |
4710d3eb | 57 | #elif MAX_LONG_DOUBLE_TYPE_SIZE == 128 |
b6b4c6c6 RH |
58 | #define REAL_WIDTH (19*8 + HOST_BITS_PER_WIDE_INT)/HOST_BITS_PER_WIDE_INT |
59 | #elif HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT | |
60 | #define REAL_WIDTH (7*8 + HOST_BITS_PER_WIDE_INT)/HOST_BITS_PER_WIDE_INT | |
61 | #endif | |
62 | #endif /* REAL_ARITHMETIC */ | |
63 | ||
64 | #ifndef REAL_WIDTH | |
4710d3eb | 65 | #if HOST_BITS_PER_WIDE_INT*2 >= MAX_LONG_DOUBLE_TYPE_SIZE |
b6b4c6c6 | 66 | #define REAL_WIDTH 2 |
4710d3eb | 67 | #elif HOST_BITS_PER_WIDE_INT*3 >= MAX_LONG_DOUBLE_TYPE_SIZE |
b6b4c6c6 | 68 | #define REAL_WIDTH 3 |
4710d3eb | 69 | #elif HOST_BITS_PER_WIDE_INT*4 >= MAX_LONG_DOUBLE_TYPE_SIZE |
b6b4c6c6 RH |
70 | #define REAL_WIDTH 4 |
71 | #endif | |
72 | #endif /* REAL_WIDTH */ | |
73 | ||
74 | #if REAL_WIDTH == 1 | |
aa0b4465 | 75 | #define CONST_DOUBLE_FORMAT "e0ww" |
b6b4c6c6 | 76 | #elif REAL_WIDTH == 2 |
aa0b4465 | 77 | #define CONST_DOUBLE_FORMAT "e0ww" |
b6b4c6c6 | 78 | #elif REAL_WIDTH == 3 |
aa0b4465 | 79 | #define CONST_DOUBLE_FORMAT "e0www" |
b6b4c6c6 | 80 | #elif REAL_WIDTH == 4 |
aa0b4465 | 81 | #define CONST_DOUBLE_FORMAT "e0wwww" |
b6b4c6c6 RH |
82 | #elif REAL_WIDTH == 5 |
83 | #define CONST_DOUBLE_FORMAT "e0wwwww" | |
aa0b4465 ZW |
84 | #else |
85 | #define CONST_DOUBLE_FORMAT /* nothing - will cause syntax error */ | |
86 | #endif | |
87 | ||
6f29feb1 | 88 | /* Indexed by rtx code, gives number of operands for an rtx with that code. |
aa0b4465 | 89 | Does NOT include rtx header data (code and links). */ |
6f29feb1 | 90 | |
aa0b4465 ZW |
91 | #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) sizeof FORMAT - 1 , |
92 | ||
93 | const int rtx_length[NUM_RTX_CODE + 1] = { | |
94 | #include "rtl.def" | |
95 | }; | |
96 | ||
97 | #undef DEF_RTL_EXPR | |
6f29feb1 JW |
98 | |
99 | /* Indexed by rtx code, gives the name of that kind of rtx, as a C string. */ | |
100 | ||
101 | #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) NAME , | |
102 | ||
5f06c983 | 103 | const char * const rtx_name[] = { |
6f29feb1 JW |
104 | #include "rtl.def" /* rtl expressions are documented here */ |
105 | }; | |
106 | ||
107 | #undef DEF_RTL_EXPR | |
108 | ||
109 | /* Indexed by machine mode, gives the name of that machine mode. | |
110 | This name does not include the letters "mode". */ | |
111 | ||
112 | #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) NAME, | |
113 | ||
a4ec8d12 | 114 | const char * const mode_name[(int) MAX_MACHINE_MODE + 1] = { |
6f29feb1 | 115 | #include "machmode.def" |
913f68c1 JC |
116 | /* Add an extra field to avoid a core dump if someone tries to convert |
117 | MAX_MACHINE_MODE to a string. */ | |
118 | "" | |
6f29feb1 JW |
119 | }; |
120 | ||
121 | #undef DEF_MACHMODE | |
122 | ||
123 | /* Indexed by machine mode, gives the length of the mode, in bytes. | |
124 | GET_MODE_CLASS uses this. */ | |
125 | ||
126 | #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) CLASS, | |
127 | ||
aa0b4465 | 128 | const enum mode_class mode_class[(int) MAX_MACHINE_MODE] = { |
6f29feb1 JW |
129 | #include "machmode.def" |
130 | }; | |
131 | ||
132 | #undef DEF_MACHMODE | |
133 | ||
134 | /* Indexed by machine mode, gives the length of the mode, in bytes. | |
135 | GET_MODE_SIZE uses this. */ | |
136 | ||
137 | #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) SIZE, | |
138 | ||
770ae6cc | 139 | const unsigned int mode_size[(int) MAX_MACHINE_MODE] = { |
6f29feb1 JW |
140 | #include "machmode.def" |
141 | }; | |
142 | ||
143 | #undef DEF_MACHMODE | |
144 | ||
145 | /* Indexed by machine mode, gives the length of the mode's subunit. | |
146 | GET_MODE_UNIT_SIZE uses this. */ | |
147 | ||
148 | #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) UNIT, | |
149 | ||
770ae6cc | 150 | const unsigned int mode_unit_size[(int) MAX_MACHINE_MODE] = { |
6f29feb1 JW |
151 | #include "machmode.def" /* machine modes are documented here */ |
152 | }; | |
153 | ||
154 | #undef DEF_MACHMODE | |
155 | ||
156 | /* Indexed by machine mode, gives next wider natural mode | |
157 | (QI -> HI -> SI -> DI, etc.) Widening multiply instructions | |
158 | use this. */ | |
159 | ||
160 | #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) \ | |
913f68c1 | 161 | (unsigned char) WIDER, |
6f29feb1 | 162 | |
aa0b4465 | 163 | const unsigned char mode_wider_mode[(int) MAX_MACHINE_MODE] = { |
6f29feb1 JW |
164 | #include "machmode.def" /* machine modes are documented here */ |
165 | }; | |
166 | ||
167 | #undef DEF_MACHMODE | |
168 | ||
913f68c1 JC |
169 | #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) \ |
170 | ((SIZE) * BITS_PER_UNIT >= HOST_BITS_PER_WIDE_INT) ? ~(unsigned HOST_WIDE_INT)0 : ((unsigned HOST_WIDE_INT) 1 << (SIZE) * BITS_PER_UNIT) - 1, | |
171 | ||
172 | /* Indexed by machine mode, gives mask of significant bits in mode. */ | |
173 | ||
aa0b4465 | 174 | const unsigned HOST_WIDE_INT mode_mask_array[(int) MAX_MACHINE_MODE] = { |
913f68c1 JC |
175 | #include "machmode.def" |
176 | }; | |
177 | ||
aa0b4465 ZW |
178 | /* Indexed by mode class, gives the narrowest mode for each class. |
179 | The Q modes are always of width 1 (2 for complex) - it is impossible | |
180 | for any mode to be narrower. */ | |
181 | ||
182 | const enum machine_mode class_narrowest_mode[(int) MAX_MODE_CLASS] = { | |
183 | /* MODE_RANDOM */ VOIDmode, | |
184 | /* MODE_INT */ QImode, | |
185 | /* MODE_FLOAT */ QFmode, | |
186 | /* MODE_PARTIAL_INT */ PQImode, | |
187 | /* MODE_CC */ CCmode, | |
188 | /* MODE_COMPLEX_INT */ CQImode, | |
189 | /* MODE_COMPLEX_FLOAT */ QCmode | |
190 | }; | |
f590cca1 | 191 | |
4a39a918 | 192 | |
6f29feb1 JW |
193 | /* Indexed by rtx code, gives a sequence of operand-types for |
194 | rtx's of that code. The sequence is a C string in which | |
6dc42e49 | 195 | each character describes one operand. */ |
6f29feb1 | 196 | |
aa0b4465 | 197 | const char * const rtx_format[] = { |
6f29feb1 JW |
198 | /* "*" undefined. |
199 | can cause a warning message | |
200 | "0" field is unused (or used in a phase-dependent manner) | |
201 | prints nothing | |
202 | "i" an integer | |
203 | prints the integer | |
204 | "n" like "i", but prints entries from `note_insn_name' | |
c166a311 CH |
205 | "w" an integer of width HOST_BITS_PER_WIDE_INT |
206 | prints the integer | |
6f29feb1 JW |
207 | "s" a pointer to a string |
208 | prints the string | |
209 | "S" like "s", but optional: | |
210 | the containing rtx may end before this operand | |
211 | "e" a pointer to an rtl expression | |
212 | prints the expression | |
213 | "E" a pointer to a vector that points to a number of rtl expressions | |
214 | prints a list of the rtl expressions | |
215 | "V" like "E", but optional: | |
216 | the containing rtx may end before this operand | |
217 | "u" a pointer to another insn | |
0dfa1860 MM |
218 | prints the uid of the insn. |
219 | "b" is a pointer to a bitmap header. | |
220 | "t" is a tree pointer. */ | |
6f29feb1 JW |
221 | |
222 | #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) FORMAT , | |
223 | #include "rtl.def" /* rtl expressions are defined here */ | |
224 | #undef DEF_RTL_EXPR | |
225 | }; | |
226 | ||
227 | /* Indexed by rtx code, gives a character representing the "class" of | |
228 | that rtx code. See rtl.def for documentation on the defined classes. */ | |
229 | ||
1f9a015e | 230 | const char rtx_class[] = { |
f590cca1 | 231 | #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS, |
6f29feb1 JW |
232 | #include "rtl.def" /* rtl expressions are defined here */ |
233 | #undef DEF_RTL_EXPR | |
234 | }; | |
235 | ||
236 | /* Names for kinds of NOTEs and REG_NOTEs. */ | |
237 | ||
d636c18c | 238 | const char * const note_insn_name[NOTE_INSN_MAX - NOTE_INSN_BIAS] = |
f590cca1 | 239 | { |
d636c18c | 240 | "", "NOTE_INSN_DELETED", |
f590cca1 RH |
241 | "NOTE_INSN_BLOCK_BEG", "NOTE_INSN_BLOCK_END", |
242 | "NOTE_INSN_LOOP_BEG", "NOTE_INSN_LOOP_END", | |
f590cca1 | 243 | "NOTE_INSN_LOOP_CONT", "NOTE_INSN_LOOP_VTOP", |
d636c18c | 244 | "NOTE_INSN_FUNCTION_END", "NOTE_INSN_SETJMP", |
f590cca1 RH |
245 | "NOTE_INSN_PROLOGUE_END", "NOTE_INSN_EPILOGUE_BEG", |
246 | "NOTE_INSN_DELETED_LABEL", "NOTE_INSN_FUNCTION_BEG", | |
247 | "NOTE_INSN_EH_REGION_BEG", "NOTE_INSN_EH_REGION_END", | |
b3b42a4d | 248 | "NOTE_INSN_REPEATED_LINE_NUMBER", "NOTE_INSN_RANGE_BEG", |
f590cca1 | 249 | "NOTE_INSN_RANGE_END", "NOTE_INSN_LIVE", |
994a57cd | 250 | "NOTE_INSN_BASIC_BLOCK", "NOTE_INSN_EXPECTED_VALUE" |
f590cca1 RH |
251 | }; |
252 | ||
253 | const char * const reg_note_name[] = | |
254 | { | |
255 | "", "REG_DEAD", "REG_INC", "REG_EQUIV", "REG_EQUAL", | |
256 | "REG_WAS_0", "REG_RETVAL", "REG_LIBCALL", "REG_NONNEG", | |
257 | "REG_NO_CONFLICT", "REG_UNUSED", "REG_CC_SETTER", "REG_CC_USER", | |
258 | "REG_LABEL", "REG_DEP_ANTI", "REG_DEP_OUTPUT", "REG_BR_PROB", | |
259 | "REG_EXEC_COUNT", "REG_NOALIAS", "REG_SAVE_AREA", "REG_BR_PRED", | |
260 | "REG_FRAME_RELATED_EXPR", "REG_EH_CONTEXT", "REG_EH_REGION", | |
261 | "REG_EH_RETHROW", "REG_SAVE_NOTE" | |
262 | }; | |
6f29feb1 | 263 | |
cdadb1dd | 264 | static void fatal_with_file_and_line PARAMS ((FILE *, const char *, ...)) |
47ee9bcb | 265 | ATTRIBUTE_PRINTF_2 ATTRIBUTE_NORETURN; |
cdadb1dd KG |
266 | static void fatal_expected_char PARAMS ((FILE *, int, int)) ATTRIBUTE_NORETURN; |
267 | static void read_name PARAMS ((char *, FILE *)); | |
268 | static const char *trim_filename PARAMS ((const char *)); | |
956d6950 | 269 | \f |
6f29feb1 JW |
270 | /* Allocate an rtx vector of N elements. |
271 | Store the length, and initialize all elements to zero. */ | |
272 | ||
273 | rtvec | |
274 | rtvec_alloc (n) | |
275 | int n; | |
276 | { | |
277 | rtvec rt; | |
f590cca1 | 278 | |
a3770a81 RH |
279 | if (ggc_p) |
280 | rt = ggc_alloc_rtvec (n); | |
281 | else | |
282 | { | |
283 | int i; | |
284 | ||
285 | rt = (rtvec) obstack_alloc (rtl_obstack, | |
286 | sizeof (struct rtvec_def) | |
287 | + (( n - 1) * sizeof (rtx))); | |
288 | ||
289 | /* clear out the vector */ | |
290 | for (i = 0; i < n; i++) | |
291 | rt->elem[i] = 0; | |
292 | } | |
6f29feb1 | 293 | |
395d53bb | 294 | PUT_NUM_ELEM (rt, n); |
6f29feb1 JW |
295 | return rt; |
296 | } | |
297 | ||
298 | /* Allocate an rtx of code CODE. The CODE is stored in the rtx; | |
299 | all the rest is initialized to zero. */ | |
300 | ||
301 | rtx | |
302 | rtx_alloc (code) | |
303 | RTX_CODE code; | |
304 | { | |
305 | rtx rt; | |
6f29feb1 | 306 | |
a3770a81 RH |
307 | if (ggc_p) |
308 | rt = ggc_alloc_rtx (GET_RTX_LENGTH (code)); | |
309 | else | |
310 | { | |
311 | register struct obstack *ob = rtl_obstack; | |
312 | register int nelts = GET_RTX_LENGTH (code); | |
313 | register int length = sizeof (struct rtx_def) | |
314 | + (nelts - 1) * sizeof (rtunion); | |
315 | ||
316 | /* This function is called more than any other in GCC, so we | |
317 | manipulate the obstack directly. | |
f590cca1 | 318 | |
a3770a81 RH |
319 | Even though rtx objects are word aligned, we may be sharing |
320 | an obstack with tree nodes, which may have to be double-word | |
321 | aligned. So align our length to the alignment mask in the | |
322 | obstack. */ | |
323 | ||
324 | length = (length + ob->alignment_mask) & ~ ob->alignment_mask; | |
325 | ||
326 | if (ob->chunk_limit - ob->next_free < length) | |
327 | _obstack_newchunk (ob, length); | |
328 | rt = (rtx)ob->object_base; | |
329 | ob->next_free += length; | |
330 | ob->object_base = ob->next_free; | |
331 | ||
332 | /* We want to clear everything up to the FLD array. Normally, | |
333 | this is one int, but we don't want to assume that and it | |
334 | isn't very portable anyway; this is. */ | |
335 | ||
336 | memset (rt, 0, sizeof (struct rtx_def) - sizeof (rtunion)); | |
337 | } | |
2151a093 | 338 | |
6f29feb1 | 339 | PUT_CODE (rt, code); |
6f29feb1 JW |
340 | return rt; |
341 | } | |
9b404774 RS |
342 | |
343 | /* Free the rtx X and all RTL allocated since X. */ | |
344 | ||
345 | void | |
346 | rtx_free (x) | |
347 | rtx x; | |
348 | { | |
a3770a81 RH |
349 | if (!ggc_p) |
350 | obstack_free (rtl_obstack, x); | |
9b404774 | 351 | } |
6f29feb1 JW |
352 | \f |
353 | /* Create a new copy of an rtx. | |
354 | Recursively copies the operands of the rtx, | |
355 | except for those few rtx codes that are sharable. */ | |
356 | ||
357 | rtx | |
358 | copy_rtx (orig) | |
359 | register rtx orig; | |
360 | { | |
361 | register rtx copy; | |
362 | register int i, j; | |
363 | register RTX_CODE code; | |
6f7d635c | 364 | register const char *format_ptr; |
6f29feb1 JW |
365 | |
366 | code = GET_CODE (orig); | |
367 | ||
368 | switch (code) | |
369 | { | |
370 | case REG: | |
371 | case QUEUED: | |
372 | case CONST_INT: | |
373 | case CONST_DOUBLE: | |
374 | case SYMBOL_REF: | |
375 | case CODE_LABEL: | |
376 | case PC: | |
377 | case CC0: | |
cf526dcc | 378 | case SCRATCH: |
0f41302f | 379 | /* SCRATCH must be shared because they represent distinct values. */ |
e9a25f70 | 380 | case ADDRESSOF: |
6f29feb1 | 381 | return orig; |
cf526dcc RK |
382 | |
383 | case CONST: | |
384 | /* CONST can be shared if it contains a SYMBOL_REF. If it contains | |
385 | a LABEL_REF, it isn't sharable. */ | |
386 | if (GET_CODE (XEXP (orig, 0)) == PLUS | |
387 | && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF | |
388 | && GET_CODE (XEXP (XEXP (orig, 0), 1)) == CONST_INT) | |
389 | return orig; | |
390 | break; | |
391 | ||
cc81e625 JW |
392 | /* A MEM with a constant address is not sharable. The problem is that |
393 | the constant address may need to be reloaded. If the mem is shared, | |
394 | then reloading one copy of this mem will cause all copies to appear | |
395 | to have been reloaded. */ | |
e9a25f70 JL |
396 | |
397 | default: | |
398 | break; | |
6f29feb1 JW |
399 | } |
400 | ||
401 | copy = rtx_alloc (code); | |
a4c6502a MM |
402 | |
403 | /* Copy the various flags, and other information. We assume that | |
404 | all fields need copying, and then clear the fields that should | |
405 | not be copied. That is the sensible default behavior, and forces | |
406 | us to explicitly document why we are *not* copying a flag. */ | |
8db99db2 | 407 | memcpy (copy, orig, sizeof (struct rtx_def) - sizeof (rtunion)); |
a4c6502a MM |
408 | |
409 | /* We do not copy the USED flag, which is used as a mark bit during | |
410 | walks over the RTL. */ | |
411 | copy->used = 0; | |
412 | ||
0a1c58a2 | 413 | /* We do not copy FRAME_RELATED for INSNs. */ |
a4c6502a | 414 | if (GET_RTX_CLASS (code) == 'i') |
0a1c58a2 JL |
415 | copy->frame_related = 0; |
416 | copy->jump = orig->jump; | |
417 | copy->call = orig->call; | |
418 | ||
6f29feb1 JW |
419 | format_ptr = GET_RTX_FORMAT (GET_CODE (copy)); |
420 | ||
421 | for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++) | |
422 | { | |
e63db8f6 | 423 | copy->fld[i] = orig->fld[i]; |
6f29feb1 JW |
424 | switch (*format_ptr++) |
425 | { | |
426 | case 'e': | |
6f29feb1 JW |
427 | if (XEXP (orig, i) != NULL) |
428 | XEXP (copy, i) = copy_rtx (XEXP (orig, i)); | |
429 | break; | |
430 | ||
431 | case 'E': | |
432 | case 'V': | |
6f29feb1 JW |
433 | if (XVEC (orig, i) != NULL) |
434 | { | |
435 | XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i)); | |
436 | for (j = 0; j < XVECLEN (copy, i); j++) | |
437 | XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j)); | |
438 | } | |
439 | break; | |
440 | ||
0dfa1860 MM |
441 | case 'b': |
442 | { | |
443 | bitmap new_bits = BITMAP_OBSTACK_ALLOC (rtl_obstack); | |
444 | bitmap_copy (new_bits, XBITMAP (orig, i)); | |
445 | XBITMAP (copy, i) = new_bits; | |
446 | break; | |
447 | } | |
448 | ||
449 | case 't': | |
c166a311 | 450 | case 'w': |
c166a311 | 451 | case 'i': |
c166a311 CH |
452 | case 's': |
453 | case 'S': | |
e63db8f6 | 454 | case 'u': |
ef178af3 | 455 | case '0': |
e63db8f6 | 456 | /* These are left unchanged. */ |
ef178af3 | 457 | break; |
f590cca1 | 458 | |
c166a311 CH |
459 | default: |
460 | abort (); | |
6f29feb1 JW |
461 | } |
462 | } | |
463 | return copy; | |
464 | } | |
465 | ||
466 | /* Similar to `copy_rtx' except that if MAY_SHARE is present, it is | |
467 | placed in the result directly, rather than being copied. */ | |
468 | ||
469 | rtx | |
470 | copy_most_rtx (orig, may_share) | |
471 | register rtx orig; | |
472 | register rtx may_share; | |
473 | { | |
474 | register rtx copy; | |
475 | register int i, j; | |
476 | register RTX_CODE code; | |
6f7d635c | 477 | register const char *format_ptr; |
6f29feb1 JW |
478 | |
479 | if (orig == may_share) | |
480 | return orig; | |
481 | ||
482 | code = GET_CODE (orig); | |
483 | ||
484 | switch (code) | |
485 | { | |
486 | case REG: | |
487 | case QUEUED: | |
488 | case CONST_INT: | |
489 | case CONST_DOUBLE: | |
490 | case SYMBOL_REF: | |
491 | case CODE_LABEL: | |
492 | case PC: | |
493 | case CC0: | |
494 | return orig; | |
e9a25f70 JL |
495 | default: |
496 | break; | |
6f29feb1 JW |
497 | } |
498 | ||
499 | copy = rtx_alloc (code); | |
500 | PUT_MODE (copy, GET_MODE (orig)); | |
501 | copy->in_struct = orig->in_struct; | |
502 | copy->volatil = orig->volatil; | |
503 | copy->unchanging = orig->unchanging; | |
504 | copy->integrated = orig->integrated; | |
f590cca1 | 505 | |
6f29feb1 JW |
506 | format_ptr = GET_RTX_FORMAT (GET_CODE (copy)); |
507 | ||
508 | for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++) | |
509 | { | |
510 | switch (*format_ptr++) | |
511 | { | |
512 | case 'e': | |
513 | XEXP (copy, i) = XEXP (orig, i); | |
514 | if (XEXP (orig, i) != NULL && XEXP (orig, i) != may_share) | |
515 | XEXP (copy, i) = copy_most_rtx (XEXP (orig, i), may_share); | |
516 | break; | |
f1027406 RK |
517 | |
518 | case 'u': | |
519 | XEXP (copy, i) = XEXP (orig, i); | |
520 | break; | |
6f29feb1 JW |
521 | |
522 | case 'E': | |
523 | case 'V': | |
524 | XVEC (copy, i) = XVEC (orig, i); | |
525 | if (XVEC (orig, i) != NULL) | |
526 | { | |
527 | XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i)); | |
528 | for (j = 0; j < XVECLEN (copy, i); j++) | |
529 | XVECEXP (copy, i, j) | |
530 | = copy_most_rtx (XVECEXP (orig, i, j), may_share); | |
531 | } | |
532 | break; | |
533 | ||
c166a311 CH |
534 | case 'w': |
535 | XWINT (copy, i) = XWINT (orig, i); | |
536 | break; | |
537 | ||
538 | case 'n': | |
539 | case 'i': | |
6f29feb1 JW |
540 | XINT (copy, i) = XINT (orig, i); |
541 | break; | |
c166a311 | 542 | |
8f985ec4 ZW |
543 | case 't': |
544 | XTREE (copy, i) = XTREE (orig, i); | |
545 | break; | |
546 | ||
c166a311 CH |
547 | case 's': |
548 | case 'S': | |
549 | XSTR (copy, i) = XSTR (orig, i); | |
550 | break; | |
551 | ||
ef178af3 ZW |
552 | case '0': |
553 | /* Copy this through the wide int field; that's safest. */ | |
554 | X0WINT (copy, i) = X0WINT (orig, i); | |
555 | break; | |
556 | ||
c166a311 CH |
557 | default: |
558 | abort (); | |
6f29feb1 JW |
559 | } |
560 | } | |
561 | return copy; | |
562 | } | |
ce9d4c6d R |
563 | |
564 | /* Create a new copy of an rtx. Only copy just one level. */ | |
565 | rtx | |
566 | shallow_copy_rtx (orig) | |
567 | rtx orig; | |
568 | { | |
569 | register int i; | |
ce9d4c6d R |
570 | register RTX_CODE code = GET_CODE (orig); |
571 | register rtx copy = rtx_alloc (code); | |
572 | ||
573 | PUT_MODE (copy, GET_MODE (orig)); | |
574 | copy->in_struct = orig->in_struct; | |
575 | copy->volatil = orig->volatil; | |
576 | copy->unchanging = orig->unchanging; | |
577 | copy->integrated = orig->integrated; | |
578 | ||
579 | for (i = 0; i < GET_RTX_LENGTH (code); i++) | |
580 | copy->fld[i] = orig->fld[i]; | |
581 | ||
582 | return copy; | |
583 | } | |
6f29feb1 | 584 | \f |
b5ee7789 CM |
585 | /* This is 1 until after the rtl generation pass. */ |
586 | int rtx_equal_function_value_matters; | |
587 | \f | |
588 | /* Return 1 if X and Y are identical-looking rtx's. | |
589 | This is the Lisp function EQUAL for rtx arguments. */ | |
590 | ||
591 | int | |
592 | rtx_equal_p (x, y) | |
593 | rtx x, y; | |
594 | { | |
595 | register int i; | |
596 | register int j; | |
597 | register enum rtx_code code; | |
598 | register const char *fmt; | |
599 | ||
600 | if (x == y) | |
601 | return 1; | |
602 | if (x == 0 || y == 0) | |
603 | return 0; | |
604 | ||
605 | code = GET_CODE (x); | |
606 | /* Rtx's of different codes cannot be equal. */ | |
607 | if (code != GET_CODE (y)) | |
608 | return 0; | |
609 | ||
610 | /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent. | |
611 | (REG:SI x) and (REG:HI x) are NOT equivalent. */ | |
612 | ||
613 | if (GET_MODE (x) != GET_MODE (y)) | |
614 | return 0; | |
615 | ||
c13e8210 MM |
616 | /* Some RTL can be compared nonrecursively. */ |
617 | switch (code) | |
618 | { | |
619 | case REG: | |
620 | /* Until rtl generation is complete, don't consider a reference to the | |
621 | return register of the current function the same as the return from a | |
622 | called function. This eases the job of function integration. Once the | |
623 | distinction is no longer needed, they can be considered equivalent. */ | |
624 | return (REGNO (x) == REGNO (y) | |
625 | && (! rtx_equal_function_value_matters | |
626 | || REG_FUNCTION_VALUE_P (x) == REG_FUNCTION_VALUE_P (y))); | |
627 | ||
628 | case LABEL_REF: | |
629 | return XEXP (x, 0) == XEXP (y, 0); | |
630 | ||
631 | case SYMBOL_REF: | |
632 | return XSTR (x, 0) == XSTR (y, 0); | |
633 | ||
634 | case SCRATCH: | |
635 | case CONST_DOUBLE: | |
636 | case CONST_INT: | |
637 | return 0; | |
638 | ||
639 | default: | |
640 | break; | |
641 | } | |
b5ee7789 CM |
642 | |
643 | /* Compare the elements. If any pair of corresponding elements | |
644 | fail to match, return 0 for the whole things. */ | |
645 | ||
646 | fmt = GET_RTX_FORMAT (code); | |
647 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
648 | { | |
649 | switch (fmt[i]) | |
650 | { | |
651 | case 'w': | |
652 | if (XWINT (x, i) != XWINT (y, i)) | |
653 | return 0; | |
654 | break; | |
655 | ||
656 | case 'n': | |
657 | case 'i': | |
658 | if (XINT (x, i) != XINT (y, i)) | |
659 | return 0; | |
660 | break; | |
661 | ||
662 | case 'V': | |
663 | case 'E': | |
664 | /* Two vectors must have the same length. */ | |
665 | if (XVECLEN (x, i) != XVECLEN (y, i)) | |
666 | return 0; | |
667 | ||
668 | /* And the corresponding elements must match. */ | |
669 | for (j = 0; j < XVECLEN (x, i); j++) | |
670 | if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0) | |
671 | return 0; | |
672 | break; | |
673 | ||
674 | case 'e': | |
675 | if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0) | |
676 | return 0; | |
677 | break; | |
678 | ||
679 | case 'S': | |
680 | case 's': | |
681 | if (strcmp (XSTR (x, i), XSTR (y, i))) | |
682 | return 0; | |
683 | break; | |
684 | ||
685 | case 'u': | |
686 | /* These are just backpointers, so they don't matter. */ | |
687 | break; | |
688 | ||
689 | case '0': | |
690 | case 't': | |
691 | break; | |
692 | ||
693 | /* It is believed that rtx's at this level will never | |
694 | contain anything but integers and other rtx's, | |
695 | except for within LABEL_REFs and SYMBOL_REFs. */ | |
696 | default: | |
697 | abort (); | |
698 | } | |
699 | } | |
700 | return 1; | |
701 | } | |
702 | \f | |
6f29feb1 JW |
703 | /* Subroutines of read_rtx. */ |
704 | ||
bcdaba58 RH |
705 | /* The current line number for the file. */ |
706 | int read_rtx_lineno = 1; | |
707 | ||
708 | /* The filename for aborting with file and line. */ | |
709 | const char *read_rtx_filename = "<unknown>"; | |
6f29feb1 JW |
710 | |
711 | static void | |
cdadb1dd | 712 | fatal_with_file_and_line VPARAMS ((FILE *infile, const char *msg, ...)) |
6f29feb1 | 713 | { |
bcdaba58 RH |
714 | #ifndef ANSI_PROTOTYPES |
715 | FILE *infile; | |
716 | const char *msg; | |
717 | #endif | |
718 | va_list ap; | |
719 | char context[64]; | |
720 | size_t i; | |
721 | int c; | |
722 | ||
723 | VA_START (ap, msg); | |
724 | ||
725 | #ifndef ANSI_PROTOTYPES | |
726 | infile = va_arg (ap, FILE *); | |
727 | msg = va_arg (ap, const char *); | |
728 | #endif | |
729 | ||
730 | fprintf (stderr, "%s:%d: ", read_rtx_filename, read_rtx_lineno); | |
731 | vfprintf (stderr, msg, ap); | |
732 | putc ('\n', stderr); | |
733 | ||
734 | /* Gather some following context. */ | |
735 | for (i = 0; i < sizeof(context)-1; ++i) | |
6f29feb1 JW |
736 | { |
737 | c = getc (infile); | |
bcdaba58 RH |
738 | if (c == EOF) |
739 | break; | |
740 | if (c == '\r' || c == '\n') | |
741 | break; | |
742 | context[i] = c; | |
6f29feb1 | 743 | } |
bcdaba58 RH |
744 | context[i] = '\0'; |
745 | ||
746 | fprintf (stderr, "%s:%d: following context is `%s'\n", | |
747 | read_rtx_filename, read_rtx_lineno, context); | |
748 | ||
749 | va_end (ap); | |
750 | exit (1); | |
751 | } | |
752 | ||
753 | /* Dump code after printing a message. Used when read_rtx finds | |
754 | invalid data. */ | |
755 | ||
756 | static void | |
757 | fatal_expected_char (infile, expected_c, actual_c) | |
758 | FILE *infile; | |
759 | int expected_c, actual_c; | |
760 | { | |
761 | fatal_with_file_and_line (infile, "expected character `%c', found `%c'", | |
762 | expected_c, actual_c); | |
6f29feb1 JW |
763 | } |
764 | ||
765 | /* Read chars from INFILE until a non-whitespace char | |
766 | and return that. Comments, both Lisp style and C style, | |
767 | are treated as whitespace. | |
768 | Tools such as genflags use this function. */ | |
769 | ||
770 | int | |
771 | read_skip_spaces (infile) | |
772 | FILE *infile; | |
773 | { | |
774 | register int c; | |
bcdaba58 | 775 | while (1) |
6f29feb1 | 776 | { |
bcdaba58 RH |
777 | c = getc (infile); |
778 | switch (c) | |
6f29feb1 | 779 | { |
bcdaba58 RH |
780 | case '\n': |
781 | read_rtx_lineno++; | |
782 | break; | |
783 | ||
784 | case ' ': case '\t': case '\f': case '\r': | |
785 | break; | |
786 | ||
787 | case ';': | |
f590cca1 | 788 | do |
bcdaba58 RH |
789 | c = getc (infile); |
790 | while (c != '\n' && c != EOF); | |
791 | read_rtx_lineno++; | |
792 | break; | |
793 | ||
794 | case '/': | |
795 | { | |
796 | register int prevc; | |
797 | c = getc (infile); | |
798 | if (c != '*') | |
799 | fatal_expected_char (infile, '*', c); | |
f590cca1 | 800 | |
bcdaba58 RH |
801 | prevc = 0; |
802 | while ((c = getc (infile)) && c != EOF) | |
803 | { | |
804 | if (c == '\n') | |
805 | read_rtx_lineno++; | |
806 | else if (prevc == '*' && c == '/') | |
807 | break; | |
808 | prevc = c; | |
809 | } | |
810 | } | |
811 | break; | |
812 | ||
813 | default: | |
814 | return c; | |
6f29feb1 | 815 | } |
6f29feb1 | 816 | } |
6f29feb1 JW |
817 | } |
818 | ||
819 | /* Read an rtx code name into the buffer STR[]. | |
820 | It is terminated by any of the punctuation chars of rtx printed syntax. */ | |
821 | ||
822 | static void | |
823 | read_name (str, infile) | |
824 | char *str; | |
825 | FILE *infile; | |
826 | { | |
827 | register char *p; | |
828 | register int c; | |
829 | ||
830 | c = read_skip_spaces(infile); | |
831 | ||
832 | p = str; | |
833 | while (1) | |
834 | { | |
835 | if (c == ' ' || c == '\n' || c == '\t' || c == '\f') | |
836 | break; | |
837 | if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/' | |
838 | || c == '(' || c == '[') | |
839 | { | |
840 | ungetc (c, infile); | |
841 | break; | |
842 | } | |
843 | *p++ = c; | |
844 | c = getc (infile); | |
845 | } | |
846 | if (p == str) | |
bcdaba58 RH |
847 | fatal_with_file_and_line (infile, "missing name or number"); |
848 | if (c == '\n') | |
849 | read_rtx_lineno++; | |
6f29feb1 JW |
850 | |
851 | *p = 0; | |
852 | } | |
853 | \f | |
cbe36725 RH |
854 | /* Provide a version of a function to read a long long if the system does |
855 | not provide one. */ | |
856 | #if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ) | |
857 | HOST_WIDE_INT | |
858 | atoll(p) | |
859 | const char *p; | |
860 | { | |
861 | int neg = 0; | |
862 | HOST_WIDE_INT tmp_wide; | |
863 | ||
e9a780ec | 864 | while (ISSPACE(*p)) |
cbe36725 RH |
865 | p++; |
866 | if (*p == '-') | |
867 | neg = 1, p++; | |
868 | else if (*p == '+') | |
869 | p++; | |
870 | ||
871 | tmp_wide = 0; | |
e9a780ec | 872 | while (ISDIGIT(*p)) |
cbe36725 RH |
873 | { |
874 | HOST_WIDE_INT new_wide = tmp_wide*10 + (*p - '0'); | |
875 | if (new_wide < tmp_wide) | |
876 | { | |
877 | /* Return INT_MAX equiv on overflow. */ | |
878 | tmp_wide = (~(unsigned HOST_WIDE_INT)0) >> 1; | |
879 | break; | |
880 | } | |
881 | tmp_wide = new_wide; | |
882 | p++; | |
883 | } | |
884 | ||
885 | if (neg) | |
886 | tmp_wide = -tmp_wide; | |
887 | return tmp_wide; | |
888 | } | |
889 | #endif | |
890 | ||
6f29feb1 JW |
891 | /* Read an rtx in printed representation from INFILE |
892 | and return an actual rtx in core constructed accordingly. | |
893 | read_rtx is not used in the compiler proper, but rather in | |
894 | the utilities gen*.c that construct C code from machine descriptions. */ | |
895 | ||
896 | rtx | |
897 | read_rtx (infile) | |
898 | FILE *infile; | |
899 | { | |
900 | register int i, j, list_counter; | |
901 | RTX_CODE tmp_code; | |
6f7d635c | 902 | register const char *format_ptr; |
6f29feb1 JW |
903 | /* tmp_char is a buffer used for reading decimal integers |
904 | and names of rtx types and machine modes. | |
905 | Therefore, 256 must be enough. */ | |
906 | char tmp_char[256]; | |
907 | rtx return_rtx; | |
908 | register int c; | |
909 | int tmp_int; | |
c166a311 | 910 | HOST_WIDE_INT tmp_wide; |
6f29feb1 JW |
911 | |
912 | /* Linked list structure for making RTXs: */ | |
913 | struct rtx_list | |
914 | { | |
915 | struct rtx_list *next; | |
bcdaba58 | 916 | rtx value; /* Value of this node. */ |
6f29feb1 JW |
917 | }; |
918 | ||
919 | c = read_skip_spaces (infile); /* Should be open paren. */ | |
920 | if (c != '(') | |
bcdaba58 | 921 | fatal_expected_char (infile, '(', c); |
6f29feb1 JW |
922 | |
923 | read_name (tmp_char, infile); | |
924 | ||
925 | tmp_code = UNKNOWN; | |
926 | ||
14a774a9 RK |
927 | for (i = 0; i < NUM_RTX_CODE; i++) |
928 | if (! strcmp (tmp_char, GET_RTX_NAME (i))) | |
929 | { | |
930 | tmp_code = (RTX_CODE) i; /* get value for name */ | |
931 | break; | |
932 | } | |
933 | ||
6f29feb1 | 934 | if (tmp_code == UNKNOWN) |
49886fe1 | 935 | fatal_with_file_and_line (infile, "unknown rtx code `%s'", tmp_char); |
14a774a9 | 936 | |
6f29feb1 JW |
937 | /* (NIL) stands for an expression that isn't there. */ |
938 | if (tmp_code == NIL) | |
939 | { | |
940 | /* Discard the closeparen. */ | |
14a774a9 RK |
941 | while ((c = getc (infile)) && c != ')') |
942 | ; | |
943 | ||
6f29feb1 JW |
944 | return 0; |
945 | } | |
946 | ||
14a774a9 RK |
947 | /* If we end up with an insn expression then we free this space below. */ |
948 | return_rtx = rtx_alloc (tmp_code); | |
6f29feb1 JW |
949 | format_ptr = GET_RTX_FORMAT (GET_CODE (return_rtx)); |
950 | ||
951 | /* If what follows is `: mode ', read it and | |
952 | store the mode in the rtx. */ | |
953 | ||
954 | i = read_skip_spaces (infile); | |
955 | if (i == ':') | |
956 | { | |
6f29feb1 | 957 | read_name (tmp_char, infile); |
14a774a9 RK |
958 | for (j = 0; j < NUM_MACHINE_MODES; j++) |
959 | if (! strcmp (GET_MODE_NAME (j), tmp_char)) | |
6f29feb1 JW |
960 | break; |
961 | ||
14a774a9 | 962 | if (j == MAX_MACHINE_MODE) |
49886fe1 | 963 | fatal_with_file_and_line (infile, "unknown mode `%s'", tmp_char); |
14a774a9 RK |
964 | |
965 | PUT_MODE (return_rtx, (enum machine_mode) j); | |
6f29feb1 JW |
966 | } |
967 | else | |
968 | ungetc (i, infile); | |
969 | ||
970 | for (i = 0; i < GET_RTX_LENGTH (GET_CODE (return_rtx)); i++) | |
971 | switch (*format_ptr++) | |
972 | { | |
973 | /* 0 means a field for internal use only. | |
974 | Don't expect it to be present in the input. */ | |
975 | case '0': | |
976 | break; | |
977 | ||
978 | case 'e': | |
979 | case 'u': | |
980 | XEXP (return_rtx, i) = read_rtx (infile); | |
981 | break; | |
982 | ||
983 | case 'V': | |
984 | /* 'V' is an optional vector: if a closeparen follows, | |
985 | just store NULL for this element. */ | |
986 | c = read_skip_spaces (infile); | |
987 | ungetc (c, infile); | |
988 | if (c == ')') | |
989 | { | |
990 | XVEC (return_rtx, i) = 0; | |
991 | break; | |
992 | } | |
993 | /* Now process the vector. */ | |
f590cca1 | 994 | |
6f29feb1 JW |
995 | case 'E': |
996 | { | |
997 | register struct rtx_list *next_rtx, *rtx_list_link; | |
4399e7a3 | 998 | struct rtx_list *list_rtx = NULL; |
6f29feb1 JW |
999 | |
1000 | c = read_skip_spaces (infile); | |
1001 | if (c != '[') | |
bcdaba58 | 1002 | fatal_expected_char (infile, '[', c); |
6f29feb1 JW |
1003 | |
1004 | /* add expressions to a list, while keeping a count */ | |
1005 | next_rtx = NULL; | |
1006 | list_counter = 0; | |
1007 | while ((c = read_skip_spaces (infile)) && c != ']') | |
1008 | { | |
1009 | ungetc (c, infile); | |
1010 | list_counter++; | |
1011 | rtx_list_link = (struct rtx_list *) | |
1012 | alloca (sizeof (struct rtx_list)); | |
1013 | rtx_list_link->value = read_rtx (infile); | |
1014 | if (next_rtx == 0) | |
1015 | list_rtx = rtx_list_link; | |
1016 | else | |
1017 | next_rtx->next = rtx_list_link; | |
1018 | next_rtx = rtx_list_link; | |
1019 | rtx_list_link->next = 0; | |
1020 | } | |
1021 | /* get vector length and allocate it */ | |
1022 | XVEC (return_rtx, i) = (list_counter | |
c166a311 | 1023 | ? rtvec_alloc (list_counter) : NULL_RTVEC); |
6f29feb1 JW |
1024 | if (list_counter > 0) |
1025 | { | |
1026 | next_rtx = list_rtx; | |
1027 | for (j = 0; j < list_counter; j++, | |
1028 | next_rtx = next_rtx->next) | |
1029 | XVECEXP (return_rtx, i, j) = next_rtx->value; | |
1030 | } | |
1031 | /* close bracket gotten */ | |
1032 | } | |
1033 | break; | |
1034 | ||
1035 | case 'S': | |
1036 | /* 'S' is an optional string: if a closeparen follows, | |
1037 | just store NULL for this element. */ | |
1038 | c = read_skip_spaces (infile); | |
1039 | ungetc (c, infile); | |
1040 | if (c == ')') | |
1041 | { | |
1042 | XSTR (return_rtx, i) = 0; | |
1043 | break; | |
1044 | } | |
1045 | ||
1046 | case 's': | |
1047 | { | |
1048 | int saw_paren = 0; | |
1049 | register char *stringbuf; | |
6f29feb1 JW |
1050 | |
1051 | c = read_skip_spaces (infile); | |
1052 | if (c == '(') | |
1053 | { | |
1054 | saw_paren = 1; | |
1055 | c = read_skip_spaces (infile); | |
1056 | } | |
1057 | if (c != '"') | |
bcdaba58 | 1058 | fatal_expected_char (infile, '"', c); |
6f29feb1 JW |
1059 | |
1060 | while (1) | |
1061 | { | |
2dcb563f | 1062 | c = getc (infile); /* Read the string */ |
bcdaba58 RH |
1063 | if (c == '\n') |
1064 | read_rtx_lineno++; | |
2dcb563f | 1065 | if (c == '\\') |
6f29feb1 | 1066 | { |
2dcb563f | 1067 | c = getc (infile); /* Read the string */ |
6f29feb1 JW |
1068 | /* \; makes stuff for a C string constant containing |
1069 | newline and tab. */ | |
2dcb563f | 1070 | if (c == ';') |
81dd58a6 RS |
1071 | { |
1072 | obstack_grow (rtl_obstack, "\\n\\t", 4); | |
1073 | continue; | |
1074 | } | |
aece2740 RH |
1075 | if (c == '\n') |
1076 | read_rtx_lineno++; | |
6f29feb1 | 1077 | } |
2dcb563f | 1078 | else if (c == '"') |
6f29feb1 | 1079 | break; |
2dcb563f RS |
1080 | |
1081 | obstack_1grow (rtl_obstack, c); | |
6f29feb1 JW |
1082 | } |
1083 | ||
2dcb563f RS |
1084 | obstack_1grow (rtl_obstack, 0); |
1085 | stringbuf = (char *) obstack_finish (rtl_obstack); | |
6f29feb1 JW |
1086 | |
1087 | if (saw_paren) | |
1088 | { | |
1089 | c = read_skip_spaces (infile); | |
1090 | if (c != ')') | |
bcdaba58 | 1091 | fatal_expected_char (infile, ')', c); |
6f29feb1 JW |
1092 | } |
1093 | XSTR (return_rtx, i) = stringbuf; | |
1094 | } | |
1095 | break; | |
1096 | ||
c166a311 CH |
1097 | case 'w': |
1098 | read_name (tmp_char, infile); | |
1099 | #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
1100 | tmp_wide = atoi (tmp_char); | |
1101 | #else | |
76d31c63 | 1102 | #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG |
c166a311 | 1103 | tmp_wide = atol (tmp_char); |
76d31c63 | 1104 | #else |
f590cca1 | 1105 | /* Prefer atoll over atoq, since the former is in the ISO C9X draft. |
cbe36725 RH |
1106 | But prefer not to use our hand-rolled function above either. */ |
1107 | #if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ) | |
c5afbb49 JL |
1108 | tmp_wide = atoll (tmp_char); |
1109 | #else | |
76d31c63 JL |
1110 | tmp_wide = atoq (tmp_char); |
1111 | #endif | |
c5afbb49 | 1112 | #endif |
c166a311 CH |
1113 | #endif |
1114 | XWINT (return_rtx, i) = tmp_wide; | |
1115 | break; | |
1116 | ||
6f29feb1 JW |
1117 | case 'i': |
1118 | case 'n': | |
1119 | read_name (tmp_char, infile); | |
1120 | tmp_int = atoi (tmp_char); | |
1121 | XINT (return_rtx, i) = tmp_int; | |
1122 | break; | |
1123 | ||
1124 | default: | |
1125 | fprintf (stderr, | |
1126 | "switch format wrong in rtl.read_rtx(). format was: %c.\n", | |
1127 | format_ptr[-1]); | |
1128 | fprintf (stderr, "\tfile position: %ld\n", ftell (infile)); | |
1129 | abort (); | |
1130 | } | |
1131 | ||
1132 | c = read_skip_spaces (infile); | |
1133 | if (c != ')') | |
bcdaba58 | 1134 | fatal_expected_char (infile, ')', c); |
6f29feb1 JW |
1135 | |
1136 | return return_rtx; | |
1137 | } | |
987009bf | 1138 | |
f4524c9e | 1139 | #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) |
ef178af3 ZW |
1140 | void |
1141 | rtl_check_failed_bounds (r, n, file, line, func) | |
1142 | rtx r; | |
1143 | int n; | |
1144 | const char *file; | |
1145 | int line; | |
1146 | const char *func; | |
1147 | { | |
1148 | error ("RTL check: access of elt %d of `%s' with last elt %d", | |
1149 | n, GET_RTX_NAME (GET_CODE (r)), GET_RTX_LENGTH (GET_CODE (r))-1); | |
1150 | fancy_abort (file, line, func); | |
1151 | } | |
1152 | ||
1153 | void | |
1154 | rtl_check_failed_type1 (r, n, c1, file, line, func) | |
1155 | rtx r; | |
1156 | int n; | |
1157 | int c1; | |
1158 | const char *file; | |
1159 | int line; | |
1160 | const char *func; | |
1161 | { | |
1162 | error ("RTL check: expected elt %d type '%c', have '%c' (rtx %s)", | |
1163 | n, c1, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r))); | |
1164 | fancy_abort (file, line, func); | |
1165 | } | |
1166 | ||
1167 | void | |
1168 | rtl_check_failed_type2 (r, n, c1, c2, file, line, func) | |
1169 | rtx r; | |
1170 | int n; | |
1171 | int c1; | |
1172 | int c2; | |
1173 | const char *file; | |
1174 | int line; | |
1175 | const char *func; | |
1176 | { | |
1177 | error ("RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s)", | |
1178 | n, c1, c2, | |
1179 | GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE(r))); | |
1180 | fancy_abort (file, line, func); | |
1181 | } | |
1182 | ||
83ab3839 RH |
1183 | void |
1184 | rtl_check_failed_code1 (r, code, file, line, func) | |
1185 | rtx r; | |
1186 | enum rtx_code code; | |
1187 | const char *file; | |
1188 | int line; | |
1189 | const char *func; | |
1190 | { | |
1191 | error ("RTL check: expected code `%s', have `%s'", | |
1192 | GET_RTX_NAME (code), GET_RTX_NAME (GET_CODE (r))); | |
1193 | fancy_abort (file, line, func); | |
1194 | } | |
1195 | ||
1196 | void | |
1197 | rtl_check_failed_code2 (r, code1, code2, file, line, func) | |
1198 | rtx r; | |
1199 | enum rtx_code code1, code2; | |
1200 | const char *file; | |
1201 | int line; | |
1202 | const char *func; | |
1203 | { | |
1204 | error ("RTL check: expected code `%s' or `%s', have `%s'", | |
1205 | GET_RTX_NAME (code1), GET_RTX_NAME (code2), | |
1206 | GET_RTX_NAME (GET_CODE (r))); | |
1207 | fancy_abort (file, line, func); | |
1208 | } | |
1209 | ||
ef178af3 ZW |
1210 | /* XXX Maybe print the vector? */ |
1211 | void | |
1212 | rtvec_check_failed_bounds (r, n, file, line, func) | |
1213 | rtvec r; | |
1214 | int n; | |
1215 | const char *file; | |
1216 | int line; | |
1217 | const char *func; | |
1218 | { | |
1219 | error ("RTL check: access of elt %d of vector with last elt %d", | |
1220 | n, GET_NUM_ELEM (r)-1); | |
1221 | fancy_abort (file, line, func); | |
1222 | } | |
f4524c9e | 1223 | #endif /* ENABLE_RTL_CHECKING */ |
ef178af3 | 1224 | |
987009bf ZW |
1225 | /* These are utility functions used by fatal-error functions all over the |
1226 | code. rtl.c happens to be linked by all the programs that need them, | |
1227 | so these are here. In the future we want to break out all error handling | |
1228 | to its own module. */ | |
1229 | ||
1230 | /* Given a partial pathname as input, return another pathname that | |
1231 | shares no directory elements with the pathname of __FILE__. This | |
1232 | is used by fancy_abort() to print `Internal compiler error in expr.c' | |
1233 | instead of `Internal compiler error in ../../egcs/gcc/expr.c'. */ | |
1234 | static const char * | |
1235 | trim_filename (name) | |
1236 | const char *name; | |
1237 | { | |
aa0b4465 | 1238 | static const char this_file[] = __FILE__; |
987009bf ZW |
1239 | const char *p = name, *q = this_file; |
1240 | ||
1241 | while (*p == *q && *p != 0 && *q != 0) p++, q++; | |
1242 | while (p > name && p[-1] != DIR_SEPARATOR | |
1243 | #ifdef DIR_SEPARATOR_2 | |
1244 | && p[-1] != DIR_SEPARATOR_2 | |
1245 | #endif | |
1246 | ) | |
1247 | p--; | |
1248 | ||
1249 | return p; | |
1250 | } | |
1251 | ||
1252 | /* Report an internal compiler error in a friendly manner and without | |
ef178af3 | 1253 | dumping core. */ |
987009bf | 1254 | |
987009bf ZW |
1255 | void |
1256 | fancy_abort (file, line, function) | |
1257 | const char *file; | |
1258 | int line; | |
1259 | const char *function; | |
1260 | { | |
1261 | if (function == NULL) | |
1262 | function = "?"; | |
1263 | fatal ( | |
1264 | "Internal compiler error in `%s', at %s:%d\n\ | |
1265 | Please submit a full bug report.\n\ | |
8b97e23b ML |
1266 | See %s for instructions.", |
1267 | function, trim_filename (file), line, GCCBUGURL); | |
987009bf | 1268 | } |