]> gcc.gnu.org Git - gcc.git/blob - gcc/rtl.c
cse.c (dump_class): New function.
[gcc.git] / gcc / rtl.c
1 /* Allocate and read RTL for GNU C Compiler.
2 Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21
22 #include "config.h"
23 #include "system.h"
24 #include "rtl.h"
25 #include "real.h"
26 #include "bitmap.h"
27
28 #include "obstack.h"
29 #define obstack_chunk_alloc xmalloc
30 #define obstack_chunk_free free
31
32 /* Obstack used for allocating RTL objects.
33 Between functions, this is the permanent_obstack.
34 While parsing and expanding a function, this is maybepermanent_obstack
35 so we can save it if it is an inline function.
36 During optimization and output, this is function_obstack. */
37
38 extern struct obstack *rtl_obstack;
39 \f
40 /* Indexed by rtx code, gives number of operands for an rtx with that code.
41 Does NOT include rtx header data (code and links).
42 This array is initialized in init_rtl. */
43
44 int rtx_length[NUM_RTX_CODE + 1];
45
46 /* Indexed by rtx code, gives the name of that kind of rtx, as a C string. */
47
48 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) NAME ,
49
50 char *rtx_name[] = {
51 #include "rtl.def" /* rtl expressions are documented here */
52 };
53
54 #undef DEF_RTL_EXPR
55
56 /* Indexed by machine mode, gives the name of that machine mode.
57 This name does not include the letters "mode". */
58
59 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) NAME,
60
61 char *mode_name[(int) MAX_MACHINE_MODE + 1] = {
62 #include "machmode.def"
63
64 #ifdef EXTRA_CC_MODES
65 EXTRA_CC_NAMES,
66 #endif
67 /* Add an extra field to avoid a core dump if someone tries to convert
68 MAX_MACHINE_MODE to a string. */
69 ""
70 };
71
72 #undef DEF_MACHMODE
73
74 /* Indexed by machine mode, gives the length of the mode, in bytes.
75 GET_MODE_CLASS uses this. */
76
77 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) CLASS,
78
79 enum mode_class mode_class[(int) MAX_MACHINE_MODE] = {
80 #include "machmode.def"
81 };
82
83 #undef DEF_MACHMODE
84
85 /* Indexed by machine mode, gives the length of the mode, in bytes.
86 GET_MODE_SIZE uses this. */
87
88 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) SIZE,
89
90 int mode_size[(int) MAX_MACHINE_MODE] = {
91 #include "machmode.def"
92 };
93
94 #undef DEF_MACHMODE
95
96 /* Indexed by machine mode, gives the length of the mode's subunit.
97 GET_MODE_UNIT_SIZE uses this. */
98
99 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) UNIT,
100
101 int mode_unit_size[(int) MAX_MACHINE_MODE] = {
102 #include "machmode.def" /* machine modes are documented here */
103 };
104
105 #undef DEF_MACHMODE
106
107 /* Indexed by machine mode, gives next wider natural mode
108 (QI -> HI -> SI -> DI, etc.) Widening multiply instructions
109 use this. */
110
111 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) \
112 (unsigned char) WIDER,
113
114 unsigned char mode_wider_mode[(int) MAX_MACHINE_MODE] = {
115 #include "machmode.def" /* machine modes are documented here */
116 };
117
118 #undef DEF_MACHMODE
119
120 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) \
121 ((SIZE) * BITS_PER_UNIT >= HOST_BITS_PER_WIDE_INT) ? ~(unsigned HOST_WIDE_INT)0 : ((unsigned HOST_WIDE_INT) 1 << (SIZE) * BITS_PER_UNIT) - 1,
122
123 /* Indexed by machine mode, gives mask of significant bits in mode. */
124
125 unsigned HOST_WIDE_INT mode_mask_array[(int) MAX_MACHINE_MODE] = {
126 #include "machmode.def"
127 };
128
129 /* Indexed by mode class, gives the narrowest mode for each class. */
130
131 enum machine_mode class_narrowest_mode[(int) MAX_MODE_CLASS];
132
133 /* Indexed by rtx code, gives a sequence of operand-types for
134 rtx's of that code. The sequence is a C string in which
135 each character describes one operand. */
136
137 char *rtx_format[] = {
138 /* "*" undefined.
139 can cause a warning message
140 "0" field is unused (or used in a phase-dependent manner)
141 prints nothing
142 "i" an integer
143 prints the integer
144 "n" like "i", but prints entries from `note_insn_name'
145 "w" an integer of width HOST_BITS_PER_WIDE_INT
146 prints the integer
147 "s" a pointer to a string
148 prints the string
149 "S" like "s", but optional:
150 the containing rtx may end before this operand
151 "e" a pointer to an rtl expression
152 prints the expression
153 "E" a pointer to a vector that points to a number of rtl expressions
154 prints a list of the rtl expressions
155 "V" like "E", but optional:
156 the containing rtx may end before this operand
157 "u" a pointer to another insn
158 prints the uid of the insn.
159 "b" is a pointer to a bitmap header.
160 "t" is a tree pointer. */
161
162 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) FORMAT ,
163 #include "rtl.def" /* rtl expressions are defined here */
164 #undef DEF_RTL_EXPR
165 };
166
167 /* Indexed by rtx code, gives a character representing the "class" of
168 that rtx code. See rtl.def for documentation on the defined classes. */
169
170 char rtx_class[] = {
171 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS,
172 #include "rtl.def" /* rtl expressions are defined here */
173 #undef DEF_RTL_EXPR
174 };
175
176 /* Names for kinds of NOTEs and REG_NOTEs. */
177
178 char *note_insn_name[] = { 0 , "NOTE_INSN_DELETED",
179 "NOTE_INSN_BLOCK_BEG", "NOTE_INSN_BLOCK_END",
180 "NOTE_INSN_LOOP_BEG", "NOTE_INSN_LOOP_END",
181 "NOTE_INSN_FUNCTION_END", "NOTE_INSN_SETJMP",
182 "NOTE_INSN_LOOP_CONT", "NOTE_INSN_LOOP_VTOP",
183 "NOTE_INSN_PROLOGUE_END", "NOTE_INSN_EPILOGUE_BEG",
184 "NOTE_INSN_DELETED_LABEL", "NOTE_INSN_FUNCTION_BEG",
185 "NOTE_INSN_EH_REGION_BEG", "NOTE_INSN_EH_REGION_END",
186 "NOTE_REPEATED_LINE_NUMBER", "NOTE_INSN_RANGE_START",
187 "NOTE_INSN_RANGE_END", "NOTE_INSN_LIVE" };
188
189 char *reg_note_name[] = { "", "REG_DEAD", "REG_INC", "REG_EQUIV", "REG_WAS_0",
190 "REG_EQUAL", "REG_RETVAL", "REG_LIBCALL",
191 "REG_NONNEG", "REG_NO_CONFLICT", "REG_UNUSED",
192 "REG_CC_SETTER", "REG_CC_USER", "REG_LABEL",
193 "REG_DEP_ANTI", "REG_DEP_OUTPUT", "REG_BR_PROB",
194 "REG_EXEC_COUNT", "REG_NOALIAS", "REG_SAVE_AREA",
195 "REG_BR_PRED", "REG_EH_CONTEXT",
196 "REG_FRAME_RELATED_EXPR", "REG_EH_REGION",
197 "REG_EH_RETHROW" };
198
199 static void dump_and_abort PROTO((int, int, FILE *)) ATTRIBUTE_NORETURN;
200 static void read_name PROTO((char *, FILE *));
201 \f
202 /* Allocate an rtx vector of N elements.
203 Store the length, and initialize all elements to zero. */
204
205 rtvec
206 rtvec_alloc (n)
207 int n;
208 {
209 rtvec rt;
210 int i;
211
212 rt = (rtvec) obstack_alloc (rtl_obstack,
213 sizeof (struct rtvec_def)
214 + (( n - 1) * sizeof (rtunion)));
215
216 /* clear out the vector */
217 PUT_NUM_ELEM (rt, n);
218
219 for (i = 0; i < n; i++)
220 rt->elem[i].rtwint = 0;
221
222 return rt;
223 }
224
225 /* Allocate an rtx of code CODE. The CODE is stored in the rtx;
226 all the rest is initialized to zero. */
227
228 rtx
229 rtx_alloc (code)
230 RTX_CODE code;
231 {
232 rtx rt;
233 register struct obstack *ob = rtl_obstack;
234 register int nelts = GET_RTX_LENGTH (code);
235 register int length = sizeof (struct rtx_def)
236 + (nelts - 1) * sizeof (rtunion);
237
238 /* This function is called more than any other in GCC,
239 so we manipulate the obstack directly.
240
241 Even though rtx objects are word aligned, we may be sharing an obstack
242 with tree nodes, which may have to be double-word aligned. So align
243 our length to the alignment mask in the obstack. */
244
245 length = (length + ob->alignment_mask) & ~ ob->alignment_mask;
246
247 if (ob->chunk_limit - ob->next_free < length)
248 _obstack_newchunk (ob, length);
249 rt = (rtx)ob->object_base;
250 ob->next_free += length;
251 ob->object_base = ob->next_free;
252
253 /* We want to clear everything up to the FLD array. Normally, this is
254 one int, but we don't want to assume that and it isn't very portable
255 anyway; this is. */
256
257 memset (rt, 0, sizeof (struct rtx_def) - sizeof (rtunion));
258
259 PUT_CODE (rt, code);
260
261 return rt;
262 }
263
264 /* Free the rtx X and all RTL allocated since X. */
265
266 void
267 rtx_free (x)
268 rtx x;
269 {
270 obstack_free (rtl_obstack, x);
271 }
272 \f
273 /* Create a new copy of an rtx.
274 Recursively copies the operands of the rtx,
275 except for those few rtx codes that are sharable. */
276
277 rtx
278 copy_rtx (orig)
279 register rtx orig;
280 {
281 register rtx copy;
282 register int i, j;
283 register RTX_CODE code;
284 register char *format_ptr;
285
286 code = GET_CODE (orig);
287
288 switch (code)
289 {
290 case REG:
291 case QUEUED:
292 case CONST_INT:
293 case CONST_DOUBLE:
294 case SYMBOL_REF:
295 case CODE_LABEL:
296 case PC:
297 case CC0:
298 case SCRATCH:
299 /* SCRATCH must be shared because they represent distinct values. */
300 case ADDRESSOF:
301 return orig;
302
303 case CONST:
304 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
305 a LABEL_REF, it isn't sharable. */
306 if (GET_CODE (XEXP (orig, 0)) == PLUS
307 && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
308 && GET_CODE (XEXP (XEXP (orig, 0), 1)) == CONST_INT)
309 return orig;
310 break;
311
312 /* A MEM with a constant address is not sharable. The problem is that
313 the constant address may need to be reloaded. If the mem is shared,
314 then reloading one copy of this mem will cause all copies to appear
315 to have been reloaded. */
316
317 default:
318 break;
319 }
320
321 copy = rtx_alloc (code);
322
323 /* Copy the various flags, and other information. We assume that
324 all fields need copying, and then clear the fields that should
325 not be copied. That is the sensible default behavior, and forces
326 us to explicitly document why we are *not* copying a flag. */
327 bcopy (orig, copy, sizeof (struct rtx_def) - sizeof (rtunion));
328
329 /* We do not copy the USED flag, which is used as a mark bit during
330 walks over the RTL. */
331 copy->used = 0;
332
333 /* We do not copy JUMP, CALL, or FRAME_RELATED for INSNs. */
334 if (GET_RTX_CLASS (code) == 'i')
335 {
336 copy->jump = 0;
337 copy->call = 0;
338 copy->frame_related = 0;
339 }
340
341 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
342
343 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
344 {
345 switch (*format_ptr++)
346 {
347 case 'e':
348 XEXP (copy, i) = XEXP (orig, i);
349 if (XEXP (orig, i) != NULL)
350 XEXP (copy, i) = copy_rtx (XEXP (orig, i));
351 break;
352
353 case '0':
354 case 'u':
355 XEXP (copy, i) = XEXP (orig, i);
356 break;
357
358 case 'E':
359 case 'V':
360 XVEC (copy, i) = XVEC (orig, i);
361 if (XVEC (orig, i) != NULL)
362 {
363 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
364 for (j = 0; j < XVECLEN (copy, i); j++)
365 XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
366 }
367 break;
368
369 case 'b':
370 {
371 bitmap new_bits = BITMAP_OBSTACK_ALLOC (rtl_obstack);
372 bitmap_copy (new_bits, XBITMAP (orig, i));
373 XBITMAP (copy, i) = new_bits;
374 break;
375 }
376
377 case 't':
378 XTREE (copy, i) = XTREE (orig, i);
379 break;
380
381 case 'w':
382 XWINT (copy, i) = XWINT (orig, i);
383 break;
384
385 case 'i':
386 XINT (copy, i) = XINT (orig, i);
387 break;
388
389 case 's':
390 case 'S':
391 XSTR (copy, i) = XSTR (orig, i);
392 break;
393
394 default:
395 abort ();
396 }
397 }
398 return copy;
399 }
400
401 /* Similar to `copy_rtx' except that if MAY_SHARE is present, it is
402 placed in the result directly, rather than being copied. */
403
404 rtx
405 copy_most_rtx (orig, may_share)
406 register rtx orig;
407 register rtx may_share;
408 {
409 register rtx copy;
410 register int i, j;
411 register RTX_CODE code;
412 register char *format_ptr;
413
414 if (orig == may_share)
415 return orig;
416
417 code = GET_CODE (orig);
418
419 switch (code)
420 {
421 case REG:
422 case QUEUED:
423 case CONST_INT:
424 case CONST_DOUBLE:
425 case SYMBOL_REF:
426 case CODE_LABEL:
427 case PC:
428 case CC0:
429 return orig;
430 default:
431 break;
432 }
433
434 copy = rtx_alloc (code);
435 PUT_MODE (copy, GET_MODE (orig));
436 copy->in_struct = orig->in_struct;
437 copy->volatil = orig->volatil;
438 copy->unchanging = orig->unchanging;
439 copy->integrated = orig->integrated;
440
441 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
442
443 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
444 {
445 switch (*format_ptr++)
446 {
447 case 'e':
448 XEXP (copy, i) = XEXP (orig, i);
449 if (XEXP (orig, i) != NULL && XEXP (orig, i) != may_share)
450 XEXP (copy, i) = copy_most_rtx (XEXP (orig, i), may_share);
451 break;
452
453 case '0':
454 case 'u':
455 XEXP (copy, i) = XEXP (orig, i);
456 break;
457
458 case 'E':
459 case 'V':
460 XVEC (copy, i) = XVEC (orig, i);
461 if (XVEC (orig, i) != NULL)
462 {
463 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
464 for (j = 0; j < XVECLEN (copy, i); j++)
465 XVECEXP (copy, i, j)
466 = copy_most_rtx (XVECEXP (orig, i, j), may_share);
467 }
468 break;
469
470 case 'w':
471 XWINT (copy, i) = XWINT (orig, i);
472 break;
473
474 case 'n':
475 case 'i':
476 XINT (copy, i) = XINT (orig, i);
477 break;
478
479 case 's':
480 case 'S':
481 XSTR (copy, i) = XSTR (orig, i);
482 break;
483
484 default:
485 abort ();
486 }
487 }
488 return copy;
489 }
490 \f
491 /* Subroutines of read_rtx. */
492
493 /* Dump code after printing a message. Used when read_rtx finds
494 invalid data. */
495
496 static void
497 dump_and_abort (expected_c, actual_c, infile)
498 int expected_c, actual_c;
499 FILE *infile;
500 {
501 int c, i;
502
503 if (expected_c >= 0)
504 fprintf (stderr,
505 "Expected character %c. Found character %c.",
506 expected_c, actual_c);
507 fprintf (stderr, " At file position: %ld\n", ftell (infile));
508 fprintf (stderr, "Following characters are:\n\t");
509 for (i = 0; i < 200; i++)
510 {
511 c = getc (infile);
512 if (EOF == c) break;
513 putc (c, stderr);
514 }
515 fprintf (stderr, "Aborting.\n");
516 abort ();
517 }
518
519 /* Read chars from INFILE until a non-whitespace char
520 and return that. Comments, both Lisp style and C style,
521 are treated as whitespace.
522 Tools such as genflags use this function. */
523
524 int
525 read_skip_spaces (infile)
526 FILE *infile;
527 {
528 register int c;
529 while ((c = getc (infile)))
530 {
531 if (c == ' ' || c == '\n' || c == '\t' || c == '\f')
532 ;
533 else if (c == ';')
534 {
535 while ((c = getc (infile)) && c != '\n' && c != EOF)
536 ;
537 }
538 else if (c == '/')
539 {
540 register int prevc;
541 c = getc (infile);
542 if (c != '*')
543 dump_and_abort ('*', c, infile);
544
545 prevc = 0;
546 while ((c = getc (infile)) && c != EOF)
547 {
548 if (prevc == '*' && c == '/')
549 break;
550 prevc = c;
551 }
552 }
553 else break;
554 }
555 return c;
556 }
557
558 /* Read an rtx code name into the buffer STR[].
559 It is terminated by any of the punctuation chars of rtx printed syntax. */
560
561 static void
562 read_name (str, infile)
563 char *str;
564 FILE *infile;
565 {
566 register char *p;
567 register int c;
568
569 c = read_skip_spaces(infile);
570
571 p = str;
572 while (1)
573 {
574 if (c == ' ' || c == '\n' || c == '\t' || c == '\f')
575 break;
576 if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
577 || c == '(' || c == '[')
578 {
579 ungetc (c, infile);
580 break;
581 }
582 *p++ = c;
583 c = getc (infile);
584 }
585 if (p == str)
586 {
587 fprintf (stderr, "missing name or number");
588 dump_and_abort (-1, -1, infile);
589 }
590
591 *p = 0;
592 }
593 \f
594 /* Provide a version of a function to read a long long if the system does
595 not provide one. */
596 #if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ)
597 HOST_WIDE_INT
598 atoll(p)
599 const char *p;
600 {
601 int neg = 0;
602 HOST_WIDE_INT tmp_wide;
603
604 while (ISSPACE(*p))
605 p++;
606 if (*p == '-')
607 neg = 1, p++;
608 else if (*p == '+')
609 p++;
610
611 tmp_wide = 0;
612 while (ISDIGIT(*p))
613 {
614 HOST_WIDE_INT new_wide = tmp_wide*10 + (*p - '0');
615 if (new_wide < tmp_wide)
616 {
617 /* Return INT_MAX equiv on overflow. */
618 tmp_wide = (~(unsigned HOST_WIDE_INT)0) >> 1;
619 break;
620 }
621 tmp_wide = new_wide;
622 p++;
623 }
624
625 if (neg)
626 tmp_wide = -tmp_wide;
627 return tmp_wide;
628 }
629 #endif
630
631 /* Read an rtx in printed representation from INFILE
632 and return an actual rtx in core constructed accordingly.
633 read_rtx is not used in the compiler proper, but rather in
634 the utilities gen*.c that construct C code from machine descriptions. */
635
636 rtx
637 read_rtx (infile)
638 FILE *infile;
639 {
640 register int i, j, list_counter;
641 RTX_CODE tmp_code;
642 register char *format_ptr;
643 /* tmp_char is a buffer used for reading decimal integers
644 and names of rtx types and machine modes.
645 Therefore, 256 must be enough. */
646 char tmp_char[256];
647 rtx return_rtx;
648 register int c;
649 int tmp_int;
650 HOST_WIDE_INT tmp_wide;
651
652 /* Linked list structure for making RTXs: */
653 struct rtx_list
654 {
655 struct rtx_list *next;
656 rtx value; /* Value of this node... */
657 };
658
659 c = read_skip_spaces (infile); /* Should be open paren. */
660 if (c != '(')
661 dump_and_abort ('(', c, infile);
662
663 read_name (tmp_char, infile);
664
665 tmp_code = UNKNOWN;
666
667 for (i=0; i < NUM_RTX_CODE; i++) /* @@ might speed this search up */
668 {
669 if (!(strcmp (tmp_char, GET_RTX_NAME (i))))
670 {
671 tmp_code = (RTX_CODE) i; /* get value for name */
672 break;
673 }
674 }
675 if (tmp_code == UNKNOWN)
676 {
677 fprintf (stderr,
678 "Unknown rtx read in rtl.read_rtx(). Code name was %s .",
679 tmp_char);
680 }
681 /* (NIL) stands for an expression that isn't there. */
682 if (tmp_code == NIL)
683 {
684 /* Discard the closeparen. */
685 while ((c = getc (infile)) && c != ')');
686 return 0;
687 }
688
689 return_rtx = rtx_alloc (tmp_code); /* if we end up with an insn expression
690 then we free this space below. */
691 format_ptr = GET_RTX_FORMAT (GET_CODE (return_rtx));
692
693 /* If what follows is `: mode ', read it and
694 store the mode in the rtx. */
695
696 i = read_skip_spaces (infile);
697 if (i == ':')
698 {
699 register int k;
700 read_name (tmp_char, infile);
701 for (k = 0; k < NUM_MACHINE_MODES; k++)
702 if (!strcmp (GET_MODE_NAME (k), tmp_char))
703 break;
704
705 PUT_MODE (return_rtx, (enum machine_mode) k );
706 }
707 else
708 ungetc (i, infile);
709
710 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (return_rtx)); i++)
711 switch (*format_ptr++)
712 {
713 /* 0 means a field for internal use only.
714 Don't expect it to be present in the input. */
715 case '0':
716 break;
717
718 case 'e':
719 case 'u':
720 XEXP (return_rtx, i) = read_rtx (infile);
721 break;
722
723 case 'V':
724 /* 'V' is an optional vector: if a closeparen follows,
725 just store NULL for this element. */
726 c = read_skip_spaces (infile);
727 ungetc (c, infile);
728 if (c == ')')
729 {
730 XVEC (return_rtx, i) = 0;
731 break;
732 }
733 /* Now process the vector. */
734
735 case 'E':
736 {
737 register struct rtx_list *next_rtx, *rtx_list_link;
738 struct rtx_list *list_rtx = NULL;
739
740 c = read_skip_spaces (infile);
741 if (c != '[')
742 dump_and_abort ('[', c, infile);
743
744 /* add expressions to a list, while keeping a count */
745 next_rtx = NULL;
746 list_counter = 0;
747 while ((c = read_skip_spaces (infile)) && c != ']')
748 {
749 ungetc (c, infile);
750 list_counter++;
751 rtx_list_link = (struct rtx_list *)
752 alloca (sizeof (struct rtx_list));
753 rtx_list_link->value = read_rtx (infile);
754 if (next_rtx == 0)
755 list_rtx = rtx_list_link;
756 else
757 next_rtx->next = rtx_list_link;
758 next_rtx = rtx_list_link;
759 rtx_list_link->next = 0;
760 }
761 /* get vector length and allocate it */
762 XVEC (return_rtx, i) = (list_counter
763 ? rtvec_alloc (list_counter) : NULL_RTVEC);
764 if (list_counter > 0)
765 {
766 next_rtx = list_rtx;
767 for (j = 0; j < list_counter; j++,
768 next_rtx = next_rtx->next)
769 XVECEXP (return_rtx, i, j) = next_rtx->value;
770 }
771 /* close bracket gotten */
772 }
773 break;
774
775 case 'S':
776 /* 'S' is an optional string: if a closeparen follows,
777 just store NULL for this element. */
778 c = read_skip_spaces (infile);
779 ungetc (c, infile);
780 if (c == ')')
781 {
782 XSTR (return_rtx, i) = 0;
783 break;
784 }
785
786 case 's':
787 {
788 int saw_paren = 0;
789 register char *stringbuf;
790
791 c = read_skip_spaces (infile);
792 if (c == '(')
793 {
794 saw_paren = 1;
795 c = read_skip_spaces (infile);
796 }
797 if (c != '"')
798 dump_and_abort ('"', c, infile);
799
800 while (1)
801 {
802 c = getc (infile); /* Read the string */
803 if (c == '\\')
804 {
805 c = getc (infile); /* Read the string */
806 /* \; makes stuff for a C string constant containing
807 newline and tab. */
808 if (c == ';')
809 {
810 obstack_grow (rtl_obstack, "\\n\\t", 4);
811 continue;
812 }
813 }
814 else if (c == '"')
815 break;
816
817 obstack_1grow (rtl_obstack, c);
818 }
819
820 obstack_1grow (rtl_obstack, 0);
821 stringbuf = (char *) obstack_finish (rtl_obstack);
822
823 if (saw_paren)
824 {
825 c = read_skip_spaces (infile);
826 if (c != ')')
827 dump_and_abort (')', c, infile);
828 }
829 XSTR (return_rtx, i) = stringbuf;
830 }
831 break;
832
833 case 'w':
834 read_name (tmp_char, infile);
835 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
836 tmp_wide = atoi (tmp_char);
837 #else
838 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
839 tmp_wide = atol (tmp_char);
840 #else
841 /* Prefer atoll over atoq, since the former is in the ISO C9X draft.
842 But prefer not to use our hand-rolled function above either. */
843 #if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ)
844 tmp_wide = atoll (tmp_char);
845 #else
846 tmp_wide = atoq (tmp_char);
847 #endif
848 #endif
849 #endif
850 XWINT (return_rtx, i) = tmp_wide;
851 break;
852
853 case 'i':
854 case 'n':
855 read_name (tmp_char, infile);
856 tmp_int = atoi (tmp_char);
857 XINT (return_rtx, i) = tmp_int;
858 break;
859
860 default:
861 fprintf (stderr,
862 "switch format wrong in rtl.read_rtx(). format was: %c.\n",
863 format_ptr[-1]);
864 fprintf (stderr, "\tfile position: %ld\n", ftell (infile));
865 abort ();
866 }
867
868 c = read_skip_spaces (infile);
869 if (c != ')')
870 dump_and_abort (')', c, infile);
871
872 return return_rtx;
873 }
874 \f
875 /* This is called once per compilation, before any rtx's are constructed.
876 It initializes the vector `rtx_length', the extra CC modes, if any,
877 and computes certain commonly-used modes. */
878
879 void
880 init_rtl ()
881 {
882 int min_class_size[(int) MAX_MODE_CLASS];
883 enum machine_mode mode;
884 int i;
885
886 for (i = 0; i < NUM_RTX_CODE; i++)
887 rtx_length[i] = strlen (rtx_format[i]);
888
889 /* Make CONST_DOUBLE bigger, if real values are bigger than
890 it normally expects to have room for.
891 Note that REAL_VALUE_TYPE is not defined by default,
892 since tree.h is not included. But the default dfn as `double'
893 would do no harm. */
894 #ifdef REAL_VALUE_TYPE
895 i = sizeof (REAL_VALUE_TYPE) / sizeof (rtunion) + 2;
896 if (rtx_length[(int) CONST_DOUBLE] < i)
897 {
898 char *s = (char *) xmalloc (i + 1);
899 rtx_length[(int) CONST_DOUBLE] = i;
900 rtx_format[(int) CONST_DOUBLE] = s;
901 *s++ = 'e';
902 *s++ = '0';
903 /* Set the GET_RTX_FORMAT of CONST_DOUBLE to a string
904 of as many `w's as we now have elements. Subtract two from
905 the size to account for the 'e' and the '0'. */
906 for (i = 2; i < rtx_length[(int) CONST_DOUBLE]; i++)
907 *s++ = 'w';
908 *s++ = 0;
909 }
910 #endif
911
912 #ifdef EXTRA_CC_MODES
913 for (i = (int) CCmode + 1; i < (int) MAX_MACHINE_MODE; i++)
914 {
915 mode_class[i] = MODE_CC;
916 mode_mask_array[i] = mode_mask_array[(int) CCmode];
917 mode_size[i] = mode_size[(int) CCmode];
918 mode_unit_size[i] = mode_unit_size[(int) CCmode];
919 mode_wider_mode[i - 1] = i;
920 mode_wider_mode[i] = (unsigned char)VOIDmode;
921 }
922 #endif
923
924 /* Find the narrowest mode for each class. */
925
926 for (i = 0; i < (int) MAX_MODE_CLASS; i++)
927 min_class_size[i] = 1000;
928
929 for (mode = VOIDmode; (int) mode < (int) MAX_MACHINE_MODE;
930 mode = (enum machine_mode) ((int) mode + 1))
931 {
932 if (GET_MODE_SIZE (mode) < min_class_size[(int) GET_MODE_CLASS (mode)])
933 {
934 class_narrowest_mode[(int) GET_MODE_CLASS (mode)] = mode;
935 min_class_size[(int) GET_MODE_CLASS (mode)] = GET_MODE_SIZE (mode);
936 }
937 }
938 }
This page took 0.072956 seconds and 5 git commands to generate.