]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/genmodes.c
poly_int: GET_MODE_SIZE
[thirdparty/gcc.git] / gcc / genmodes.c
CommitLineData
47a2c1d4 1/* Generate the machine mode enumeration and associated tables.
8e8f6434 2 Copyright (C) 2003-2018 Free Software Foundation, Inc.
47a2c1d4 3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8c4c00c1 8Software Foundation; either version 3, or (at your option) any later
47a2c1d4 9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
8c4c00c1 17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
47a2c1d4 19
20#include "bconfig.h"
21#include "system.h"
22#include "errors.h"
23
24/* enum mode_class is normally defined by machmode.h but we can't
25 include that header here. */
26#include "mode-classes.def"
27
28#define DEF_MODE_CLASS(M) M
29enum mode_class { MODE_CLASSES, MAX_MODE_CLASS };
30#undef DEF_MODE_CLASS
31
32/* Text names of mode classes, for output. */
33#define DEF_MODE_CLASS(M) #M
34static const char *const mode_class_names[MAX_MODE_CLASS] =
35{
36 MODE_CLASSES
37};
38#undef DEF_MODE_CLASS
39#undef MODE_CLASSES
40
41#ifdef EXTRA_MODES_FILE
42# define HAVE_EXTRA_MODES 1
43#else
44# define HAVE_EXTRA_MODES 0
45# define EXTRA_MODES_FILE ""
46#endif
47
48/* Data structure for building up what we know about a mode.
49 They're clustered by mode class. */
50struct mode_data
51{
52 struct mode_data *next; /* next this class - arbitrary order */
53
54 const char *name; /* printable mode name -- SI, not SImode */
e916c70c 55 enum mode_class cl; /* this mode class */
7c0390e7 56 unsigned int precision; /* size in bits, equiv to TYPE_PRECISION */
47a2c1d4 57 unsigned int bytesize; /* storage size in addressable units */
58 unsigned int ncomponents; /* number of subunits */
59 unsigned int alignment; /* mode alignment */
3c28f41a 60 const char *format; /* floating point format - float modes only */
47a2c1d4 61
62 struct mode_data *component; /* mode of components */
63 struct mode_data *wider; /* next wider mode */
64
b8bc42e9 65 struct mode_data *contained; /* Pointer to list of modes that have
66 this mode as a component. */
67 struct mode_data *next_cont; /* Next mode in that list. */
68
3c62cae0 69 struct mode_data *complex; /* complex type with mode as component. */
47a2c1d4 70 const char *file; /* file and line of definition, */
71 unsigned int line; /* for error reporting */
3c28f41a 72 unsigned int counter; /* Rank ordering of modes */
c559c639 73 unsigned int ibit; /* the number of integral bits */
74 unsigned int fbit; /* the number of fractional bits */
e2ec52ca 75 bool need_bytesize_adj; /* true if this mode need dynamic size
76 adjustment */
9f75f026 77 unsigned int int_n; /* If nonzero, then __int<INT_N> will be defined */
47a2c1d4 78};
79
f58875bf 80static struct mode_data *modes[MAX_MODE_CLASS];
47a2c1d4 81static unsigned int n_modes[MAX_MODE_CLASS];
82static struct mode_data *void_mode;
83
84static const struct mode_data blank_mode = {
85 0, "<unknown>", MAX_MODE_CLASS,
e916c70c 86 -1U, -1U, -1U, -1U,
3c62cae0 87 0, 0, 0, 0, 0, 0,
9f75f026 88 "<unknown>", 0, 0, 0, 0, false, 0
47a2c1d4 89};
90
f58875bf 91static htab_t modes_by_name;
92
93/* Data structure for recording target-specified runtime adjustments
94 to a particular mode. We support varying the byte size, the
95 alignment, and the floating point format. */
96struct mode_adjust
97{
98 struct mode_adjust *next;
99 struct mode_data *mode;
100 const char *adjustment;
101
102 const char *file;
103 unsigned int line;
104};
105
106static struct mode_adjust *adj_bytesize;
107static struct mode_adjust *adj_alignment;
108static struct mode_adjust *adj_format;
c559c639 109static struct mode_adjust *adj_ibit;
110static struct mode_adjust *adj_fbit;
f58875bf 111
47a2c1d4 112/* Mode class operations. */
113static enum mode_class
e916c70c 114complex_class (enum mode_class c)
47a2c1d4 115{
e916c70c 116 switch (c)
47a2c1d4 117 {
118 case MODE_INT: return MODE_COMPLEX_INT;
119 case MODE_FLOAT: return MODE_COMPLEX_FLOAT;
120 default:
e916c70c 121 error ("no complex class for class %s", mode_class_names[c]);
47a2c1d4 122 return MODE_RANDOM;
123 }
124}
125
126static enum mode_class
e916c70c 127vector_class (enum mode_class cl)
47a2c1d4 128{
e916c70c 129 switch (cl)
47a2c1d4 130 {
131 case MODE_INT: return MODE_VECTOR_INT;
132 case MODE_FLOAT: return MODE_VECTOR_FLOAT;
c559c639 133 case MODE_FRACT: return MODE_VECTOR_FRACT;
134 case MODE_UFRACT: return MODE_VECTOR_UFRACT;
135 case MODE_ACCUM: return MODE_VECTOR_ACCUM;
136 case MODE_UACCUM: return MODE_VECTOR_UACCUM;
47a2c1d4 137 default:
e916c70c 138 error ("no vector class for class %s", mode_class_names[cl]);
47a2c1d4 139 return MODE_RANDOM;
140 }
141}
142
f58875bf 143/* Utility routines. */
144static inline struct mode_data *
145find_mode (const char *name)
47a2c1d4 146{
f58875bf 147 struct mode_data key;
47a2c1d4 148
f58875bf 149 key.name = name;
e916c70c 150 return (struct mode_data *) htab_find (modes_by_name, &key);
47a2c1d4 151}
152
153static struct mode_data *
e916c70c 154new_mode (enum mode_class cl, const char *name,
47a2c1d4 155 const char *file, unsigned int line)
156{
157 struct mode_data *m;
3c28f41a 158 static unsigned int count = 0;
47a2c1d4 159
f58875bf 160 m = find_mode (name);
47a2c1d4 161 if (m)
162 {
163 error ("%s:%d: duplicate definition of mode \"%s\"",
164 trim_filename (file), line, name);
165 error ("%s:%d: previous definition here", m->file, m->line);
166 return m;
167 }
168
e916c70c 169 m = XNEW (struct mode_data);
47a2c1d4 170 memcpy (m, &blank_mode, sizeof (struct mode_data));
e916c70c 171 m->cl = cl;
47a2c1d4 172 m->name = name;
173 if (file)
174 m->file = trim_filename (file);
175 m->line = line;
3c28f41a 176 m->counter = count++;
47a2c1d4 177
e916c70c 178 m->next = modes[cl];
179 modes[cl] = m;
180 n_modes[cl]++;
f58875bf 181
182 *htab_find_slot (modes_by_name, m, INSERT) = m;
48e1416a 183
47a2c1d4 184 return m;
185}
186
f58875bf 187static hashval_t
188hash_mode (const void *p)
189{
190 const struct mode_data *m = (const struct mode_data *)p;
191 return htab_hash_string (m->name);
192}
193
194static int
195eq_mode (const void *p, const void *q)
196{
197 const struct mode_data *a = (const struct mode_data *)p;
198 const struct mode_data *b = (const struct mode_data *)q;
199
200 return !strcmp (a->name, b->name);
201}
202
47a2c1d4 203#define for_all_modes(C, M) \
204 for (C = 0; C < MAX_MODE_CLASS; C++) \
f58875bf 205 for (M = modes[C]; M; M = M->next)
206
207static void ATTRIBUTE_UNUSED
208new_adjust (const char *name,
209 struct mode_adjust **category, const char *catname,
210 const char *adjustment,
c559c639 211 enum mode_class required_class_from,
212 enum mode_class required_class_to,
f58875bf 213 const char *file, unsigned int line)
214{
215 struct mode_data *mode = find_mode (name);
216 struct mode_adjust *a;
217
218 file = trim_filename (file);
219
220 if (!mode)
221 {
222 error ("%s:%d: no mode \"%s\"", file, line, name);
223 return;
224 }
225
c559c639 226 if (required_class_from != MODE_RANDOM
227 && (mode->cl < required_class_from || mode->cl > required_class_to))
f58875bf 228 {
c559c639 229 error ("%s:%d: mode \"%s\" is not among class {%s, %s}",
230 file, line, name, mode_class_names[required_class_from] + 5,
231 mode_class_names[required_class_to] + 5);
f58875bf 232 return;
233 }
48e1416a 234
f58875bf 235 for (a = *category; a; a = a->next)
236 if (a->mode == mode)
237 {
238 error ("%s:%d: mode \"%s\" already has a %s adjustment",
239 file, line, name, catname);
240 error ("%s:%d: previous adjustment here", a->file, a->line);
241 return;
242 }
243
9318f22c 244 a = XNEW (struct mode_adjust);
f58875bf 245 a->mode = mode;
246 a->adjustment = adjustment;
247 a->file = file;
248 a->line = line;
249
250 a->next = *category;
251 *category = a;
252}
47a2c1d4 253
254/* Diagnose failure to meet expectations in a partially filled out
255 mode structure. */
256enum requirement { SET, UNSET, OPTIONAL };
257
258#define validate_field_(mname, fname, req, val, unset, file, line) do { \
259 switch (req) \
260 { \
261 case SET: \
262 if (val == unset) \
263 error ("%s:%d: (%s) field %s must be set", \
264 file, line, mname, fname); \
265 break; \
266 case UNSET: \
267 if (val != unset) \
268 error ("%s:%d: (%s) field %s must not be set", \
269 file, line, mname, fname); \
270 case OPTIONAL: \
271 break; \
272 } \
273} while (0)
274
275#define validate_field(M, F) \
276 validate_field_(M->name, #F, r_##F, M->F, blank_mode.F, M->file, M->line)
277
278static void
279validate_mode (struct mode_data *m,
7c0390e7 280 enum requirement r_precision,
47a2c1d4 281 enum requirement r_bytesize,
282 enum requirement r_component,
15460c97 283 enum requirement r_ncomponents,
284 enum requirement r_format)
47a2c1d4 285{
7c0390e7 286 validate_field (m, precision);
47a2c1d4 287 validate_field (m, bytesize);
288 validate_field (m, component);
289 validate_field (m, ncomponents);
15460c97 290 validate_field (m, format);
47a2c1d4 291}
292#undef validate_field
293#undef validate_field_
294
295/* Given a partially-filled-out mode structure, figure out what we can
296 and fill the rest of it in; die if it isn't enough. */
297static void
298complete_mode (struct mode_data *m)
299{
300 unsigned int alignment;
301
302 if (!m->name)
303 {
304 error ("%s:%d: mode with no name", m->file, m->line);
305 return;
306 }
e916c70c 307 if (m->cl == MAX_MODE_CLASS)
47a2c1d4 308 {
309 error ("%s:%d: %smode has no mode class", m->file, m->line, m->name);
310 return;
311 }
312
e916c70c 313 switch (m->cl)
47a2c1d4 314 {
315 case MODE_RANDOM:
316 /* Nothing more need be said. */
317 if (!strcmp (m->name, "VOID"))
318 void_mode = m;
319
15460c97 320 validate_mode (m, UNSET, UNSET, UNSET, UNSET, UNSET);
47a2c1d4 321
7c0390e7 322 m->precision = 0;
47a2c1d4 323 m->bytesize = 0;
324 m->ncomponents = 0;
325 m->component = 0;
326 break;
327
328 case MODE_CC:
329 /* Again, nothing more need be said. For historical reasons,
330 the size of a CC mode is four units. */
15460c97 331 validate_mode (m, UNSET, UNSET, UNSET, UNSET, UNSET);
47a2c1d4 332
333 m->bytesize = 4;
24b7dafb 334 m->ncomponents = 1;
47a2c1d4 335 m->component = 0;
336 break;
337
338 case MODE_INT:
058a1b7a 339 case MODE_POINTER_BOUNDS:
47a2c1d4 340 case MODE_FLOAT:
3c28f41a 341 case MODE_DECIMAL_FLOAT:
c559c639 342 case MODE_FRACT:
343 case MODE_UFRACT:
344 case MODE_ACCUM:
345 case MODE_UACCUM:
47a2c1d4 346 /* A scalar mode must have a byte size, may have a bit size,
15460c97 347 and must not have components. A float mode must have a
348 format. */
349 validate_mode (m, OPTIONAL, SET, UNSET, UNSET,
c559c639 350 (m->cl == MODE_FLOAT || m->cl == MODE_DECIMAL_FLOAT)
351 ? SET : UNSET);
47a2c1d4 352
24b7dafb 353 m->ncomponents = 1;
47a2c1d4 354 m->component = 0;
355 break;
356
357 case MODE_PARTIAL_INT:
358 /* A partial integer mode uses ->component to say what the
359 corresponding full-size integer mode is, and may also
360 specify a bit size. */
15460c97 361 validate_mode (m, OPTIONAL, UNSET, SET, UNSET, UNSET);
47a2c1d4 362
363 m->bytesize = m->component->bytesize;
364
24b7dafb 365 m->ncomponents = 1;
47a2c1d4 366 break;
367
368 case MODE_COMPLEX_INT:
369 case MODE_COMPLEX_FLOAT:
370 /* Complex modes should have a component indicated, but no more. */
15460c97 371 validate_mode (m, UNSET, UNSET, SET, UNSET, UNSET);
47a2c1d4 372 m->ncomponents = 2;
7c0390e7 373 if (m->component->precision != (unsigned int)-1)
374 m->precision = 2 * m->component->precision;
47a2c1d4 375 m->bytesize = 2 * m->component->bytesize;
376 break;
377
378 case MODE_VECTOR_INT:
379 case MODE_VECTOR_FLOAT:
c559c639 380 case MODE_VECTOR_FRACT:
381 case MODE_VECTOR_UFRACT:
382 case MODE_VECTOR_ACCUM:
383 case MODE_VECTOR_UACCUM:
47a2c1d4 384 /* Vector modes should have a component and a number of components. */
15460c97 385 validate_mode (m, UNSET, UNSET, SET, SET, UNSET);
7c0390e7 386 if (m->component->precision != (unsigned int)-1)
387 m->precision = m->ncomponents * m->component->precision;
47a2c1d4 388 m->bytesize = m->ncomponents * m->component->bytesize;
389 break;
390
391 default:
e0a4c0c2 392 gcc_unreachable ();
47a2c1d4 393 }
394
395 /* If not already specified, the mode alignment defaults to the largest
396 power of two that divides the size of the object. Complex types are
397 not more aligned than their contents. */
e916c70c 398 if (m->cl == MODE_COMPLEX_INT || m->cl == MODE_COMPLEX_FLOAT)
47a2c1d4 399 alignment = m->component->bytesize;
400 else
401 alignment = m->bytesize;
402
403 m->alignment = alignment & (~alignment + 1);
b8bc42e9 404
405 /* If this mode has components, make the component mode point back
406 to this mode, for the sake of adjustments. */
407 if (m->component)
408 {
409 m->next_cont = m->component->contained;
410 m->component->contained = m;
411 }
47a2c1d4 412}
413
414static void
415complete_all_modes (void)
416{
417 struct mode_data *m;
e916c70c 418 int cl;
419
420 for_all_modes (cl, m)
47a2c1d4 421 complete_mode (m);
422}
423
424/* For each mode in class CLASS, construct a corresponding complex mode. */
9af5ce0c 425#define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, __LINE__)
47a2c1d4 426static void
e916c70c 427make_complex_modes (enum mode_class cl,
47a2c1d4 428 const char *file, unsigned int line)
429{
430 struct mode_data *m;
431 struct mode_data *c;
e916c70c 432 enum mode_class cclass = complex_class (cl);
47a2c1d4 433
434 if (cclass == MODE_RANDOM)
435 return;
e916c70c 436
437 for (m = modes[cl]; m; m = m->next)
47a2c1d4 438 {
cdf7d299 439 char *p, *buf;
2e045eaa 440 size_t m_len;
441
47a2c1d4 442 /* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */
7c0390e7 443 if (m->precision == 1)
47a2c1d4 444 continue;
445
2e045eaa 446 m_len = strlen (m->name);
cdf7d299 447 /* The leading "1 +" is in case we prepend a "C" below. */
448 buf = (char *) xmalloc (1 + m_len + 1);
47a2c1d4 449
450 /* Float complex modes are named SCmode, etc.
451 Int complex modes are named CSImode, etc.
452 This inconsistency should be eliminated. */
cdf7d299 453 p = 0;
e916c70c 454 if (cl == MODE_FLOAT)
47a2c1d4 455 {
2e045eaa 456 memcpy (buf, m->name, m_len + 1);
47a2c1d4 457 p = strchr (buf, 'F');
cdf7d299 458 if (p == 0 && strchr (buf, 'D') == 0)
47a2c1d4 459 {
3c28f41a 460 error ("%s:%d: float mode \"%s\" has no 'F' or 'D'",
47a2c1d4 461 m->file, m->line, m->name);
cdf7d299 462 free (buf);
47a2c1d4 463 continue;
464 }
47a2c1d4 465 }
cdf7d299 466 if (p != 0)
467 *p = 'C';
47a2c1d4 468 else
cdf7d299 469 {
470 buf[0] = 'C';
471 memcpy (buf + 1, m->name, m_len + 1);
472 }
47a2c1d4 473
cdf7d299 474 c = new_mode (cclass, buf, file, line);
47a2c1d4 475 c->component = m;
3c62cae0 476 m->complex = c;
47a2c1d4 477 }
478}
479
e916c70c 480/* For all modes in class CL, construct vector modes of width
47a2c1d4 481 WIDTH, having as many components as necessary. */
9af5ce0c 482#define VECTOR_MODES(C, W) make_vector_modes (MODE_##C, W, __FILE__, __LINE__)
259ff179 483static void ATTRIBUTE_UNUSED
e916c70c 484make_vector_modes (enum mode_class cl, unsigned int width,
47a2c1d4 485 const char *file, unsigned int line)
486{
487 struct mode_data *m;
488 struct mode_data *v;
b18dea91 489 /* Big enough for a 32-bit UINT_MAX plus the text. */
490 char buf[12];
47a2c1d4 491 unsigned int ncomponents;
e916c70c 492 enum mode_class vclass = vector_class (cl);
47a2c1d4 493
494 if (vclass == MODE_RANDOM)
495 return;
496
e916c70c 497 for (m = modes[cl]; m; m = m->next)
47a2c1d4 498 {
499 /* Do not construct vector modes with only one element, or
500 vector modes where the element size doesn't divide the full
501 size evenly. */
502 ncomponents = width / m->bytesize;
503 if (ncomponents < 2)
504 continue;
505 if (width % m->bytesize)
506 continue;
507
508 /* Skip QFmode and BImode. FIXME: this special case should
509 not be necessary. */
e916c70c 510 if (cl == MODE_FLOAT && m->bytesize == 1)
47a2c1d4 511 continue;
e916c70c 512 if (cl == MODE_INT && m->precision == 1)
47a2c1d4 513 continue;
514
515 if ((size_t)snprintf (buf, sizeof buf, "V%u%s", ncomponents, m->name)
516 >= sizeof buf)
517 {
518 error ("%s:%d: mode name \"%s\" is too long",
519 m->file, m->line, m->name);
520 continue;
521 }
522
523 v = new_mode (vclass, xstrdup (buf), file, line);
524 v->component = m;
525 v->ncomponents = ncomponents;
526 }
527}
528
529/* Input. */
530
9af5ce0c 531#define _SPECIAL_MODE(C, N) \
532 make_special_mode (MODE_##C, #N, __FILE__, __LINE__)
47a2c1d4 533#define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N)
534#define CC_MODE(N) _SPECIAL_MODE (CC, N)
535
536static void
e916c70c 537make_special_mode (enum mode_class cl, const char *name,
47a2c1d4 538 const char *file, unsigned int line)
539{
e916c70c 540 new_mode (cl, name, file, line);
47a2c1d4 541}
542
058a1b7a 543#define POINTER_BOUNDS_MODE(N, Y) \
544 make_pointer_bounds_mode (#N, Y, __FILE__, __LINE__)
545
546static void ATTRIBUTE_UNUSED
547make_pointer_bounds_mode (const char *name,
548 unsigned int bytesize,
549 const char *file, unsigned int line)
550{
551 struct mode_data *m = new_mode (MODE_POINTER_BOUNDS, name, file, line);
552 m->bytesize = bytesize;
553}
554
555
e916c70c 556#define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
15460c97 557#define FRACTIONAL_INT_MODE(N, B, Y) \
558 make_int_mode (#N, B, Y, __FILE__, __LINE__)
47a2c1d4 559
15460c97 560static void
561make_int_mode (const char *name,
7c0390e7 562 unsigned int precision, unsigned int bytesize,
15460c97 563 const char *file, unsigned int line)
564{
565 struct mode_data *m = new_mode (MODE_INT, name, file, line);
566 m->bytesize = bytesize;
7c0390e7 567 m->precision = precision;
15460c97 568}
569
c559c639 570#define FRACT_MODE(N, Y, F) \
571 make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, __LINE__)
572
573#define UFRACT_MODE(N, Y, F) \
574 make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, __LINE__)
575
576#define ACCUM_MODE(N, Y, I, F) \
577 make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, __LINE__)
578
579#define UACCUM_MODE(N, Y, I, F) \
580 make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, __LINE__)
581
582/* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT,
583 FILE, and LINE. */
584
585static void
586make_fixed_point_mode (enum mode_class cl,
587 const char *name,
588 unsigned int bytesize,
589 unsigned int ibit,
590 unsigned int fbit,
591 const char *file, unsigned int line)
592{
593 struct mode_data *m = new_mode (cl, name, file, line);
594 m->bytesize = bytesize;
595 m->ibit = ibit;
596 m->fbit = fbit;
597}
598
e916c70c 599#define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F)
15460c97 600#define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
601 make_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
47a2c1d4 602
603static void
15460c97 604make_float_mode (const char *name,
7c0390e7 605 unsigned int precision, unsigned int bytesize,
15460c97 606 const char *format,
607 const char *file, unsigned int line)
47a2c1d4 608{
15460c97 609 struct mode_data *m = new_mode (MODE_FLOAT, name, file, line);
47a2c1d4 610 m->bytesize = bytesize;
7c0390e7 611 m->precision = precision;
15460c97 612 m->format = format;
613}
614
3c28f41a 615#define DECIMAL_FLOAT_MODE(N, Y, F) \
616 FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F)
617#define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \
618 make_decimal_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
619
620static void
621make_decimal_float_mode (const char *name,
622 unsigned int precision, unsigned int bytesize,
623 const char *format,
624 const char *file, unsigned int line)
625{
626 struct mode_data *m = new_mode (MODE_DECIMAL_FLOAT, name, file, line);
627 m->bytesize = bytesize;
628 m->precision = precision;
629 m->format = format;
630}
631
15460c97 632#define RESET_FLOAT_FORMAT(N, F) \
633 reset_float_format (#N, #F, __FILE__, __LINE__)
634static void ATTRIBUTE_UNUSED
635reset_float_format (const char *name, const char *format,
f58875bf 636 const char *file, unsigned int line)
15460c97 637{
f58875bf 638 struct mode_data *m = find_mode (name);
15460c97 639 if (!m)
640 {
f58875bf 641 error ("%s:%d: no mode \"%s\"", file, line, name);
642 return;
643 }
3c28f41a 644 if (m->cl != MODE_FLOAT && m->cl != MODE_DECIMAL_FLOAT)
f58875bf 645 {
3c28f41a 646 error ("%s:%d: mode \"%s\" is not a FLOAT class", file, line, name);
15460c97 647 return;
648 }
649 m->format = format;
47a2c1d4 650}
651
9f75f026 652/* __intN support. */
653#define INT_N(M,PREC) \
654 make_int_n (#M, PREC, __FILE__, __LINE__)
655static void ATTRIBUTE_UNUSED
656make_int_n (const char *m, int bitsize,
657 const char *file, unsigned int line)
658{
659 struct mode_data *component = find_mode (m);
660 if (!component)
661 {
662 error ("%s:%d: no mode \"%s\"", file, line, m);
663 return;
664 }
665 if (component->cl != MODE_INT
666 && component->cl != MODE_PARTIAL_INT)
667 {
668 error ("%s:%d: mode \"%s\" is not class INT or PARTIAL_INT", file, line, m);
669 return;
670 }
671 if (component->int_n != 0)
672 {
673 error ("%s:%d: mode \"%s\" already has an intN", file, line, m);
674 return;
675 }
676
677 component->int_n = bitsize;
678}
679
0d58d930 680/* Partial integer modes are specified by relation to a full integer
681 mode. */
682#define PARTIAL_INT_MODE(M,PREC,NAME) \
683 make_partial_integer_mode (#M, #NAME, PREC, __FILE__, __LINE__)
47a2c1d4 684static void ATTRIBUTE_UNUSED
685make_partial_integer_mode (const char *base, const char *name,
7c0390e7 686 unsigned int precision,
47a2c1d4 687 const char *file, unsigned int line)
688{
689 struct mode_data *m;
f58875bf 690 struct mode_data *component = find_mode (base);
47a2c1d4 691 if (!component)
692 {
f58875bf 693 error ("%s:%d: no mode \"%s\"", file, line, name);
694 return;
695 }
e916c70c 696 if (component->cl != MODE_INT)
f58875bf 697 {
698 error ("%s:%d: mode \"%s\" is not class INT", file, line, name);
47a2c1d4 699 return;
700 }
e916c70c 701
47a2c1d4 702 m = new_mode (MODE_PARTIAL_INT, name, file, line);
7c0390e7 703 m->precision = precision;
47a2c1d4 704 m->component = component;
705}
706
707/* A single vector mode can be specified by naming its component
708 mode and the number of components. */
709#define VECTOR_MODE(C, M, N) \
710 make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__);
711static void ATTRIBUTE_UNUSED
712make_vector_mode (enum mode_class bclass,
713 const char *base,
714 unsigned int ncomponents,
715 const char *file, unsigned int line)
716{
717 struct mode_data *v;
718 enum mode_class vclass = vector_class (bclass);
f58875bf 719 struct mode_data *component = find_mode (base);
0d58d930 720 char namebuf[16];
47a2c1d4 721
722 if (vclass == MODE_RANDOM)
723 return;
724 if (component == 0)
725 {
f58875bf 726 error ("%s:%d: no mode \"%s\"", file, line, base);
727 return;
728 }
0bdbecff 729 if (component->cl != bclass
730 && (component->cl != MODE_PARTIAL_INT
731 || bclass != MODE_INT))
f58875bf 732 {
733 error ("%s:%d: mode \"%s\" is not class %s",
47a2c1d4 734 file, line, base, mode_class_names[bclass] + 5);
735 return;
736 }
737
738 if ((size_t)snprintf (namebuf, sizeof namebuf, "V%u%s",
739 ncomponents, base) >= sizeof namebuf)
740 {
741 error ("%s:%d: mode name \"%s\" is too long",
99cb7891 742 file, line, base);
47a2c1d4 743 return;
744 }
745
746 v = new_mode (vclass, xstrdup (namebuf), file, line);
747 v->ncomponents = ncomponents;
748 v->component = component;
749}
f58875bf 750
751/* Adjustability. */
c559c639 752#define _ADD_ADJUST(A, M, X, C1, C2) \
753 new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, __LINE__)
f58875bf 754
9af5ce0c 755#define ADJUST_BYTESIZE(M, X) _ADD_ADJUST (bytesize, M, X, RANDOM, RANDOM)
756#define ADJUST_ALIGNMENT(M, X) _ADD_ADJUST (alignment, M, X, RANDOM, RANDOM)
757#define ADJUST_FLOAT_FORMAT(M, X) _ADD_ADJUST (format, M, X, FLOAT, FLOAT)
758#define ADJUST_IBIT(M, X) _ADD_ADJUST (ibit, M, X, ACCUM, UACCUM)
759#define ADJUST_FBIT(M, X) _ADD_ADJUST (fbit, M, X, FRACT, UACCUM)
47a2c1d4 760
2cb32abf 761static int bits_per_unit;
762static int max_bitsize_mode_any_int;
763
47a2c1d4 764static void
765create_modes (void)
766{
767#include "machmode.def"
2cb32abf 768
769 /* So put the default value unless the target needs a non standard
770 value. */
771#ifdef BITS_PER_UNIT
772 bits_per_unit = BITS_PER_UNIT;
773#else
774 bits_per_unit = 8;
775#endif
776
777#ifdef MAX_BITSIZE_MODE_ANY_INT
778 max_bitsize_mode_any_int = MAX_BITSIZE_MODE_ANY_INT;
779#else
780 max_bitsize_mode_any_int = 0;
781#endif
47a2c1d4 782}
783
466432a3 784#ifndef NUM_POLY_INT_COEFFS
785#define NUM_POLY_INT_COEFFS 1
786#endif
787
47a2c1d4 788/* Processing. */
789
790/* Sort a list of modes into the order needed for the WIDER field:
7c0390e7 791 major sort by precision, minor sort by component precision.
47a2c1d4 792
793 For instance:
794 QI < HI < SI < DI < TI
795 V4QI < V2HI < V8QI < V4HI < V2SI.
796
7c0390e7 797 If the precision is not set, sort by the bytesize. A mode with
798 precision set gets sorted before a mode without precision set, if
47a2c1d4 799 they have the same bytesize; this is the right thing because
7c0390e7 800 the precision must always be smaller than the bytesize * BITS_PER_UNIT.
47a2c1d4 801 We don't have to do anything special to get this done -- an unset
7c0390e7 802 precision shows up as (unsigned int)-1, i.e. UINT_MAX. */
47a2c1d4 803static int
804cmp_modes (const void *a, const void *b)
805{
aae87fc3 806 const struct mode_data *const m = *(const struct mode_data *const*)a;
807 const struct mode_data *const n = *(const struct mode_data *const*)b;
47a2c1d4 808
809 if (m->bytesize > n->bytesize)
810 return 1;
811 else if (m->bytesize < n->bytesize)
812 return -1;
813
7c0390e7 814 if (m->precision > n->precision)
47a2c1d4 815 return 1;
7c0390e7 816 else if (m->precision < n->precision)
47a2c1d4 817 return -1;
818
819 if (!m->component && !n->component)
3c28f41a 820 {
821 if (m->counter < n->counter)
822 return -1;
823 else
824 return 1;
825 }
47a2c1d4 826
827 if (m->component->bytesize > n->component->bytesize)
828 return 1;
829 else if (m->component->bytesize < n->component->bytesize)
830 return -1;
831
7c0390e7 832 if (m->component->precision > n->component->precision)
47a2c1d4 833 return 1;
7c0390e7 834 else if (m->component->precision < n->component->precision)
47a2c1d4 835 return -1;
836
3c28f41a 837 if (m->counter < n->counter)
838 return -1;
839 else
840 return 1;
47a2c1d4 841}
842
843static void
844calc_wider_mode (void)
845{
e916c70c 846 int c;
47a2c1d4 847 struct mode_data *m;
848 struct mode_data **sortbuf;
849 unsigned int max_n_modes = 0;
850 unsigned int i, j;
851
852 for (c = 0; c < MAX_MODE_CLASS; c++)
853 max_n_modes = MAX (max_n_modes, n_modes[c]);
854
f0873ccc 855 /* Allocate max_n_modes + 1 entries to leave room for the extra null
856 pointer assigned after the qsort call below. */
de44e2b0 857 sortbuf = XALLOCAVEC (struct mode_data *, max_n_modes + 1);
47a2c1d4 858
859 for (c = 0; c < MAX_MODE_CLASS; c++)
860 {
861 /* "wider" is not meaningful for MODE_RANDOM and MODE_CC.
862 However, we want these in textual order, and we have
863 precisely the reverse. */
864 if (c == MODE_RANDOM || c == MODE_CC)
865 {
866 struct mode_data *prev, *next;
867
f58875bf 868 for (prev = 0, m = modes[c]; m; m = next)
47a2c1d4 869 {
870 m->wider = void_mode;
871
872 /* this is nreverse */
873 next = m->next;
874 m->next = prev;
875 prev = m;
876 }
f58875bf 877 modes[c] = prev;
47a2c1d4 878 }
879 else
880 {
f58875bf 881 if (!modes[c])
47a2c1d4 882 continue;
883
f58875bf 884 for (i = 0, m = modes[c]; m; i++, m = m->next)
47a2c1d4 885 sortbuf[i] = m;
886
c3808779 887 (qsort) (sortbuf, i, sizeof (struct mode_data *), cmp_modes);
47a2c1d4 888
889 sortbuf[i] = 0;
890 for (j = 0; j < i; j++)
c8076084 891 {
892 sortbuf[j]->next = sortbuf[j + 1];
893 if (c == MODE_PARTIAL_INT)
894 sortbuf[j]->wider = sortbuf[j]->component;
895 else
896 sortbuf[j]->wider = sortbuf[j]->next;
897 }
47a2c1d4 898
f58875bf 899 modes[c] = sortbuf[0];
47a2c1d4 900 }
901 }
902}
903
ba7efd65 904/* Text to add to the constant part of a poly_int_pod initializer in
905 order to fill out te whole structure. */
906#if NUM_POLY_INT_COEFFS == 1
907#define ZERO_COEFFS ""
908#elif NUM_POLY_INT_COEFFS == 2
909#define ZERO_COEFFS ", 0"
910#else
911#error "Unknown value of NUM_POLY_INT_COEFFS"
912#endif
913
47a2c1d4 914/* Output routines. */
915
916#define tagged_printf(FMT, ARG, TAG) do { \
cc253ec9 917 int count_ = printf (" " FMT ",", ARG); \
47a2c1d4 918 printf ("%*s/* %s */\n", 27 - count_, "", TAG); \
919} while (0)
920
921#define print_decl(TYPE, NAME, ASIZE) \
f58875bf 922 puts ("\nconst " TYPE " " NAME "[" ASIZE "] =\n{");
923
924#define print_maybe_const_decl(TYPE, NAME, ASIZE, CATEGORY) \
925 printf ("\n" TYPE " " NAME "[" ASIZE "] = \n{\n", \
926 adj_##CATEGORY ? "" : "const ")
47a2c1d4 927
928#define print_closer() puts ("};")
929
f9cb58ae 930/* Compute the max bitsize of some of the classes of integers. It may
931 be that there are needs for the other integer classes, and this
932 code is easy to extend. */
933static void
934emit_max_int (void)
935{
936 unsigned int max, mmax;
937 struct mode_data *i;
938 int j;
939
940 puts ("");
2cb32abf 941
942 printf ("#define BITS_PER_UNIT (%d)\n", bits_per_unit);
943
944 if (max_bitsize_mode_any_int == 0)
945 {
946 for (max = 1, i = modes[MODE_INT]; i; i = i->next)
947 if (max < i->bytesize)
948 max = i->bytesize;
949 mmax = max;
950 for (max = 1, i = modes[MODE_PARTIAL_INT]; i; i = i->next)
951 if (max < i->bytesize)
952 max = i->bytesize;
953 if (max > mmax)
954 mmax = max;
502c7fa9 955 printf ("#define MAX_BITSIZE_MODE_ANY_INT (%d*BITS_PER_UNIT)\n", mmax);
2cb32abf 956 }
957 else
958 printf ("#define MAX_BITSIZE_MODE_ANY_INT %d\n", max_bitsize_mode_any_int);
f9cb58ae 959
960 mmax = 0;
961 for (j = 0; j < MAX_MODE_CLASS; j++)
962 for (i = modes[j]; i; i = i->next)
963 if (mmax < i->bytesize)
964 mmax = i->bytesize;
502c7fa9 965 printf ("#define MAX_BITSIZE_MODE_ANY_MODE (%d*BITS_PER_UNIT)\n", mmax);
f9cb58ae 966}
967
e2ec52ca 968/* Emit mode_size_inline routine into insn-modes.h header. */
969static void
970emit_mode_size_inline (void)
971{
972 int c;
973 struct mode_adjust *a;
974 struct mode_data *m;
975
976 /* Size adjustments must be propagated to all containing modes. */
977 for (a = adj_bytesize; a; a = a->next)
978 {
979 a->mode->need_bytesize_adj = true;
980 for (m = a->mode->contained; m; m = m->next_cont)
981 m->need_bytesize_adj = true;
982 }
983
984 printf ("\
985#ifdef __cplusplus\n\
986inline __attribute__((__always_inline__))\n\
987#else\n\
988extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
989#endif\n\
52acb7ae 990poly_uint16\n\
3754d046 991mode_size_inline (machine_mode mode)\n\
e2ec52ca 992{\n\
52acb7ae 993 extern %spoly_uint16_pod mode_size[NUM_MACHINE_MODES];\n\
7e1856f1 994 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\
e2ec52ca 995 switch (mode)\n\
996 {\n", adj_bytesize ? "" : "const ");
997
998 for_all_modes (c, m)
999 if (!m->need_bytesize_adj)
1e0295b9 1000 printf (" case E_%smode: return %u;\n", m->name, m->bytesize);
e2ec52ca 1001
1002 puts ("\
1003 default: return mode_size[mode];\n\
1004 }\n\
1005}\n");
1006}
1007
1008/* Emit mode_nunits_inline routine into insn-modes.h header. */
1009static void
1010emit_mode_nunits_inline (void)
1011{
1012 int c;
1013 struct mode_data *m;
1014
1015 puts ("\
1016#ifdef __cplusplus\n\
1017inline __attribute__((__always_inline__))\n\
1018#else\n\
1019extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
1020#endif\n\
ba7efd65 1021poly_uint16\n\
3754d046 1022mode_nunits_inline (machine_mode mode)\n\
e2ec52ca 1023{\n\
ba7efd65 1024 extern poly_uint16_pod mode_nunits[NUM_MACHINE_MODES];\n\
e2ec52ca 1025 switch (mode)\n\
1026 {");
1027
1028 for_all_modes (c, m)
1e0295b9 1029 printf (" case E_%smode: return %u;\n", m->name, m->ncomponents);
e2ec52ca 1030
1031 puts ("\
1032 default: return mode_nunits[mode];\n\
1033 }\n\
1034}\n");
1035}
1036
1037/* Emit mode_inner_inline routine into insn-modes.h header. */
1038static void
1039emit_mode_inner_inline (void)
1040{
1041 int c;
1042 struct mode_data *m;
1043
1044 puts ("\
1045#ifdef __cplusplus\n\
1046inline __attribute__((__always_inline__))\n\
1047#else\n\
1048extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
1049#endif\n\
1050unsigned char\n\
3754d046 1051mode_inner_inline (machine_mode mode)\n\
e2ec52ca 1052{\n\
1053 extern const unsigned char mode_inner[NUM_MACHINE_MODES];\n\
7e1856f1 1054 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\
e2ec52ca 1055 switch (mode)\n\
1056 {");
1057
1058 for_all_modes (c, m)
1e0295b9 1059 printf (" case E_%smode: return E_%smode;\n", m->name,
e2ec52ca 1060 c != MODE_PARTIAL_INT && m->component
d145b68b 1061 ? m->component->name : m->name);
e2ec52ca 1062
1063 puts ("\
1064 default: return mode_inner[mode];\n\
1065 }\n\
1066}\n");
1067}
1068
a0509d0e 1069/* Emit mode_unit_size_inline routine into insn-modes.h header. */
1070static void
1071emit_mode_unit_size_inline (void)
1072{
1073 int c;
1074 struct mode_data *m;
1075
1076 puts ("\
1077#ifdef __cplusplus\n\
1078inline __attribute__((__always_inline__))\n\
1079#else\n\
1080extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
1081#endif\n\
1082unsigned char\n\
1083mode_unit_size_inline (machine_mode mode)\n\
1084{\n\
6c090767 1085 extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];\
1086\n\
7e1856f1 1087 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\
a0509d0e 1088 switch (mode)\n\
1089 {");
1090
1091 for_all_modes (c, m)
1092 {
1093 const char *name = m->name;
1094 struct mode_data *m2 = m;
1095 if (c != MODE_PARTIAL_INT && m2->component)
1096 m2 = m2->component;
1097 if (!m2->need_bytesize_adj)
1e0295b9 1098 printf (" case E_%smode: return %u;\n", name, m2->bytesize);
a0509d0e 1099 }
1100
1101 puts ("\
1102 default: return mode_unit_size[mode];\n\
1103 }\n\
1104}\n");
1105}
1106
1107/* Emit mode_unit_precision_inline routine into insn-modes.h header. */
1108static void
1109emit_mode_unit_precision_inline (void)
1110{
1111 int c;
1112 struct mode_data *m;
1113
1114 puts ("\
1115#ifdef __cplusplus\n\
1116inline __attribute__((__always_inline__))\n\
1117#else\n\
1118extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
1119#endif\n\
1120unsigned short\n\
1121mode_unit_precision_inline (machine_mode mode)\n\
1122{\n\
1123 extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];\n\
7e1856f1 1124 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\
a0509d0e 1125 switch (mode)\n\
1126 {");
1127
1128 for_all_modes (c, m)
1129 {
1130 struct mode_data *m2
1131 = (c != MODE_PARTIAL_INT && m->component) ? m->component : m;
1132 if (m2->precision != (unsigned int)-1)
1e0295b9 1133 printf (" case E_%smode: return %u;\n", m->name, m2->precision);
a0509d0e 1134 else
1e0295b9 1135 printf (" case E_%smode: return %u*BITS_PER_UNIT;\n",
a0509d0e 1136 m->name, m2->bytesize);
1137 }
1138
1139 puts ("\
1140 default: return mode_unit_precision[mode];\n\
1141 }\n\
1142}\n");
1143}
1144
47fbdc12 1145/* Return the best machine mode class for MODE, or null if machine_mode
1146 should be used. */
1147
1148static const char *
1149get_mode_class (struct mode_data *mode)
1150{
1151 switch (mode->cl)
1152 {
af8303fa 1153 case MODE_INT:
1154 case MODE_PARTIAL_INT:
1155 return "scalar_int_mode";
1156
9fcae33e 1157 case MODE_FRACT:
1158 case MODE_UFRACT:
1159 case MODE_ACCUM:
1160 case MODE_UACCUM:
1161 case MODE_POINTER_BOUNDS:
1162 return "scalar_mode";
1163
47fbdc12 1164 case MODE_FLOAT:
1165 case MODE_DECIMAL_FLOAT:
1166 return "scalar_float_mode";
1167
430c243d 1168 case MODE_COMPLEX_INT:
1169 case MODE_COMPLEX_FLOAT:
1170 return "complex_mode";
1171
47fbdc12 1172 default:
1173 return NULL;
1174 }
1175}
1176
47a2c1d4 1177static void
1178emit_insn_modes_h (void)
1179{
e916c70c 1180 int c;
47a2c1d4 1181 struct mode_data *m, *first, *last;
9f75f026 1182 int n_int_n_ents = 0;
47a2c1d4 1183
1184 printf ("/* Generated automatically from machmode.def%s%s\n",
1185 HAVE_EXTRA_MODES ? " and " : "",
1186 EXTRA_MODES_FILE);
1187
1188 puts ("\
1189 by genmodes. */\n\
1190\n\
1191#ifndef GCC_INSN_MODES_H\n\
1192#define GCC_INSN_MODES_H\n\
1193\n\
1194enum machine_mode\n{");
1195
1196 for (c = 0; c < MAX_MODE_CLASS; c++)
f58875bf 1197 for (m = modes[c]; m; m = m->next)
47a2c1d4 1198 {
1e0295b9 1199 int count_ = printf (" E_%smode,", m->name);
47a2c1d4 1200 printf ("%*s/* %s:%d */\n", 27 - count_, "",
1201 trim_filename (m->file), m->line);
d5957f0d 1202 printf ("#define HAVE_%smode\n", m->name);
fb398229 1203 printf ("#ifdef USE_ENUM_MODES\n");
1204 printf ("#define %smode E_%smode\n", m->name, m->name);
1205 printf ("#else\n");
47fbdc12 1206 if (const char *mode_class = get_mode_class (m))
1207 printf ("#define %smode (%s ((%s::from_int) E_%smode))\n",
1208 m->name, mode_class, mode_class, m->name);
1209 else
1210 printf ("#define %smode ((void) 0, E_%smode)\n",
1211 m->name, m->name);
fb398229 1212 printf ("#endif\n");
47a2c1d4 1213 }
1214
1215 puts (" MAX_MACHINE_MODE,\n");
1216
1217 for (c = 0; c < MAX_MODE_CLASS; c++)
1218 {
f58875bf 1219 first = modes[c];
47a2c1d4 1220 last = 0;
1221 for (m = first; m; last = m, m = m->next)
1222 ;
1223
1224 /* Don't use BImode for MIN_MODE_INT, since otherwise the middle
1225 end will try to use it for bitfields in structures and the
1226 like, which we do not want. Only the target md file should
1227 generate BImode widgets. */
0d58d930 1228 if (first && first->precision == 1 && c == MODE_INT)
47a2c1d4 1229 first = first->next;
1230
1231 if (first && last)
1e0295b9 1232 printf (" MIN_%s = E_%smode,\n MAX_%s = E_%smode,\n\n",
47a2c1d4 1233 mode_class_names[c], first->name,
1234 mode_class_names[c], last->name);
1235 else
1e0295b9 1236 printf (" MIN_%s = E_%smode,\n MAX_%s = E_%smode,\n\n",
47a2c1d4 1237 mode_class_names[c], void_mode->name,
1238 mode_class_names[c], void_mode->name);
1239 }
1240
1241 puts ("\
1242 NUM_MACHINE_MODES = MAX_MACHINE_MODE\n\
f58875bf 1243};\n");
1244
1245 /* I can't think of a better idea, can you? */
1246 printf ("#define CONST_MODE_SIZE%s\n", adj_bytesize ? "" : " const");
a0509d0e 1247 printf ("#define CONST_MODE_UNIT_SIZE%s\n", adj_bytesize ? "" : " const");
f58875bf 1248 printf ("#define CONST_MODE_BASE_ALIGN%s\n", adj_alignment ? "" : " const");
1249#if 0 /* disabled for backward compatibility, temporary */
1250 printf ("#define CONST_REAL_FORMAT_FOR_MODE%s\n", adj_format ? "" :" const");
1251#endif
c559c639 1252 printf ("#define CONST_MODE_IBIT%s\n", adj_ibit ? "" : " const");
1253 printf ("#define CONST_MODE_FBIT%s\n", adj_fbit ? "" : " const");
f9cb58ae 1254 emit_max_int ();
9f75f026 1255
1256 for_all_modes (c, m)
1257 if (m->int_n)
1258 n_int_n_ents ++;
1259
1260 printf ("#define NUM_INT_N_ENTS %d\n", n_int_n_ents);
1261
466432a3 1262 printf ("#define NUM_POLY_INT_COEFFS %d\n", NUM_POLY_INT_COEFFS);
1263
8734172d 1264 puts ("\
1265\n\
1266#endif /* insn-modes.h */");
1267}
1268
1269static void
1270emit_insn_modes_inline_h (void)
1271{
1272 printf ("/* Generated automatically from machmode.def%s%s\n",
1273 HAVE_EXTRA_MODES ? " and " : "",
1274 EXTRA_MODES_FILE);
1275
1276 puts ("\
1277 by genmodes. */\n\
1278\n\
1279#ifndef GCC_INSN_MODES_INLINE_H\n\
1280#define GCC_INSN_MODES_INLINE_H");
1281
3754d046 1282 puts ("\n#if !defined (USED_FOR_TARGET) && GCC_VERSION >= 4001\n");
e2ec52ca 1283 emit_mode_size_inline ();
1284 emit_mode_nunits_inline ();
1285 emit_mode_inner_inline ();
a0509d0e 1286 emit_mode_unit_size_inline ();
1287 emit_mode_unit_precision_inline ();
e2ec52ca 1288 puts ("#endif /* GCC_VERSION >= 4001 */");
1289
f58875bf 1290 puts ("\
47a2c1d4 1291\n\
8734172d 1292#endif /* insn-modes-inline.h */");
47a2c1d4 1293}
1294
1295static void
1296emit_insn_modes_c_header (void)
1297{
1298 printf ("/* Generated automatically from machmode.def%s%s\n",
1299 HAVE_EXTRA_MODES ? " and " : "",
1300 EXTRA_MODES_FILE);
1301
1302 puts ("\
1303 by genmodes. */\n\
1304\n\
47a2c1d4 1305#include \"config.h\"\n\
1306#include \"system.h\"\n\
1307#include \"coretypes.h\"\n\
1308#include \"tm.h\"\n\
15460c97 1309#include \"real.h\"");
1310}
1311
1312static void
1313emit_min_insn_modes_c_header (void)
1314{
1315 printf ("/* Generated automatically from machmode.def%s%s\n",
1316 HAVE_EXTRA_MODES ? " and " : "",
1317 EXTRA_MODES_FILE);
1318
1319 puts ("\
1320 by genmodes. */\n\
1321\n\
1322#include \"bconfig.h\"\n\
1323#include \"system.h\"\n\
8734172d 1324#include \"coretypes.h\"");
47a2c1d4 1325}
1326
1327static void
1328emit_mode_name (void)
1329{
e916c70c 1330 int c;
47a2c1d4 1331 struct mode_data *m;
1332
1333 print_decl ("char *const", "mode_name", "NUM_MACHINE_MODES");
1334
1335 for_all_modes (c, m)
1336 printf (" \"%s\",\n", m->name);
1337
1338 print_closer ();
1339}
1340
1341static void
1342emit_mode_class (void)
1343{
e916c70c 1344 int c;
47a2c1d4 1345 struct mode_data *m;
1346
1347 print_decl ("unsigned char", "mode_class", "NUM_MACHINE_MODES");
1348
1349 for_all_modes (c, m)
e916c70c 1350 tagged_printf ("%s", mode_class_names[m->cl], m->name);
47a2c1d4 1351
1352 print_closer ();
1353}
1354
1355static void
7c0390e7 1356emit_mode_precision (void)
47a2c1d4 1357{
e916c70c 1358 int c;
47a2c1d4 1359 struct mode_data *m;
1360
3ce67adc 1361 print_decl ("poly_uint16_pod", "mode_precision", "NUM_MACHINE_MODES");
47a2c1d4 1362
1363 for_all_modes (c, m)
7c0390e7 1364 if (m->precision != (unsigned int)-1)
3ce67adc 1365 tagged_printf ("{ %u" ZERO_COEFFS " }", m->precision, m->name);
47a2c1d4 1366 else
3ce67adc 1367 tagged_printf ("{ %u * BITS_PER_UNIT" ZERO_COEFFS " }",
1368 m->bytesize, m->name);
47a2c1d4 1369
1370 print_closer ();
1371}
1372
1373static void
1374emit_mode_size (void)
1375{
e916c70c 1376 int c;
47a2c1d4 1377 struct mode_data *m;
1378
52acb7ae 1379 print_maybe_const_decl ("%spoly_uint16_pod", "mode_size",
f58875bf 1380 "NUM_MACHINE_MODES", bytesize);
47a2c1d4 1381
1382 for_all_modes (c, m)
52acb7ae 1383 tagged_printf ("{ %u" ZERO_COEFFS " }", m->bytesize, m->name);
47a2c1d4 1384
1385 print_closer ();
1386}
1387
1388static void
b8bc42e9 1389emit_mode_nunits (void)
47a2c1d4 1390{
e916c70c 1391 int c;
47a2c1d4 1392 struct mode_data *m;
1393
ba7efd65 1394 print_decl ("poly_uint16_pod", "mode_nunits", "NUM_MACHINE_MODES");
47a2c1d4 1395
1396 for_all_modes (c, m)
ba7efd65 1397 tagged_printf ("{ %u" ZERO_COEFFS " }", m->ncomponents, m->name);
47a2c1d4 1398
1399 print_closer ();
1400}
1401
1402static void
1403emit_mode_wider (void)
1404{
e916c70c 1405 int c;
47a2c1d4 1406 struct mode_data *m;
1407
1408 print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES");
1409
1410 for_all_modes (c, m)
1e0295b9 1411 tagged_printf ("E_%smode",
47a2c1d4 1412 m->wider ? m->wider->name : void_mode->name,
1413 m->name);
1414
1415 print_closer ();
06633980 1416 print_decl ("unsigned char", "mode_2xwider", "NUM_MACHINE_MODES");
1417
1418 for_all_modes (c, m)
1419 {
1420 struct mode_data * m2;
1421
1422 for (m2 = m;
1423 m2 && m2 != void_mode;
1424 m2 = m2->wider)
1425 {
1426 if (m2->bytesize < 2 * m->bytesize)
1427 continue;
1428 if (m->precision != (unsigned int) -1)
1429 {
1430 if (m2->precision != 2 * m->precision)
1431 continue;
1432 }
1433 else
1434 {
1435 if (m2->precision != (unsigned int) -1)
1436 continue;
1437 }
1438
de44e2b0 1439 /* For vectors we want twice the number of components,
1440 with the same element type. */
1441 if (m->cl == MODE_VECTOR_INT
1442 || m->cl == MODE_VECTOR_FLOAT
1443 || m->cl == MODE_VECTOR_FRACT
1444 || m->cl == MODE_VECTOR_UFRACT
1445 || m->cl == MODE_VECTOR_ACCUM
1446 || m->cl == MODE_VECTOR_UACCUM)
1447 {
1448 if (m2->ncomponents != 2 * m->ncomponents)
1449 continue;
1450 if (m->component != m2->component)
1451 continue;
1452 }
1453
06633980 1454 break;
1455 }
1456 if (m2 == void_mode)
1457 m2 = 0;
1e0295b9 1458 tagged_printf ("E_%smode",
06633980 1459 m2 ? m2->name : void_mode->name,
1460 m->name);
1461 }
1462
1463 print_closer ();
47a2c1d4 1464}
1465
3c62cae0 1466static void
1467emit_mode_complex (void)
1468{
1469 int c;
1470 struct mode_data *m;
1471
1472 print_decl ("unsigned char", "mode_complex", "NUM_MACHINE_MODES");
1473
1474 for_all_modes (c, m)
1e0295b9 1475 tagged_printf ("E_%smode",
3c62cae0 1476 m->complex ? m->complex->name : void_mode->name,
1477 m->name);
1478
1479 print_closer ();
1480}
1481
47a2c1d4 1482static void
1483emit_mode_mask (void)
1484{
e916c70c 1485 int c;
47a2c1d4 1486 struct mode_data *m;
1487
1488 print_decl ("unsigned HOST_WIDE_INT", "mode_mask_array",
1489 "NUM_MACHINE_MODES");
1490 puts ("\
63bebd18 1491#define MODE_MASK(m) \\\n\
47a2c1d4 1492 ((m) >= HOST_BITS_PER_WIDE_INT) \\\n\
7097b942 1493 ? HOST_WIDE_INT_M1U \\\n\
edc19fd0 1494 : (HOST_WIDE_INT_1U << (m)) - 1\n");
47a2c1d4 1495
1496 for_all_modes (c, m)
7c0390e7 1497 if (m->precision != (unsigned int)-1)
1498 tagged_printf ("MODE_MASK (%u)", m->precision, m->name);
47a2c1d4 1499 else
63bebd18 1500 tagged_printf ("MODE_MASK (%u*BITS_PER_UNIT)", m->bytesize, m->name);
47a2c1d4 1501
63bebd18 1502 puts ("#undef MODE_MASK");
47a2c1d4 1503 print_closer ();
1504}
1505
1506static void
1507emit_mode_inner (void)
1508{
e916c70c 1509 int c;
47a2c1d4 1510 struct mode_data *m;
1511
1512 print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES");
1513
1514 for_all_modes (c, m)
1e0295b9 1515 tagged_printf ("E_%smode",
c8076084 1516 c != MODE_PARTIAL_INT && m->component
d145b68b 1517 ? m->component->name : m->name,
47a2c1d4 1518 m->name);
1519
1520 print_closer ();
1521}
1522
a0509d0e 1523/* Emit mode_unit_size array into insn-modes.c file. */
1524static void
1525emit_mode_unit_size (void)
1526{
1527 int c;
1528 struct mode_data *m;
1529
1530 print_maybe_const_decl ("%sunsigned char", "mode_unit_size",
1531 "NUM_MACHINE_MODES", bytesize);
1532
1533 for_all_modes (c, m)
1534 tagged_printf ("%u",
1535 c != MODE_PARTIAL_INT && m->component
1536 ? m->component->bytesize : m->bytesize, m->name);
1537
1538 print_closer ();
1539}
1540
1541/* Emit mode_unit_precision array into insn-modes.c file. */
1542static void
1543emit_mode_unit_precision (void)
1544{
1545 int c;
1546 struct mode_data *m;
1547
1548 print_decl ("unsigned short", "mode_unit_precision", "NUM_MACHINE_MODES");
1549
1550 for_all_modes (c, m)
1551 {
1552 struct mode_data *m2 = (c != MODE_PARTIAL_INT && m->component) ?
1553 m->component : m;
1554 if (m2->precision != (unsigned int)-1)
1555 tagged_printf ("%u", m2->precision, m->name);
1556 else
1557 tagged_printf ("%u*BITS_PER_UNIT", m2->bytesize, m->name);
1558 }
1559
1560 print_closer ();
1561}
1562
1563
47a2c1d4 1564static void
1565emit_mode_base_align (void)
1566{
e916c70c 1567 int c;
47a2c1d4 1568 struct mode_data *m;
1569
37d0f067 1570 print_maybe_const_decl ("%sunsigned short",
f58875bf 1571 "mode_base_align", "NUM_MACHINE_MODES",
1572 alignment);
47a2c1d4 1573
1574 for_all_modes (c, m)
1575 tagged_printf ("%u", m->alignment, m->name);
1576
1577 print_closer ();
1578}
1579
1580static void
1581emit_class_narrowest_mode (void)
1582{
e916c70c 1583 int c;
47a2c1d4 1584
1585 print_decl ("unsigned char", "class_narrowest_mode", "MAX_MODE_CLASS");
1586
1587 for (c = 0; c < MAX_MODE_CLASS; c++)
1588 /* Bleah, all this to get the comment right for MIN_MODE_INT. */
1589 tagged_printf ("MIN_%s", mode_class_names[c],
f58875bf 1590 modes[c]
0d58d930 1591 ? ((c != MODE_INT || modes[c]->precision != 1)
f58875bf 1592 ? modes[c]->name
1593 : (modes[c]->next
1594 ? modes[c]->next->name
47a2c1d4 1595 : void_mode->name))
1596 : void_mode->name);
48e1416a 1597
47a2c1d4 1598 print_closer ();
1599}
1600
15460c97 1601static void
1602emit_real_format_for_mode (void)
1603{
1604 struct mode_data *m;
1605
f58875bf 1606 /* The entities pointed to by this table are constant, whether
1607 or not the table itself is constant.
1608
1609 For backward compatibility this table is always writable
4c834714 1610 (several targets modify it in TARGET_OPTION_OVERRIDE). FIXME:
f58875bf 1611 convert all said targets to use ADJUST_FORMAT instead. */
1612#if 0
1613 print_maybe_const_decl ("const struct real_format *%s",
1614 "real_format_for_mode",
1615 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1",
1616 format);
1617#else
1618 print_decl ("struct real_format *\n", "real_format_for_mode",
3c28f41a 1619 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1 "
1620 "+ MAX_MODE_DECIMAL_FLOAT - MIN_MODE_DECIMAL_FLOAT + 1");
f58875bf 1621#endif
15460c97 1622
3c28f41a 1623 /* The beginning of the table is entries for float modes. */
f58875bf 1624 for (m = modes[MODE_FLOAT]; m; m = m->next)
15460c97 1625 if (!strcmp (m->format, "0"))
1626 tagged_printf ("%s", m->format, m->name);
1627 else
1628 tagged_printf ("&%s", m->format, m->name);
1629
3c28f41a 1630 /* The end of the table is entries for decimal float modes. */
1631 for (m = modes[MODE_DECIMAL_FLOAT]; m; m = m->next)
1632 if (!strcmp (m->format, "0"))
1633 tagged_printf ("%s", m->format, m->name);
1634 else
1635 tagged_printf ("&%s", m->format, m->name);
1636
15460c97 1637 print_closer ();
1638}
1639
f58875bf 1640static void
1641emit_mode_adjustments (void)
1642{
1643 struct mode_adjust *a;
b8bc42e9 1644 struct mode_data *m;
f58875bf 1645
b8bc42e9 1646 puts ("\
1647\nvoid\
1648\ninit_adjust_machine_modes (void)\
1649\n{\
52acb7ae 1650\n poly_uint16 ps ATTRIBUTE_UNUSED;\n\
1651 size_t s ATTRIBUTE_UNUSED;");
f58875bf 1652
b8bc42e9 1653 /* Size adjustments must be propagated to all containing modes.
1654 A size adjustment forces us to recalculate the alignment too. */
f58875bf 1655 for (a = adj_bytesize; a; a = a->next)
b8bc42e9 1656 {
52acb7ae 1657 printf ("\n /* %s:%d */\n", a->file, a->line);
1658 switch (a->mode->cl)
1659 {
1660 case MODE_VECTOR_INT:
1661 case MODE_VECTOR_FLOAT:
1662 case MODE_VECTOR_FRACT:
1663 case MODE_VECTOR_UFRACT:
1664 case MODE_VECTOR_ACCUM:
1665 case MODE_VECTOR_UACCUM:
1666 printf (" ps = %s;\n", a->adjustment);
1667 printf (" s = mode_unit_size[E_%smode];\n", a->mode->name);
1668 break;
1669
1670 default:
1671 printf (" ps = s = %s;\n", a->adjustment);
1672 printf (" mode_unit_size[E_%smode] = s;\n", a->mode->name);
1673 break;
1674 }
1675 printf (" mode_size[E_%smode] = ps;\n", a->mode->name);
1676 printf (" mode_base_align[E_%smode] = known_alignment (ps);\n",
b8bc42e9 1677 a->mode->name);
1678
1679 for (m = a->mode->contained; m; m = m->next_cont)
1680 {
e916c70c 1681 switch (m->cl)
b8bc42e9 1682 {
1683 case MODE_COMPLEX_INT:
1684 case MODE_COMPLEX_FLOAT:
1e0295b9 1685 printf (" mode_size[E_%smode] = 2*s;\n", m->name);
1686 printf (" mode_unit_size[E_%smode] = s;\n", m->name);
1687 printf (" mode_base_align[E_%smode] = s & (~s + 1);\n",
b8bc42e9 1688 m->name);
1689 break;
1690
1691 case MODE_VECTOR_INT:
1692 case MODE_VECTOR_FLOAT:
c559c639 1693 case MODE_VECTOR_FRACT:
1694 case MODE_VECTOR_UFRACT:
1695 case MODE_VECTOR_ACCUM:
1696 case MODE_VECTOR_UACCUM:
52acb7ae 1697 printf (" mode_size[E_%smode] = %d * ps;\n",
b8bc42e9 1698 m->name, m->ncomponents);
1e0295b9 1699 printf (" mode_unit_size[E_%smode] = s;\n", m->name);
52acb7ae 1700 printf (" mode_base_align[E_%smode]"
1701 " = known_alignment (%d * ps);\n",
1702 m->name, m->ncomponents);
b8bc42e9 1703 break;
1704
1705 default:
1706 internal_error (
1707 "mode %s is neither vector nor complex but contains %s",
1708 m->name, a->mode->name);
1709 /* NOTREACHED */
1710 }
1711 }
1712 }
f58875bf 1713
b8bc42e9 1714 /* Alignment adjustments propagate too.
1715 ??? This may not be the right thing for vector modes. */
f58875bf 1716 for (a = adj_alignment; a; a = a->next)
b8bc42e9 1717 {
1718 printf ("\n /* %s:%d */\n s = %s;\n",
1719 a->file, a->line, a->adjustment);
1e0295b9 1720 printf (" mode_base_align[E_%smode] = s;\n", a->mode->name);
f58875bf 1721
b8bc42e9 1722 for (m = a->mode->contained; m; m = m->next_cont)
1723 {
e916c70c 1724 switch (m->cl)
b8bc42e9 1725 {
1726 case MODE_COMPLEX_INT:
1727 case MODE_COMPLEX_FLOAT:
1e0295b9 1728 printf (" mode_base_align[E_%smode] = s;\n", m->name);
b8bc42e9 1729 break;
1730
1731 case MODE_VECTOR_INT:
1732 case MODE_VECTOR_FLOAT:
c559c639 1733 case MODE_VECTOR_FRACT:
1734 case MODE_VECTOR_UFRACT:
1735 case MODE_VECTOR_ACCUM:
1736 case MODE_VECTOR_UACCUM:
1e0295b9 1737 printf (" mode_base_align[E_%smode] = %d*s;\n",
b8bc42e9 1738 m->name, m->ncomponents);
1739 break;
1740
1741 default:
1742 internal_error (
1743 "mode %s is neither vector nor complex but contains %s",
1744 m->name, a->mode->name);
1745 /* NOTREACHED */
1746 }
1747 }
1748 }
c559c639 1749
1750 /* Ibit adjustments don't have to propagate. */
1751 for (a = adj_ibit; a; a = a->next)
1752 {
1753 printf ("\n /* %s:%d */\n s = %s;\n",
1754 a->file, a->line, a->adjustment);
1e0295b9 1755 printf (" mode_ibit[E_%smode] = s;\n", a->mode->name);
c559c639 1756 }
1757
1758 /* Fbit adjustments don't have to propagate. */
1759 for (a = adj_fbit; a; a = a->next)
1760 {
1761 printf ("\n /* %s:%d */\n s = %s;\n",
1762 a->file, a->line, a->adjustment);
1e0295b9 1763 printf (" mode_fbit[E_%smode] = s;\n", a->mode->name);
c559c639 1764 }
48e1416a 1765
b8bc42e9 1766 /* Real mode formats don't have to propagate anywhere. */
f58875bf 1767 for (a = adj_format; a; a = a->next)
1e0295b9 1768 printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (E_%smode) = %s;\n",
f58875bf 1769 a->file, a->line, a->mode->name, a->adjustment);
1770
1771 puts ("}");
1772}
1773
c559c639 1774/* Emit ibit for all modes. */
1775
1776static void
1777emit_mode_ibit (void)
1778{
1779 int c;
1780 struct mode_data *m;
1781
1782 print_maybe_const_decl ("%sunsigned char",
1783 "mode_ibit", "NUM_MACHINE_MODES",
1784 ibit);
1785
1786 for_all_modes (c, m)
1787 tagged_printf ("%u", m->ibit, m->name);
1788
1789 print_closer ();
1790}
1791
1792/* Emit fbit for all modes. */
1793
1794static void
1795emit_mode_fbit (void)
1796{
1797 int c;
1798 struct mode_data *m;
1799
1800 print_maybe_const_decl ("%sunsigned char",
1801 "mode_fbit", "NUM_MACHINE_MODES",
1802 fbit);
1803
1804 for_all_modes (c, m)
1805 tagged_printf ("%u", m->fbit, m->name);
1806
1807 print_closer ();
1808}
1809
9f75f026 1810/* Emit __intN for all modes. */
1811
1812static void
1813emit_mode_int_n (void)
1814{
1815 int c;
1816 struct mode_data *m;
1817 struct mode_data **mode_sort;
1818 int n_modes = 0;
1819 int i, j;
1820
1821 print_decl ("int_n_data_t", "int_n_data", "");
1822
1823 n_modes = 0;
1824 for_all_modes (c, m)
1825 if (m->int_n)
1826 n_modes ++;
1827 mode_sort = XALLOCAVEC (struct mode_data *, n_modes);
1828
1829 n_modes = 0;
1830 for_all_modes (c, m)
1831 if (m->int_n)
1832 mode_sort[n_modes++] = m;
1833
1834 /* Yes, this is a bubblesort, but there are at most four (and
1835 usually only 1-2) entries to sort. */
1836 for (i = 0; i<n_modes - 1; i++)
1837 for (j = i + 1; j < n_modes; j++)
1838 if (mode_sort[i]->int_n > mode_sort[j]->int_n)
dfcf26a5 1839 std::swap (mode_sort[i], mode_sort[j]);
9f75f026 1840
1841 for (i = 0; i < n_modes; i ++)
1842 {
1843 m = mode_sort[i];
1844 printf(" {\n");
1845 tagged_printf ("%u", m->int_n, m->name);
ced5293f 1846 printf ("{ E_%smode },", m->name);
9f75f026 1847 printf(" },\n");
1848 }
1849
1850 print_closer ();
1851}
1852
c559c639 1853
47a2c1d4 1854static void
1855emit_insn_modes_c (void)
1856{
1857 emit_insn_modes_c_header ();
1858 emit_mode_name ();
1859 emit_mode_class ();
7c0390e7 1860 emit_mode_precision ();
47a2c1d4 1861 emit_mode_size ();
b8bc42e9 1862 emit_mode_nunits ();
47a2c1d4 1863 emit_mode_wider ();
3c62cae0 1864 emit_mode_complex ();
47a2c1d4 1865 emit_mode_mask ();
1866 emit_mode_inner ();
a0509d0e 1867 emit_mode_unit_size ();
1868 emit_mode_unit_precision ();
47a2c1d4 1869 emit_mode_base_align ();
1870 emit_class_narrowest_mode ();
15460c97 1871 emit_real_format_for_mode ();
f58875bf 1872 emit_mode_adjustments ();
c559c639 1873 emit_mode_ibit ();
1874 emit_mode_fbit ();
9f75f026 1875 emit_mode_int_n ();
15460c97 1876}
1877
1878static void
1879emit_min_insn_modes_c (void)
1880{
1881 emit_min_insn_modes_c_header ();
1882 emit_mode_name ();
1883 emit_mode_class ();
9b067f04 1884 emit_mode_nunits ();
15460c97 1885 emit_mode_wider ();
9b067f04 1886 emit_mode_inner ();
15460c97 1887 emit_class_narrowest_mode ();
47a2c1d4 1888}
1889
1890/* Master control. */
1891int
d4473c84 1892main (int argc, char **argv)
47a2c1d4 1893{
8734172d 1894 bool gen_header = false, gen_inlines = false, gen_min = false;
47a2c1d4 1895 progname = argv[0];
1896
1897 if (argc == 1)
15460c97 1898 ;
47a2c1d4 1899 else if (argc == 2 && !strcmp (argv[1], "-h"))
1900 gen_header = true;
8734172d 1901 else if (argc == 2 && !strcmp (argv[1], "-i"))
1902 gen_inlines = true;
15460c97 1903 else if (argc == 2 && !strcmp (argv[1], "-m"))
1904 gen_min = true;
47a2c1d4 1905 else
1906 {
8734172d 1907 error ("usage: %s [-h|-i|-m] > file", progname);
47a2c1d4 1908 return FATAL_EXIT_CODE;
1909 }
1910
f58875bf 1911 modes_by_name = htab_create_alloc (64, hash_mode, eq_mode, 0, xcalloc, free);
1912
47a2c1d4 1913 create_modes ();
1914 complete_all_modes ();
1915
1916 if (have_error)
1917 return FATAL_EXIT_CODE;
48e1416a 1918
47a2c1d4 1919 calc_wider_mode ();
1920
1921 if (gen_header)
1922 emit_insn_modes_h ();
8734172d 1923 else if (gen_inlines)
1924 emit_insn_modes_inline_h ();
15460c97 1925 else if (gen_min)
1926 emit_min_insn_modes_c ();
47a2c1d4 1927 else
1928 emit_insn_modes_c ();
1929
1930 if (fflush (stdout) || fclose (stdout))
1931 return FATAL_EXIT_CODE;
1932 return SUCCESS_EXIT_CODE;
1933}