Mercurial > hg > CbC > CbC_gcc
annotate gcc/genmodes.c @ 127:4c56639505ff
fix function.c and add CbC-example Makefile
author | mir3636 |
---|---|
date | Wed, 11 Apr 2018 18:46:58 +0900 |
parents | 04ced10e8804 |
children | 84e7813d76e9 |
rev | line source |
---|---|
0 | 1 /* Generate the machine mode enumeration and associated tables. |
111 | 2 Copyright (C) 2003-2017 Free Software Foundation, Inc. |
0 | 3 |
4 This file is part of GCC. | |
5 | |
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. | |
10 | |
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. | |
15 | |
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/>. */ | |
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 | |
29 enum 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 | |
34 static 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. */ | |
50 struct mode_data | |
51 { | |
52 struct mode_data *next; /* next this class - arbitrary order */ | |
53 | |
54 const char *name; /* printable mode name -- SI, not SImode */ | |
55 enum mode_class cl; /* this mode class */ | |
56 unsigned int precision; /* size in bits, equiv to TYPE_PRECISION */ | |
57 unsigned int bytesize; /* storage size in addressable units */ | |
58 unsigned int ncomponents; /* number of subunits */ | |
59 unsigned int alignment; /* mode alignment */ | |
60 const char *format; /* floating point format - float modes only */ | |
61 | |
62 struct mode_data *component; /* mode of components */ | |
63 struct mode_data *wider; /* next wider mode */ | |
64 | |
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 | |
111 | 69 struct mode_data *complex; /* complex type with mode as component. */ |
0 | 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 */ | |
111 | 75 bool need_bytesize_adj; /* true if this mode need dynamic size |
76 adjustment */ | |
77 unsigned int int_n; /* If nonzero, then __int<INT_N> will be defined */ | |
0 | 78 }; |
79 | |
80 static struct mode_data *modes[MAX_MODE_CLASS]; | |
81 static unsigned int n_modes[MAX_MODE_CLASS]; | |
82 static struct mode_data *void_mode; | |
83 | |
84 static const struct mode_data blank_mode = { | |
85 0, "<unknown>", MAX_MODE_CLASS, | |
86 -1U, -1U, -1U, -1U, | |
87 0, 0, 0, 0, 0, 0, | |
111 | 88 "<unknown>", 0, 0, 0, 0, false, 0 |
0 | 89 }; |
90 | |
91 static 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. */ | |
96 struct 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 | |
106 static struct mode_adjust *adj_bytesize; | |
107 static struct mode_adjust *adj_alignment; | |
108 static struct mode_adjust *adj_format; | |
109 static struct mode_adjust *adj_ibit; | |
110 static struct mode_adjust *adj_fbit; | |
111 | |
112 /* Mode class operations. */ | |
113 static enum mode_class | |
114 complex_class (enum mode_class c) | |
115 { | |
116 switch (c) | |
117 { | |
118 case MODE_INT: return MODE_COMPLEX_INT; | |
119 case MODE_FLOAT: return MODE_COMPLEX_FLOAT; | |
120 default: | |
121 error ("no complex class for class %s", mode_class_names[c]); | |
122 return MODE_RANDOM; | |
123 } | |
124 } | |
125 | |
126 static enum mode_class | |
127 vector_class (enum mode_class cl) | |
128 { | |
129 switch (cl) | |
130 { | |
131 case MODE_INT: return MODE_VECTOR_INT; | |
132 case MODE_FLOAT: return MODE_VECTOR_FLOAT; | |
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; | |
137 default: | |
138 error ("no vector class for class %s", mode_class_names[cl]); | |
139 return MODE_RANDOM; | |
140 } | |
141 } | |
142 | |
143 /* Utility routines. */ | |
144 static inline struct mode_data * | |
145 find_mode (const char *name) | |
146 { | |
147 struct mode_data key; | |
148 | |
149 key.name = name; | |
150 return (struct mode_data *) htab_find (modes_by_name, &key); | |
151 } | |
152 | |
153 static struct mode_data * | |
154 new_mode (enum mode_class cl, const char *name, | |
155 const char *file, unsigned int line) | |
156 { | |
157 struct mode_data *m; | |
158 static unsigned int count = 0; | |
159 | |
160 m = find_mode (name); | |
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 | |
169 m = XNEW (struct mode_data); | |
170 memcpy (m, &blank_mode, sizeof (struct mode_data)); | |
171 m->cl = cl; | |
172 m->name = name; | |
173 if (file) | |
174 m->file = trim_filename (file); | |
175 m->line = line; | |
176 m->counter = count++; | |
177 | |
178 m->next = modes[cl]; | |
179 modes[cl] = m; | |
180 n_modes[cl]++; | |
181 | |
182 *htab_find_slot (modes_by_name, m, INSERT) = m; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
183 |
0 | 184 return m; |
185 } | |
186 | |
187 static hashval_t | |
188 hash_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 | |
194 static int | |
195 eq_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 | |
203 #define for_all_modes(C, M) \ | |
204 for (C = 0; C < MAX_MODE_CLASS; C++) \ | |
205 for (M = modes[C]; M; M = M->next) | |
206 | |
207 static void ATTRIBUTE_UNUSED | |
208 new_adjust (const char *name, | |
209 struct mode_adjust **category, const char *catname, | |
210 const char *adjustment, | |
211 enum mode_class required_class_from, | |
212 enum mode_class required_class_to, | |
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 | |
226 if (required_class_from != MODE_RANDOM | |
227 && (mode->cl < required_class_from || mode->cl > required_class_to)) | |
228 { | |
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); | |
232 return; | |
233 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
234 |
0 | 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 | |
244 a = XNEW (struct mode_adjust); | |
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 } | |
253 | |
254 /* Diagnose failure to meet expectations in a partially filled out | |
255 mode structure. */ | |
256 enum 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 | |
278 static void | |
279 validate_mode (struct mode_data *m, | |
280 enum requirement r_precision, | |
281 enum requirement r_bytesize, | |
282 enum requirement r_component, | |
283 enum requirement r_ncomponents, | |
284 enum requirement r_format) | |
285 { | |
286 validate_field (m, precision); | |
287 validate_field (m, bytesize); | |
288 validate_field (m, component); | |
289 validate_field (m, ncomponents); | |
290 validate_field (m, format); | |
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. */ | |
297 static void | |
298 complete_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 } | |
307 if (m->cl == MAX_MODE_CLASS) | |
308 { | |
309 error ("%s:%d: %smode has no mode class", m->file, m->line, m->name); | |
310 return; | |
311 } | |
312 | |
313 switch (m->cl) | |
314 { | |
315 case MODE_RANDOM: | |
316 /* Nothing more need be said. */ | |
317 if (!strcmp (m->name, "VOID")) | |
318 void_mode = m; | |
319 | |
320 validate_mode (m, UNSET, UNSET, UNSET, UNSET, UNSET); | |
321 | |
322 m->precision = 0; | |
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. */ | |
331 validate_mode (m, UNSET, UNSET, UNSET, UNSET, UNSET); | |
332 | |
333 m->bytesize = 4; | |
334 m->ncomponents = 1; | |
335 m->component = 0; | |
336 break; | |
337 | |
338 case MODE_INT: | |
111 | 339 case MODE_POINTER_BOUNDS: |
0 | 340 case MODE_FLOAT: |
341 case MODE_DECIMAL_FLOAT: | |
342 case MODE_FRACT: | |
343 case MODE_UFRACT: | |
344 case MODE_ACCUM: | |
345 case MODE_UACCUM: | |
346 /* A scalar mode must have a byte size, may have a bit size, | |
347 and must not have components. A float mode must have a | |
348 format. */ | |
349 validate_mode (m, OPTIONAL, SET, UNSET, UNSET, | |
350 (m->cl == MODE_FLOAT || m->cl == MODE_DECIMAL_FLOAT) | |
351 ? SET : UNSET); | |
352 | |
353 m->ncomponents = 1; | |
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. */ | |
361 validate_mode (m, OPTIONAL, UNSET, SET, UNSET, UNSET); | |
362 | |
363 m->bytesize = m->component->bytesize; | |
364 | |
365 m->ncomponents = 1; | |
366 break; | |
367 | |
368 case MODE_COMPLEX_INT: | |
369 case MODE_COMPLEX_FLOAT: | |
370 /* Complex modes should have a component indicated, but no more. */ | |
371 validate_mode (m, UNSET, UNSET, SET, UNSET, UNSET); | |
372 m->ncomponents = 2; | |
373 if (m->component->precision != (unsigned int)-1) | |
374 m->precision = 2 * m->component->precision; | |
375 m->bytesize = 2 * m->component->bytesize; | |
376 break; | |
377 | |
378 case MODE_VECTOR_INT: | |
379 case MODE_VECTOR_FLOAT: | |
380 case MODE_VECTOR_FRACT: | |
381 case MODE_VECTOR_UFRACT: | |
382 case MODE_VECTOR_ACCUM: | |
383 case MODE_VECTOR_UACCUM: | |
384 /* Vector modes should have a component and a number of components. */ | |
385 validate_mode (m, UNSET, UNSET, SET, SET, UNSET); | |
386 if (m->component->precision != (unsigned int)-1) | |
387 m->precision = m->ncomponents * m->component->precision; | |
388 m->bytesize = m->ncomponents * m->component->bytesize; | |
389 break; | |
390 | |
391 default: | |
392 gcc_unreachable (); | |
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. */ | |
398 if (m->cl == MODE_COMPLEX_INT || m->cl == MODE_COMPLEX_FLOAT) | |
399 alignment = m->component->bytesize; | |
400 else | |
401 alignment = m->bytesize; | |
402 | |
403 m->alignment = alignment & (~alignment + 1); | |
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 } | |
412 } | |
413 | |
414 static void | |
415 complete_all_modes (void) | |
416 { | |
417 struct mode_data *m; | |
418 int cl; | |
419 | |
420 for_all_modes (cl, m) | |
421 complete_mode (m); | |
422 } | |
423 | |
424 /* For each mode in class CLASS, construct a corresponding complex mode. */ | |
111 | 425 #define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, __LINE__) |
0 | 426 static void |
427 make_complex_modes (enum mode_class cl, | |
428 const char *file, unsigned int line) | |
429 { | |
430 struct mode_data *m; | |
431 struct mode_data *c; | |
432 enum mode_class cclass = complex_class (cl); | |
433 | |
434 if (cclass == MODE_RANDOM) | |
435 return; | |
436 | |
437 for (m = modes[cl]; m; m = m->next) | |
438 { | |
111 | 439 char *p, *buf; |
440 size_t m_len; | |
441 | |
0 | 442 /* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */ |
443 if (m->precision == 1) | |
444 continue; | |
445 | |
111 | 446 m_len = strlen (m->name); |
447 /* The leading "1 +" is in case we prepend a "C" below. */ | |
448 buf = (char *) xmalloc (1 + m_len + 1); | |
0 | 449 |
450 /* Float complex modes are named SCmode, etc. | |
451 Int complex modes are named CSImode, etc. | |
452 This inconsistency should be eliminated. */ | |
111 | 453 p = 0; |
0 | 454 if (cl == MODE_FLOAT) |
455 { | |
111 | 456 memcpy (buf, m->name, m_len + 1); |
0 | 457 p = strchr (buf, 'F'); |
111 | 458 if (p == 0 && strchr (buf, 'D') == 0) |
0 | 459 { |
460 error ("%s:%d: float mode \"%s\" has no 'F' or 'D'", | |
461 m->file, m->line, m->name); | |
111 | 462 free (buf); |
0 | 463 continue; |
464 } | |
465 } | |
111 | 466 if (p != 0) |
467 *p = 'C'; | |
0 | 468 else |
111 | 469 { |
470 buf[0] = 'C'; | |
471 memcpy (buf + 1, m->name, m_len + 1); | |
472 } | |
0 | 473 |
111 | 474 c = new_mode (cclass, buf, file, line); |
0 | 475 c->component = m; |
111 | 476 m->complex = c; |
0 | 477 } |
478 } | |
479 | |
480 /* For all modes in class CL, construct vector modes of width | |
481 WIDTH, having as many components as necessary. */ | |
111 | 482 #define VECTOR_MODES(C, W) make_vector_modes (MODE_##C, W, __FILE__, __LINE__) |
0 | 483 static void ATTRIBUTE_UNUSED |
484 make_vector_modes (enum mode_class cl, unsigned int width, | |
485 const char *file, unsigned int line) | |
486 { | |
487 struct mode_data *m; | |
488 struct mode_data *v; | |
111 | 489 /* Big enough for a 32-bit UINT_MAX plus the text. */ |
490 char buf[12]; | |
0 | 491 unsigned int ncomponents; |
492 enum mode_class vclass = vector_class (cl); | |
493 | |
494 if (vclass == MODE_RANDOM) | |
495 return; | |
496 | |
497 for (m = modes[cl]; m; m = m->next) | |
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. */ | |
510 if (cl == MODE_FLOAT && m->bytesize == 1) | |
511 continue; | |
512 if (cl == MODE_INT && m->precision == 1) | |
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 | |
111 | 531 #define _SPECIAL_MODE(C, N) \ |
532 make_special_mode (MODE_##C, #N, __FILE__, __LINE__) | |
0 | 533 #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N) |
534 #define CC_MODE(N) _SPECIAL_MODE (CC, N) | |
535 | |
536 static void | |
537 make_special_mode (enum mode_class cl, const char *name, | |
538 const char *file, unsigned int line) | |
539 { | |
540 new_mode (cl, name, file, line); | |
541 } | |
542 | |
111 | 543 #define POINTER_BOUNDS_MODE(N, Y) \ |
544 make_pointer_bounds_mode (#N, Y, __FILE__, __LINE__) | |
545 | |
546 static void ATTRIBUTE_UNUSED | |
547 make_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 | |
0 | 556 #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y) |
557 #define FRACTIONAL_INT_MODE(N, B, Y) \ | |
558 make_int_mode (#N, B, Y, __FILE__, __LINE__) | |
559 | |
560 static void | |
561 make_int_mode (const char *name, | |
562 unsigned int precision, unsigned int bytesize, | |
563 const char *file, unsigned int line) | |
564 { | |
565 struct mode_data *m = new_mode (MODE_INT, name, file, line); | |
566 m->bytesize = bytesize; | |
567 m->precision = precision; | |
568 } | |
569 | |
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 | |
585 static void | |
586 make_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 | |
599 #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F) | |
600 #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \ | |
601 make_float_mode (#N, B, Y, #F, __FILE__, __LINE__) | |
602 | |
603 static void | |
604 make_float_mode (const char *name, | |
605 unsigned int precision, unsigned int bytesize, | |
606 const char *format, | |
607 const char *file, unsigned int line) | |
608 { | |
609 struct mode_data *m = new_mode (MODE_FLOAT, name, file, line); | |
610 m->bytesize = bytesize; | |
611 m->precision = precision; | |
612 m->format = format; | |
613 } | |
614 | |
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 | |
620 static void | |
621 make_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 | |
632 #define RESET_FLOAT_FORMAT(N, F) \ | |
633 reset_float_format (#N, #F, __FILE__, __LINE__) | |
634 static void ATTRIBUTE_UNUSED | |
635 reset_float_format (const char *name, const char *format, | |
636 const char *file, unsigned int line) | |
637 { | |
638 struct mode_data *m = find_mode (name); | |
639 if (!m) | |
640 { | |
641 error ("%s:%d: no mode \"%s\"", file, line, name); | |
642 return; | |
643 } | |
644 if (m->cl != MODE_FLOAT && m->cl != MODE_DECIMAL_FLOAT) | |
645 { | |
646 error ("%s:%d: mode \"%s\" is not a FLOAT class", file, line, name); | |
647 return; | |
648 } | |
649 m->format = format; | |
650 } | |
651 | |
111 | 652 /* __intN support. */ |
653 #define INT_N(M,PREC) \ | |
654 make_int_n (#M, PREC, __FILE__, __LINE__) | |
655 static void ATTRIBUTE_UNUSED | |
656 make_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 | |
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__) | |
0 | 684 static void ATTRIBUTE_UNUSED |
685 make_partial_integer_mode (const char *base, const char *name, | |
686 unsigned int precision, | |
687 const char *file, unsigned int line) | |
688 { | |
689 struct mode_data *m; | |
690 struct mode_data *component = find_mode (base); | |
691 if (!component) | |
692 { | |
693 error ("%s:%d: no mode \"%s\"", file, line, name); | |
694 return; | |
695 } | |
696 if (component->cl != MODE_INT) | |
697 { | |
698 error ("%s:%d: mode \"%s\" is not class INT", file, line, name); | |
699 return; | |
700 } | |
701 | |
702 m = new_mode (MODE_PARTIAL_INT, name, file, line); | |
703 m->precision = precision; | |
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__); | |
711 static void ATTRIBUTE_UNUSED | |
712 make_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); | |
719 struct mode_data *component = find_mode (base); | |
111 | 720 char namebuf[16]; |
0 | 721 |
722 if (vclass == MODE_RANDOM) | |
723 return; | |
724 if (component == 0) | |
725 { | |
726 error ("%s:%d: no mode \"%s\"", file, line, base); | |
727 return; | |
728 } | |
729 if (component->cl != bclass | |
730 && (component->cl != MODE_PARTIAL_INT | |
731 || bclass != MODE_INT)) | |
732 { | |
733 error ("%s:%d: mode \"%s\" is not class %s", | |
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", | |
742 file, line, base); | |
743 return; | |
744 } | |
745 | |
746 v = new_mode (vclass, xstrdup (namebuf), file, line); | |
747 v->ncomponents = ncomponents; | |
748 v->component = component; | |
749 } | |
750 | |
751 /* Adjustability. */ | |
752 #define _ADD_ADJUST(A, M, X, C1, C2) \ | |
753 new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, __LINE__) | |
754 | |
111 | 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) | |
760 | |
761 static int bits_per_unit; | |
762 static int max_bitsize_mode_any_int; | |
0 | 763 |
764 static void | |
765 create_modes (void) | |
766 { | |
767 #include "machmode.def" | |
111 | 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 | |
0 | 782 } |
783 | |
784 /* Processing. */ | |
785 | |
786 /* Sort a list of modes into the order needed for the WIDER field: | |
787 major sort by precision, minor sort by component precision. | |
788 | |
789 For instance: | |
790 QI < HI < SI < DI < TI | |
791 V4QI < V2HI < V8QI < V4HI < V2SI. | |
792 | |
793 If the precision is not set, sort by the bytesize. A mode with | |
794 precision set gets sorted before a mode without precision set, if | |
795 they have the same bytesize; this is the right thing because | |
796 the precision must always be smaller than the bytesize * BITS_PER_UNIT. | |
797 We don't have to do anything special to get this done -- an unset | |
798 precision shows up as (unsigned int)-1, i.e. UINT_MAX. */ | |
799 static int | |
800 cmp_modes (const void *a, const void *b) | |
801 { | |
802 const struct mode_data *const m = *(const struct mode_data *const*)a; | |
803 const struct mode_data *const n = *(const struct mode_data *const*)b; | |
804 | |
805 if (m->bytesize > n->bytesize) | |
806 return 1; | |
807 else if (m->bytesize < n->bytesize) | |
808 return -1; | |
809 | |
810 if (m->precision > n->precision) | |
811 return 1; | |
812 else if (m->precision < n->precision) | |
813 return -1; | |
814 | |
815 if (!m->component && !n->component) | |
816 { | |
817 if (m->counter < n->counter) | |
818 return -1; | |
819 else | |
820 return 1; | |
821 } | |
822 | |
823 if (m->component->bytesize > n->component->bytesize) | |
824 return 1; | |
825 else if (m->component->bytesize < n->component->bytesize) | |
826 return -1; | |
827 | |
828 if (m->component->precision > n->component->precision) | |
829 return 1; | |
830 else if (m->component->precision < n->component->precision) | |
831 return -1; | |
832 | |
833 if (m->counter < n->counter) | |
834 return -1; | |
835 else | |
836 return 1; | |
837 } | |
838 | |
839 static void | |
840 calc_wider_mode (void) | |
841 { | |
842 int c; | |
843 struct mode_data *m; | |
844 struct mode_data **sortbuf; | |
845 unsigned int max_n_modes = 0; | |
846 unsigned int i, j; | |
847 | |
848 for (c = 0; c < MAX_MODE_CLASS; c++) | |
849 max_n_modes = MAX (max_n_modes, n_modes[c]); | |
850 | |
851 /* Allocate max_n_modes + 1 entries to leave room for the extra null | |
852 pointer assigned after the qsort call below. */ | |
111 | 853 sortbuf = XALLOCAVEC (struct mode_data *, max_n_modes + 1); |
0 | 854 |
855 for (c = 0; c < MAX_MODE_CLASS; c++) | |
856 { | |
857 /* "wider" is not meaningful for MODE_RANDOM and MODE_CC. | |
858 However, we want these in textual order, and we have | |
859 precisely the reverse. */ | |
860 if (c == MODE_RANDOM || c == MODE_CC) | |
861 { | |
862 struct mode_data *prev, *next; | |
863 | |
864 for (prev = 0, m = modes[c]; m; m = next) | |
865 { | |
866 m->wider = void_mode; | |
867 | |
868 /* this is nreverse */ | |
869 next = m->next; | |
870 m->next = prev; | |
871 prev = m; | |
872 } | |
873 modes[c] = prev; | |
874 } | |
875 else | |
876 { | |
877 if (!modes[c]) | |
878 continue; | |
879 | |
880 for (i = 0, m = modes[c]; m; i++, m = m->next) | |
881 sortbuf[i] = m; | |
882 | |
111 | 883 (qsort) (sortbuf, i, sizeof (struct mode_data *), cmp_modes); |
0 | 884 |
885 sortbuf[i] = 0; | |
886 for (j = 0; j < i; j++) | |
111 | 887 { |
888 sortbuf[j]->next = sortbuf[j + 1]; | |
889 if (c == MODE_PARTIAL_INT) | |
890 sortbuf[j]->wider = sortbuf[j]->component; | |
891 else | |
892 sortbuf[j]->wider = sortbuf[j]->next; | |
893 } | |
0 | 894 |
895 modes[c] = sortbuf[0]; | |
896 } | |
897 } | |
898 } | |
899 | |
900 /* Output routines. */ | |
901 | |
902 #define tagged_printf(FMT, ARG, TAG) do { \ | |
903 int count_ = printf (" " FMT ",", ARG); \ | |
904 printf ("%*s/* %s */\n", 27 - count_, "", TAG); \ | |
905 } while (0) | |
906 | |
907 #define print_decl(TYPE, NAME, ASIZE) \ | |
908 puts ("\nconst " TYPE " " NAME "[" ASIZE "] =\n{"); | |
909 | |
910 #define print_maybe_const_decl(TYPE, NAME, ASIZE, CATEGORY) \ | |
911 printf ("\n" TYPE " " NAME "[" ASIZE "] = \n{\n", \ | |
912 adj_##CATEGORY ? "" : "const ") | |
913 | |
914 #define print_closer() puts ("};") | |
915 | |
111 | 916 /* Compute the max bitsize of some of the classes of integers. It may |
917 be that there are needs for the other integer classes, and this | |
918 code is easy to extend. */ | |
919 static void | |
920 emit_max_int (void) | |
921 { | |
922 unsigned int max, mmax; | |
923 struct mode_data *i; | |
924 int j; | |
925 | |
926 puts (""); | |
927 | |
928 printf ("#define BITS_PER_UNIT (%d)\n", bits_per_unit); | |
929 | |
930 if (max_bitsize_mode_any_int == 0) | |
931 { | |
932 for (max = 1, i = modes[MODE_INT]; i; i = i->next) | |
933 if (max < i->bytesize) | |
934 max = i->bytesize; | |
935 mmax = max; | |
936 for (max = 1, i = modes[MODE_PARTIAL_INT]; i; i = i->next) | |
937 if (max < i->bytesize) | |
938 max = i->bytesize; | |
939 if (max > mmax) | |
940 mmax = max; | |
941 printf ("#define MAX_BITSIZE_MODE_ANY_INT (%d*BITS_PER_UNIT)\n", mmax); | |
942 } | |
943 else | |
944 printf ("#define MAX_BITSIZE_MODE_ANY_INT %d\n", max_bitsize_mode_any_int); | |
945 | |
946 mmax = 0; | |
947 for (j = 0; j < MAX_MODE_CLASS; j++) | |
948 for (i = modes[j]; i; i = i->next) | |
949 if (mmax < i->bytesize) | |
950 mmax = i->bytesize; | |
951 printf ("#define MAX_BITSIZE_MODE_ANY_MODE (%d*BITS_PER_UNIT)\n", mmax); | |
952 } | |
953 | |
954 /* Emit mode_size_inline routine into insn-modes.h header. */ | |
955 static void | |
956 emit_mode_size_inline (void) | |
957 { | |
958 int c; | |
959 struct mode_adjust *a; | |
960 struct mode_data *m; | |
961 | |
962 /* Size adjustments must be propagated to all containing modes. */ | |
963 for (a = adj_bytesize; a; a = a->next) | |
964 { | |
965 a->mode->need_bytesize_adj = true; | |
966 for (m = a->mode->contained; m; m = m->next_cont) | |
967 m->need_bytesize_adj = true; | |
968 } | |
969 | |
970 printf ("\ | |
971 #ifdef __cplusplus\n\ | |
972 inline __attribute__((__always_inline__))\n\ | |
973 #else\n\ | |
974 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ | |
975 #endif\n\ | |
976 unsigned short\n\ | |
977 mode_size_inline (machine_mode mode)\n\ | |
978 {\n\ | |
979 extern %sunsigned short mode_size[NUM_MACHINE_MODES];\n\ | |
980 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\ | |
981 switch (mode)\n\ | |
982 {\n", adj_bytesize ? "" : "const "); | |
983 | |
984 for_all_modes (c, m) | |
985 if (!m->need_bytesize_adj) | |
986 printf (" case E_%smode: return %u;\n", m->name, m->bytesize); | |
987 | |
988 puts ("\ | |
989 default: return mode_size[mode];\n\ | |
990 }\n\ | |
991 }\n"); | |
992 } | |
993 | |
994 /* Emit mode_nunits_inline routine into insn-modes.h header. */ | |
995 static void | |
996 emit_mode_nunits_inline (void) | |
997 { | |
998 int c; | |
999 struct mode_data *m; | |
1000 | |
1001 puts ("\ | |
1002 #ifdef __cplusplus\n\ | |
1003 inline __attribute__((__always_inline__))\n\ | |
1004 #else\n\ | |
1005 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ | |
1006 #endif\n\ | |
1007 unsigned char\n\ | |
1008 mode_nunits_inline (machine_mode mode)\n\ | |
1009 {\n\ | |
1010 extern const unsigned char mode_nunits[NUM_MACHINE_MODES];\n\ | |
1011 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\ | |
1012 switch (mode)\n\ | |
1013 {"); | |
1014 | |
1015 for_all_modes (c, m) | |
1016 printf (" case E_%smode: return %u;\n", m->name, m->ncomponents); | |
1017 | |
1018 puts ("\ | |
1019 default: return mode_nunits[mode];\n\ | |
1020 }\n\ | |
1021 }\n"); | |
1022 } | |
1023 | |
1024 /* Emit mode_inner_inline routine into insn-modes.h header. */ | |
1025 static void | |
1026 emit_mode_inner_inline (void) | |
1027 { | |
1028 int c; | |
1029 struct mode_data *m; | |
1030 | |
1031 puts ("\ | |
1032 #ifdef __cplusplus\n\ | |
1033 inline __attribute__((__always_inline__))\n\ | |
1034 #else\n\ | |
1035 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ | |
1036 #endif\n\ | |
1037 unsigned char\n\ | |
1038 mode_inner_inline (machine_mode mode)\n\ | |
1039 {\n\ | |
1040 extern const unsigned char mode_inner[NUM_MACHINE_MODES];\n\ | |
1041 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\ | |
1042 switch (mode)\n\ | |
1043 {"); | |
1044 | |
1045 for_all_modes (c, m) | |
1046 printf (" case E_%smode: return E_%smode;\n", m->name, | |
1047 c != MODE_PARTIAL_INT && m->component | |
1048 ? m->component->name : m->name); | |
1049 | |
1050 puts ("\ | |
1051 default: return mode_inner[mode];\n\ | |
1052 }\n\ | |
1053 }\n"); | |
1054 } | |
1055 | |
1056 /* Emit mode_unit_size_inline routine into insn-modes.h header. */ | |
1057 static void | |
1058 emit_mode_unit_size_inline (void) | |
1059 { | |
1060 int c; | |
1061 struct mode_data *m; | |
1062 | |
1063 puts ("\ | |
1064 #ifdef __cplusplus\n\ | |
1065 inline __attribute__((__always_inline__))\n\ | |
1066 #else\n\ | |
1067 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ | |
1068 #endif\n\ | |
1069 unsigned char\n\ | |
1070 mode_unit_size_inline (machine_mode mode)\n\ | |
1071 {\n\ | |
1072 extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];\ | |
1073 \n\ | |
1074 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\ | |
1075 switch (mode)\n\ | |
1076 {"); | |
1077 | |
1078 for_all_modes (c, m) | |
1079 { | |
1080 const char *name = m->name; | |
1081 struct mode_data *m2 = m; | |
1082 if (c != MODE_PARTIAL_INT && m2->component) | |
1083 m2 = m2->component; | |
1084 if (!m2->need_bytesize_adj) | |
1085 printf (" case E_%smode: return %u;\n", name, m2->bytesize); | |
1086 } | |
1087 | |
1088 puts ("\ | |
1089 default: return mode_unit_size[mode];\n\ | |
1090 }\n\ | |
1091 }\n"); | |
1092 } | |
1093 | |
1094 /* Emit mode_unit_precision_inline routine into insn-modes.h header. */ | |
1095 static void | |
1096 emit_mode_unit_precision_inline (void) | |
1097 { | |
1098 int c; | |
1099 struct mode_data *m; | |
1100 | |
1101 puts ("\ | |
1102 #ifdef __cplusplus\n\ | |
1103 inline __attribute__((__always_inline__))\n\ | |
1104 #else\n\ | |
1105 extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ | |
1106 #endif\n\ | |
1107 unsigned short\n\ | |
1108 mode_unit_precision_inline (machine_mode mode)\n\ | |
1109 {\n\ | |
1110 extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];\n\ | |
1111 gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\ | |
1112 switch (mode)\n\ | |
1113 {"); | |
1114 | |
1115 for_all_modes (c, m) | |
1116 { | |
1117 struct mode_data *m2 | |
1118 = (c != MODE_PARTIAL_INT && m->component) ? m->component : m; | |
1119 if (m2->precision != (unsigned int)-1) | |
1120 printf (" case E_%smode: return %u;\n", m->name, m2->precision); | |
1121 else | |
1122 printf (" case E_%smode: return %u*BITS_PER_UNIT;\n", | |
1123 m->name, m2->bytesize); | |
1124 } | |
1125 | |
1126 puts ("\ | |
1127 default: return mode_unit_precision[mode];\n\ | |
1128 }\n\ | |
1129 }\n"); | |
1130 } | |
1131 | |
1132 /* Return the best machine mode class for MODE, or null if machine_mode | |
1133 should be used. */ | |
1134 | |
1135 static const char * | |
1136 get_mode_class (struct mode_data *mode) | |
1137 { | |
1138 switch (mode->cl) | |
1139 { | |
1140 case MODE_INT: | |
1141 case MODE_PARTIAL_INT: | |
1142 return "scalar_int_mode"; | |
1143 | |
1144 case MODE_FRACT: | |
1145 case MODE_UFRACT: | |
1146 case MODE_ACCUM: | |
1147 case MODE_UACCUM: | |
1148 case MODE_POINTER_BOUNDS: | |
1149 return "scalar_mode"; | |
1150 | |
1151 case MODE_FLOAT: | |
1152 case MODE_DECIMAL_FLOAT: | |
1153 return "scalar_float_mode"; | |
1154 | |
1155 case MODE_COMPLEX_INT: | |
1156 case MODE_COMPLEX_FLOAT: | |
1157 return "complex_mode"; | |
1158 | |
1159 default: | |
1160 return NULL; | |
1161 } | |
1162 } | |
1163 | |
0 | 1164 static void |
1165 emit_insn_modes_h (void) | |
1166 { | |
1167 int c; | |
1168 struct mode_data *m, *first, *last; | |
111 | 1169 int n_int_n_ents = 0; |
0 | 1170 |
1171 printf ("/* Generated automatically from machmode.def%s%s\n", | |
1172 HAVE_EXTRA_MODES ? " and " : "", | |
1173 EXTRA_MODES_FILE); | |
1174 | |
1175 puts ("\ | |
1176 by genmodes. */\n\ | |
1177 \n\ | |
1178 #ifndef GCC_INSN_MODES_H\n\ | |
1179 #define GCC_INSN_MODES_H\n\ | |
1180 \n\ | |
1181 enum machine_mode\n{"); | |
1182 | |
1183 for (c = 0; c < MAX_MODE_CLASS; c++) | |
1184 for (m = modes[c]; m; m = m->next) | |
1185 { | |
111 | 1186 int count_ = printf (" E_%smode,", m->name); |
0 | 1187 printf ("%*s/* %s:%d */\n", 27 - count_, "", |
1188 trim_filename (m->file), m->line); | |
111 | 1189 printf ("#define HAVE_%smode\n", m->name); |
1190 printf ("#ifdef USE_ENUM_MODES\n"); | |
1191 printf ("#define %smode E_%smode\n", m->name, m->name); | |
1192 printf ("#else\n"); | |
1193 if (const char *mode_class = get_mode_class (m)) | |
1194 printf ("#define %smode (%s ((%s::from_int) E_%smode))\n", | |
1195 m->name, mode_class, mode_class, m->name); | |
1196 else | |
1197 printf ("#define %smode ((void) 0, E_%smode)\n", | |
1198 m->name, m->name); | |
1199 printf ("#endif\n"); | |
0 | 1200 } |
1201 | |
1202 puts (" MAX_MACHINE_MODE,\n"); | |
1203 | |
1204 for (c = 0; c < MAX_MODE_CLASS; c++) | |
1205 { | |
1206 first = modes[c]; | |
1207 last = 0; | |
1208 for (m = first; m; last = m, m = m->next) | |
1209 ; | |
1210 | |
1211 /* Don't use BImode for MIN_MODE_INT, since otherwise the middle | |
1212 end will try to use it for bitfields in structures and the | |
1213 like, which we do not want. Only the target md file should | |
1214 generate BImode widgets. */ | |
111 | 1215 if (first && first->precision == 1 && c == MODE_INT) |
0 | 1216 first = first->next; |
1217 | |
1218 if (first && last) | |
111 | 1219 printf (" MIN_%s = E_%smode,\n MAX_%s = E_%smode,\n\n", |
0 | 1220 mode_class_names[c], first->name, |
1221 mode_class_names[c], last->name); | |
1222 else | |
111 | 1223 printf (" MIN_%s = E_%smode,\n MAX_%s = E_%smode,\n\n", |
0 | 1224 mode_class_names[c], void_mode->name, |
1225 mode_class_names[c], void_mode->name); | |
1226 } | |
1227 | |
1228 puts ("\ | |
1229 NUM_MACHINE_MODES = MAX_MACHINE_MODE\n\ | |
1230 };\n"); | |
1231 | |
1232 /* I can't think of a better idea, can you? */ | |
1233 printf ("#define CONST_MODE_SIZE%s\n", adj_bytesize ? "" : " const"); | |
111 | 1234 printf ("#define CONST_MODE_UNIT_SIZE%s\n", adj_bytesize ? "" : " const"); |
0 | 1235 printf ("#define CONST_MODE_BASE_ALIGN%s\n", adj_alignment ? "" : " const"); |
1236 #if 0 /* disabled for backward compatibility, temporary */ | |
1237 printf ("#define CONST_REAL_FORMAT_FOR_MODE%s\n", adj_format ? "" :" const"); | |
1238 #endif | |
1239 printf ("#define CONST_MODE_IBIT%s\n", adj_ibit ? "" : " const"); | |
1240 printf ("#define CONST_MODE_FBIT%s\n", adj_fbit ? "" : " const"); | |
111 | 1241 emit_max_int (); |
1242 | |
1243 for_all_modes (c, m) | |
1244 if (m->int_n) | |
1245 n_int_n_ents ++; | |
1246 | |
1247 printf ("#define NUM_INT_N_ENTS %d\n", n_int_n_ents); | |
1248 | |
0 | 1249 puts ("\ |
1250 \n\ | |
1251 #endif /* insn-modes.h */"); | |
1252 } | |
1253 | |
1254 static void | |
111 | 1255 emit_insn_modes_inline_h (void) |
1256 { | |
1257 printf ("/* Generated automatically from machmode.def%s%s\n", | |
1258 HAVE_EXTRA_MODES ? " and " : "", | |
1259 EXTRA_MODES_FILE); | |
1260 | |
1261 puts ("\ | |
1262 by genmodes. */\n\ | |
1263 \n\ | |
1264 #ifndef GCC_INSN_MODES_INLINE_H\n\ | |
1265 #define GCC_INSN_MODES_INLINE_H"); | |
1266 | |
1267 puts ("\n#if !defined (USED_FOR_TARGET) && GCC_VERSION >= 4001\n"); | |
1268 emit_mode_size_inline (); | |
1269 emit_mode_nunits_inline (); | |
1270 emit_mode_inner_inline (); | |
1271 emit_mode_unit_size_inline (); | |
1272 emit_mode_unit_precision_inline (); | |
1273 puts ("#endif /* GCC_VERSION >= 4001 */"); | |
1274 | |
1275 puts ("\ | |
1276 \n\ | |
1277 #endif /* insn-modes-inline.h */"); | |
1278 } | |
1279 | |
1280 static void | |
0 | 1281 emit_insn_modes_c_header (void) |
1282 { | |
1283 printf ("/* Generated automatically from machmode.def%s%s\n", | |
1284 HAVE_EXTRA_MODES ? " and " : "", | |
1285 EXTRA_MODES_FILE); | |
1286 | |
1287 puts ("\ | |
1288 by genmodes. */\n\ | |
1289 \n\ | |
1290 #include \"config.h\"\n\ | |
1291 #include \"system.h\"\n\ | |
1292 #include \"coretypes.h\"\n\ | |
1293 #include \"tm.h\"\n\ | |
1294 #include \"real.h\""); | |
1295 } | |
1296 | |
1297 static void | |
1298 emit_min_insn_modes_c_header (void) | |
1299 { | |
1300 printf ("/* Generated automatically from machmode.def%s%s\n", | |
1301 HAVE_EXTRA_MODES ? " and " : "", | |
1302 EXTRA_MODES_FILE); | |
1303 | |
1304 puts ("\ | |
1305 by genmodes. */\n\ | |
1306 \n\ | |
1307 #include \"bconfig.h\"\n\ | |
1308 #include \"system.h\"\n\ | |
111 | 1309 #include \"coretypes.h\""); |
0 | 1310 } |
1311 | |
1312 static void | |
1313 emit_mode_name (void) | |
1314 { | |
1315 int c; | |
1316 struct mode_data *m; | |
1317 | |
1318 print_decl ("char *const", "mode_name", "NUM_MACHINE_MODES"); | |
1319 | |
1320 for_all_modes (c, m) | |
1321 printf (" \"%s\",\n", m->name); | |
1322 | |
1323 print_closer (); | |
1324 } | |
1325 | |
1326 static void | |
1327 emit_mode_class (void) | |
1328 { | |
1329 int c; | |
1330 struct mode_data *m; | |
1331 | |
1332 print_decl ("unsigned char", "mode_class", "NUM_MACHINE_MODES"); | |
1333 | |
1334 for_all_modes (c, m) | |
1335 tagged_printf ("%s", mode_class_names[m->cl], m->name); | |
1336 | |
1337 print_closer (); | |
1338 } | |
1339 | |
1340 static void | |
1341 emit_mode_precision (void) | |
1342 { | |
1343 int c; | |
1344 struct mode_data *m; | |
1345 | |
1346 print_decl ("unsigned short", "mode_precision", "NUM_MACHINE_MODES"); | |
1347 | |
1348 for_all_modes (c, m) | |
1349 if (m->precision != (unsigned int)-1) | |
1350 tagged_printf ("%u", m->precision, m->name); | |
1351 else | |
1352 tagged_printf ("%u*BITS_PER_UNIT", m->bytesize, m->name); | |
1353 | |
1354 print_closer (); | |
1355 } | |
1356 | |
1357 static void | |
1358 emit_mode_size (void) | |
1359 { | |
1360 int c; | |
1361 struct mode_data *m; | |
1362 | |
111 | 1363 print_maybe_const_decl ("%sunsigned short", "mode_size", |
0 | 1364 "NUM_MACHINE_MODES", bytesize); |
1365 | |
1366 for_all_modes (c, m) | |
1367 tagged_printf ("%u", m->bytesize, m->name); | |
1368 | |
1369 print_closer (); | |
1370 } | |
1371 | |
1372 static void | |
1373 emit_mode_nunits (void) | |
1374 { | |
1375 int c; | |
1376 struct mode_data *m; | |
1377 | |
1378 print_decl ("unsigned char", "mode_nunits", "NUM_MACHINE_MODES"); | |
1379 | |
1380 for_all_modes (c, m) | |
1381 tagged_printf ("%u", m->ncomponents, m->name); | |
1382 | |
1383 print_closer (); | |
1384 } | |
1385 | |
1386 static void | |
1387 emit_mode_wider (void) | |
1388 { | |
1389 int c; | |
1390 struct mode_data *m; | |
1391 | |
1392 print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES"); | |
1393 | |
1394 for_all_modes (c, m) | |
111 | 1395 tagged_printf ("E_%smode", |
0 | 1396 m->wider ? m->wider->name : void_mode->name, |
1397 m->name); | |
1398 | |
1399 print_closer (); | |
1400 print_decl ("unsigned char", "mode_2xwider", "NUM_MACHINE_MODES"); | |
1401 | |
1402 for_all_modes (c, m) | |
1403 { | |
1404 struct mode_data * m2; | |
1405 | |
1406 for (m2 = m; | |
1407 m2 && m2 != void_mode; | |
1408 m2 = m2->wider) | |
1409 { | |
1410 if (m2->bytesize < 2 * m->bytesize) | |
1411 continue; | |
1412 if (m->precision != (unsigned int) -1) | |
1413 { | |
1414 if (m2->precision != 2 * m->precision) | |
1415 continue; | |
1416 } | |
1417 else | |
1418 { | |
1419 if (m2->precision != (unsigned int) -1) | |
1420 continue; | |
1421 } | |
1422 | |
111 | 1423 /* For vectors we want twice the number of components, |
1424 with the same element type. */ | |
1425 if (m->cl == MODE_VECTOR_INT | |
1426 || m->cl == MODE_VECTOR_FLOAT | |
1427 || m->cl == MODE_VECTOR_FRACT | |
1428 || m->cl == MODE_VECTOR_UFRACT | |
1429 || m->cl == MODE_VECTOR_ACCUM | |
1430 || m->cl == MODE_VECTOR_UACCUM) | |
1431 { | |
1432 if (m2->ncomponents != 2 * m->ncomponents) | |
1433 continue; | |
1434 if (m->component != m2->component) | |
1435 continue; | |
1436 } | |
1437 | |
0 | 1438 break; |
1439 } | |
1440 if (m2 == void_mode) | |
1441 m2 = 0; | |
111 | 1442 tagged_printf ("E_%smode", |
0 | 1443 m2 ? m2->name : void_mode->name, |
1444 m->name); | |
1445 } | |
1446 | |
1447 print_closer (); | |
1448 } | |
1449 | |
1450 static void | |
111 | 1451 emit_mode_complex (void) |
1452 { | |
1453 int c; | |
1454 struct mode_data *m; | |
1455 | |
1456 print_decl ("unsigned char", "mode_complex", "NUM_MACHINE_MODES"); | |
1457 | |
1458 for_all_modes (c, m) | |
1459 tagged_printf ("E_%smode", | |
1460 m->complex ? m->complex->name : void_mode->name, | |
1461 m->name); | |
1462 | |
1463 print_closer (); | |
1464 } | |
1465 | |
1466 static void | |
0 | 1467 emit_mode_mask (void) |
1468 { | |
1469 int c; | |
1470 struct mode_data *m; | |
1471 | |
1472 print_decl ("unsigned HOST_WIDE_INT", "mode_mask_array", | |
1473 "NUM_MACHINE_MODES"); | |
1474 puts ("\ | |
1475 #define MODE_MASK(m) \\\n\ | |
1476 ((m) >= HOST_BITS_PER_WIDE_INT) \\\n\ | |
111 | 1477 ? HOST_WIDE_INT_M1U \\\n\ |
1478 : (HOST_WIDE_INT_1U << (m)) - 1\n"); | |
0 | 1479 |
1480 for_all_modes (c, m) | |
1481 if (m->precision != (unsigned int)-1) | |
1482 tagged_printf ("MODE_MASK (%u)", m->precision, m->name); | |
1483 else | |
1484 tagged_printf ("MODE_MASK (%u*BITS_PER_UNIT)", m->bytesize, m->name); | |
1485 | |
1486 puts ("#undef MODE_MASK"); | |
1487 print_closer (); | |
1488 } | |
1489 | |
1490 static void | |
1491 emit_mode_inner (void) | |
1492 { | |
1493 int c; | |
1494 struct mode_data *m; | |
1495 | |
1496 print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES"); | |
1497 | |
1498 for_all_modes (c, m) | |
111 | 1499 tagged_printf ("E_%smode", |
1500 c != MODE_PARTIAL_INT && m->component | |
1501 ? m->component->name : m->name, | |
0 | 1502 m->name); |
1503 | |
1504 print_closer (); | |
1505 } | |
1506 | |
111 | 1507 /* Emit mode_unit_size array into insn-modes.c file. */ |
1508 static void | |
1509 emit_mode_unit_size (void) | |
1510 { | |
1511 int c; | |
1512 struct mode_data *m; | |
1513 | |
1514 print_maybe_const_decl ("%sunsigned char", "mode_unit_size", | |
1515 "NUM_MACHINE_MODES", bytesize); | |
1516 | |
1517 for_all_modes (c, m) | |
1518 tagged_printf ("%u", | |
1519 c != MODE_PARTIAL_INT && m->component | |
1520 ? m->component->bytesize : m->bytesize, m->name); | |
1521 | |
1522 print_closer (); | |
1523 } | |
1524 | |
1525 /* Emit mode_unit_precision array into insn-modes.c file. */ | |
1526 static void | |
1527 emit_mode_unit_precision (void) | |
1528 { | |
1529 int c; | |
1530 struct mode_data *m; | |
1531 | |
1532 print_decl ("unsigned short", "mode_unit_precision", "NUM_MACHINE_MODES"); | |
1533 | |
1534 for_all_modes (c, m) | |
1535 { | |
1536 struct mode_data *m2 = (c != MODE_PARTIAL_INT && m->component) ? | |
1537 m->component : m; | |
1538 if (m2->precision != (unsigned int)-1) | |
1539 tagged_printf ("%u", m2->precision, m->name); | |
1540 else | |
1541 tagged_printf ("%u*BITS_PER_UNIT", m2->bytesize, m->name); | |
1542 } | |
1543 | |
1544 print_closer (); | |
1545 } | |
1546 | |
1547 | |
0 | 1548 static void |
1549 emit_mode_base_align (void) | |
1550 { | |
1551 int c; | |
1552 struct mode_data *m; | |
1553 | |
111 | 1554 print_maybe_const_decl ("%sunsigned short", |
0 | 1555 "mode_base_align", "NUM_MACHINE_MODES", |
1556 alignment); | |
1557 | |
1558 for_all_modes (c, m) | |
1559 tagged_printf ("%u", m->alignment, m->name); | |
1560 | |
1561 print_closer (); | |
1562 } | |
1563 | |
1564 static void | |
1565 emit_class_narrowest_mode (void) | |
1566 { | |
1567 int c; | |
1568 | |
1569 print_decl ("unsigned char", "class_narrowest_mode", "MAX_MODE_CLASS"); | |
1570 | |
1571 for (c = 0; c < MAX_MODE_CLASS; c++) | |
1572 /* Bleah, all this to get the comment right for MIN_MODE_INT. */ | |
1573 tagged_printf ("MIN_%s", mode_class_names[c], | |
1574 modes[c] | |
111 | 1575 ? ((c != MODE_INT || modes[c]->precision != 1) |
0 | 1576 ? modes[c]->name |
1577 : (modes[c]->next | |
1578 ? modes[c]->next->name | |
1579 : void_mode->name)) | |
1580 : void_mode->name); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1581 |
0 | 1582 print_closer (); |
1583 } | |
1584 | |
1585 static void | |
1586 emit_real_format_for_mode (void) | |
1587 { | |
1588 struct mode_data *m; | |
1589 | |
1590 /* The entities pointed to by this table are constant, whether | |
1591 or not the table itself is constant. | |
1592 | |
1593 For backward compatibility this table is always writable | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1594 (several targets modify it in TARGET_OPTION_OVERRIDE). FIXME: |
0 | 1595 convert all said targets to use ADJUST_FORMAT instead. */ |
1596 #if 0 | |
1597 print_maybe_const_decl ("const struct real_format *%s", | |
1598 "real_format_for_mode", | |
1599 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1", | |
1600 format); | |
1601 #else | |
1602 print_decl ("struct real_format *\n", "real_format_for_mode", | |
1603 "MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1 " | |
1604 "+ MAX_MODE_DECIMAL_FLOAT - MIN_MODE_DECIMAL_FLOAT + 1"); | |
1605 #endif | |
1606 | |
1607 /* The beginning of the table is entries for float modes. */ | |
1608 for (m = modes[MODE_FLOAT]; m; m = m->next) | |
1609 if (!strcmp (m->format, "0")) | |
1610 tagged_printf ("%s", m->format, m->name); | |
1611 else | |
1612 tagged_printf ("&%s", m->format, m->name); | |
1613 | |
1614 /* The end of the table is entries for decimal float modes. */ | |
1615 for (m = modes[MODE_DECIMAL_FLOAT]; m; m = m->next) | |
1616 if (!strcmp (m->format, "0")) | |
1617 tagged_printf ("%s", m->format, m->name); | |
1618 else | |
1619 tagged_printf ("&%s", m->format, m->name); | |
1620 | |
1621 print_closer (); | |
1622 } | |
1623 | |
1624 static void | |
1625 emit_mode_adjustments (void) | |
1626 { | |
1627 struct mode_adjust *a; | |
1628 struct mode_data *m; | |
1629 | |
1630 puts ("\ | |
1631 \nvoid\ | |
1632 \ninit_adjust_machine_modes (void)\ | |
1633 \n{\ | |
1634 \n size_t s ATTRIBUTE_UNUSED;"); | |
1635 | |
1636 /* Size adjustments must be propagated to all containing modes. | |
1637 A size adjustment forces us to recalculate the alignment too. */ | |
1638 for (a = adj_bytesize; a; a = a->next) | |
1639 { | |
1640 printf ("\n /* %s:%d */\n s = %s;\n", | |
1641 a->file, a->line, a->adjustment); | |
111 | 1642 printf (" mode_size[E_%smode] = s;\n", a->mode->name); |
1643 printf (" mode_unit_size[E_%smode] = s;\n", a->mode->name); | |
1644 printf (" mode_base_align[E_%smode] = s & (~s + 1);\n", | |
0 | 1645 a->mode->name); |
1646 | |
1647 for (m = a->mode->contained; m; m = m->next_cont) | |
1648 { | |
1649 switch (m->cl) | |
1650 { | |
1651 case MODE_COMPLEX_INT: | |
1652 case MODE_COMPLEX_FLOAT: | |
111 | 1653 printf (" mode_size[E_%smode] = 2*s;\n", m->name); |
1654 printf (" mode_unit_size[E_%smode] = s;\n", m->name); | |
1655 printf (" mode_base_align[E_%smode] = s & (~s + 1);\n", | |
0 | 1656 m->name); |
1657 break; | |
1658 | |
1659 case MODE_VECTOR_INT: | |
1660 case MODE_VECTOR_FLOAT: | |
1661 case MODE_VECTOR_FRACT: | |
1662 case MODE_VECTOR_UFRACT: | |
1663 case MODE_VECTOR_ACCUM: | |
1664 case MODE_VECTOR_UACCUM: | |
111 | 1665 printf (" mode_size[E_%smode] = %d*s;\n", |
0 | 1666 m->name, m->ncomponents); |
111 | 1667 printf (" mode_unit_size[E_%smode] = s;\n", m->name); |
1668 printf (" mode_base_align[E_%smode] = (%d*s) & (~(%d*s)+1);\n", | |
0 | 1669 m->name, m->ncomponents, m->ncomponents); |
1670 break; | |
1671 | |
1672 default: | |
1673 internal_error ( | |
1674 "mode %s is neither vector nor complex but contains %s", | |
1675 m->name, a->mode->name); | |
1676 /* NOTREACHED */ | |
1677 } | |
1678 } | |
1679 } | |
1680 | |
1681 /* Alignment adjustments propagate too. | |
1682 ??? This may not be the right thing for vector modes. */ | |
1683 for (a = adj_alignment; a; a = a->next) | |
1684 { | |
1685 printf ("\n /* %s:%d */\n s = %s;\n", | |
1686 a->file, a->line, a->adjustment); | |
111 | 1687 printf (" mode_base_align[E_%smode] = s;\n", a->mode->name); |
0 | 1688 |
1689 for (m = a->mode->contained; m; m = m->next_cont) | |
1690 { | |
1691 switch (m->cl) | |
1692 { | |
1693 case MODE_COMPLEX_INT: | |
1694 case MODE_COMPLEX_FLOAT: | |
111 | 1695 printf (" mode_base_align[E_%smode] = s;\n", m->name); |
0 | 1696 break; |
1697 | |
1698 case MODE_VECTOR_INT: | |
1699 case MODE_VECTOR_FLOAT: | |
1700 case MODE_VECTOR_FRACT: | |
1701 case MODE_VECTOR_UFRACT: | |
1702 case MODE_VECTOR_ACCUM: | |
1703 case MODE_VECTOR_UACCUM: | |
111 | 1704 printf (" mode_base_align[E_%smode] = %d*s;\n", |
0 | 1705 m->name, m->ncomponents); |
1706 break; | |
1707 | |
1708 default: | |
1709 internal_error ( | |
1710 "mode %s is neither vector nor complex but contains %s", | |
1711 m->name, a->mode->name); | |
1712 /* NOTREACHED */ | |
1713 } | |
1714 } | |
1715 } | |
1716 | |
1717 /* Ibit adjustments don't have to propagate. */ | |
1718 for (a = adj_ibit; a; a = a->next) | |
1719 { | |
1720 printf ("\n /* %s:%d */\n s = %s;\n", | |
1721 a->file, a->line, a->adjustment); | |
111 | 1722 printf (" mode_ibit[E_%smode] = s;\n", a->mode->name); |
0 | 1723 } |
1724 | |
1725 /* Fbit adjustments don't have to propagate. */ | |
1726 for (a = adj_fbit; a; a = a->next) | |
1727 { | |
1728 printf ("\n /* %s:%d */\n s = %s;\n", | |
1729 a->file, a->line, a->adjustment); | |
111 | 1730 printf (" mode_fbit[E_%smode] = s;\n", a->mode->name); |
0 | 1731 } |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1732 |
0 | 1733 /* Real mode formats don't have to propagate anywhere. */ |
1734 for (a = adj_format; a; a = a->next) | |
111 | 1735 printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (E_%smode) = %s;\n", |
0 | 1736 a->file, a->line, a->mode->name, a->adjustment); |
1737 | |
1738 puts ("}"); | |
1739 } | |
1740 | |
1741 /* Emit ibit for all modes. */ | |
1742 | |
1743 static void | |
1744 emit_mode_ibit (void) | |
1745 { | |
1746 int c; | |
1747 struct mode_data *m; | |
1748 | |
1749 print_maybe_const_decl ("%sunsigned char", | |
1750 "mode_ibit", "NUM_MACHINE_MODES", | |
1751 ibit); | |
1752 | |
1753 for_all_modes (c, m) | |
1754 tagged_printf ("%u", m->ibit, m->name); | |
1755 | |
1756 print_closer (); | |
1757 } | |
1758 | |
1759 /* Emit fbit for all modes. */ | |
1760 | |
1761 static void | |
1762 emit_mode_fbit (void) | |
1763 { | |
1764 int c; | |
1765 struct mode_data *m; | |
1766 | |
1767 print_maybe_const_decl ("%sunsigned char", | |
1768 "mode_fbit", "NUM_MACHINE_MODES", | |
1769 fbit); | |
1770 | |
1771 for_all_modes (c, m) | |
1772 tagged_printf ("%u", m->fbit, m->name); | |
1773 | |
1774 print_closer (); | |
1775 } | |
1776 | |
111 | 1777 /* Emit __intN for all modes. */ |
1778 | |
1779 static void | |
1780 emit_mode_int_n (void) | |
1781 { | |
1782 int c; | |
1783 struct mode_data *m; | |
1784 struct mode_data **mode_sort; | |
1785 int n_modes = 0; | |
1786 int i, j; | |
1787 | |
1788 print_decl ("int_n_data_t", "int_n_data", ""); | |
1789 | |
1790 n_modes = 0; | |
1791 for_all_modes (c, m) | |
1792 if (m->int_n) | |
1793 n_modes ++; | |
1794 mode_sort = XALLOCAVEC (struct mode_data *, n_modes); | |
1795 | |
1796 n_modes = 0; | |
1797 for_all_modes (c, m) | |
1798 if (m->int_n) | |
1799 mode_sort[n_modes++] = m; | |
1800 | |
1801 /* Yes, this is a bubblesort, but there are at most four (and | |
1802 usually only 1-2) entries to sort. */ | |
1803 for (i = 0; i<n_modes - 1; i++) | |
1804 for (j = i + 1; j < n_modes; j++) | |
1805 if (mode_sort[i]->int_n > mode_sort[j]->int_n) | |
1806 std::swap (mode_sort[i], mode_sort[j]); | |
1807 | |
1808 for (i = 0; i < n_modes; i ++) | |
1809 { | |
1810 m = mode_sort[i]; | |
1811 printf(" {\n"); | |
1812 tagged_printf ("%u", m->int_n, m->name); | |
1813 printf ("{ E_%smode },", m->name); | |
1814 printf(" },\n"); | |
1815 } | |
1816 | |
1817 print_closer (); | |
1818 } | |
1819 | |
0 | 1820 |
1821 static void | |
1822 emit_insn_modes_c (void) | |
1823 { | |
1824 emit_insn_modes_c_header (); | |
1825 emit_mode_name (); | |
1826 emit_mode_class (); | |
1827 emit_mode_precision (); | |
1828 emit_mode_size (); | |
1829 emit_mode_nunits (); | |
1830 emit_mode_wider (); | |
111 | 1831 emit_mode_complex (); |
0 | 1832 emit_mode_mask (); |
1833 emit_mode_inner (); | |
111 | 1834 emit_mode_unit_size (); |
1835 emit_mode_unit_precision (); | |
0 | 1836 emit_mode_base_align (); |
1837 emit_class_narrowest_mode (); | |
1838 emit_real_format_for_mode (); | |
1839 emit_mode_adjustments (); | |
1840 emit_mode_ibit (); | |
1841 emit_mode_fbit (); | |
111 | 1842 emit_mode_int_n (); |
0 | 1843 } |
1844 | |
1845 static void | |
1846 emit_min_insn_modes_c (void) | |
1847 { | |
1848 emit_min_insn_modes_c_header (); | |
1849 emit_mode_name (); | |
1850 emit_mode_class (); | |
111 | 1851 emit_mode_nunits (); |
0 | 1852 emit_mode_wider (); |
111 | 1853 emit_mode_inner (); |
0 | 1854 emit_class_narrowest_mode (); |
1855 } | |
1856 | |
1857 /* Master control. */ | |
1858 int | |
1859 main (int argc, char **argv) | |
1860 { | |
111 | 1861 bool gen_header = false, gen_inlines = false, gen_min = false; |
0 | 1862 progname = argv[0]; |
1863 | |
1864 if (argc == 1) | |
1865 ; | |
1866 else if (argc == 2 && !strcmp (argv[1], "-h")) | |
1867 gen_header = true; | |
111 | 1868 else if (argc == 2 && !strcmp (argv[1], "-i")) |
1869 gen_inlines = true; | |
0 | 1870 else if (argc == 2 && !strcmp (argv[1], "-m")) |
1871 gen_min = true; | |
1872 else | |
1873 { | |
111 | 1874 error ("usage: %s [-h|-i|-m] > file", progname); |
0 | 1875 return FATAL_EXIT_CODE; |
1876 } | |
1877 | |
1878 modes_by_name = htab_create_alloc (64, hash_mode, eq_mode, 0, xcalloc, free); | |
1879 | |
1880 create_modes (); | |
1881 complete_all_modes (); | |
1882 | |
1883 if (have_error) | |
1884 return FATAL_EXIT_CODE; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1885 |
0 | 1886 calc_wider_mode (); |
1887 | |
1888 if (gen_header) | |
1889 emit_insn_modes_h (); | |
111 | 1890 else if (gen_inlines) |
1891 emit_insn_modes_inline_h (); | |
0 | 1892 else if (gen_min) |
1893 emit_min_insn_modes_c (); | |
1894 else | |
1895 emit_insn_modes_c (); | |
1896 | |
1897 if (fflush (stdout) || fclose (stdout)) | |
1898 return FATAL_EXIT_CODE; | |
1899 return SUCCESS_EXIT_CODE; | |
1900 } |