Import final gcc2 snapshot (990109)
[official-gcc.git] / gcc / rtl.c
blob8802b504b03bf5f49635c632c6780dd19351b8fb
1 /* Allocate and read RTL for GNU C Compiler.
2 Copyright (C) 1987, 88, 91, 94, 97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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.
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.
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. */
22 #include "config.h"
23 #include "system.h"
24 #include "rtl.h"
25 #include "real.h"
27 #include "obstack.h"
28 #define obstack_chunk_alloc xmalloc
29 #define obstack_chunk_free free
31 /* Obstack used for allocating RTL objects.
32 Between functions, this is the permanent_obstack.
33 While parsing and expanding a function, this is maybepermanent_obstack
34 so we can save it if it is an inline function.
35 During optimization and output, this is function_obstack. */
37 extern struct obstack *rtl_obstack;
39 /* Indexed by rtx code, gives number of operands for an rtx with that code.
40 Does NOT include rtx header data (code and links).
41 This array is initialized in init_rtl. */
43 int rtx_length[NUM_RTX_CODE + 1];
45 /* Indexed by rtx code, gives the name of that kind of rtx, as a C string. */
47 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) NAME ,
49 char *rtx_name[] = {
50 #include "rtl.def" /* rtl expressions are documented here */
53 #undef DEF_RTL_EXPR
55 /* Indexed by machine mode, gives the name of that machine mode.
56 This name does not include the letters "mode". */
58 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) NAME,
60 char *mode_name[(int) MAX_MACHINE_MODE] = {
61 #include "machmode.def"
63 #ifdef EXTRA_CC_MODES
64 EXTRA_CC_NAMES
65 #endif
69 #undef DEF_MACHMODE
71 /* Indexed by machine mode, gives the length of the mode, in bytes.
72 GET_MODE_CLASS uses this. */
74 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) CLASS,
76 enum mode_class mode_class[(int) MAX_MACHINE_MODE] = {
77 #include "machmode.def"
80 #undef DEF_MACHMODE
82 /* Indexed by machine mode, gives the length of the mode, in bytes.
83 GET_MODE_SIZE uses this. */
85 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) SIZE,
87 int mode_size[(int) MAX_MACHINE_MODE] = {
88 #include "machmode.def"
91 #undef DEF_MACHMODE
93 /* Indexed by machine mode, gives the length of the mode's subunit.
94 GET_MODE_UNIT_SIZE uses this. */
96 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) UNIT,
98 int mode_unit_size[(int) MAX_MACHINE_MODE] = {
99 #include "machmode.def" /* machine modes are documented here */
102 #undef DEF_MACHMODE
104 /* Indexed by machine mode, gives next wider natural mode
105 (QI -> HI -> SI -> DI, etc.) Widening multiply instructions
106 use this. */
108 #define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER) \
109 (enum machine_mode) WIDER,
111 enum machine_mode mode_wider_mode[(int) MAX_MACHINE_MODE] = {
112 #include "machmode.def" /* machine modes are documented here */
115 #undef DEF_MACHMODE
117 /* Indexed by mode class, gives the narrowest mode for each class. */
119 enum machine_mode class_narrowest_mode[(int) MAX_MODE_CLASS];
121 /* Indexed by rtx code, gives a sequence of operand-types for
122 rtx's of that code. The sequence is a C string in which
123 each character describes one operand. */
125 char *rtx_format[] = {
126 /* "*" undefined.
127 can cause a warning message
128 "0" field is unused (or used in a phase-dependent manner)
129 prints nothing
130 "i" an integer
131 prints the integer
132 "n" like "i", but prints entries from `note_insn_name'
133 "w" an integer of width HOST_BITS_PER_WIDE_INT
134 prints the integer
135 "s" a pointer to a string
136 prints the string
137 "S" like "s", but optional:
138 the containing rtx may end before this operand
139 "e" a pointer to an rtl expression
140 prints the expression
141 "E" a pointer to a vector that points to a number of rtl expressions
142 prints a list of the rtl expressions
143 "V" like "E", but optional:
144 the containing rtx may end before this operand
145 "u" a pointer to another insn
146 prints the uid of the insn. */
148 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) FORMAT ,
149 #include "rtl.def" /* rtl expressions are defined here */
150 #undef DEF_RTL_EXPR
153 /* Indexed by rtx code, gives a character representing the "class" of
154 that rtx code. See rtl.def for documentation on the defined classes. */
156 char rtx_class[] = {
157 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS,
158 #include "rtl.def" /* rtl expressions are defined here */
159 #undef DEF_RTL_EXPR
162 /* Names for kinds of NOTEs and REG_NOTEs. */
164 char *note_insn_name[] = { 0 , "NOTE_INSN_DELETED",
165 "NOTE_INSN_BLOCK_BEG", "NOTE_INSN_BLOCK_END",
166 "NOTE_INSN_LOOP_BEG", "NOTE_INSN_LOOP_END",
167 "NOTE_INSN_FUNCTION_END", "NOTE_INSN_SETJMP",
168 "NOTE_INSN_LOOP_CONT", "NOTE_INSN_LOOP_VTOP",
169 "NOTE_INSN_PROLOGUE_END", "NOTE_INSN_EPILOGUE_BEG",
170 "NOTE_INSN_DELETED_LABEL", "NOTE_INSN_FUNCTION_BEG",
171 "NOTE_INSN_EH_REGION_BEG", "NOTE_INSN_EH_REGION_END",
172 "NOTE_REPEATED_LINE_NUMBER" };
174 char *reg_note_name[] = { "", "REG_DEAD", "REG_INC", "REG_EQUIV", "REG_WAS_0",
175 "REG_EQUAL", "REG_RETVAL", "REG_LIBCALL",
176 "REG_NONNEG", "REG_NO_CONFLICT", "REG_UNUSED",
177 "REG_CC_SETTER", "REG_CC_USER", "REG_LABEL",
178 "REG_DEP_ANTI", "REG_DEP_OUTPUT", "REG_BR_PROB",
179 "REG_EXEC_COUNT" };
181 static void dump_and_abort PROTO((int, int, FILE *));
182 static void read_name PROTO((char *, FILE *));
184 /* Allocate an rtx vector of N elements.
185 Store the length, and initialize all elements to zero. */
187 rtvec
188 rtvec_alloc (n)
189 int n;
191 rtvec rt;
192 int i;
194 rt = (rtvec) obstack_alloc (rtl_obstack,
195 sizeof (struct rtvec_def)
196 + (( n - 1) * sizeof (rtunion)));
198 /* clear out the vector */
199 PUT_NUM_ELEM (rt, n);
201 for (i = 0; i < n; i++)
202 rt->elem[i].rtwint = 0;
204 return rt;
207 /* Allocate an rtx of code CODE. The CODE is stored in the rtx;
208 all the rest is initialized to zero. */
211 rtx_alloc (code)
212 RTX_CODE code;
214 rtx rt;
215 register struct obstack *ob = rtl_obstack;
216 register int nelts = GET_RTX_LENGTH (code);
217 register int length = sizeof (struct rtx_def)
218 + (nelts - 1) * sizeof (rtunion);
220 /* This function is called more than any other in GCC,
221 so we manipulate the obstack directly.
223 Even though rtx objects are word aligned, we may be sharing an obstack
224 with tree nodes, which may have to be double-word aligned. So align
225 our length to the alignment mask in the obstack. */
227 length = (length + ob->alignment_mask) & ~ ob->alignment_mask;
229 if (ob->chunk_limit - ob->next_free < length)
230 _obstack_newchunk (ob, length);
232 rt = (rtx) ob->object_base;
233 ob->next_free += length;
234 ob->object_base = ob->next_free;
236 /* We want to clear everything up to the FLD array. Normally, this is
237 one int, but we don't want to assume that and it isn't very portable
238 anyway; this is. */
240 if (sizeof (struct rtx_def) - sizeof (rtunion) == sizeof (int))
241 *(int *) rt = 0;
242 else if (sizeof (struct rtx_def) - sizeof (rtunion)
243 == sizeof (HOST_WIDE_INT))
244 *(HOST_WIDE_INT *) rt = 0;
245 else
246 bzero((char *) rt, sizeof (struct rtx_def) - sizeof (rtunion));
248 PUT_CODE (rt, code);
250 return rt;
253 /* Like the above, but allocate based only on the length. This is called
254 by the routines built into genrtl.c. */
257 obstack_alloc_rtx (length)
258 int length;
260 rtx rt;
261 register struct obstack *ob = rtl_obstack;
263 /* This function is called more than any other in GCC,
264 so we manipulate the obstack directly.
266 Even though rtx objects are word aligned, we may be sharing an obstack
267 with tree nodes, which may have to be double-word aligned. So align
268 our length to the alignment mask in the obstack. */
270 length = (length + ob->alignment_mask) & ~ ob->alignment_mask;
272 if (ob->chunk_limit - ob->next_free < length)
273 _obstack_newchunk (ob, length);
275 rt = (rtx) ob->object_base;
276 ob->next_free += length;
277 ob->object_base = ob->next_free;
279 /* We want to clear everything up to the FLD array. Normally, this is
280 one int, but we don't want to assume that and it isn't very portable
281 anyway; this is. */
283 if (sizeof (struct rtx_def) - sizeof (rtunion) == sizeof (int))
284 *(int *) rt = 0;
285 else if (sizeof (struct rtx_def) - sizeof (rtunion)
286 == sizeof (HOST_WIDE_INT))
287 *(HOST_WIDE_INT *) rt = 0;
288 else
289 bzero((char *) rt, sizeof (struct rtx_def) - sizeof (rtunion));
291 return rt;
294 /* Free the rtx X and all RTL allocated since X. */
296 void
297 rtx_free (x)
298 rtx x;
300 obstack_free (rtl_obstack, x);
303 /* Create a new copy of an rtx.
304 Recursively copies the operands of the rtx,
305 except for those few rtx codes that are sharable. */
308 copy_rtx (orig)
309 register rtx orig;
311 register rtx copy;
312 register int i, j;
313 register RTX_CODE code;
314 register char *format_ptr;
316 code = GET_CODE (orig);
318 switch (code)
320 case REG:
321 case QUEUED:
322 case CONST_INT:
323 case CONST_DOUBLE:
324 case SYMBOL_REF:
325 case CODE_LABEL:
326 case PC:
327 case CC0:
328 case SCRATCH:
329 /* SCRATCH must be shared because they represent distinct values. */
330 case ADDRESSOF:
331 return orig;
333 case CONST:
334 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
335 a LABEL_REF, it isn't sharable. */
336 if (GET_CODE (XEXP (orig, 0)) == PLUS
337 && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
338 && GET_CODE (XEXP (XEXP (orig, 0), 1)) == CONST_INT)
339 return orig;
340 break;
342 /* A MEM with a constant address is not sharable. The problem is that
343 the constant address may need to be reloaded. If the mem is shared,
344 then reloading one copy of this mem will cause all copies to appear
345 to have been reloaded. */
347 default:
348 break;
351 copy = rtx_alloc (code);
352 PUT_MODE (copy, GET_MODE (orig));
353 copy->in_struct = orig->in_struct;
354 copy->volatil = orig->volatil;
355 copy->unchanging = orig->unchanging;
356 copy->integrated = orig->integrated;
358 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
360 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
362 switch (*format_ptr++)
364 case 'e':
365 XEXP (copy, i) = XEXP (orig, i);
366 if (XEXP (orig, i) != NULL)
367 XEXP (copy, i) = copy_rtx (XEXP (orig, i));
368 break;
370 case '0':
371 case 'u':
372 XEXP (copy, i) = XEXP (orig, i);
373 break;
375 case 'E':
376 case 'V':
377 XVEC (copy, i) = XVEC (orig, i);
378 if (XVEC (orig, i) != NULL)
380 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
381 for (j = 0; j < XVECLEN (copy, i); j++)
382 XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
384 break;
386 case 'w':
387 XWINT (copy, i) = XWINT (orig, i);
388 break;
390 case 'i':
391 XINT (copy, i) = XINT (orig, i);
392 break;
394 case 's':
395 case 'S':
396 XSTR (copy, i) = XSTR (orig, i);
397 break;
399 default:
400 abort ();
403 return copy;
406 /* Similar to `copy_rtx' except that if MAY_SHARE is present, it is
407 placed in the result directly, rather than being copied. */
410 copy_most_rtx (orig, may_share)
411 register rtx orig;
412 register rtx may_share;
414 register rtx copy;
415 register int i, j;
416 register RTX_CODE code;
417 register char *format_ptr;
419 if (orig == may_share)
420 return orig;
422 code = GET_CODE (orig);
424 switch (code)
426 case REG:
427 case QUEUED:
428 case CONST_INT:
429 case CONST_DOUBLE:
430 case SYMBOL_REF:
431 case CODE_LABEL:
432 case PC:
433 case CC0:
434 return orig;
435 default:
436 break;
439 copy = rtx_alloc (code);
440 PUT_MODE (copy, GET_MODE (orig));
441 copy->in_struct = orig->in_struct;
442 copy->volatil = orig->volatil;
443 copy->unchanging = orig->unchanging;
444 copy->integrated = orig->integrated;
446 format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
448 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
450 switch (*format_ptr++)
452 case 'e':
453 XEXP (copy, i) = XEXP (orig, i);
454 if (XEXP (orig, i) != NULL && XEXP (orig, i) != may_share)
455 XEXP (copy, i) = copy_most_rtx (XEXP (orig, i), may_share);
456 break;
458 case '0':
459 case 'u':
460 XEXP (copy, i) = XEXP (orig, i);
461 break;
463 case 'E':
464 case 'V':
465 XVEC (copy, i) = XVEC (orig, i);
466 if (XVEC (orig, i) != NULL)
468 XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
469 for (j = 0; j < XVECLEN (copy, i); j++)
470 XVECEXP (copy, i, j)
471 = copy_most_rtx (XVECEXP (orig, i, j), may_share);
473 break;
475 case 'w':
476 XWINT (copy, i) = XWINT (orig, i);
477 break;
479 case 'n':
480 case 'i':
481 XINT (copy, i) = XINT (orig, i);
482 break;
484 case 's':
485 case 'S':
486 XSTR (copy, i) = XSTR (orig, i);
487 break;
489 default:
490 abort ();
493 return copy;
496 /* Subroutines of read_rtx. */
498 /* Dump code after printing a message. Used when read_rtx finds
499 invalid data. */
501 static void
502 dump_and_abort (expected_c, actual_c, infile)
503 int expected_c, actual_c;
504 FILE *infile;
506 int c, i;
508 if (expected_c >= 0)
509 fprintf (stderr,
510 "Expected character %c. Found character %c.",
511 expected_c, actual_c);
512 fprintf (stderr, " At file position: %ld\n", ftell (infile));
513 fprintf (stderr, "Following characters are:\n\t");
514 for (i = 0; i < 200; i++)
516 c = getc (infile);
517 if (EOF == c) break;
518 putc (c, stderr);
520 fprintf (stderr, "Aborting.\n");
521 abort ();
524 /* Read chars from INFILE until a non-whitespace char
525 and return that. Comments, both Lisp style and C style,
526 are treated as whitespace.
527 Tools such as genflags use this function. */
530 read_skip_spaces (infile)
531 FILE *infile;
533 register int c;
534 while (c = getc (infile))
536 if (c == ' ' || c == '\n' || c == '\t' || c == '\f')
538 else if (c == ';')
540 while ((c = getc (infile)) && c != '\n') ;
542 else if (c == '/')
544 register int prevc;
545 c = getc (infile);
546 if (c != '*')
547 dump_and_abort ('*', c, infile);
549 prevc = 0;
550 while (c = getc (infile))
552 if (prevc == '*' && c == '/')
553 break;
554 prevc = c;
557 else break;
559 return c;
562 /* Read an rtx code name into the buffer STR[].
563 It is terminated by any of the punctuation chars of rtx printed syntax. */
565 static void
566 read_name (str, infile)
567 char *str;
568 FILE *infile;
570 register char *p;
571 register int c;
573 c = read_skip_spaces(infile);
575 p = str;
576 while (1)
578 if (c == ' ' || c == '\n' || c == '\t' || c == '\f')
579 break;
580 if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
581 || c == '(' || c == '[')
583 ungetc (c, infile);
584 break;
586 *p++ = c;
587 c = getc (infile);
589 if (p == str)
591 fprintf (stderr, "missing name or number");
592 dump_and_abort (-1, -1, infile);
595 *p = 0;
598 /* Read an rtx in printed representation from INFILE
599 and return an actual rtx in core constructed accordingly.
600 read_rtx is not used in the compiler proper, but rather in
601 the utilities gen*.c that construct C code from machine descriptions. */
604 read_rtx (infile)
605 FILE *infile;
607 register int i, j, list_counter;
608 RTX_CODE tmp_code;
609 register char *format_ptr;
610 /* tmp_char is a buffer used for reading decimal integers
611 and names of rtx types and machine modes.
612 Therefore, 256 must be enough. */
613 char tmp_char[256];
614 rtx return_rtx;
615 register int c;
616 int tmp_int;
617 HOST_WIDE_INT tmp_wide;
619 /* Linked list structure for making RTXs: */
620 struct rtx_list
622 struct rtx_list *next;
623 rtx value; /* Value of this node... */
626 c = read_skip_spaces (infile); /* Should be open paren. */
627 if (c != '(')
628 dump_and_abort ('(', c, infile);
630 read_name (tmp_char, infile);
632 tmp_code = UNKNOWN;
634 for (i=0; i < NUM_RTX_CODE; i++) /* @@ might speed this search up */
636 if (!(strcmp (tmp_char, GET_RTX_NAME (i))))
638 tmp_code = (RTX_CODE) i; /* get value for name */
639 break;
642 if (tmp_code == UNKNOWN)
644 fprintf (stderr,
645 "Unknown rtx read in rtl.read_rtx(). Code name was %s .",
646 tmp_char);
648 /* (NIL) stands for an expression that isn't there. */
649 if (tmp_code == NIL)
651 /* Discard the closeparen. */
652 while ((c = getc (infile)) && c != ')');
653 return 0;
656 return_rtx = rtx_alloc (tmp_code); /* if we end up with an insn expression
657 then we free this space below. */
658 format_ptr = GET_RTX_FORMAT (GET_CODE (return_rtx));
660 /* If what follows is `: mode ', read it and
661 store the mode in the rtx. */
663 i = read_skip_spaces (infile);
664 if (i == ':')
666 register int k;
667 read_name (tmp_char, infile);
668 for (k = 0; k < NUM_MACHINE_MODES; k++)
669 if (!strcmp (GET_MODE_NAME (k), tmp_char))
670 break;
672 PUT_MODE (return_rtx, (enum machine_mode) k );
674 else
675 ungetc (i, infile);
677 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (return_rtx)); i++)
678 switch (*format_ptr++)
680 /* 0 means a field for internal use only.
681 Don't expect it to be present in the input. */
682 case '0':
683 break;
685 case 'e':
686 case 'u':
687 XEXP (return_rtx, i) = read_rtx (infile);
688 break;
690 case 'V':
691 /* 'V' is an optional vector: if a closeparen follows,
692 just store NULL for this element. */
693 c = read_skip_spaces (infile);
694 ungetc (c, infile);
695 if (c == ')')
697 XVEC (return_rtx, i) = 0;
698 break;
700 /* Now process the vector. */
702 case 'E':
704 register struct rtx_list *next_rtx, *rtx_list_link;
705 struct rtx_list *list_rtx;
707 c = read_skip_spaces (infile);
708 if (c != '[')
709 dump_and_abort ('[', c, infile);
711 /* add expressions to a list, while keeping a count */
712 next_rtx = NULL;
713 list_counter = 0;
714 while ((c = read_skip_spaces (infile)) && c != ']')
716 ungetc (c, infile);
717 list_counter++;
718 rtx_list_link = (struct rtx_list *)
719 alloca (sizeof (struct rtx_list));
720 rtx_list_link->value = read_rtx (infile);
721 if (next_rtx == 0)
722 list_rtx = rtx_list_link;
723 else
724 next_rtx->next = rtx_list_link;
725 next_rtx = rtx_list_link;
726 rtx_list_link->next = 0;
728 /* get vector length and allocate it */
729 XVEC (return_rtx, i) = (list_counter
730 ? rtvec_alloc (list_counter) : NULL_RTVEC);
731 if (list_counter > 0)
733 next_rtx = list_rtx;
734 for (j = 0; j < list_counter; j++,
735 next_rtx = next_rtx->next)
736 XVECEXP (return_rtx, i, j) = next_rtx->value;
738 /* close bracket gotten */
740 break;
742 case 'S':
743 /* 'S' is an optional string: if a closeparen follows,
744 just store NULL for this element. */
745 c = read_skip_spaces (infile);
746 ungetc (c, infile);
747 if (c == ')')
749 XSTR (return_rtx, i) = 0;
750 break;
753 case 's':
755 int saw_paren = 0;
756 register char *stringbuf;
758 c = read_skip_spaces (infile);
759 if (c == '(')
761 saw_paren = 1;
762 c = read_skip_spaces (infile);
764 if (c != '"')
765 dump_and_abort ('"', c, infile);
767 while (1)
769 c = getc (infile); /* Read the string */
770 if (c == '\\')
772 c = getc (infile); /* Read the string */
773 /* \; makes stuff for a C string constant containing
774 newline and tab. */
775 if (c == ';')
777 obstack_grow (rtl_obstack, "\\n\\t", 4);
778 continue;
781 else if (c == '"')
782 break;
784 obstack_1grow (rtl_obstack, c);
787 obstack_1grow (rtl_obstack, 0);
788 stringbuf = (char *) obstack_finish (rtl_obstack);
790 if (saw_paren)
792 c = read_skip_spaces (infile);
793 if (c != ')')
794 dump_and_abort (')', c, infile);
796 XSTR (return_rtx, i) = stringbuf;
798 break;
800 case 'w':
801 read_name (tmp_char, infile);
802 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
803 tmp_wide = atoi (tmp_char);
804 #else
805 tmp_wide = atol (tmp_char);
806 #endif
807 XWINT (return_rtx, i) = tmp_wide;
808 break;
810 case 'i':
811 case 'n':
812 read_name (tmp_char, infile);
813 tmp_int = atoi (tmp_char);
814 XINT (return_rtx, i) = tmp_int;
815 break;
817 default:
818 fprintf (stderr,
819 "switch format wrong in rtl.read_rtx(). format was: %c.\n",
820 format_ptr[-1]);
821 fprintf (stderr, "\tfile position: %ld\n", ftell (infile));
822 abort ();
825 c = read_skip_spaces (infile);
826 if (c != ')')
827 dump_and_abort (')', c, infile);
829 return return_rtx;
832 /* This is called once per compilation, before any rtx's are constructed.
833 It initializes the vector `rtx_length', the extra CC modes, if any,
834 and computes certain commonly-used modes. */
836 void
837 init_rtl ()
839 int min_class_size[(int) MAX_MODE_CLASS];
840 enum machine_mode mode;
841 int i;
843 for (i = 0; i < NUM_RTX_CODE; i++)
844 rtx_length[i] = strlen (rtx_format[i]);
846 /* Make CONST_DOUBLE bigger, if real values are bigger than
847 it normally expects to have room for.
848 Note that REAL_VALUE_TYPE is not defined by default,
849 since tree.h is not included. But the default dfn as `double'
850 would do no harm. */
851 #ifdef REAL_VALUE_TYPE
852 i = sizeof (REAL_VALUE_TYPE) / sizeof (rtunion) + 2;
853 if (rtx_length[(int) CONST_DOUBLE] < i)
855 char *s = (char *) xmalloc (i + 1);
856 rtx_length[(int) CONST_DOUBLE] = i;
857 rtx_format[(int) CONST_DOUBLE] = s;
858 *s++ = 'e';
859 *s++ = '0';
860 /* Set the GET_RTX_FORMAT of CONST_DOUBLE to a string
861 of as many `w's as we now have elements. Subtract two from
862 the size to account for the 'e' and the '0'. */
863 for (i = 2; i < rtx_length[(int) CONST_DOUBLE]; i++)
864 *s++ = 'w';
865 *s++ = 0;
867 #endif
869 #ifdef EXTRA_CC_MODES
870 for (i = (int) CCmode + 1; i < (int) MAX_MACHINE_MODE; i++)
872 mode_class[i] = MODE_CC;
873 mode_size[i] = mode_size[(int) CCmode];
874 mode_unit_size[i] = mode_unit_size[(int) CCmode];
875 mode_wider_mode[i - 1] = (enum machine_mode) i;
876 mode_wider_mode[i] = VOIDmode;
878 #endif
880 /* Find the narrowest mode for each class. */
882 for (i = 0; i < (int) MAX_MODE_CLASS; i++)
883 min_class_size[i] = 1000;
885 for (mode = VOIDmode; (int) mode < (int) MAX_MACHINE_MODE;
886 mode = (enum machine_mode) ((int) mode + 1))
888 if (GET_MODE_SIZE (mode) < min_class_size[(int) GET_MODE_CLASS (mode)])
890 class_narrowest_mode[(int) GET_MODE_CLASS (mode)] = mode;
891 min_class_size[(int) GET_MODE_CLASS (mode)] = GET_MODE_SIZE (mode);