2014-09-18 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / genmodes.c
blob0215a1883c82f4702c9de19ecab27b92b86f0558
1 /* Generate the machine mode enumeration and associated tables.
2 Copyright (C) 2003-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include "bconfig.h"
21 #include "system.h"
22 #include "errors.h"
23 #include "hashtab.h"
25 /* enum mode_class is normally defined by machmode.h but we can't
26 include that header here. */
27 #include "mode-classes.def"
29 #define DEF_MODE_CLASS(M) M
30 enum mode_class { MODE_CLASSES, MAX_MODE_CLASS };
31 #undef DEF_MODE_CLASS
33 /* Text names of mode classes, for output. */
34 #define DEF_MODE_CLASS(M) #M
35 static const char *const mode_class_names[MAX_MODE_CLASS] =
37 MODE_CLASSES
39 #undef DEF_MODE_CLASS
40 #undef MODE_CLASSES
42 #ifdef EXTRA_MODES_FILE
43 # define HAVE_EXTRA_MODES 1
44 #else
45 # define HAVE_EXTRA_MODES 0
46 # define EXTRA_MODES_FILE ""
47 #endif
49 /* Data structure for building up what we know about a mode.
50 They're clustered by mode class. */
51 struct mode_data
53 struct mode_data *next; /* next this class - arbitrary order */
55 const char *name; /* printable mode name -- SI, not SImode */
56 enum mode_class cl; /* this mode class */
57 unsigned int precision; /* size in bits, equiv to TYPE_PRECISION */
58 unsigned int bytesize; /* storage size in addressable units */
59 unsigned int ncomponents; /* number of subunits */
60 unsigned int alignment; /* mode alignment */
61 const char *format; /* floating point format - float modes only */
63 struct mode_data *component; /* mode of components */
64 struct mode_data *wider; /* next wider mode */
66 struct mode_data *contained; /* Pointer to list of modes that have
67 this mode as a component. */
68 struct mode_data *next_cont; /* Next mode in that list. */
70 const char *file; /* file and line of definition, */
71 unsigned int line; /* for error reporting */
72 unsigned int counter; /* Rank ordering of modes */
73 unsigned int ibit; /* the number of integral bits */
74 unsigned int fbit; /* the number of fractional bits */
75 bool need_bytesize_adj; /* true if this mode need dynamic size
76 adjustment */
79 static struct mode_data *modes[MAX_MODE_CLASS];
80 static unsigned int n_modes[MAX_MODE_CLASS];
81 static struct mode_data *void_mode;
83 static const struct mode_data blank_mode = {
84 0, "<unknown>", MAX_MODE_CLASS,
85 -1U, -1U, -1U, -1U,
86 0, 0, 0, 0, 0,
87 "<unknown>", 0, 0, 0, 0, false
90 static htab_t modes_by_name;
92 /* Data structure for recording target-specified runtime adjustments
93 to a particular mode. We support varying the byte size, the
94 alignment, and the floating point format. */
95 struct mode_adjust
97 struct mode_adjust *next;
98 struct mode_data *mode;
99 const char *adjustment;
101 const char *file;
102 unsigned int line;
105 static struct mode_adjust *adj_bytesize;
106 static struct mode_adjust *adj_alignment;
107 static struct mode_adjust *adj_format;
108 static struct mode_adjust *adj_ibit;
109 static struct mode_adjust *adj_fbit;
111 /* Mode class operations. */
112 static enum mode_class
113 complex_class (enum mode_class c)
115 switch (c)
117 case MODE_INT: return MODE_COMPLEX_INT;
118 case MODE_FLOAT: return MODE_COMPLEX_FLOAT;
119 default:
120 error ("no complex class for class %s", mode_class_names[c]);
121 return MODE_RANDOM;
125 static enum mode_class
126 vector_class (enum mode_class cl)
128 switch (cl)
130 case MODE_INT: return MODE_VECTOR_INT;
131 case MODE_FLOAT: return MODE_VECTOR_FLOAT;
132 case MODE_FRACT: return MODE_VECTOR_FRACT;
133 case MODE_UFRACT: return MODE_VECTOR_UFRACT;
134 case MODE_ACCUM: return MODE_VECTOR_ACCUM;
135 case MODE_UACCUM: return MODE_VECTOR_UACCUM;
136 default:
137 error ("no vector class for class %s", mode_class_names[cl]);
138 return MODE_RANDOM;
142 /* Utility routines. */
143 static inline struct mode_data *
144 find_mode (const char *name)
146 struct mode_data key;
148 key.name = name;
149 return (struct mode_data *) htab_find (modes_by_name, &key);
152 static struct mode_data *
153 new_mode (enum mode_class cl, const char *name,
154 const char *file, unsigned int line)
156 struct mode_data *m;
157 static unsigned int count = 0;
159 m = find_mode (name);
160 if (m)
162 error ("%s:%d: duplicate definition of mode \"%s\"",
163 trim_filename (file), line, name);
164 error ("%s:%d: previous definition here", m->file, m->line);
165 return m;
168 m = XNEW (struct mode_data);
169 memcpy (m, &blank_mode, sizeof (struct mode_data));
170 m->cl = cl;
171 m->name = name;
172 if (file)
173 m->file = trim_filename (file);
174 m->line = line;
175 m->counter = count++;
177 m->next = modes[cl];
178 modes[cl] = m;
179 n_modes[cl]++;
181 *htab_find_slot (modes_by_name, m, INSERT) = m;
183 return m;
186 static hashval_t
187 hash_mode (const void *p)
189 const struct mode_data *m = (const struct mode_data *)p;
190 return htab_hash_string (m->name);
193 static int
194 eq_mode (const void *p, const void *q)
196 const struct mode_data *a = (const struct mode_data *)p;
197 const struct mode_data *b = (const struct mode_data *)q;
199 return !strcmp (a->name, b->name);
202 #define for_all_modes(C, M) \
203 for (C = 0; C < MAX_MODE_CLASS; C++) \
204 for (M = modes[C]; M; M = M->next)
206 static void ATTRIBUTE_UNUSED
207 new_adjust (const char *name,
208 struct mode_adjust **category, const char *catname,
209 const char *adjustment,
210 enum mode_class required_class_from,
211 enum mode_class required_class_to,
212 const char *file, unsigned int line)
214 struct mode_data *mode = find_mode (name);
215 struct mode_adjust *a;
217 file = trim_filename (file);
219 if (!mode)
221 error ("%s:%d: no mode \"%s\"", file, line, name);
222 return;
225 if (required_class_from != MODE_RANDOM
226 && (mode->cl < required_class_from || mode->cl > required_class_to))
228 error ("%s:%d: mode \"%s\" is not among class {%s, %s}",
229 file, line, name, mode_class_names[required_class_from] + 5,
230 mode_class_names[required_class_to] + 5);
231 return;
234 for (a = *category; a; a = a->next)
235 if (a->mode == mode)
237 error ("%s:%d: mode \"%s\" already has a %s adjustment",
238 file, line, name, catname);
239 error ("%s:%d: previous adjustment here", a->file, a->line);
240 return;
243 a = XNEW (struct mode_adjust);
244 a->mode = mode;
245 a->adjustment = adjustment;
246 a->file = file;
247 a->line = line;
249 a->next = *category;
250 *category = a;
253 /* Diagnose failure to meet expectations in a partially filled out
254 mode structure. */
255 enum requirement { SET, UNSET, OPTIONAL };
257 #define validate_field_(mname, fname, req, val, unset, file, line) do { \
258 switch (req) \
260 case SET: \
261 if (val == unset) \
262 error ("%s:%d: (%s) field %s must be set", \
263 file, line, mname, fname); \
264 break; \
265 case UNSET: \
266 if (val != unset) \
267 error ("%s:%d: (%s) field %s must not be set", \
268 file, line, mname, fname); \
269 case OPTIONAL: \
270 break; \
272 } while (0)
274 #define validate_field(M, F) \
275 validate_field_(M->name, #F, r_##F, M->F, blank_mode.F, M->file, M->line)
277 static void
278 validate_mode (struct mode_data *m,
279 enum requirement r_precision,
280 enum requirement r_bytesize,
281 enum requirement r_component,
282 enum requirement r_ncomponents,
283 enum requirement r_format)
285 validate_field (m, precision);
286 validate_field (m, bytesize);
287 validate_field (m, component);
288 validate_field (m, ncomponents);
289 validate_field (m, format);
291 #undef validate_field
292 #undef validate_field_
294 /* Given a partially-filled-out mode structure, figure out what we can
295 and fill the rest of it in; die if it isn't enough. */
296 static void
297 complete_mode (struct mode_data *m)
299 unsigned int alignment;
301 if (!m->name)
303 error ("%s:%d: mode with no name", m->file, m->line);
304 return;
306 if (m->cl == MAX_MODE_CLASS)
308 error ("%s:%d: %smode has no mode class", m->file, m->line, m->name);
309 return;
312 switch (m->cl)
314 case MODE_RANDOM:
315 /* Nothing more need be said. */
316 if (!strcmp (m->name, "VOID"))
317 void_mode = m;
319 validate_mode (m, UNSET, UNSET, UNSET, UNSET, UNSET);
321 m->precision = 0;
322 m->bytesize = 0;
323 m->ncomponents = 0;
324 m->component = 0;
325 break;
327 case MODE_CC:
328 /* Again, nothing more need be said. For historical reasons,
329 the size of a CC mode is four units. */
330 validate_mode (m, UNSET, UNSET, UNSET, UNSET, UNSET);
332 m->bytesize = 4;
333 m->ncomponents = 1;
334 m->component = 0;
335 break;
337 case MODE_INT:
338 case MODE_FLOAT:
339 case MODE_DECIMAL_FLOAT:
340 case MODE_FRACT:
341 case MODE_UFRACT:
342 case MODE_ACCUM:
343 case MODE_UACCUM:
344 /* A scalar mode must have a byte size, may have a bit size,
345 and must not have components. A float mode must have a
346 format. */
347 validate_mode (m, OPTIONAL, SET, UNSET, UNSET,
348 (m->cl == MODE_FLOAT || m->cl == MODE_DECIMAL_FLOAT)
349 ? SET : UNSET);
351 m->ncomponents = 1;
352 m->component = 0;
353 break;
355 case MODE_PARTIAL_INT:
356 /* A partial integer mode uses ->component to say what the
357 corresponding full-size integer mode is, and may also
358 specify a bit size. */
359 validate_mode (m, OPTIONAL, UNSET, SET, UNSET, UNSET);
361 m->bytesize = m->component->bytesize;
363 m->ncomponents = 1;
364 break;
366 case MODE_COMPLEX_INT:
367 case MODE_COMPLEX_FLOAT:
368 /* Complex modes should have a component indicated, but no more. */
369 validate_mode (m, UNSET, UNSET, SET, UNSET, UNSET);
370 m->ncomponents = 2;
371 if (m->component->precision != (unsigned int)-1)
372 m->precision = 2 * m->component->precision;
373 m->bytesize = 2 * m->component->bytesize;
374 break;
376 case MODE_VECTOR_INT:
377 case MODE_VECTOR_FLOAT:
378 case MODE_VECTOR_FRACT:
379 case MODE_VECTOR_UFRACT:
380 case MODE_VECTOR_ACCUM:
381 case MODE_VECTOR_UACCUM:
382 /* Vector modes should have a component and a number of components. */
383 validate_mode (m, UNSET, UNSET, SET, SET, UNSET);
384 if (m->component->precision != (unsigned int)-1)
385 m->precision = m->ncomponents * m->component->precision;
386 m->bytesize = m->ncomponents * m->component->bytesize;
387 break;
389 default:
390 gcc_unreachable ();
393 /* If not already specified, the mode alignment defaults to the largest
394 power of two that divides the size of the object. Complex types are
395 not more aligned than their contents. */
396 if (m->cl == MODE_COMPLEX_INT || m->cl == MODE_COMPLEX_FLOAT)
397 alignment = m->component->bytesize;
398 else
399 alignment = m->bytesize;
401 m->alignment = alignment & (~alignment + 1);
403 /* If this mode has components, make the component mode point back
404 to this mode, for the sake of adjustments. */
405 if (m->component)
407 m->next_cont = m->component->contained;
408 m->component->contained = m;
412 static void
413 complete_all_modes (void)
415 struct mode_data *m;
416 int cl;
418 for_all_modes (cl, m)
419 complete_mode (m);
422 /* For each mode in class CLASS, construct a corresponding complex mode. */
423 #define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, __LINE__)
424 static void
425 make_complex_modes (enum mode_class cl,
426 const char *file, unsigned int line)
428 struct mode_data *m;
429 struct mode_data *c;
430 enum mode_class cclass = complex_class (cl);
432 if (cclass == MODE_RANDOM)
433 return;
435 for (m = modes[cl]; m; m = m->next)
437 char *p, *buf;
438 size_t m_len;
440 /* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */
441 if (m->precision == 1)
442 continue;
444 m_len = strlen (m->name);
445 /* The leading "1 +" is in case we prepend a "C" below. */
446 buf = (char *) xmalloc (1 + m_len + 1);
448 /* Float complex modes are named SCmode, etc.
449 Int complex modes are named CSImode, etc.
450 This inconsistency should be eliminated. */
451 p = 0;
452 if (cl == MODE_FLOAT)
454 memcpy (buf, m->name, m_len + 1);
455 p = strchr (buf, 'F');
456 if (p == 0 && strchr (buf, 'D') == 0)
458 error ("%s:%d: float mode \"%s\" has no 'F' or 'D'",
459 m->file, m->line, m->name);
460 free (buf);
461 continue;
464 if (p != 0)
465 *p = 'C';
466 else
468 buf[0] = 'C';
469 memcpy (buf + 1, m->name, m_len + 1);
472 c = new_mode (cclass, buf, file, line);
473 c->component = m;
477 /* For all modes in class CL, construct vector modes of width
478 WIDTH, having as many components as necessary. */
479 #define VECTOR_MODES(C, W) make_vector_modes (MODE_##C, W, __FILE__, __LINE__)
480 static void ATTRIBUTE_UNUSED
481 make_vector_modes (enum mode_class cl, unsigned int width,
482 const char *file, unsigned int line)
484 struct mode_data *m;
485 struct mode_data *v;
486 char buf[8];
487 unsigned int ncomponents;
488 enum mode_class vclass = vector_class (cl);
490 if (vclass == MODE_RANDOM)
491 return;
493 for (m = modes[cl]; m; m = m->next)
495 /* Do not construct vector modes with only one element, or
496 vector modes where the element size doesn't divide the full
497 size evenly. */
498 ncomponents = width / m->bytesize;
499 if (ncomponents < 2)
500 continue;
501 if (width % m->bytesize)
502 continue;
504 /* Skip QFmode and BImode. FIXME: this special case should
505 not be necessary. */
506 if (cl == MODE_FLOAT && m->bytesize == 1)
507 continue;
508 if (cl == MODE_INT && m->precision == 1)
509 continue;
511 if ((size_t)snprintf (buf, sizeof buf, "V%u%s", ncomponents, m->name)
512 >= sizeof buf)
514 error ("%s:%d: mode name \"%s\" is too long",
515 m->file, m->line, m->name);
516 continue;
519 v = new_mode (vclass, xstrdup (buf), file, line);
520 v->component = m;
521 v->ncomponents = ncomponents;
525 /* Input. */
527 #define _SPECIAL_MODE(C, N) \
528 make_special_mode (MODE_##C, #N, __FILE__, __LINE__)
529 #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N)
530 #define CC_MODE(N) _SPECIAL_MODE (CC, N)
532 static void
533 make_special_mode (enum mode_class cl, const char *name,
534 const char *file, unsigned int line)
536 new_mode (cl, name, file, line);
539 #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
540 #define FRACTIONAL_INT_MODE(N, B, Y) \
541 make_int_mode (#N, B, Y, __FILE__, __LINE__)
543 static void
544 make_int_mode (const char *name,
545 unsigned int precision, unsigned int bytesize,
546 const char *file, unsigned int line)
548 struct mode_data *m = new_mode (MODE_INT, name, file, line);
549 m->bytesize = bytesize;
550 m->precision = precision;
553 #define FRACT_MODE(N, Y, F) \
554 make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, __LINE__)
556 #define UFRACT_MODE(N, Y, F) \
557 make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, __LINE__)
559 #define ACCUM_MODE(N, Y, I, F) \
560 make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, __LINE__)
562 #define UACCUM_MODE(N, Y, I, F) \
563 make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, __LINE__)
565 /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT,
566 FILE, and LINE. */
568 static void
569 make_fixed_point_mode (enum mode_class cl,
570 const char *name,
571 unsigned int bytesize,
572 unsigned int ibit,
573 unsigned int fbit,
574 const char *file, unsigned int line)
576 struct mode_data *m = new_mode (cl, name, file, line);
577 m->bytesize = bytesize;
578 m->ibit = ibit;
579 m->fbit = fbit;
582 #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F)
583 #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
584 make_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
586 static void
587 make_float_mode (const char *name,
588 unsigned int precision, unsigned int bytesize,
589 const char *format,
590 const char *file, unsigned int line)
592 struct mode_data *m = new_mode (MODE_FLOAT, name, file, line);
593 m->bytesize = bytesize;
594 m->precision = precision;
595 m->format = format;
598 #define DECIMAL_FLOAT_MODE(N, Y, F) \
599 FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F)
600 #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \
601 make_decimal_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
603 static void
604 make_decimal_float_mode (const char *name,
605 unsigned int precision, unsigned int bytesize,
606 const char *format,
607 const char *file, unsigned int line)
609 struct mode_data *m = new_mode (MODE_DECIMAL_FLOAT, name, file, line);
610 m->bytesize = bytesize;
611 m->precision = precision;
612 m->format = format;
615 #define RESET_FLOAT_FORMAT(N, F) \
616 reset_float_format (#N, #F, __FILE__, __LINE__)
617 static void ATTRIBUTE_UNUSED
618 reset_float_format (const char *name, const char *format,
619 const char *file, unsigned int line)
621 struct mode_data *m = find_mode (name);
622 if (!m)
624 error ("%s:%d: no mode \"%s\"", file, line, name);
625 return;
627 if (m->cl != MODE_FLOAT && m->cl != MODE_DECIMAL_FLOAT)
629 error ("%s:%d: mode \"%s\" is not a FLOAT class", file, line, name);
630 return;
632 m->format = format;
635 /* Partial integer modes are specified by relation to a full integer
636 mode. */
637 #define PARTIAL_INT_MODE(M,PREC,NAME) \
638 make_partial_integer_mode (#M, #NAME, PREC, __FILE__, __LINE__)
639 static void ATTRIBUTE_UNUSED
640 make_partial_integer_mode (const char *base, const char *name,
641 unsigned int precision,
642 const char *file, unsigned int line)
644 struct mode_data *m;
645 struct mode_data *component = find_mode (base);
646 if (!component)
648 error ("%s:%d: no mode \"%s\"", file, line, name);
649 return;
651 if (component->cl != MODE_INT)
653 error ("%s:%d: mode \"%s\" is not class INT", file, line, name);
654 return;
657 m = new_mode (MODE_PARTIAL_INT, name, file, line);
658 m->precision = precision;
659 m->component = component;
662 /* A single vector mode can be specified by naming its component
663 mode and the number of components. */
664 #define VECTOR_MODE(C, M, N) \
665 make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__);
666 static void ATTRIBUTE_UNUSED
667 make_vector_mode (enum mode_class bclass,
668 const char *base,
669 unsigned int ncomponents,
670 const char *file, unsigned int line)
672 struct mode_data *v;
673 enum mode_class vclass = vector_class (bclass);
674 struct mode_data *component = find_mode (base);
675 char namebuf[16];
677 if (vclass == MODE_RANDOM)
678 return;
679 if (component == 0)
681 error ("%s:%d: no mode \"%s\"", file, line, base);
682 return;
684 if (component->cl != bclass
685 && (component->cl != MODE_PARTIAL_INT
686 || bclass != MODE_INT))
688 error ("%s:%d: mode \"%s\" is not class %s",
689 file, line, base, mode_class_names[bclass] + 5);
690 return;
693 if ((size_t)snprintf (namebuf, sizeof namebuf, "V%u%s",
694 ncomponents, base) >= sizeof namebuf)
696 error ("%s:%d: mode name \"%s\" is too long",
697 file, line, base);
698 return;
701 v = new_mode (vclass, xstrdup (namebuf), file, line);
702 v->ncomponents = ncomponents;
703 v->component = component;
706 /* Adjustability. */
707 #define _ADD_ADJUST(A, M, X, C1, C2) \
708 new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, __LINE__)
710 #define ADJUST_BYTESIZE(M, X) _ADD_ADJUST (bytesize, M, X, RANDOM, RANDOM)
711 #define ADJUST_ALIGNMENT(M, X) _ADD_ADJUST (alignment, M, X, RANDOM, RANDOM)
712 #define ADJUST_FLOAT_FORMAT(M, X) _ADD_ADJUST (format, M, X, FLOAT, FLOAT)
713 #define ADJUST_IBIT(M, X) _ADD_ADJUST (ibit, M, X, ACCUM, UACCUM)
714 #define ADJUST_FBIT(M, X) _ADD_ADJUST (fbit, M, X, FRACT, UACCUM)
716 static int bits_per_unit;
717 static int max_bitsize_mode_any_int;
719 static void
720 create_modes (void)
722 #include "machmode.def"
724 /* So put the default value unless the target needs a non standard
725 value. */
726 #ifdef BITS_PER_UNIT
727 bits_per_unit = BITS_PER_UNIT;
728 #else
729 bits_per_unit = 8;
730 #endif
732 #ifdef MAX_BITSIZE_MODE_ANY_INT
733 max_bitsize_mode_any_int = MAX_BITSIZE_MODE_ANY_INT;
734 #else
735 max_bitsize_mode_any_int = 0;
736 #endif
739 /* Processing. */
741 /* Sort a list of modes into the order needed for the WIDER field:
742 major sort by precision, minor sort by component precision.
744 For instance:
745 QI < HI < SI < DI < TI
746 V4QI < V2HI < V8QI < V4HI < V2SI.
748 If the precision is not set, sort by the bytesize. A mode with
749 precision set gets sorted before a mode without precision set, if
750 they have the same bytesize; this is the right thing because
751 the precision must always be smaller than the bytesize * BITS_PER_UNIT.
752 We don't have to do anything special to get this done -- an unset
753 precision shows up as (unsigned int)-1, i.e. UINT_MAX. */
754 static int
755 cmp_modes (const void *a, const void *b)
757 const struct mode_data *const m = *(const struct mode_data *const*)a;
758 const struct mode_data *const n = *(const struct mode_data *const*)b;
760 if (m->bytesize > n->bytesize)
761 return 1;
762 else if (m->bytesize < n->bytesize)
763 return -1;
765 if (m->precision > n->precision)
766 return 1;
767 else if (m->precision < n->precision)
768 return -1;
770 if (!m->component && !n->component)
772 if (m->counter < n->counter)
773 return -1;
774 else
775 return 1;
778 if (m->component->bytesize > n->component->bytesize)
779 return 1;
780 else if (m->component->bytesize < n->component->bytesize)
781 return -1;
783 if (m->component->precision > n->component->precision)
784 return 1;
785 else if (m->component->precision < n->component->precision)
786 return -1;
788 if (m->counter < n->counter)
789 return -1;
790 else
791 return 1;
794 static void
795 calc_wider_mode (void)
797 int c;
798 struct mode_data *m;
799 struct mode_data **sortbuf;
800 unsigned int max_n_modes = 0;
801 unsigned int i, j;
803 for (c = 0; c < MAX_MODE_CLASS; c++)
804 max_n_modes = MAX (max_n_modes, n_modes[c]);
806 /* Allocate max_n_modes + 1 entries to leave room for the extra null
807 pointer assigned after the qsort call below. */
808 sortbuf = XALLOCAVEC (struct mode_data *, max_n_modes + 1);
810 for (c = 0; c < MAX_MODE_CLASS; c++)
812 /* "wider" is not meaningful for MODE_RANDOM and MODE_CC.
813 However, we want these in textual order, and we have
814 precisely the reverse. */
815 if (c == MODE_RANDOM || c == MODE_CC)
817 struct mode_data *prev, *next;
819 for (prev = 0, m = modes[c]; m; m = next)
821 m->wider = void_mode;
823 /* this is nreverse */
824 next = m->next;
825 m->next = prev;
826 prev = m;
828 modes[c] = prev;
830 else
832 if (!modes[c])
833 continue;
835 for (i = 0, m = modes[c]; m; i++, m = m->next)
836 sortbuf[i] = m;
838 qsort (sortbuf, i, sizeof (struct mode_data *), cmp_modes);
840 sortbuf[i] = 0;
841 for (j = 0; j < i; j++)
843 sortbuf[j]->next = sortbuf[j + 1];
844 if (c == MODE_PARTIAL_INT)
845 sortbuf[j]->wider = sortbuf[j]->component;
846 else
847 sortbuf[j]->wider = sortbuf[j]->next;
850 modes[c] = sortbuf[0];
855 /* Output routines. */
857 #define tagged_printf(FMT, ARG, TAG) do { \
858 int count_ = printf (" " FMT ",", ARG); \
859 printf ("%*s/* %s */\n", 27 - count_, "", TAG); \
860 } while (0)
862 #define print_decl(TYPE, NAME, ASIZE) \
863 puts ("\nconst " TYPE " " NAME "[" ASIZE "] =\n{");
865 #define print_maybe_const_decl(TYPE, NAME, ASIZE, CATEGORY) \
866 printf ("\n" TYPE " " NAME "[" ASIZE "] = \n{\n", \
867 adj_##CATEGORY ? "" : "const ")
869 #define print_closer() puts ("};")
871 /* Compute the max bitsize of some of the classes of integers. It may
872 be that there are needs for the other integer classes, and this
873 code is easy to extend. */
874 static void
875 emit_max_int (void)
877 unsigned int max, mmax;
878 struct mode_data *i;
879 int j;
881 puts ("");
883 printf ("#define BITS_PER_UNIT (%d)\n", bits_per_unit);
885 if (max_bitsize_mode_any_int == 0)
887 for (max = 1, i = modes[MODE_INT]; i; i = i->next)
888 if (max < i->bytesize)
889 max = i->bytesize;
890 mmax = max;
891 for (max = 1, i = modes[MODE_PARTIAL_INT]; i; i = i->next)
892 if (max < i->bytesize)
893 max = i->bytesize;
894 if (max > mmax)
895 mmax = max;
896 printf ("#define MAX_BITSIZE_MODE_ANY_INT (%d*BITS_PER_UNIT)\n", mmax);
898 else
899 printf ("#define MAX_BITSIZE_MODE_ANY_INT %d\n", max_bitsize_mode_any_int);
901 mmax = 0;
902 for (j = 0; j < MAX_MODE_CLASS; j++)
903 for (i = modes[j]; i; i = i->next)
904 if (mmax < i->bytesize)
905 mmax = i->bytesize;
906 printf ("#define MAX_BITSIZE_MODE_ANY_MODE (%d*BITS_PER_UNIT)\n", mmax);
909 /* Emit mode_size_inline routine into insn-modes.h header. */
910 static void
911 emit_mode_size_inline (void)
913 int c;
914 struct mode_adjust *a;
915 struct mode_data *m;
917 /* Size adjustments must be propagated to all containing modes. */
918 for (a = adj_bytesize; a; a = a->next)
920 a->mode->need_bytesize_adj = true;
921 for (m = a->mode->contained; m; m = m->next_cont)
922 m->need_bytesize_adj = true;
925 printf ("\
926 #ifdef __cplusplus\n\
927 inline __attribute__((__always_inline__))\n\
928 #else\n\
929 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
930 #endif\n\
931 unsigned char\n\
932 mode_size_inline (enum machine_mode mode)\n\
933 {\n\
934 extern %sunsigned char mode_size[NUM_MACHINE_MODES];\n\
935 switch (mode)\n\
936 {\n", adj_bytesize ? "" : "const ");
938 for_all_modes (c, m)
939 if (!m->need_bytesize_adj)
940 printf (" case %smode: return %u;\n", m->name, m->bytesize);
942 puts ("\
943 default: return mode_size[mode];\n\
944 }\n\
945 }\n");
948 /* Emit mode_nunits_inline routine into insn-modes.h header. */
949 static void
950 emit_mode_nunits_inline (void)
952 int c;
953 struct mode_data *m;
955 puts ("\
956 #ifdef __cplusplus\n\
957 inline __attribute__((__always_inline__))\n\
958 #else\n\
959 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
960 #endif\n\
961 unsigned char\n\
962 mode_nunits_inline (enum machine_mode mode)\n\
963 {\n\
964 extern const unsigned char mode_nunits[NUM_MACHINE_MODES];\n\
965 switch (mode)\n\
966 {");
968 for_all_modes (c, m)
969 printf (" case %smode: return %u;\n", m->name, m->ncomponents);
971 puts ("\
972 default: return mode_nunits[mode];\n\
973 }\n\
974 }\n");
977 /* Emit mode_inner_inline routine into insn-modes.h header. */
978 static void
979 emit_mode_inner_inline (void)
981 int c;
982 struct mode_data *m;
984 puts ("\
985 #ifdef __cplusplus\n\
986 inline __attribute__((__always_inline__))\n\
987 #else\n\
988 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
989 #endif\n\
990 unsigned char\n\
991 mode_inner_inline (enum machine_mode mode)\n\
992 {\n\
993 extern const unsigned char mode_inner[NUM_MACHINE_MODES];\n\
994 switch (mode)\n\
995 {");
997 for_all_modes (c, m)
998 printf (" case %smode: return %smode;\n", m->name,
999 c != MODE_PARTIAL_INT && m->component
1000 ? m->component->name : void_mode->name);
1002 puts ("\
1003 default: return mode_inner[mode];\n\
1004 }\n\
1005 }\n");
1008 static void
1009 emit_insn_modes_h (void)
1011 int c;
1012 struct mode_data *m, *first, *last;
1014 printf ("/* Generated automatically from machmode.def%s%s\n",
1015 HAVE_EXTRA_MODES ? " and " : "",
1016 EXTRA_MODES_FILE);
1018 puts ("\
1019 by genmodes. */\n\
1021 #ifndef GCC_INSN_MODES_H\n\
1022 #define GCC_INSN_MODES_H\n\
1024 enum machine_mode\n{");
1026 for (c = 0; c < MAX_MODE_CLASS; c++)
1027 for (m = modes[c]; m; m = m->next)
1029 int count_ = printf (" %smode,", m->name);
1030 printf ("%*s/* %s:%d */\n", 27 - count_, "",
1031 trim_filename (m->file), m->line);
1032 printf ("#define HAVE_%smode\n", m->name);
1035 puts (" MAX_MACHINE_MODE,\n");
1037 for (c = 0; c < MAX_MODE_CLASS; c++)
1039 first = modes[c];
1040 last = 0;
1041 for (m = first; m; last = m, m = m->next)
1044 /* Don't use BImode for MIN_MODE_INT, since otherwise the middle
1045 end will try to use it for bitfields in structures and the
1046 like, which we do not want. Only the target md file should
1047 generate BImode widgets. */
1048 if (first && first->precision == 1 && c == MODE_INT)
1049 first = first->next;
1051 if (first && last)
1052 printf (" MIN_%s = %smode,\n MAX_%s = %smode,\n\n",
1053 mode_class_names[c], first->name,
1054 mode_class_names[c], last->name);
1055 else
1056 printf (" MIN_%s = %smode,\n MAX_%s = %smode,\n\n",
1057 mode_class_names[c], void_mode->name,
1058 mode_class_names[c], void_mode->name);
1061 puts ("\
1062 NUM_MACHINE_MODES = MAX_MACHINE_MODE\n\
1063 };\n");
1065 /* I can't think of a better idea, can you? */
1066 printf ("#define CONST_MODE_SIZE%s\n", adj_bytesize ? "" : " const");
1067 printf ("#define CONST_MODE_BASE_ALIGN%s\n", adj_alignment ? "" : " const");
1068 #if 0 /* disabled for backward compatibility, temporary */
1069 printf ("#define CONST_REAL_FORMAT_FOR_MODE%s\n", adj_format ? "" :" const");
1070 #endif
1071 printf ("#define CONST_MODE_IBIT%s\n", adj_ibit ? "" : " const");
1072 printf ("#define CONST_MODE_FBIT%s\n", adj_fbit ? "" : " const");
1073 emit_max_int ();
1074 puts ("\n#if GCC_VERSION >= 4001\n");
1075 emit_mode_size_inline ();
1076 emit_mode_nunits_inline ();
1077 emit_mode_inner_inline ();
1078 puts ("#endif /* GCC_VERSION >= 4001 */");
1080 puts ("\
1082 #endif /* insn-modes.h */");
1085 static void
1086 emit_insn_modes_c_header (void)
1088 printf ("/* Generated automatically from machmode.def%s%s\n",
1089 HAVE_EXTRA_MODES ? " and " : "",
1090 EXTRA_MODES_FILE);
1092 puts ("\
1093 by genmodes. */\n\
1095 #include \"config.h\"\n\
1096 #include \"system.h\"\n\
1097 #include \"coretypes.h\"\n\
1098 #include \"tm.h\"\n\
1099 #include \"machmode.h\"\n\
1100 #include \"real.h\"");
1103 static void
1104 emit_min_insn_modes_c_header (void)
1106 printf ("/* Generated automatically from machmode.def%s%s\n",
1107 HAVE_EXTRA_MODES ? " and " : "",
1108 EXTRA_MODES_FILE);
1110 puts ("\
1111 by genmodes. */\n\
1113 #include \"bconfig.h\"\n\
1114 #include \"system.h\"\n\
1115 #include \"machmode.h\"");
1118 static void
1119 emit_mode_name (void)
1121 int c;
1122 struct mode_data *m;
1124 print_decl ("char *const", "mode_name", "NUM_MACHINE_MODES");
1126 for_all_modes (c, m)
1127 printf (" \"%s\",\n", m->name);
1129 print_closer ();
1132 static void
1133 emit_mode_class (void)
1135 int c;
1136 struct mode_data *m;
1138 print_decl ("unsigned char", "mode_class", "NUM_MACHINE_MODES");
1140 for_all_modes (c, m)
1141 tagged_printf ("%s", mode_class_names[m->cl], m->name);
1143 print_closer ();
1146 static void
1147 emit_mode_precision (void)
1149 int c;
1150 struct mode_data *m;
1152 print_decl ("unsigned short", "mode_precision", "NUM_MACHINE_MODES");
1154 for_all_modes (c, m)
1155 if (m->precision != (unsigned int)-1)
1156 tagged_printf ("%u", m->precision, m->name);
1157 else
1158 tagged_printf ("%u*BITS_PER_UNIT", m->bytesize, m->name);
1160 print_closer ();
1163 static void
1164 emit_mode_size (void)
1166 int c;
1167 struct mode_data *m;
1169 print_maybe_const_decl ("%sunsigned char", "mode_size",
1170 "NUM_MACHINE_MODES", bytesize);
1172 for_all_modes (c, m)
1173 tagged_printf ("%u", m->bytesize, m->name);
1175 print_closer ();
1178 static void
1179 emit_mode_nunits (void)
1181 int c;
1182 struct mode_data *m;
1184 print_decl ("unsigned char", "mode_nunits", "NUM_MACHINE_MODES");
1186 for_all_modes (c, m)
1187 tagged_printf ("%u", m->ncomponents, m->name);
1189 print_closer ();
1192 static void
1193 emit_mode_wider (void)
1195 int c;
1196 struct mode_data *m;
1198 print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES");
1200 for_all_modes (c, m)
1201 tagged_printf ("%smode",
1202 m->wider ? m->wider->name : void_mode->name,
1203 m->name);
1205 print_closer ();
1206 print_decl ("unsigned char", "mode_2xwider", "NUM_MACHINE_MODES");
1208 for_all_modes (c, m)
1210 struct mode_data * m2;
1212 for (m2 = m;
1213 m2 && m2 != void_mode;
1214 m2 = m2->wider)
1216 if (m2->bytesize < 2 * m->bytesize)
1217 continue;
1218 if (m->precision != (unsigned int) -1)
1220 if (m2->precision != 2 * m->precision)
1221 continue;
1223 else
1225 if (m2->precision != (unsigned int) -1)
1226 continue;
1229 /* For vectors we want twice the number of components,
1230 with the same element type. */
1231 if (m->cl == MODE_VECTOR_INT
1232 || m->cl == MODE_VECTOR_FLOAT
1233 || m->cl == MODE_VECTOR_FRACT
1234 || m->cl == MODE_VECTOR_UFRACT
1235 || m->cl == MODE_VECTOR_ACCUM
1236 || m->cl == MODE_VECTOR_UACCUM)
1238 if (m2->ncomponents != 2 * m->ncomponents)
1239 continue;
1240 if (m->component != m2->component)
1241 continue;
1244 break;
1246 if (m2 == void_mode)
1247 m2 = 0;
1248 tagged_printf ("%smode",
1249 m2 ? m2->name : void_mode->name,
1250 m->name);
1253 print_closer ();
1256 static void
1257 emit_mode_mask (void)
1259 int c;
1260 struct mode_data *m;
1262 print_decl ("unsigned HOST_WIDE_INT", "mode_mask_array",
1263 "NUM_MACHINE_MODES");
1264 puts ("\
1265 #define MODE_MASK(m) \\\n\
1266 ((m) >= HOST_BITS_PER_WIDE_INT) \\\n\
1267 ? ~(unsigned HOST_WIDE_INT) 0 \\\n\
1268 : ((unsigned HOST_WIDE_INT) 1 << (m)) - 1\n");
1270 for_all_modes (c, m)
1271 if (m->precision != (unsigned int)-1)
1272 tagged_printf ("MODE_MASK (%u)", m->precision, m->name);
1273 else
1274 tagged_printf ("MODE_MASK (%u*BITS_PER_UNIT)", m->bytesize, m->name);
1276 puts ("#undef MODE_MASK");
1277 print_closer ();
1280 static void
1281 emit_mode_inner (void)
1283 int c;
1284 struct mode_data *m;
1286 print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES");
1288 for_all_modes (c, m)
1289 tagged_printf ("%smode",
1290 c != MODE_PARTIAL_INT && m->component
1291 ? m->component->name : void_mode->name,
1292 m->name);
1294 print_closer ();
1297 static void
1298 emit_mode_base_align (void)
1300 int c;
1301 struct mode_data *m;
1303 print_maybe_const_decl ("%sunsigned char",
1304 "mode_base_align", "NUM_MACHINE_MODES",
1305 alignment);
1307 for_all_modes (c, m)
1308 tagged_printf ("%u", m->alignment, m->name);
1310 print_closer ();
1313 static void
1314 emit_class_narrowest_mode (void)
1316 int c;
1318 print_decl ("unsigned char", "class_narrowest_mode", "MAX_MODE_CLASS");
1320 for (c = 0; c < MAX_MODE_CLASS; c++)
1321 /* Bleah, all this to get the comment right for MIN_MODE_INT. */
1322 tagged_printf ("MIN_%s", mode_class_names[c],
1323 modes[c]
1324 ? ((c != MODE_INT || modes[c]->precision != 1)
1325 ? modes[c]->name
1326 : (modes[c]->next
1327 ? modes[c]->next->name
1328 : void_mode->name))
1329 : void_mode->name);
1331 print_closer ();
1334 static void
1335 emit_real_format_for_mode (void)
1337 struct mode_data *m;
1339 /* The entities pointed to by this table are constant, whether
1340 or not the table itself is constant.
1342 For backward compatibility this table is always writable
1343 (several targets modify it in TARGET_OPTION_OVERRIDE). FIXME:
1344 convert all said targets to use ADJUST_FORMAT instead. */
1345 #if 0
1346 print_maybe_const_decl ("const struct real_format *%s",
1347 "real_format_for_mode",
1348 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1",
1349 format);
1350 #else
1351 print_decl ("struct real_format *\n", "real_format_for_mode",
1352 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1 "
1353 "+ MAX_MODE_DECIMAL_FLOAT - MIN_MODE_DECIMAL_FLOAT + 1");
1354 #endif
1356 /* The beginning of the table is entries for float modes. */
1357 for (m = modes[MODE_FLOAT]; m; m = m->next)
1358 if (!strcmp (m->format, "0"))
1359 tagged_printf ("%s", m->format, m->name);
1360 else
1361 tagged_printf ("&%s", m->format, m->name);
1363 /* The end of the table is entries for decimal float modes. */
1364 for (m = modes[MODE_DECIMAL_FLOAT]; m; m = m->next)
1365 if (!strcmp (m->format, "0"))
1366 tagged_printf ("%s", m->format, m->name);
1367 else
1368 tagged_printf ("&%s", m->format, m->name);
1370 print_closer ();
1373 static void
1374 emit_mode_adjustments (void)
1376 struct mode_adjust *a;
1377 struct mode_data *m;
1379 puts ("\
1380 \nvoid\
1381 \ninit_adjust_machine_modes (void)\
1382 \n{\
1383 \n size_t s ATTRIBUTE_UNUSED;");
1385 /* Size adjustments must be propagated to all containing modes.
1386 A size adjustment forces us to recalculate the alignment too. */
1387 for (a = adj_bytesize; a; a = a->next)
1389 printf ("\n /* %s:%d */\n s = %s;\n",
1390 a->file, a->line, a->adjustment);
1391 printf (" mode_size[%smode] = s;\n", a->mode->name);
1392 printf (" mode_base_align[%smode] = s & (~s + 1);\n",
1393 a->mode->name);
1395 for (m = a->mode->contained; m; m = m->next_cont)
1397 switch (m->cl)
1399 case MODE_COMPLEX_INT:
1400 case MODE_COMPLEX_FLOAT:
1401 printf (" mode_size[%smode] = 2*s;\n", m->name);
1402 printf (" mode_base_align[%smode] = s & (~s + 1);\n",
1403 m->name);
1404 break;
1406 case MODE_VECTOR_INT:
1407 case MODE_VECTOR_FLOAT:
1408 case MODE_VECTOR_FRACT:
1409 case MODE_VECTOR_UFRACT:
1410 case MODE_VECTOR_ACCUM:
1411 case MODE_VECTOR_UACCUM:
1412 printf (" mode_size[%smode] = %d*s;\n",
1413 m->name, m->ncomponents);
1414 printf (" mode_base_align[%smode] = (%d*s) & (~(%d*s)+1);\n",
1415 m->name, m->ncomponents, m->ncomponents);
1416 break;
1418 default:
1419 internal_error (
1420 "mode %s is neither vector nor complex but contains %s",
1421 m->name, a->mode->name);
1422 /* NOTREACHED */
1427 /* Alignment adjustments propagate too.
1428 ??? This may not be the right thing for vector modes. */
1429 for (a = adj_alignment; a; a = a->next)
1431 printf ("\n /* %s:%d */\n s = %s;\n",
1432 a->file, a->line, a->adjustment);
1433 printf (" mode_base_align[%smode] = s;\n", a->mode->name);
1435 for (m = a->mode->contained; m; m = m->next_cont)
1437 switch (m->cl)
1439 case MODE_COMPLEX_INT:
1440 case MODE_COMPLEX_FLOAT:
1441 printf (" mode_base_align[%smode] = s;\n", m->name);
1442 break;
1444 case MODE_VECTOR_INT:
1445 case MODE_VECTOR_FLOAT:
1446 case MODE_VECTOR_FRACT:
1447 case MODE_VECTOR_UFRACT:
1448 case MODE_VECTOR_ACCUM:
1449 case MODE_VECTOR_UACCUM:
1450 printf (" mode_base_align[%smode] = %d*s;\n",
1451 m->name, m->ncomponents);
1452 break;
1454 default:
1455 internal_error (
1456 "mode %s is neither vector nor complex but contains %s",
1457 m->name, a->mode->name);
1458 /* NOTREACHED */
1463 /* Ibit adjustments don't have to propagate. */
1464 for (a = adj_ibit; a; a = a->next)
1466 printf ("\n /* %s:%d */\n s = %s;\n",
1467 a->file, a->line, a->adjustment);
1468 printf (" mode_ibit[%smode] = s;\n", a->mode->name);
1471 /* Fbit adjustments don't have to propagate. */
1472 for (a = adj_fbit; a; a = a->next)
1474 printf ("\n /* %s:%d */\n s = %s;\n",
1475 a->file, a->line, a->adjustment);
1476 printf (" mode_fbit[%smode] = s;\n", a->mode->name);
1479 /* Real mode formats don't have to propagate anywhere. */
1480 for (a = adj_format; a; a = a->next)
1481 printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (%smode) = %s;\n",
1482 a->file, a->line, a->mode->name, a->adjustment);
1484 puts ("}");
1487 /* Emit ibit for all modes. */
1489 static void
1490 emit_mode_ibit (void)
1492 int c;
1493 struct mode_data *m;
1495 print_maybe_const_decl ("%sunsigned char",
1496 "mode_ibit", "NUM_MACHINE_MODES",
1497 ibit);
1499 for_all_modes (c, m)
1500 tagged_printf ("%u", m->ibit, m->name);
1502 print_closer ();
1505 /* Emit fbit for all modes. */
1507 static void
1508 emit_mode_fbit (void)
1510 int c;
1511 struct mode_data *m;
1513 print_maybe_const_decl ("%sunsigned char",
1514 "mode_fbit", "NUM_MACHINE_MODES",
1515 fbit);
1517 for_all_modes (c, m)
1518 tagged_printf ("%u", m->fbit, m->name);
1520 print_closer ();
1524 static void
1525 emit_insn_modes_c (void)
1527 emit_insn_modes_c_header ();
1528 emit_mode_name ();
1529 emit_mode_class ();
1530 emit_mode_precision ();
1531 emit_mode_size ();
1532 emit_mode_nunits ();
1533 emit_mode_wider ();
1534 emit_mode_mask ();
1535 emit_mode_inner ();
1536 emit_mode_base_align ();
1537 emit_class_narrowest_mode ();
1538 emit_real_format_for_mode ();
1539 emit_mode_adjustments ();
1540 emit_mode_ibit ();
1541 emit_mode_fbit ();
1544 static void
1545 emit_min_insn_modes_c (void)
1547 emit_min_insn_modes_c_header ();
1548 emit_mode_name ();
1549 emit_mode_class ();
1550 emit_mode_wider ();
1551 emit_class_narrowest_mode ();
1554 /* Master control. */
1556 main (int argc, char **argv)
1558 bool gen_header = false, gen_min = false;
1559 progname = argv[0];
1561 if (argc == 1)
1563 else if (argc == 2 && !strcmp (argv[1], "-h"))
1564 gen_header = true;
1565 else if (argc == 2 && !strcmp (argv[1], "-m"))
1566 gen_min = true;
1567 else
1569 error ("usage: %s [-h|-m] > file", progname);
1570 return FATAL_EXIT_CODE;
1573 modes_by_name = htab_create_alloc (64, hash_mode, eq_mode, 0, xcalloc, free);
1575 create_modes ();
1576 complete_all_modes ();
1578 if (have_error)
1579 return FATAL_EXIT_CODE;
1581 calc_wider_mode ();
1583 if (gen_header)
1584 emit_insn_modes_h ();
1585 else if (gen_min)
1586 emit_min_insn_modes_c ();
1587 else
1588 emit_insn_modes_c ();
1590 if (fflush (stdout) || fclose (stdout))
1591 return FATAL_EXIT_CODE;
1592 return SUCCESS_EXIT_CODE;