OSDN Git Service

More copyright fixes. Oh what fun.
[pf3gnuchains/gcc-fork.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   length = (sizeof (struct rtx_def) - sizeof (rtunion) - 1) / sizeof (int);
258   for (; length >= 0; length--)
259     ((int *) rt)[length] = 0;
260
261   PUT_CODE (rt, code);
262
263   return rt;
264 }
265
266 /* Free the rtx X and all RTL allocated since X.  */
267
268 void
269 rtx_free (x)
270      rtx x;
271 {
272   obstack_free (rtl_obstack, x);
273 }
274 \f
275 /* Create a new copy of an rtx.
276    Recursively copies the operands of the rtx,
277    except for those few rtx codes that are sharable.  */
278
279 rtx
280 copy_rtx (orig)
281      register rtx orig;
282 {
283   register rtx copy;
284   register int i, j;
285   register RTX_CODE code;
286   register char *format_ptr;
287
288   code = GET_CODE (orig);
289
290   switch (code)
291     {
292     case REG:
293     case QUEUED:
294     case CONST_INT:
295     case CONST_DOUBLE:
296     case SYMBOL_REF:
297     case CODE_LABEL:
298     case PC:
299     case CC0:
300     case SCRATCH:
301       /* SCRATCH must be shared because they represent distinct values.  */
302     case ADDRESSOF:
303       return orig;
304
305     case CONST:
306       /* CONST can be shared if it contains a SYMBOL_REF.  If it contains
307          a LABEL_REF, it isn't sharable.  */
308       if (GET_CODE (XEXP (orig, 0)) == PLUS
309           && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
310           && GET_CODE (XEXP (XEXP (orig, 0), 1)) == CONST_INT)
311         return orig;
312       break;
313
314       /* A MEM with a constant address is not sharable.  The problem is that
315          the constant address may need to be reloaded.  If the mem is shared,
316          then reloading one copy of this mem will cause all copies to appear
317          to have been reloaded.  */
318
319     default:
320       break;
321     }
322
323   copy = rtx_alloc (code);
324   PUT_MODE (copy, GET_MODE (orig));
325   copy->in_struct = orig->in_struct;
326   copy->volatil = orig->volatil;
327   copy->unchanging = orig->unchanging;
328   copy->integrated = orig->integrated;
329   
330   format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
331
332   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
333     {
334       switch (*format_ptr++)
335         {
336         case 'e':
337           XEXP (copy, i) = XEXP (orig, i);
338           if (XEXP (orig, i) != NULL)
339             XEXP (copy, i) = copy_rtx (XEXP (orig, i));
340           break;
341
342         case '0':
343         case 'u':
344           XEXP (copy, i) = XEXP (orig, i);
345           break;
346
347         case 'E':
348         case 'V':
349           XVEC (copy, i) = XVEC (orig, i);
350           if (XVEC (orig, i) != NULL)
351             {
352               XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
353               for (j = 0; j < XVECLEN (copy, i); j++)
354                 XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
355             }
356           break;
357
358         case 'b':
359           {
360             bitmap new_bits = BITMAP_OBSTACK_ALLOC (rtl_obstack);
361             bitmap_copy (new_bits, XBITMAP (orig, i));
362             XBITMAP (copy, i) = new_bits;
363             break;
364           }
365
366         case 't':
367           XTREE (copy, i) = XTREE (orig, i);
368           break;
369
370         case 'w':
371           XWINT (copy, i) = XWINT (orig, i);
372           break;
373
374         case 'i':
375           XINT (copy, i) = XINT (orig, i);
376           break;
377
378         case 's':
379         case 'S':
380           XSTR (copy, i) = XSTR (orig, i);
381           break;
382
383         default:
384           abort ();
385         }
386     }
387   return copy;
388 }
389
390 /* Similar to `copy_rtx' except that if MAY_SHARE is present, it is
391    placed in the result directly, rather than being copied.  */
392
393 rtx
394 copy_most_rtx (orig, may_share)
395      register rtx orig;
396      register rtx may_share;
397 {
398   register rtx copy;
399   register int i, j;
400   register RTX_CODE code;
401   register char *format_ptr;
402
403   if (orig == may_share)
404     return orig;
405
406   code = GET_CODE (orig);
407
408   switch (code)
409     {
410     case REG:
411     case QUEUED:
412     case CONST_INT:
413     case CONST_DOUBLE:
414     case SYMBOL_REF:
415     case CODE_LABEL:
416     case PC:
417     case CC0:
418       return orig;
419     default:
420       break;
421     }
422
423   copy = rtx_alloc (code);
424   PUT_MODE (copy, GET_MODE (orig));
425   copy->in_struct = orig->in_struct;
426   copy->volatil = orig->volatil;
427   copy->unchanging = orig->unchanging;
428   copy->integrated = orig->integrated;
429   
430   format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
431
432   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
433     {
434       switch (*format_ptr++)
435         {
436         case 'e':
437           XEXP (copy, i) = XEXP (orig, i);
438           if (XEXP (orig, i) != NULL && XEXP (orig, i) != may_share)
439             XEXP (copy, i) = copy_most_rtx (XEXP (orig, i), may_share);
440           break;
441
442         case '0':
443         case 'u':
444           XEXP (copy, i) = XEXP (orig, i);
445           break;
446
447         case 'E':
448         case 'V':
449           XVEC (copy, i) = XVEC (orig, i);
450           if (XVEC (orig, i) != NULL)
451             {
452               XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
453               for (j = 0; j < XVECLEN (copy, i); j++)
454                 XVECEXP (copy, i, j)
455                   = copy_most_rtx (XVECEXP (orig, i, j), may_share);
456             }
457           break;
458
459         case 'w':
460           XWINT (copy, i) = XWINT (orig, i);
461           break;
462
463         case 'n':
464         case 'i':
465           XINT (copy, i) = XINT (orig, i);
466           break;
467
468         case 's':
469         case 'S':
470           XSTR (copy, i) = XSTR (orig, i);
471           break;
472
473         default:
474           abort ();
475         }
476     }
477   return copy;
478 }
479 \f
480 /* Subroutines of read_rtx.  */
481
482 /* Dump code after printing a message.  Used when read_rtx finds
483    invalid data.  */
484
485 static void
486 dump_and_abort (expected_c, actual_c, infile)
487      int expected_c, actual_c;
488      FILE *infile;
489 {
490   int c, i;
491
492   if (expected_c >= 0)
493     fprintf (stderr,
494              "Expected character %c.  Found character %c.",
495              expected_c, actual_c);
496   fprintf (stderr, "  At file position: %ld\n", ftell (infile));
497   fprintf (stderr, "Following characters are:\n\t");
498   for (i = 0; i < 200; i++)
499     {
500       c = getc (infile);
501       if (EOF == c) break;
502       putc (c, stderr);
503     }
504   fprintf (stderr, "Aborting.\n");
505   abort ();
506 }
507
508 /* Read chars from INFILE until a non-whitespace char
509    and return that.  Comments, both Lisp style and C style,
510    are treated as whitespace.
511    Tools such as genflags use this function.  */
512
513 int
514 read_skip_spaces (infile)
515      FILE *infile;
516 {
517   register int c;
518   while ((c = getc (infile)))
519     {
520       if (c == ' ' || c == '\n' || c == '\t' || c == '\f')
521         ;
522       else if (c == ';')
523         {
524           while ((c = getc (infile)) && c != '\n' && c != EOF)
525             ;
526         }
527       else if (c == '/')
528         {
529           register int prevc;
530           c = getc (infile);
531           if (c != '*')
532             dump_and_abort ('*', c, infile);
533           
534           prevc = 0;
535           while ((c = getc (infile)) && c != EOF)
536             {
537               if (prevc == '*' && c == '/')
538                 break;
539               prevc = c;
540             }
541         }
542       else break;
543     }
544   return c;
545 }
546
547 /* Read an rtx code name into the buffer STR[].
548    It is terminated by any of the punctuation chars of rtx printed syntax.  */
549
550 static void
551 read_name (str, infile)
552      char *str;
553      FILE *infile;
554 {
555   register char *p;
556   register int c;
557
558   c = read_skip_spaces(infile);
559
560   p = str;
561   while (1)
562     {
563       if (c == ' ' || c == '\n' || c == '\t' || c == '\f')
564         break;
565       if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
566           || c == '(' || c == '[')
567         {
568           ungetc (c, infile);
569           break;
570         }
571       *p++ = c;
572       c = getc (infile);
573     }
574   if (p == str)
575     {
576       fprintf (stderr, "missing name or number");
577       dump_and_abort (-1, -1, infile);
578     }
579
580   *p = 0;
581 }
582 \f
583 /* Provide a version of a function to read a long long if the system does
584    not provide one.  */
585 #if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ)
586 HOST_WIDE_INT
587 atoll(p)
588     const char *p;
589 {
590   int neg = 0;
591   HOST_WIDE_INT tmp_wide;
592
593   while (ISSPACE(*p))
594     p++;
595   if (*p == '-')
596     neg = 1, p++;
597   else if (*p == '+')
598     p++;
599
600   tmp_wide = 0;
601   while (ISDIGIT(*p))
602     {
603       HOST_WIDE_INT new_wide = tmp_wide*10 + (*p - '0');
604       if (new_wide < tmp_wide)
605         {
606           /* Return INT_MAX equiv on overflow.  */
607           tmp_wide = (~(unsigned HOST_WIDE_INT)0) >> 1;
608           break;
609         }
610       tmp_wide = new_wide;
611       p++;
612     }
613
614   if (neg)
615     tmp_wide = -tmp_wide;
616   return tmp_wide;
617 }
618 #endif
619
620 /* Read an rtx in printed representation from INFILE
621    and return an actual rtx in core constructed accordingly.
622    read_rtx is not used in the compiler proper, but rather in
623    the utilities gen*.c that construct C code from machine descriptions.  */
624
625 rtx
626 read_rtx (infile)
627      FILE *infile;
628 {
629   register int i, j, list_counter;
630   RTX_CODE tmp_code;
631   register char *format_ptr;
632   /* tmp_char is a buffer used for reading decimal integers
633      and names of rtx types and machine modes.
634      Therefore, 256 must be enough.  */
635   char tmp_char[256];
636   rtx return_rtx;
637   register int c;
638   int tmp_int;
639   HOST_WIDE_INT tmp_wide;
640
641   /* Linked list structure for making RTXs: */
642   struct rtx_list
643     {
644       struct rtx_list *next;
645       rtx value;                /* Value of this node...                */
646     };
647
648   c = read_skip_spaces (infile); /* Should be open paren.  */
649   if (c != '(')
650     dump_and_abort ('(', c, infile);
651
652   read_name (tmp_char, infile);
653
654   tmp_code = UNKNOWN;
655
656   for (i=0; i < NUM_RTX_CODE; i++) /* @@ might speed this search up */
657     {
658       if (!(strcmp (tmp_char, GET_RTX_NAME (i))))
659         {
660           tmp_code = (RTX_CODE) i;      /* get value for name */
661           break;
662         }
663     }
664   if (tmp_code == UNKNOWN)
665     {
666       fprintf (stderr,
667                "Unknown rtx read in rtl.read_rtx(). Code name was %s .",
668                tmp_char);
669     }
670   /* (NIL) stands for an expression that isn't there.  */
671   if (tmp_code == NIL)
672     {
673       /* Discard the closeparen.  */
674       while ((c = getc (infile)) && c != ')');
675       return 0;
676     }
677
678   return_rtx = rtx_alloc (tmp_code); /* if we end up with an insn expression
679                                        then we free this space below.  */
680   format_ptr = GET_RTX_FORMAT (GET_CODE (return_rtx));
681
682   /* If what follows is `: mode ', read it and
683      store the mode in the rtx.  */
684
685   i = read_skip_spaces (infile);
686   if (i == ':')
687     {
688       register int k;
689       read_name (tmp_char, infile);
690       for (k = 0; k < NUM_MACHINE_MODES; k++)
691         if (!strcmp (GET_MODE_NAME (k), tmp_char))
692           break;
693
694       PUT_MODE (return_rtx, (enum machine_mode) k );
695     }
696   else
697     ungetc (i, infile);
698
699   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (return_rtx)); i++)
700     switch (*format_ptr++)
701       {
702         /* 0 means a field for internal use only.
703            Don't expect it to be present in the input.  */
704       case '0':
705         break;
706
707       case 'e':
708       case 'u':
709         XEXP (return_rtx, i) = read_rtx (infile);
710         break;
711
712       case 'V':
713         /* 'V' is an optional vector: if a closeparen follows,
714            just store NULL for this element.  */
715         c = read_skip_spaces (infile);
716         ungetc (c, infile);
717         if (c == ')')
718           {
719             XVEC (return_rtx, i) = 0;
720             break;
721           }
722         /* Now process the vector.  */
723   
724       case 'E':
725         {
726           register struct rtx_list *next_rtx, *rtx_list_link;
727           struct rtx_list *list_rtx = NULL;
728
729           c = read_skip_spaces (infile);
730           if (c != '[')
731             dump_and_abort ('[', c, infile);
732
733           /* add expressions to a list, while keeping a count */
734           next_rtx = NULL;
735           list_counter = 0;
736           while ((c = read_skip_spaces (infile)) && c != ']')
737             {
738               ungetc (c, infile);
739               list_counter++;
740               rtx_list_link = (struct rtx_list *)
741                 alloca (sizeof (struct rtx_list));
742               rtx_list_link->value = read_rtx (infile);
743               if (next_rtx == 0)
744                 list_rtx = rtx_list_link;
745               else
746                 next_rtx->next = rtx_list_link;
747               next_rtx = rtx_list_link;
748               rtx_list_link->next = 0;
749             }
750           /* get vector length and allocate it */
751           XVEC (return_rtx, i) = (list_counter
752                                   ? rtvec_alloc (list_counter) : NULL_RTVEC);
753           if (list_counter > 0)
754             {
755               next_rtx = list_rtx;
756               for (j = 0; j < list_counter; j++,
757                    next_rtx = next_rtx->next)
758                 XVECEXP (return_rtx, i, j) = next_rtx->value;
759             }
760           /* close bracket gotten */
761         }
762         break;
763
764       case 'S':
765         /* 'S' is an optional string: if a closeparen follows,
766            just store NULL for this element.  */
767         c = read_skip_spaces (infile);
768         ungetc (c, infile);
769         if (c == ')')
770           {
771             XSTR (return_rtx, i) = 0;
772             break;
773           }
774
775       case 's':
776         {
777           int saw_paren = 0;
778           register char *stringbuf;
779
780           c = read_skip_spaces (infile);
781           if (c == '(')
782             {
783               saw_paren = 1;
784               c = read_skip_spaces (infile);
785             }
786           if (c != '"')
787             dump_and_abort ('"', c, infile);
788
789           while (1)
790             {
791               c = getc (infile); /* Read the string  */
792               if (c == '\\')
793                 {
794                   c = getc (infile);    /* Read the string  */
795                   /* \; makes stuff for a C string constant containing
796                      newline and tab.  */
797                   if (c == ';')
798                     {
799                       obstack_grow (rtl_obstack, "\\n\\t", 4);
800                       continue;
801                     }
802                 }
803               else if (c == '"')
804                 break;
805
806               obstack_1grow (rtl_obstack, c);
807             }
808
809           obstack_1grow (rtl_obstack, 0);
810           stringbuf = (char *) obstack_finish (rtl_obstack);
811
812           if (saw_paren)
813             {
814               c = read_skip_spaces (infile);
815               if (c != ')')
816                 dump_and_abort (')', c, infile);
817             }
818           XSTR (return_rtx, i) = stringbuf;
819         }
820         break;
821
822       case 'w':
823         read_name (tmp_char, infile);
824 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
825         tmp_wide = atoi (tmp_char);
826 #else
827 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
828         tmp_wide = atol (tmp_char);
829 #else
830         /* Prefer atoll over atoq, since the former is in the ISO C9X draft. 
831            But prefer not to use our hand-rolled function above either.  */
832 #if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ)
833         tmp_wide = atoll (tmp_char);
834 #else
835         tmp_wide = atoq (tmp_char);
836 #endif
837 #endif
838 #endif
839         XWINT (return_rtx, i) = tmp_wide;
840         break;
841
842       case 'i':
843       case 'n':
844         read_name (tmp_char, infile);
845         tmp_int = atoi (tmp_char);
846         XINT (return_rtx, i) = tmp_int;
847         break;
848
849       default:
850         fprintf (stderr,
851                  "switch format wrong in rtl.read_rtx(). format was: %c.\n",
852                  format_ptr[-1]);
853         fprintf (stderr, "\tfile position: %ld\n", ftell (infile));
854         abort ();
855       }
856
857   c = read_skip_spaces (infile);
858   if (c != ')')
859     dump_and_abort (')', c, infile);
860
861   return return_rtx;
862 }
863 \f
864 /* This is called once per compilation, before any rtx's are constructed.
865    It initializes the vector `rtx_length', the extra CC modes, if any,
866    and computes certain commonly-used modes.  */
867
868 void
869 init_rtl ()
870 {
871   int min_class_size[(int) MAX_MODE_CLASS];
872   enum machine_mode mode;
873   int i;
874
875   for (i = 0; i < NUM_RTX_CODE; i++)
876     rtx_length[i] = strlen (rtx_format[i]);
877
878   /* Make CONST_DOUBLE bigger, if real values are bigger than
879      it normally expects to have room for.
880      Note that REAL_VALUE_TYPE is not defined by default,
881      since tree.h is not included.  But the default dfn as `double'
882      would do no harm.  */
883 #ifdef REAL_VALUE_TYPE
884   i = sizeof (REAL_VALUE_TYPE) / sizeof (rtunion) + 2;
885   if (rtx_length[(int) CONST_DOUBLE] < i)
886     {
887       char *s = (char *) xmalloc (i + 1);
888       rtx_length[(int) CONST_DOUBLE] = i;
889       rtx_format[(int) CONST_DOUBLE] = s;
890       *s++ = 'e';
891       *s++ = '0';
892       /* Set the GET_RTX_FORMAT of CONST_DOUBLE to a string
893          of as many `w's as we now have elements.  Subtract two from
894          the size to account for the 'e' and the '0'.  */
895       for (i = 2; i < rtx_length[(int) CONST_DOUBLE]; i++)
896         *s++ = 'w';
897       *s++ = 0;
898     }
899 #endif
900
901 #ifdef EXTRA_CC_MODES
902   for (i = (int) CCmode + 1; i < (int) MAX_MACHINE_MODE; i++)
903     {
904       mode_class[i] = MODE_CC;
905       mode_mask_array[i] = mode_mask_array[(int) CCmode];
906       mode_size[i] = mode_size[(int) CCmode];
907       mode_unit_size[i] = mode_unit_size[(int) CCmode];
908       mode_wider_mode[i - 1] = i;
909       mode_wider_mode[i] = (unsigned char)VOIDmode;
910     }
911 #endif
912
913   /* Find the narrowest mode for each class.  */
914
915   for (i = 0; i < (int) MAX_MODE_CLASS; i++)
916     min_class_size[i] = 1000;
917
918   for (mode = VOIDmode; (int) mode < (int) MAX_MACHINE_MODE;
919        mode = (enum machine_mode) ((int) mode + 1))
920     {
921       if (GET_MODE_SIZE (mode) < min_class_size[(int) GET_MODE_CLASS (mode)])
922         {
923           class_narrowest_mode[(int) GET_MODE_CLASS (mode)] = mode;
924           min_class_size[(int) GET_MODE_CLASS (mode)] = GET_MODE_SIZE (mode);
925         }
926     }
927 }