1 /* Generate the machine mode enumeration and associated tables.
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 /* enum mode_class is normally defined by machmode.h but we can't
28 include that header here. */
29 #include "mode-classes.def"
31 #define DEF_MODE_CLASS(M) M
32 enum mode_class
{ MODE_CLASSES
, MAX_MODE_CLASS
};
35 /* Text names of mode classes, for output. */
36 #define DEF_MODE_CLASS(M) #M
37 static const char *const mode_class_names
[MAX_MODE_CLASS
] =
44 #ifdef EXTRA_MODES_FILE
45 # define HAVE_EXTRA_MODES 1
47 # define HAVE_EXTRA_MODES 0
48 # define EXTRA_MODES_FILE ""
51 /* Data structure for building up what we know about a mode.
52 They're clustered by mode class. */
55 struct mode_data
*next
; /* next this class - arbitrary order */
57 const char *name
; /* printable mode name -- SI, not SImode */
58 enum mode_class
class; /* this mode class */
59 unsigned int bitsize
; /* size in bits, equiv to TYPE_PRECISION */
60 unsigned int bytesize
; /* storage size in addressable units */
61 unsigned int ncomponents
; /* number of subunits */
62 unsigned int alignment
; /* mode alignment */
63 const char *format
; /* floating point format - MODE_FLOAT only */
65 struct mode_data
*component
; /* mode of components */
66 struct mode_data
*wider
; /* next wider mode */
68 const char *file
; /* file and line of definition, */
69 unsigned int line
; /* for error reporting */
72 static struct mode_data
*modes
[MAX_MODE_CLASS
];
73 static unsigned int n_modes
[MAX_MODE_CLASS
];
74 static struct mode_data
*void_mode
;
76 static const struct mode_data blank_mode
= {
77 0, "<unknown>", MAX_MODE_CLASS
,
83 static htab_t modes_by_name
;
85 /* Data structure for recording target-specified runtime adjustments
86 to a particular mode. We support varying the byte size, the
87 alignment, and the floating point format. */
90 struct mode_adjust
*next
;
91 struct mode_data
*mode
;
92 const char *adjustment
;
98 static struct mode_adjust
*adj_bytesize
;
99 static struct mode_adjust
*adj_alignment
;
100 static struct mode_adjust
*adj_format
;
102 /* Mode class operations. */
103 static enum mode_class
104 complex_class (enum mode_class
class)
108 case MODE_INT
: return MODE_COMPLEX_INT
;
109 case MODE_FLOAT
: return MODE_COMPLEX_FLOAT
;
111 error ("no complex class for class %s", mode_class_names
[class]);
116 static enum mode_class
117 vector_class (enum mode_class
class)
121 case MODE_INT
: return MODE_VECTOR_INT
;
122 case MODE_FLOAT
: return MODE_VECTOR_FLOAT
;
124 error ("no vector class for class %s", mode_class_names
[class]);
129 /* Utility routines. */
130 static inline struct mode_data
*
131 find_mode (const char *name
)
133 struct mode_data key
;
136 return htab_find (modes_by_name
, &key
);
139 static struct mode_data
*
140 new_mode (enum mode_class
class, const char *name
,
141 const char *file
, unsigned int line
)
145 m
= find_mode (name
);
148 error ("%s:%d: duplicate definition of mode \"%s\"",
149 trim_filename (file
), line
, name
);
150 error ("%s:%d: previous definition here", m
->file
, m
->line
);
154 m
= xmalloc (sizeof (struct mode_data
));
155 memcpy (m
, &blank_mode
, sizeof (struct mode_data
));
159 m
->file
= trim_filename (file
);
162 m
->next
= modes
[class];
166 *htab_find_slot (modes_by_name
, m
, INSERT
) = m
;
172 hash_mode (const void *p
)
174 const struct mode_data
*m
= (const struct mode_data
*)p
;
175 return htab_hash_string (m
->name
);
179 eq_mode (const void *p
, const void *q
)
181 const struct mode_data
*a
= (const struct mode_data
*)p
;
182 const struct mode_data
*b
= (const struct mode_data
*)q
;
184 return !strcmp (a
->name
, b
->name
);
187 #define for_all_modes(C, M) \
188 for (C = 0; C < MAX_MODE_CLASS; C++) \
189 for (M = modes[C]; M; M = M->next)
191 static void ATTRIBUTE_UNUSED
192 new_adjust (const char *name
,
193 struct mode_adjust
**category
, const char *catname
,
194 const char *adjustment
,
195 enum mode_class required_class
,
196 const char *file
, unsigned int line
)
198 struct mode_data
*mode
= find_mode (name
);
199 struct mode_adjust
*a
;
201 file
= trim_filename (file
);
205 error ("%s:%d: no mode \"%s\"", file
, line
, name
);
209 if (required_class
!= MODE_RANDOM
&& mode
->class != required_class
)
211 error ("%s:%d: mode \"%s\" is not class %s",
212 file
, line
, name
, mode_class_names
[required_class
] + 5);
216 for (a
= *category
; a
; a
= a
->next
)
219 error ("%s:%d: mode \"%s\" already has a %s adjustment",
220 file
, line
, name
, catname
);
221 error ("%s:%d: previous adjustment here", a
->file
, a
->line
);
225 a
= xmalloc (sizeof (struct mode_adjust
));
227 a
->adjustment
= adjustment
;
235 /* Diagnose failure to meet expectations in a partially filled out
237 enum requirement
{ SET
, UNSET
, OPTIONAL
};
239 #define validate_field_(mname, fname, req, val, unset, file, line) do { \
244 error ("%s:%d: (%s) field %s must be set", \
245 file, line, mname, fname); \
249 error ("%s:%d: (%s) field %s must not be set", \
250 file, line, mname, fname); \
256 #define validate_field(M, F) \
257 validate_field_(M->name, #F, r_##F, M->F, blank_mode.F, M->file, M->line)
260 validate_mode (struct mode_data
*m
,
261 enum requirement r_bitsize
,
262 enum requirement r_bytesize
,
263 enum requirement r_component
,
264 enum requirement r_ncomponents
,
265 enum requirement r_format
)
267 validate_field (m
, bitsize
);
268 validate_field (m
, bytesize
);
269 validate_field (m
, component
);
270 validate_field (m
, ncomponents
);
271 validate_field (m
, format
);
273 #undef validate_field
274 #undef validate_field_
276 /* Given a partially-filled-out mode structure, figure out what we can
277 and fill the rest of it in; die if it isn't enough. */
279 complete_mode (struct mode_data
*m
)
281 unsigned int alignment
;
285 error ("%s:%d: mode with no name", m
->file
, m
->line
);
288 if (m
->class == MAX_MODE_CLASS
)
290 error ("%s:%d: %smode has no mode class", m
->file
, m
->line
, m
->name
);
297 /* Nothing more need be said. */
298 if (!strcmp (m
->name
, "VOID"))
301 validate_mode (m
, UNSET
, UNSET
, UNSET
, UNSET
, UNSET
);
310 /* Again, nothing more need be said. For historical reasons,
311 the size of a CC mode is four units. */
312 validate_mode (m
, UNSET
, UNSET
, UNSET
, UNSET
, UNSET
);
321 /* A scalar mode must have a byte size, may have a bit size,
322 and must not have components. A float mode must have a
324 validate_mode (m
, OPTIONAL
, SET
, UNSET
, UNSET
,
325 m
->class == MODE_FLOAT
? SET
: UNSET
);
331 case MODE_PARTIAL_INT
:
332 /* A partial integer mode uses ->component to say what the
333 corresponding full-size integer mode is, and may also
334 specify a bit size. */
335 validate_mode (m
, OPTIONAL
, UNSET
, SET
, UNSET
, UNSET
);
337 m
->bytesize
= m
->component
->bytesize
;
340 m
->component
= 0; /* ??? preserve this */
343 case MODE_COMPLEX_INT
:
344 case MODE_COMPLEX_FLOAT
:
345 /* Complex modes should have a component indicated, but no more. */
346 validate_mode (m
, UNSET
, UNSET
, SET
, UNSET
, UNSET
);
348 if (m
->component
->bitsize
!= (unsigned int)-1)
349 m
->bitsize
= 2 * m
->component
->bitsize
;
350 m
->bytesize
= 2 * m
->component
->bytesize
;
353 case MODE_VECTOR_INT
:
354 case MODE_VECTOR_FLOAT
:
355 /* Vector modes should have a component and a number of components. */
356 validate_mode (m
, UNSET
, UNSET
, SET
, SET
, UNSET
);
357 if (m
->component
->bitsize
!= (unsigned int)-1)
358 m
->bitsize
= m
->ncomponents
* m
->component
->bitsize
;
359 m
->bytesize
= m
->ncomponents
* m
->component
->bytesize
;
366 /* If not already specified, the mode alignment defaults to the largest
367 power of two that divides the size of the object. Complex types are
368 not more aligned than their contents. */
369 if (m
->class == MODE_COMPLEX_INT
|| m
->class == MODE_COMPLEX_FLOAT
)
370 alignment
= m
->component
->bytesize
;
372 alignment
= m
->bytesize
;
374 m
->alignment
= alignment
& (~alignment
+ 1);
378 complete_all_modes (void)
387 /* For each mode in class CLASS, construct a corresponding complex mode. */
388 #define COMPLEX_MODES(C) make_complex_modes(MODE_##C, __FILE__, __LINE__)
390 make_complex_modes (enum mode_class
class,
391 const char *file
, unsigned int line
)
396 enum mode_class cclass
= complex_class (class);
398 if (cclass
== MODE_RANDOM
)
401 for (m
= modes
[class]; m
; m
= m
->next
)
403 /* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */
407 if (strlen (m
->name
) >= sizeof buf
)
409 error ("%s:%d:mode name \"%s\" is too long",
410 m
->file
, m
->line
, m
->name
);
414 /* Float complex modes are named SCmode, etc.
415 Int complex modes are named CSImode, etc.
416 This inconsistency should be eliminated. */
417 if (class == MODE_FLOAT
)
420 strncpy (buf
, m
->name
, sizeof buf
);
421 p
= strchr (buf
, 'F');
424 error ("%s:%d: float mode \"%s\" has no 'F'",
425 m
->file
, m
->line
, m
->name
);
432 snprintf (buf
, sizeof buf
, "C%s", m
->name
);
434 c
= new_mode (cclass
, xstrdup (buf
), file
, line
);
439 /* For all modes in class CLASS, construct vector modes of width
440 WIDTH, having as many components as necessary. */
441 #define VECTOR_MODES(C, W) make_vector_modes(MODE_##C, W, __FILE__, __LINE__)
443 make_vector_modes (enum mode_class
class, unsigned int width
,
444 const char *file
, unsigned int line
)
449 unsigned int ncomponents
;
450 enum mode_class vclass
= vector_class (class);
452 if (vclass
== MODE_RANDOM
)
455 for (m
= modes
[class]; m
; m
= m
->next
)
457 /* Do not construct vector modes with only one element, or
458 vector modes where the element size doesn't divide the full
460 ncomponents
= width
/ m
->bytesize
;
463 if (width
% m
->bytesize
)
466 /* Skip QFmode and BImode. FIXME: this special case should
468 if (class == MODE_FLOAT
&& m
->bytesize
== 1)
470 if (class == MODE_INT
&& m
->bitsize
== 1)
473 if ((size_t)snprintf (buf
, sizeof buf
, "V%u%s", ncomponents
, m
->name
)
476 error ("%s:%d: mode name \"%s\" is too long",
477 m
->file
, m
->line
, m
->name
);
481 v
= new_mode (vclass
, xstrdup (buf
), file
, line
);
483 v
->ncomponents
= ncomponents
;
489 #define _SPECIAL_MODE(C, N) make_special_mode(MODE_##C, #N, __FILE__, __LINE__)
490 #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N)
491 #define CC_MODE(N) _SPECIAL_MODE (CC, N)
494 make_special_mode (enum mode_class
class, const char *name
,
495 const char *file
, unsigned int line
)
497 new_mode (class, name
, file
, line
);
500 #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1, Y)
501 #define FRACTIONAL_INT_MODE(N, B, Y) \
502 make_int_mode (#N, B, Y, __FILE__, __LINE__)
505 make_int_mode (const char *name
,
506 unsigned int bitsize
, unsigned int bytesize
,
507 const char *file
, unsigned int line
)
509 struct mode_data
*m
= new_mode (MODE_INT
, name
, file
, line
);
510 m
->bytesize
= bytesize
;
511 m
->bitsize
= bitsize
;
514 #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1, Y, F)
515 #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
516 make_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
519 make_float_mode (const char *name
,
520 unsigned int bitsize
, unsigned int bytesize
,
522 const char *file
, unsigned int line
)
524 struct mode_data
*m
= new_mode (MODE_FLOAT
, name
, file
, line
);
525 m
->bytesize
= bytesize
;
526 m
->bitsize
= bitsize
;
530 #define RESET_FLOAT_FORMAT(N, F) \
531 reset_float_format (#N, #F, __FILE__, __LINE__)
532 static void ATTRIBUTE_UNUSED
533 reset_float_format (const char *name
, const char *format
,
534 const char *file
, unsigned int line
)
536 struct mode_data
*m
= find_mode (name
);
539 error ("%s:%d: no mode \"%s\"", file
, line
, name
);
542 if (m
->class != MODE_FLOAT
)
544 error ("%s:%d: mode \"%s\" is not class FLOAT", file
, line
, name
);
550 /* Partial integer modes are specified by relation to a full integer mode.
551 For now, we do not attempt to narrow down their bit sizes. */
552 #define PARTIAL_INT_MODE(M) \
553 make_partial_integer_mode (#M, "P" #M, -1, __FILE__, __LINE__)
554 static void ATTRIBUTE_UNUSED
555 make_partial_integer_mode (const char *base
, const char *name
,
556 unsigned int bitsize
,
557 const char *file
, unsigned int line
)
560 struct mode_data
*component
= find_mode (base
);
563 error ("%s:%d: no mode \"%s\"", file
, line
, name
);
566 if (component
->class != MODE_INT
)
568 error ("%s:%d: mode \"%s\" is not class INT", file
, line
, name
);
572 m
= new_mode (MODE_PARTIAL_INT
, name
, file
, line
);
573 m
->bitsize
= bitsize
;
574 m
->component
= component
;
577 /* A single vector mode can be specified by naming its component
578 mode and the number of components. */
579 #define VECTOR_MODE(C, M, N) \
580 make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__);
581 static void ATTRIBUTE_UNUSED
582 make_vector_mode (enum mode_class bclass
,
584 unsigned int ncomponents
,
585 const char *file
, unsigned int line
)
588 enum mode_class vclass
= vector_class (bclass
);
589 struct mode_data
*component
= find_mode (base
);
592 if (vclass
== MODE_RANDOM
)
596 error ("%s:%d: no mode \"%s\"", file
, line
, base
);
599 if (component
->class != bclass
)
601 error ("%s:%d: mode \"%s\" is not class %s",
602 file
, line
, base
, mode_class_names
[bclass
] + 5);
606 if ((size_t)snprintf (namebuf
, sizeof namebuf
, "V%u%s",
607 ncomponents
, base
) >= sizeof namebuf
)
609 error ("%s:%d: mode name \"%s\" is too long",
614 v
= new_mode (vclass
, xstrdup (namebuf
), file
, line
);
615 v
->ncomponents
= ncomponents
;
616 v
->component
= component
;
620 #define _ADD_ADJUST(A, M, X, C) \
621 new_adjust (#M, &adj_##A, #A, #X, MODE_##C, __FILE__, __LINE__)
623 #define ADJUST_BYTESIZE(M, X) _ADD_ADJUST(bytesize, M, X, RANDOM)
624 #define ADJUST_ALIGNMENT(M, X) _ADD_ADJUST(alignment, M, X, RANDOM)
625 #define ADJUST_FLOAT_FORMAT(M, X) _ADD_ADJUST(format, M, X, FLOAT)
630 #include "machmode.def"
635 /* Sort a list of modes into the order needed for the WIDER field:
636 major sort by bitsize, minor sort by component bitsize.
639 QI < HI < SI < DI < TI
640 V4QI < V2HI < V8QI < V4HI < V2SI.
642 If the bitsize is not set, sort by the bytesize. A mode with
643 bitsize set gets sorted before a mode without bitsize set, if
644 they have the same bytesize; this is the right thing because
645 the bitsize must always be smaller than the bytesize * BITS_PER_UNIT.
646 We don't have to do anything special to get this done -- an unset
647 bitsize shows up as (unsigned int)-1, i.e. UINT_MAX. */
649 cmp_modes (const void *a
, const void *b
)
651 struct mode_data
*m
= *(struct mode_data
**)a
;
652 struct mode_data
*n
= *(struct mode_data
**)b
;
654 if (m
->bytesize
> n
->bytesize
)
656 else if (m
->bytesize
< n
->bytesize
)
659 if (m
->bitsize
> n
->bitsize
)
661 else if (m
->bitsize
< n
->bitsize
)
664 if (!m
->component
&& !n
->component
)
667 if (m
->component
->bytesize
> n
->component
->bytesize
)
669 else if (m
->component
->bytesize
< n
->component
->bytesize
)
672 if (m
->component
->bitsize
> n
->component
->bitsize
)
674 else if (m
->component
->bitsize
< n
->component
->bitsize
)
681 calc_wider_mode (void)
685 struct mode_data
**sortbuf
;
686 unsigned int max_n_modes
= 0;
689 for (c
= 0; c
< MAX_MODE_CLASS
; c
++)
690 max_n_modes
= MAX (max_n_modes
, n_modes
[c
]);
692 /* Allocate max_n_modes + 1 entries to leave room for the extra null
693 pointer assigned after the qsort call below. */
694 sortbuf
= alloca ((max_n_modes
+ 1) * sizeof (struct mode_data
*));
696 for (c
= 0; c
< MAX_MODE_CLASS
; c
++)
698 /* "wider" is not meaningful for MODE_RANDOM and MODE_CC.
699 However, we want these in textual order, and we have
700 precisely the reverse. */
701 if (c
== MODE_RANDOM
|| c
== MODE_CC
)
703 struct mode_data
*prev
, *next
;
705 for (prev
= 0, m
= modes
[c
]; m
; m
= next
)
707 m
->wider
= void_mode
;
709 /* this is nreverse */
721 for (i
= 0, m
= modes
[c
]; m
; i
++, m
= m
->next
)
724 qsort (sortbuf
, i
, sizeof (struct mode_data
*), cmp_modes
);
727 for (j
= 0; j
< i
; j
++)
728 sortbuf
[j
]->next
= sortbuf
[j
]->wider
= sortbuf
[j
+ 1];
731 modes
[c
] = sortbuf
[0];
736 /* Output routines. */
738 #define tagged_printf(FMT, ARG, TAG) do { \
740 printf (" " FMT ",%n", ARG, &count_); \
741 printf ("%*s/* %s */\n", 27 - count_, "", TAG); \
744 #define print_decl(TYPE, NAME, ASIZE) \
745 puts ("\nconst " TYPE " " NAME "[" ASIZE "] =\n{");
747 #define print_maybe_const_decl(TYPE, NAME, ASIZE, CATEGORY) \
748 printf ("\n" TYPE " " NAME "[" ASIZE "] = \n{\n", \
749 adj_##CATEGORY ? "" : "const ")
751 #define print_closer() puts ("};")
754 emit_insn_modes_h (void)
757 struct mode_data
*m
, *first
, *last
;
759 printf ("/* Generated automatically from machmode.def%s%s\n",
760 HAVE_EXTRA_MODES
? " and " : "",
766 #ifndef GCC_INSN_MODES_H\n\
767 #define GCC_INSN_MODES_H\n\
769 enum machine_mode\n{");
771 for (c
= 0; c
< MAX_MODE_CLASS
; c
++)
772 for (m
= modes
[c
]; m
; m
= m
->next
)
775 printf (" %smode,%n", m
->name
, &count_
);
776 printf ("%*s/* %s:%d */\n", 27 - count_
, "",
777 trim_filename (m
->file
), m
->line
);
780 puts (" MAX_MACHINE_MODE,\n");
782 for (c
= 0; c
< MAX_MODE_CLASS
; c
++)
786 for (m
= first
; m
; last
= m
, m
= m
->next
)
789 /* Don't use BImode for MIN_MODE_INT, since otherwise the middle
790 end will try to use it for bitfields in structures and the
791 like, which we do not want. Only the target md file should
792 generate BImode widgets. */
793 if (first
&& first
->bitsize
== 1)
797 printf (" MIN_%s = %smode,\n MAX_%s = %smode,\n\n",
798 mode_class_names
[c
], first
->name
,
799 mode_class_names
[c
], last
->name
);
801 printf (" MIN_%s = %smode,\n MAX_%s = %smode,\n\n",
802 mode_class_names
[c
], void_mode
->name
,
803 mode_class_names
[c
], void_mode
->name
);
807 NUM_MACHINE_MODES = MAX_MACHINE_MODE\n\
810 /* I can't think of a better idea, can you? */
811 printf ("#define CONST_MODE_SIZE%s\n", adj_bytesize
? "" : " const");
812 printf ("#define CONST_MODE_BASE_ALIGN%s\n", adj_alignment
? "" : " const");
813 #if 0 /* disabled for backward compatibility, temporary */
814 printf ("#define CONST_REAL_FORMAT_FOR_MODE%s\n", adj_format
? "" :" const");
818 #endif /* insn-modes.h */");
822 emit_insn_modes_c_header (void)
824 printf ("/* Generated automatically from machmode.def%s%s\n",
825 HAVE_EXTRA_MODES
? " and " : "",
831 #include \"config.h\"\n\
832 #include \"system.h\"\n\
833 #include \"coretypes.h\"\n\
835 #include \"machmode.h\"\n\
836 #include \"real.h\"");
840 emit_min_insn_modes_c_header (void)
842 printf ("/* Generated automatically from machmode.def%s%s\n",
843 HAVE_EXTRA_MODES
? " and " : "",
849 #include \"bconfig.h\"\n\
850 #include \"system.h\"\n\
851 #include \"machmode.h\"");
855 emit_mode_name (void)
860 print_decl ("char *const", "mode_name", "NUM_MACHINE_MODES");
863 printf (" \"%s\",\n", m
->name
);
869 emit_mode_class (void)
874 print_decl ("unsigned char", "mode_class", "NUM_MACHINE_MODES");
877 tagged_printf ("%s", mode_class_names
[m
->class], m
->name
);
883 emit_mode_bitsize (void)
888 print_decl ("unsigned short", "mode_bitsize", "NUM_MACHINE_MODES");
891 if (m
->bitsize
!= (unsigned int)-1)
892 tagged_printf ("%u", m
->bitsize
, m
->name
);
894 tagged_printf ("%u*BITS_PER_UNIT", m
->bytesize
, m
->name
);
900 emit_mode_size (void)
905 print_maybe_const_decl ("%sunsigned char", "mode_size",
906 "NUM_MACHINE_MODES", bytesize
);
909 tagged_printf ("%u", m
->bytesize
, m
->name
);
915 emit_mode_unit_size (void)
920 print_decl ("unsigned char", "mode_unit_size", "NUM_MACHINE_MODES");
925 ? m
->component
->bytesize
: m
->bytesize
,
932 emit_mode_wider (void)
937 print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES");
940 tagged_printf ("%smode",
941 m
->wider
? m
->wider
->name
: void_mode
->name
,
948 emit_mode_mask (void)
953 print_decl ("unsigned HOST_WIDE_INT", "mode_mask_array",
954 "NUM_MACHINE_MODES");
956 #define MODE_MASK(m) \\\n\
957 ((m) >= HOST_BITS_PER_WIDE_INT) \\\n\
958 ? ~(unsigned HOST_WIDE_INT) 0 \\\n\
959 : ((unsigned HOST_WIDE_INT) 1 << (m)) - 1\n");
962 if (m
->bitsize
!= (unsigned int)-1)
963 tagged_printf ("MODE_MASK (%u)", m
->bitsize
, m
->name
);
965 tagged_printf ("MODE_MASK (%u*BITS_PER_UNIT)", m
->bytesize
, m
->name
);
967 puts ("#undef MODE_MASK");
972 emit_mode_inner (void)
977 print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES");
980 tagged_printf ("%smode",
981 m
->component
? m
->component
->name
: void_mode
->name
,
988 emit_mode_base_align (void)
993 print_maybe_const_decl ("%sunsigned char",
994 "mode_base_align", "NUM_MACHINE_MODES",
998 tagged_printf ("%u", m
->alignment
, m
->name
);
1004 emit_class_narrowest_mode (void)
1008 print_decl ("unsigned char", "class_narrowest_mode", "MAX_MODE_CLASS");
1010 for (c
= 0; c
< MAX_MODE_CLASS
; c
++)
1011 /* Bleah, all this to get the comment right for MIN_MODE_INT. */
1012 tagged_printf ("MIN_%s", mode_class_names
[c
],
1014 ? (modes
[c
]->bitsize
!= 1
1017 ? modes
[c
]->next
->name
1025 emit_real_format_for_mode (void)
1027 struct mode_data
*m
;
1029 /* The entities pointed to by this table are constant, whether
1030 or not the table itself is constant.
1032 For backward compatibility this table is always writable
1033 (several targets modify it in OVERRIDE_OPTIONS). FIXME:
1034 convert all said targets to use ADJUST_FORMAT instead. */
1036 print_maybe_const_decl ("const struct real_format *%s",
1037 "real_format_for_mode",
1038 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1",
1041 print_decl ("struct real_format *\n", "real_format_for_mode",
1042 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1");
1045 for (m
= modes
[MODE_FLOAT
]; m
; m
= m
->next
)
1046 if (!strcmp (m
->format
, "0"))
1047 tagged_printf ("%s", m
->format
, m
->name
);
1049 tagged_printf ("&%s", m
->format
, m
->name
);
1055 emit_mode_adjustments (void)
1057 struct mode_adjust
*a
;
1059 puts ("\nvoid\ninit_adjust_machine_modes (void)\n{");
1061 for (a
= adj_bytesize
; a
; a
= a
->next
)
1062 printf (" /* %s:%d */\n mode_size[%smode] = %s;\n",
1063 a
->file
, a
->line
, a
->mode
->name
, a
->adjustment
);
1064 if (adj_bytesize
&& (adj_alignment
|| adj_format
))
1067 for (a
= adj_alignment
; a
; a
= a
->next
)
1068 printf (" /* %s:%d */\n mode_base_align[%smode] = %s;\n",
1069 a
->file
, a
->line
, a
->mode
->name
, a
->adjustment
);
1070 if (adj_alignment
&& adj_format
)
1073 for (a
= adj_format
; a
; a
= a
->next
)
1074 printf (" /* %s:%d */\n REAL_MODE_FORMAT (%smode) = %s;\n",
1075 a
->file
, a
->line
, a
->mode
->name
, a
->adjustment
);
1081 emit_insn_modes_c (void)
1083 emit_insn_modes_c_header ();
1086 emit_mode_bitsize ();
1088 emit_mode_unit_size ();
1092 emit_mode_base_align ();
1093 emit_class_narrowest_mode ();
1094 emit_real_format_for_mode ();
1095 emit_mode_adjustments ();
1099 emit_min_insn_modes_c (void)
1101 emit_min_insn_modes_c_header ();
1105 emit_class_narrowest_mode ();
1108 /* Master control. */
1110 main(int argc
, char **argv
)
1112 bool gen_header
= false, gen_min
= false;
1117 else if (argc
== 2 && !strcmp (argv
[1], "-h"))
1119 else if (argc
== 2 && !strcmp (argv
[1], "-m"))
1123 error ("usage: %s [-h|-m] > file", progname
);
1124 return FATAL_EXIT_CODE
;
1127 modes_by_name
= htab_create_alloc (64, hash_mode
, eq_mode
, 0, xcalloc
, free
);
1130 complete_all_modes ();
1133 return FATAL_EXIT_CODE
;
1138 emit_insn_modes_h ();
1140 emit_min_insn_modes_c ();
1142 emit_insn_modes_c ();
1144 if (fflush (stdout
) || fclose (stdout
))
1145 return FATAL_EXIT_CODE
;
1146 return SUCCESS_EXIT_CODE
;