1 /*
2 * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
3 *
4 * This file is part of libFirm.
5 *
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
10 *
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
14 *
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE.
18 */
19
20 /**
21 * @file
22 * @brief Data modes of operations.
23 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil
24 */
25 #include "config.h"
26
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stddef.h>
30 #include <stdbool.h>
31
32 #include "irprog_t.h"
33 #include "irmode_t.h"
34 #include "ident.h"
35 #include "tv_t.h"
36 #include "obst.h"
37 #include "irhooks.h"
38 #include "irtools.h"
39 #include "array.h"
40 #include "error.h"
41 #include "pattern_dmp.h"
42
43 /** Obstack to hold all modes. */
44 static struct obstack modes;
45
46 /** The list of all currently existing modes. */
47 static ir_mode **mode_list;
48
modes_are_equal(const ir_mode * m,const ir_mode * n)49 static bool modes_are_equal(const ir_mode *m, const ir_mode *n)
50 {
51 return m->sort == n->sort &&
52 m->arithmetic == n->arithmetic &&
53 m->size == n->size &&
54 m->sign == n->sign &&
55 m->modulo_shift == n->modulo_shift;
56 }
57
58 /**
59 * searches the modes obstack for the given mode and returns
60 * a pointer on an equal mode already in the array, NULL if
61 * none found
62 */
find_mode(const ir_mode * m)63 static ir_mode *find_mode(const ir_mode *m)
64 {
65 size_t i, n_modes;
66 for (i = 0, n_modes = ARR_LEN(mode_list); i < n_modes; ++i) {
67 ir_mode *n = mode_list[i];
68 if (modes_are_equal(n, m))
69 return n;
70 }
71 return NULL;
72 }
73
74 /**
75 * sets special values of modes
76 */
set_mode_values(ir_mode * mode)77 static void set_mode_values(ir_mode* mode)
78 {
79 switch (get_mode_sort(mode)) {
80 case irms_reference:
81 case irms_int_number:
82 case irms_float_number:
83 mode->min = get_tarval_min(mode);
84 mode->max = get_tarval_max(mode);
85 mode->null = get_tarval_null(mode);
86 mode->one = get_tarval_one(mode);
87 mode->minus_one = get_tarval_minus_one(mode);
88 if (get_mode_sort(mode) != irms_float_number) {
89 mode->all_one = get_tarval_all_one(mode);
90 } else {
91 mode->all_one = tarval_bad;
92 }
93 break;
94
95 case irms_internal_boolean:
96 mode->min = tarval_b_false;
97 mode->max = tarval_b_true;
98 mode->null = tarval_b_false;
99 mode->one = tarval_b_true;
100 mode->minus_one = tarval_bad;
101 mode->all_one = tarval_b_true;
102 break;
103
104 case irms_control_flow:
105 case irms_block:
106 case irms_tuple:
107 case irms_any:
108 case irms_bad:
109 case irms_memory:
110 mode->min = tarval_bad;
111 mode->max = tarval_bad;
112 mode->null = tarval_bad;
113 mode->one = tarval_bad;
114 mode->minus_one = tarval_bad;
115 break;
116 }
117 }
118
119 ir_mode *mode_T;
120 ir_mode *mode_X;
121 ir_mode *mode_M;
122 ir_mode *mode_BB;
123 ir_mode *mode_ANY;
124 ir_mode *mode_BAD;
125
126 ir_mode *mode_F;
127 ir_mode *mode_D;
128 ir_mode *mode_Q;
129
130 ir_mode *mode_Bs;
131 ir_mode *mode_Bu;
132 ir_mode *mode_Hs;
133 ir_mode *mode_Hu;
134 ir_mode *mode_Is;
135 ir_mode *mode_Iu;
136 ir_mode *mode_Ls;
137 ir_mode *mode_Lu;
138 ir_mode *mode_LLs;
139 ir_mode *mode_LLu;
140
141 ir_mode *mode_b;
142 ir_mode *mode_P;
143
144 ir_mode *mode_P_code;
145 ir_mode *mode_P_data;
146
get_modeT(void)147 ir_mode *get_modeT(void) { return mode_T; }
get_modeF(void)148 ir_mode *get_modeF(void) { return mode_F; }
get_modeD(void)149 ir_mode *get_modeD(void) { return mode_D; }
get_modeQ(void)150 ir_mode *get_modeQ(void) { return mode_Q; }
get_modeBs(void)151 ir_mode *get_modeBs(void) { return mode_Bs; }
get_modeBu(void)152 ir_mode *get_modeBu(void) { return mode_Bu; }
get_modeHs(void)153 ir_mode *get_modeHs(void) { return mode_Hs; }
get_modeHu(void)154 ir_mode *get_modeHu(void) { return mode_Hu; }
get_modeIs(void)155 ir_mode *get_modeIs(void) { return mode_Is; }
get_modeIu(void)156 ir_mode *get_modeIu(void) { return mode_Iu; }
get_modeLs(void)157 ir_mode *get_modeLs(void) { return mode_Ls; }
get_modeLu(void)158 ir_mode *get_modeLu(void) { return mode_Lu; }
get_modeLLs(void)159 ir_mode *get_modeLLs(void){ return mode_LLs; }
get_modeLLu(void)160 ir_mode *get_modeLLu(void){ return mode_LLu; }
get_modeb(void)161 ir_mode *get_modeb(void) { return mode_b; }
get_modeP(void)162 ir_mode *get_modeP(void) { return mode_P; }
get_modeX(void)163 ir_mode *get_modeX(void) { return mode_X; }
get_modeM(void)164 ir_mode *get_modeM(void) { return mode_M; }
get_modeBB(void)165 ir_mode *get_modeBB(void) { return mode_BB; }
get_modeANY(void)166 ir_mode *get_modeANY(void) { return mode_ANY; }
get_modeBAD(void)167 ir_mode *get_modeBAD(void) { return mode_BAD; }
168
169
170 ir_mode *(get_modeP_code)(void)
171 {
172 return get_modeP_code_();
173 }
174
175 ir_mode *(get_modeP_data)(void)
176 {
177 return get_modeP_data_();
178 }
179
set_modeP_code(ir_mode * p)180 void set_modeP_code(ir_mode *p)
181 {
182 assert(mode_is_reference(p));
183 mode_P_code = p;
184 }
185
set_modeP_data(ir_mode * p)186 void set_modeP_data(ir_mode *p)
187 {
188 assert(mode_is_reference(p));
189 mode_P_data = p;
190 mode_P = p;
191 }
192
193 /*
194 * Creates a new mode.
195 */
alloc_mode(const char * name,ir_mode_sort sort,ir_mode_arithmetic arithmetic,unsigned bit_size,int sign,unsigned modulo_shift)196 static ir_mode *alloc_mode(const char *name, ir_mode_sort sort,
197 ir_mode_arithmetic arithmetic, unsigned bit_size,
198 int sign, unsigned modulo_shift)
199 {
200 ir_mode *mode_tmpl = OALLOCZ(&modes, ir_mode);
201
202 mode_tmpl->name = new_id_from_str(name);
203 mode_tmpl->sort = sort;
204 mode_tmpl->size = bit_size;
205 mode_tmpl->sign = sign ? 1 : 0;
206 mode_tmpl->modulo_shift = modulo_shift;
207 mode_tmpl->arithmetic = arithmetic;
208 mode_tmpl->link = NULL;
209 mode_tmpl->tv_priv = NULL;
210 return mode_tmpl;
211 }
212
register_mode(ir_mode * mode)213 static ir_mode *register_mode(ir_mode *mode)
214 {
215 /* does any of the existing modes have the same properties? */
216 ir_mode *old = find_mode(mode);
217 if (old != NULL) {
218 /* remove new mode from obstack */
219 obstack_free(&modes, mode);
220 return old;
221 }
222
223 mode->kind = k_ir_mode;
224 mode->type = new_type_primitive(mode);
225 ARR_APP1(ir_mode*, mode_list, mode);
226 set_mode_values(mode);
227 hook_new_mode(mode);
228 return mode;
229 }
230
new_int_mode(const char * name,ir_mode_arithmetic arithmetic,unsigned bit_size,int sign,unsigned modulo_shift)231 ir_mode *new_int_mode(const char *name, ir_mode_arithmetic arithmetic,
232 unsigned bit_size, int sign, unsigned modulo_shift)
233 {
234 ir_mode *result = alloc_mode(name, irms_int_number, arithmetic, bit_size,
235 sign, modulo_shift);
236 return register_mode(result);
237 }
238
new_reference_mode(const char * name,ir_mode_arithmetic arithmetic,unsigned bit_size,unsigned modulo_shift)239 ir_mode *new_reference_mode(const char *name, ir_mode_arithmetic arithmetic,
240 unsigned bit_size, unsigned modulo_shift)
241 {
242 ir_mode *result = alloc_mode(name, irms_reference, arithmetic, bit_size,
243 0, modulo_shift);
244 return register_mode(result);
245 }
246
new_float_mode(const char * name,ir_mode_arithmetic arithmetic,unsigned exponent_size,unsigned mantissa_size)247 ir_mode *new_float_mode(const char *name, ir_mode_arithmetic arithmetic,
248 unsigned exponent_size, unsigned mantissa_size)
249 {
250 bool explicit_one = false;
251 unsigned bit_size = exponent_size + mantissa_size + 1;
252 ir_mode *result;
253
254 if (arithmetic == irma_x86_extended_float) {
255 explicit_one = true;
256 bit_size++;
257 } else if (arithmetic != irma_ieee754) {
258 panic("Arithmetic %s invalid for float");
259 }
260 if (exponent_size >= 256)
261 panic("Exponents >= 256 bits not supported");
262 if (mantissa_size >= 256)
263 panic("Mantissa >= 256 bits not supported");
264
265 result = alloc_mode(name, irms_float_number, irma_x86_extended_float, bit_size, 1, 0);
266 result->float_desc.exponent_size = exponent_size;
267 result->float_desc.mantissa_size = mantissa_size;
268 result->float_desc.explicit_one = explicit_one;
269 return register_mode(result);
270 }
271
272 ident *(get_mode_ident)(const ir_mode *mode)
273 {
274 return get_mode_ident_(mode);
275 }
276
get_mode_name(const ir_mode * mode)277 const char *get_mode_name(const ir_mode *mode)
278 {
279 return get_id_str(mode->name);
280 }
281
282 unsigned (get_mode_size_bits)(const ir_mode *mode)
283 {
284 return get_mode_size_bits_(mode);
285 }
286
287 unsigned (get_mode_size_bytes)(const ir_mode *mode)
288 {
289 return get_mode_size_bytes_(mode);
290 }
291
292 int (get_mode_sign)(const ir_mode *mode)
293 {
294 return get_mode_sign_(mode);
295 }
296
ir_mode_arithmetic(get_mode_arithmetic)297 ir_mode_arithmetic (get_mode_arithmetic)(const ir_mode *mode)
298 {
299 return get_mode_arithmetic_(mode);
300 }
301
302
303 unsigned int (get_mode_modulo_shift)(const ir_mode *mode)
304 {
305 return get_mode_modulo_shift_(mode);
306 }
307
308 void *(get_mode_link)(const ir_mode *mode)
309 {
310 return get_mode_link_(mode);
311 }
312
313 void (set_mode_link)(ir_mode *mode, void *l)
314 {
315 set_mode_link_(mode, l);
316 }
317
get_mode_min(ir_mode * mode)318 ir_tarval *get_mode_min(ir_mode *mode)
319 {
320 assert(mode);
321 assert(mode_is_data(mode));
322
323 return mode->min;
324 }
325
get_mode_max(ir_mode * mode)326 ir_tarval *get_mode_max(ir_mode *mode)
327 {
328 assert(mode);
329 assert(mode_is_data(mode));
330
331 return mode->max;
332 }
333
get_mode_null(ir_mode * mode)334 ir_tarval *get_mode_null(ir_mode *mode)
335 {
336 assert(mode);
337 assert(mode_is_datab(mode));
338
339 return mode->null;
340 }
341
get_mode_one(ir_mode * mode)342 ir_tarval *get_mode_one(ir_mode *mode)
343 {
344 assert(mode);
345 assert(mode_is_datab(mode));
346
347 return mode->one;
348 }
349
get_mode_minus_one(ir_mode * mode)350 ir_tarval *get_mode_minus_one(ir_mode *mode)
351 {
352 assert(mode);
353 assert(mode_is_data(mode));
354
355 return mode->minus_one;
356 }
357
get_mode_all_one(ir_mode * mode)358 ir_tarval *get_mode_all_one(ir_mode *mode)
359 {
360 assert(mode);
361 assert(mode_is_datab(mode));
362 return mode->all_one;
363 }
364
get_mode_infinite(ir_mode * mode)365 ir_tarval *get_mode_infinite(ir_mode *mode)
366 {
367 assert(mode);
368 assert(mode_is_float(mode));
369
370 return get_tarval_plus_inf(mode);
371 }
372
get_mode_NAN(ir_mode * mode)373 ir_tarval *get_mode_NAN(ir_mode *mode)
374 {
375 assert(mode);
376 assert(mode_is_float(mode));
377
378 return get_tarval_nan(mode);
379 }
380
is_mode(const void * thing)381 int is_mode(const void *thing)
382 {
383 return get_kind(thing) == k_ir_mode;
384 }
385
386 int (mode_is_signed)(const ir_mode *mode)
387 {
388 return mode_is_signed_(mode);
389 }
390
391 int (mode_is_float)(const ir_mode *mode)
392 {
393 return mode_is_float_(mode);
394 }
395
396 int (mode_is_int)(const ir_mode *mode)
397 {
398 return mode_is_int_(mode);
399 }
400
401 int (mode_is_reference)(const ir_mode *mode)
402 {
403 return mode_is_reference_(mode);
404 }
405
406 int (mode_is_num)(const ir_mode *mode)
407 {
408 return mode_is_num_(mode);
409 }
410
411 int (mode_is_data)(const ir_mode *mode)
412 {
413 return mode_is_data_(mode);
414 }
415
416 int (mode_is_datab)(const ir_mode *mode)
417 {
418 return mode_is_datab_(mode);
419 }
420
421 int (mode_is_dataM)(const ir_mode *mode)
422 {
423 return mode_is_dataM_(mode);
424 }
425
426 unsigned (get_mode_mantissa_size)(const ir_mode *mode)
427 {
428 return get_mode_mantissa_size_(mode);
429 }
430
431 unsigned (get_mode_exponent_size)(const ir_mode *mode)
432 {
433 return get_mode_exponent_size_(mode);
434 }
435
smaller_mode(const ir_mode * sm,const ir_mode * lm)436 int smaller_mode(const ir_mode *sm, const ir_mode *lm)
437 {
438 int sm_bits, lm_bits;
439
440 assert(sm);
441 assert(lm);
442
443 if (sm == lm) return 1;
444
445 sm_bits = get_mode_size_bits(sm);
446 lm_bits = get_mode_size_bits(lm);
447
448 switch (get_mode_sort(sm)) {
449 case irms_int_number:
450 switch (get_mode_sort(lm)) {
451 case irms_int_number:
452 if (get_mode_arithmetic(sm) != get_mode_arithmetic(lm))
453 return 0;
454
455 /* only two complement implemented */
456 assert(get_mode_arithmetic(sm) == irma_twos_complement);
457
458 /* integers are convertable if
459 * - both have the same sign and lm is the larger one
460 * - lm is the signed one and is at least two bits larger
461 * (one for the sign, one for the highest bit of sm)
462 * - sm & lm are two_complement and lm has greater or equal number of bits
463 */
464 if (mode_is_signed(sm)) {
465 if (!mode_is_signed(lm))
466 return 0;
467 return sm_bits <= lm_bits;
468 } else {
469 if (mode_is_signed(lm)) {
470 return sm_bits < lm_bits;
471 }
472 return sm_bits <= lm_bits;
473 }
474
475 case irms_float_number:
476 /* int to float works if the float is large enough */
477 return 0;
478
479 default:
480 break;
481 }
482 break;
483
484 case irms_float_number:
485 if (get_mode_arithmetic(sm) == get_mode_arithmetic(lm)) {
486 if ( (get_mode_sort(lm) == irms_float_number)
487 && (get_mode_size_bits(lm) >= get_mode_size_bits(sm)) )
488 return 1;
489 }
490 break;
491
492 case irms_reference:
493 /* do exist machines out there with different pointer lengths ?*/
494 return 0;
495
496 case irms_internal_boolean:
497 return mode_is_int(lm);
498
499 default:
500 break;
501 }
502
503 /* else */
504 return 0;
505 }
506
values_in_mode(const ir_mode * sm,const ir_mode * lm)507 int values_in_mode(const ir_mode *sm, const ir_mode *lm)
508 {
509 if (sm == lm)
510 return true;
511
512 if (sm == mode_b)
513 return mode_is_int(lm) || mode_is_float(lm);
514
515 ir_mode_arithmetic larith = get_mode_arithmetic(lm);
516 ir_mode_arithmetic sarith = get_mode_arithmetic(sm);
517 switch (larith) {
518 case irma_x86_extended_float:
519 case irma_ieee754:
520 if (sarith == irma_ieee754 || sarith == irma_x86_extended_float) {
521 return get_mode_size_bits(sm) <= get_mode_size_bits(lm);
522 } else if (sarith == irma_twos_complement) {
523 unsigned int_mantissa = get_mode_size_bits(sm) - (mode_is_signed(sm) ? 1 : 0);
524 unsigned float_mantissa = get_mode_mantissa_size(lm) + 1;
525 return int_mantissa <= float_mantissa;
526 }
527 break;
528 case irma_twos_complement:
529 if (sarith == irma_twos_complement) {
530 return get_mode_size_bits(sm) <= get_mode_size_bits(lm);
531 }
532 break;
533 case irma_none:
534 break;
535 }
536 return false;
537 }
538
get_reference_mode_signed_eq(ir_mode * mode)539 ir_mode *get_reference_mode_signed_eq(ir_mode *mode)
540 {
541 assert(mode_is_reference(mode));
542 return mode->eq_signed;
543 }
544
set_reference_mode_signed_eq(ir_mode * ref_mode,ir_mode * int_mode)545 void set_reference_mode_signed_eq(ir_mode *ref_mode, ir_mode *int_mode)
546 {
547 assert(mode_is_reference(ref_mode));
548 assert(mode_is_int(int_mode));
549 ref_mode->eq_signed = int_mode;
550 }
551
get_reference_mode_unsigned_eq(ir_mode * mode)552 ir_mode *get_reference_mode_unsigned_eq(ir_mode *mode)
553 {
554 assert(mode_is_reference(mode));
555 return mode->eq_unsigned;
556 }
557
set_reference_mode_unsigned_eq(ir_mode * ref_mode,ir_mode * int_mode)558 void set_reference_mode_unsigned_eq(ir_mode *ref_mode, ir_mode *int_mode)
559 {
560 assert(mode_is_reference(ref_mode));
561 assert(mode_is_int(int_mode));
562 ref_mode->eq_unsigned = int_mode;
563 }
564
new_internal_mode(const char * name,ir_mode_sort sort)565 static ir_mode *new_internal_mode(const char *name, ir_mode_sort sort)
566 {
567 ir_mode *mode = alloc_mode(name, sort, irma_none, 0, 0, 0);
568 return register_mode(mode);
569 }
570
init_mode(void)571 void init_mode(void)
572 {
573 obstack_init(&modes);
574 mode_list = NEW_ARR_F(ir_mode*, 0);
575
576 /* initialize predefined modes */
577 mode_BB = new_internal_mode("BB", irms_block);
578 mode_X = new_internal_mode("X", irms_control_flow);
579 mode_M = new_internal_mode("M", irms_memory);
580 mode_T = new_internal_mode("T", irms_tuple);
581 mode_ANY = new_internal_mode("ANY", irms_any);
582 mode_BAD = new_internal_mode("BAD", irms_bad);
583 mode_b = new_internal_mode("b", irms_internal_boolean);
584
585 mode_F = new_float_mode("F", irma_ieee754, 8, 23);
586 mode_D = new_float_mode("D", irma_ieee754, 11, 52);
587 mode_Q = new_float_mode("Q", irma_ieee754, 15, 112);
588
589 mode_Bs = new_int_mode("Bs", irma_twos_complement, 8, 1, 32);
590 mode_Bu = new_int_mode("Bu", irma_twos_complement, 8, 0, 32);
591 mode_Hs = new_int_mode("Hs", irma_twos_complement, 16, 1, 32);
592 mode_Hu = new_int_mode("Hu", irma_twos_complement, 16, 0, 32);
593 mode_Is = new_int_mode("Is", irma_twos_complement, 32, 1, 32);
594 mode_Iu = new_int_mode("Iu", irma_twos_complement, 32, 0, 32);
595 mode_Ls = new_int_mode("Ls", irma_twos_complement, 64, 1, 64);
596 mode_Lu = new_int_mode("Lu", irma_twos_complement, 64, 0, 64);
597 mode_LLs = new_int_mode("LLs", irma_twos_complement, 128, 1, 128);
598 mode_LLu = new_int_mode("LLu", irma_twos_complement, 128, 0, 128);
599
600 mode_P = new_reference_mode("P", irma_twos_complement, 32, 32);
601 set_reference_mode_signed_eq(mode_P, mode_Is);
602 set_reference_mode_unsigned_eq(mode_P, mode_Iu);
603
604 /* set the machine specific modes to the predefined ones */
605 mode_P_code = mode_P;
606 mode_P_data = mode_P;
607 }
608
find_unsigned_mode(const ir_mode * mode)609 ir_mode *find_unsigned_mode(const ir_mode *mode)
610 {
611 ir_mode n = *mode;
612
613 /* allowed for reference mode */
614 if (mode->sort == irms_reference)
615 n.sort = irms_int_number;
616
617 assert(n.sort == irms_int_number);
618 n.sign = 0;
619 return find_mode(&n);
620 }
621
find_signed_mode(const ir_mode * mode)622 ir_mode *find_signed_mode(const ir_mode *mode)
623 {
624 ir_mode n = *mode;
625
626 assert(mode->sort == irms_int_number);
627 n.sign = 1;
628 return find_mode(&n);
629 }
630
find_double_bits_int_mode(const ir_mode * mode)631 ir_mode *find_double_bits_int_mode(const ir_mode *mode)
632 {
633 ir_mode n = *mode;
634
635 assert(mode->sort == irms_int_number && mode->arithmetic == irma_twos_complement);
636
637 n.size = 2*mode->size;
638 return find_mode(&n);
639 }
640
mode_honor_signed_zeros(const ir_mode * mode)641 int mode_honor_signed_zeros(const ir_mode *mode)
642 {
643 /* for floating point, we know that IEEE 754 has +0 and -0,
644 * but always handles it identical.
645 */
646 return
647 mode->sort == irms_float_number &&
648 mode->arithmetic != irma_ieee754;
649 }
650
mode_overflow_on_unary_Minus(const ir_mode * mode)651 int mode_overflow_on_unary_Minus(const ir_mode *mode)
652 {
653 if (mode->sort == irms_float_number)
654 return mode->arithmetic == irma_ieee754 ? 0 : 1;
655 return 1;
656 }
657
mode_wrap_around(const ir_mode * mode)658 int mode_wrap_around(const ir_mode *mode)
659 {
660 /* FIXME: better would be an extra mode property */
661 return mode_is_int(mode);
662 }
663
is_reinterpret_cast(const ir_mode * src,const ir_mode * dst)664 int is_reinterpret_cast(const ir_mode *src, const ir_mode *dst)
665 {
666 ir_mode_arithmetic ma;
667
668 if (src == dst)
669 return 1;
670 if (get_mode_size_bits(src) != get_mode_size_bits(dst))
671 return 0;
672 ma = get_mode_arithmetic(src);
673 if (ma != get_mode_arithmetic(dst))
674 return 0;
675
676 return ma == irma_twos_complement;
677 }
678
679 ir_type *(get_type_for_mode) (const ir_mode *mode)
680 {
681 return get_type_for_mode_(mode);
682 }
683
ir_get_n_modes(void)684 size_t ir_get_n_modes(void)
685 {
686 return ARR_LEN(mode_list);
687 }
688
ir_get_mode(size_t num)689 ir_mode *ir_get_mode(size_t num)
690 {
691 assert(num < ARR_LEN(mode_list));
692 return mode_list[num];
693 }
694
finish_mode(void)695 void finish_mode(void)
696 {
697 obstack_free(&modes, 0);
698 DEL_ARR_F(mode_list);
699
700 mode_T = NULL;
701 mode_X = NULL;
702 mode_M = NULL;
703 mode_BB = NULL;
704 mode_ANY = NULL;
705 mode_BAD = NULL;
706
707 mode_F = NULL;
708 mode_D = NULL;
709
710 mode_Bs = NULL;
711 mode_Bu = NULL;
712 mode_Hs = NULL;
713 mode_Hu = NULL;
714 mode_Is = NULL;
715 mode_Iu = NULL;
716 mode_Ls = NULL;
717 mode_Lu = NULL;
718
719 mode_b = NULL;
720
721 mode_P = NULL;
722 mode_P_code = NULL;
723 mode_P_data = NULL;
724 }
725