irmode.c 17.8 KB
Newer Older
Christian Schäfer's avatar
Christian Schäfer committed
1
/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2
3
4
5
** All rights reserved.
**
** Authors: Martin Trapp, Christian Schaefer
**
Christian Schäfer's avatar
Christian Schäfer committed
6
7
*/

Boris Boesler's avatar
Boris Boesler committed
8
9
/* $Id$ */

Boris Boesler's avatar
added    
Boris Boesler committed
10
11
12
13
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

Götz Lindenmaier's avatar
Götz Lindenmaier committed
14
# include "irmode_t.h"
15
# include "ident.h"
16
# include <stdlib.h>
Christian Schäfer's avatar
Christian Schäfer committed
17
# include <stddef.h>
18
# include <string.h>
Christian Schäfer's avatar
Christian Schäfer committed
19
# include "tv.h"
20
# include "array.h"
Christian Schäfer's avatar
Christian Schäfer committed
21

22
#if 0
Götz Lindenmaier's avatar
Götz Lindenmaier committed
23
static long long count = 0;
24
25
26
27
#  define ANNOUNCE() printf(__FILE__": call no. %lld (%s)\n", count++, __FUNCTION__)
#else
#  define ANNOUNCE() ((void)0)
#endif
Christian Schäfer's avatar
Christian Schäfer committed
28

29
30
31
/* * *
 * local values
 * * */
32

Christian Schäfer's avatar
Christian Schäfer committed
33

Michael Beck's avatar
Michael Beck committed
34
/** dynamic array to hold all modes */
35
36
37
38
39
40
static ir_mode * modes;
/* dynamic arrays to hold special modes' values */
static tarval** modes_min;
static tarval** modes_max;
static tarval** modes_null;
static tarval** modes_one;
Christian Schäfer's avatar
Christian Schäfer committed
41

Michael Beck's avatar
Michael Beck committed
42
/** number of defined modes */
43
static int num_modes;
Christian Schäfer's avatar
Christian Schäfer committed
44

45
46
47
/* * *
 * local functions
 * * */
Christian Schäfer's avatar
Christian Schäfer committed
48

49
/**
50
 * Compare modes that don't need to have their code field
51
52
 * correctly set
 */
Michael Beck's avatar
Michael Beck committed
53
static int modes_are_equal(const ir_mode *m, const ir_mode *n)
54
55
56
{
  if (m == n) return 1;
  if ( (m->sort == n->sort) && (m->size == n->size) &&
57
58
      (m->align == n->align) && (m->sign == n->sign) &&
      (m->name == n->name)
59
     )
60
    return 1;
Christian Schäfer's avatar
Christian Schäfer committed
61

62
63
  return 0;
}
Matthias Heil's avatar
Matthias Heil committed
64

65
66
/**
 * searches the modes array for the given mode and returns
67
 * a pointer on an equal mode already in the array, NULL if
68
69
 * none found
 */
70
71
72
static ir_mode *find_mode(ir_mode *m)
{
  int i;
Matthias Heil's avatar
Matthias Heil committed
73

74
75
76
77
  for (i = 0; i < num_modes; i++)
  {
    if (modes_are_equal(m, &modes[i])) return &modes[i];
  }
Matthias Heil's avatar
Matthias Heil committed
78

79
80
  return NULL;
}
Christian Schäfer's avatar
Christian Schäfer committed
81

82
83
84
/**
 * sets special values of modes
 */
85
86
87
88
89
90
91
92
93
94
static void set_mode_values(ir_mode* mode)
{
  modes_min[get_mode_modecode(mode)] = get_tarval_min(mode);
  modes_max[get_mode_modecode(mode)] = get_tarval_max(mode);
  modes_null[get_mode_modecode(mode)] = get_tarval_null(mode);
  modes_one[get_mode_modecode(mode)] = get_tarval_one(mode);
}
/* * *
 * globals defined in irmode.h
 * * */
Matthias Heil's avatar
Matthias Heil committed
95

96
/* --- Predefined modes --- */
Christian Schäfer's avatar
Christian Schäfer committed
97

98
99
100
101
102
/* FIRM internal modes: */
ir_mode *mode_T;
ir_mode *mode_X;
ir_mode *mode_M;
ir_mode *mode_BB;
Christian Schäfer's avatar
Christian Schäfer committed
103

104
105
106
107
/* predefined numerical modes: */
ir_mode *mode_F;    /* float */
ir_mode *mode_D;    /* double */
ir_mode *mode_E;    /* long double */
Christian Schäfer's avatar
Christian Schäfer committed
108

109
110
111
112
113
114
115
116
ir_mode *mode_Bs;   /* integral values, signed and unsigned */
ir_mode *mode_Bu;   /* 8 bit */
ir_mode *mode_Hs;   /* 16 bit */
ir_mode *mode_Hu;
ir_mode *mode_Is;   /* 32 bit */
ir_mode *mode_Iu;
ir_mode *mode_Ls;   /* 64 bit */
ir_mode *mode_Lu;
Christian Schäfer's avatar
Christian Schäfer committed
117

118
119
120
121
ir_mode *mode_C;
ir_mode *mode_U;
ir_mode *mode_b;
ir_mode *mode_P;
122

123
124
125
126
127
/* * *
 * functions defined in irmode.h
 * * */

/* JNI access functions */
Michael Beck's avatar
Michael Beck committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
INLINE ir_mode *get_modeT(void) { ANNOUNCE(); return mode_T; }
INLINE ir_mode *get_modeF(void) { ANNOUNCE(); return mode_F; }
INLINE ir_mode *get_modeD(void) { ANNOUNCE(); return mode_D; }
INLINE ir_mode *get_modeE(void) { ANNOUNCE(); return mode_E; }
INLINE ir_mode *get_modeBs(void) { ANNOUNCE(); return mode_Bs; }
INLINE ir_mode *get_modeBu(void) { ANNOUNCE(); return mode_Bu; }
INLINE ir_mode *get_modeHs(void) { ANNOUNCE(); return mode_Hs; }
INLINE ir_mode *get_modeHu(void) { ANNOUNCE(); return mode_Hu; }
INLINE ir_mode *get_modeIs(void) { ANNOUNCE(); return mode_Is; }
INLINE ir_mode *get_modeIu(void) { ANNOUNCE(); return mode_Iu; }
INLINE ir_mode *get_modeLs(void) { ANNOUNCE(); return mode_Ls; }
INLINE ir_mode *get_modeLu(void) { ANNOUNCE(); return mode_Lu; }
INLINE ir_mode *get_modeC(void) { ANNOUNCE(); return mode_C; }
INLINE ir_mode *get_modeU(void) { ANNOUNCE(); return mode_U; }
INLINE ir_mode *get_modeb(void) { ANNOUNCE(); return mode_b; }
INLINE ir_mode *get_modeP(void) { ANNOUNCE(); return mode_P; }
INLINE ir_mode *get_modeX(void) { ANNOUNCE(); return mode_X; }
INLINE ir_mode *get_modeM(void) { ANNOUNCE(); return mode_M; }
INLINE ir_mode *get_modeBB(void) { ANNOUNCE(); return mode_BB; }
147

148
149
150
151
152
/**
 * Registers a new mode if not defined yet, else returns
 * the "equivalent" one.
 */
static ir_mode *register_mode(ir_mode* new_mode)
153
154
155
156
157
158
159
160
161
162
163
164
165
{
  ir_mode *mode;

  ANNOUNCE();
  assert(new_mode);

  /* first check if there already is a matching mode */
  mode = find_mode(new_mode);
  if (mode) return mode;

  /* sanity checks */
  switch (new_mode->sort)
  {
166
167
    case irms_auxiliary:
    case irms_internal_boolean:
168
      assert(0 && "internal modes cannot be user defined");
169
      return NULL;
170
171
      break;

172
    case irms_float_number:
173
      assert(0 && "not yet implemented");
174
      return NULL;
175
176
      break;

177
178
179
    case irms_int_number:
    case irms_reference:
    case irms_character:
180
181
182
      break;

    default:
183
      assert(0 && "wrong mode sort");
184
      return NULL;
185
  }
Christian Schäfer's avatar
Christian Schäfer committed
186

187
188
189
190
191
192
193
  /* copy mode struct to modes array */
  ARR_EXTEND(ir_mode, modes, 1);
  ARR_EXTEND(tarval*, modes_min, 1);
  ARR_EXTEND(tarval*, modes_max, 1);
  ARR_EXTEND(tarval*, modes_null, 1);
  ARR_EXTEND(tarval*, modes_one, 1);
  mode = &modes[num_modes];
Christian Schäfer's avatar
Christian Schäfer committed
194

195
196
197
198
199
  memcpy(mode, new_mode, sizeof(ir_mode));
  mode->code = num_modes;
  num_modes++;

  set_mode_values(mode);
Christian Schäfer's avatar
Christian Schäfer committed
200

201
  return mode;
Christian Schäfer's avatar
Christian Schäfer committed
202
203
}

204
205
206
207
208
/*
 * Creates a new mode.
 */
ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int align, int sign)
{
209
  ir_mode mode_tmpl;
210
211
212
213
214
215
216
217
218
219
220

  mode_tmpl.name    = new_id_from_str(name);
  mode_tmpl.sort    = sort;
  mode_tmpl.size    = bit_size;
  mode_tmpl.align   = align;
  mode_tmpl.sign    = sign ? 1 : 0;
  mode_tmpl.tv_priv = NULL;

  return register_mode(&mode_tmpl);
}

221
/* Functions for the direct access to all attributes od a ir_mode */
Christian Schäfer's avatar
Christian Schäfer committed
222
modecode
Michael Beck's avatar
Michael Beck committed
223
get_mode_modecode(const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
224
{
225
  ANNOUNCE();
Christian Schäfer's avatar
Christian Schäfer committed
226
227
228
229
  return mode->code;
}

ident *
Michael Beck's avatar
Michael Beck committed
230
get_mode_ident(const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
231
{
232
  ANNOUNCE();
Christian Schäfer's avatar
Christian Schäfer committed
233
234
235
  return mode->name;
}

236
const char *
Michael Beck's avatar
Michael Beck committed
237
get_mode_name(const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
238
{
239
240
  ANNOUNCE();
  return id_to_str(mode->name);
Christian Schäfer's avatar
Christian Schäfer committed
241
242
}

243
mode_sort
Michael Beck's avatar
Michael Beck committed
244
get_mode_sort(const ir_mode* mode)
245
246
247
{
  ANNOUNCE();
  return mode->sort;
Götz Lindenmaier's avatar
Götz Lindenmaier committed
248
249
}

Götz Lindenmaier's avatar
Götz Lindenmaier committed
250
INLINE int
Michael Beck's avatar
Michael Beck committed
251
get_mode_size_bits(const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
252
{
253
  ANNOUNCE();
Christian Schäfer's avatar
Christian Schäfer committed
254
255
256
  return mode->size;
}

Michael Beck's avatar
Michael Beck committed
257
int get_mode_size_bytes(const ir_mode *mode) {
Götz Lindenmaier's avatar
Götz Lindenmaier committed
258
259
  ANNOUNCE();
  int size = get_mode_size_bits(mode);
Michael Beck's avatar
Michael Beck committed
260
261
  if ((size & 7) != 0) return -1;
  return size >> 3;
Götz Lindenmaier's avatar
Götz Lindenmaier committed
262
263
}

Christian Schäfer's avatar
Christian Schäfer committed
264
int
Michael Beck's avatar
Michael Beck committed
265
get_mode_align (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
266
{
267
268
  ANNOUNCE();
  return mode->align;
Christian Schäfer's avatar
Christian Schäfer committed
269
}
270
271

int
Michael Beck's avatar
Michael Beck committed
272
get_mode_sign (const ir_mode *mode)
273
274
275
276
277
{
  ANNOUNCE();
  return mode->sign;
}

Christian Schäfer's avatar
Christian Schäfer committed
278
tarval *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
279
get_mode_min (ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
280
{
281
282
283
284
  ANNOUNCE();
  assert(mode);
  assert(get_mode_modecode(mode) < num_modes);
  assert(mode_is_data(mode));
Christian Schäfer's avatar
Christian Schäfer committed
285

286
  return modes_min[get_mode_modecode(mode)];
Christian Schäfer's avatar
Christian Schäfer committed
287
288
289
}

tarval *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
290
get_mode_max (ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
291
{
292
293
294
295
  ANNOUNCE();
  assert(mode);
  assert(get_mode_modecode(mode) < num_modes);
  assert(mode_is_data(mode));
Christian Schäfer's avatar
Christian Schäfer committed
296

297
  return modes_max[get_mode_modecode(mode)];
Christian Schäfer's avatar
Christian Schäfer committed
298
299
300
}

tarval *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
301
get_mode_null (ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
302
{
303
304
305
306
  ANNOUNCE();
  assert(mode);
  assert(get_mode_modecode(mode) < num_modes);
  assert(mode_is_data(mode));
Christian Schäfer's avatar
Christian Schäfer committed
307

308
  return modes_null[get_mode_modecode(mode)];
Christian Schäfer's avatar
Christian Schäfer committed
309
310
}

311
312
tarval *
get_mode_one (ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
313
{
314
315
316
317
  ANNOUNCE();
  assert(mode);
  assert(get_mode_modecode(mode) < num_modes);
  assert(mode_is_data(mode));
Christian Schäfer's avatar
Christian Schäfer committed
318

319
  return modes_one[get_mode_modecode(mode)];
Christian Schäfer's avatar
Christian Schäfer committed
320
321
}

322
323
tarval *
get_mode_infinite(ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
324
{
325
326
327
328
329
330
  ANNOUNCE();
  assert(mode);
  assert(get_mode_modecode(mode) < num_modes);
  assert(mode_is_float(mode));

  return get_tarval_inf(mode);
Christian Schäfer's avatar
Christian Schäfer committed
331
332
}

333
334
tarval *
get_mode_NAN(ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
335
{
336
337
338
339
340
341
  ANNOUNCE();
  assert(mode);
  assert(get_mode_modecode(mode) < num_modes);
  assert(mode_is_float(mode));

  return get_tarval_nan(mode);
Christian Schäfer's avatar
Christian Schäfer committed
342
343
344
345
346
347
348
349
}

/* Functions to check, whether a modecode is signed, float, int, num, data,
   datab or dataM. For more exact definitions read the corresponding pages
   in the firm documentation or the followingenumeration

   The set of "float" is defined as:
   ---------------------------------
Matthias Heil's avatar
Matthias Heil committed
350
   float = {irm_F, irm_D, irm_E}
Christian Schäfer's avatar
Christian Schäfer committed
351
352
353

   The set of "int" is defined as:
   -------------------------------
Matthias Heil's avatar
Matthias Heil committed
354
   int   = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
Christian Schäfer's avatar
Christian Schäfer committed
355
356
357

   The set of "num" is defined as:
   -------------------------------
Matthias Heil's avatar
Matthias Heil committed
358
359
   num   = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
            irm_Is, irm_Iu, irm_Ls, irm_Lu}
Christian Schäfer's avatar
Christian Schäfer committed
360
361
362
363
            = {float || int}

   The set of "data" is defined as:
   -------------------------------
Matthias Heil's avatar
Matthias Heil committed
364
   data  = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu,
365
366
            irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P}
            = {num || irm_C || irm_U || irm_P}
Christian Schäfer's avatar
Christian Schäfer committed
367
368
369

   The set of "datab" is defined as:
   ---------------------------------
Matthias Heil's avatar
Matthias Heil committed
370
   datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
371
            irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_b}
Matthias Heil's avatar
Matthias Heil committed
372
            = {data || irm_b }
Christian Schäfer's avatar
Christian Schäfer committed
373
374
375

   The set of "dataM" is defined as:
   ---------------------------------
Matthias Heil's avatar
Matthias Heil committed
376
   dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
377
            irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_M}
Christian Schäfer's avatar
Christian Schäfer committed
378
379
380
            = {data || irm_M}
*/

381
382
383
384
385
386
387
388
389
#ifdef MODE_ACCESS_DEFINES
#  undef mode_is_signed
#  undef mode_is_float
#  undef mode_is_int
#  undef mode_is_num
#  undef mode_is_data
#  undef mode_is_datab
#  undef mode_is_dataM
#endif
Christian Schäfer's avatar
Christian Schäfer committed
390
int
Michael Beck's avatar
Michael Beck committed
391
mode_is_signed (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
392
{
393
394
395
  ANNOUNCE();
  assert(mode);
  return mode->sign;
Christian Schäfer's avatar
Christian Schäfer committed
396
397
}

398
int
Michael Beck's avatar
Michael Beck committed
399
mode_is_float (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
400
{
401
402
  ANNOUNCE();
  assert(mode);
403
  return (get_mode_sort(mode) == irms_float_number);
Christian Schäfer's avatar
Christian Schäfer committed
404
405
}

406
int
Michael Beck's avatar
Michael Beck committed
407
mode_is_int (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
408
{
409
410
  ANNOUNCE();
  assert(mode);
411
  return (get_mode_sort(mode) == irms_int_number);
Christian Schäfer's avatar
Christian Schäfer committed
412
413
}

Michael Beck's avatar
Michael Beck committed
414
int mode_is_character (const ir_mode *mode)
415
416
417
418
419
420
{
  ANNOUNCE();
  assert(mode);
  return (get_mode_sort(mode) == irms_character);
}

Michael Beck's avatar
Michael Beck committed
421
int mode_is_reference (const ir_mode *mode)
422
423
424
425
426
427
{
  ANNOUNCE();
  assert(mode);
  return (get_mode_sort(mode) == irms_reference);
}

428
int
Michael Beck's avatar
Michael Beck committed
429
mode_is_num (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
430
{
431
432
433
  ANNOUNCE();
  assert(mode);
  return (mode_is_int(mode) || mode_is_float(mode));
Christian Schäfer's avatar
Christian Schäfer committed
434
435
}

436
int
Michael Beck's avatar
Michael Beck committed
437
mode_is_data (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
438
{
439
440
  ANNOUNCE();
  assert(mode);
441
  return (mode_is_num(mode) || get_mode_sort(mode) == irms_character || get_mode_sort(mode) == irms_reference);
Christian Schäfer's avatar
Christian Schäfer committed
442
443
444
}

int
Michael Beck's avatar
Michael Beck committed
445
mode_is_datab (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
446
{
447
448
  ANNOUNCE();
  assert(mode);
449
  return (mode_is_data(mode) || get_mode_sort(mode) == irms_internal_boolean);
Christian Schäfer's avatar
Christian Schäfer committed
450
451
452
}

int
Michael Beck's avatar
Michael Beck committed
453
mode_is_dataM (const ir_mode *mode)
Christian Schäfer's avatar
Christian Schäfer committed
454
{
455
456
457
  ANNOUNCE();
  assert(mode);
  return (mode_is_data(mode) || get_mode_modecode(mode) == irm_M);
Christian Schäfer's avatar
Christian Schäfer committed
458
}
459
460
#ifdef MODE_ACCESS_DEFINES
#  define mode_is_signed(mode) (mode)->sign
461
462
463
464
465
466
#  define mode_is_float(mode) ((mode)->sort == irms_float_number)
#  define mode_is_int(mode) ((mode)->sort == irms_int_number)
#  define mode_is_num(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number))
#  define mode_is_data(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference))
#  define mode_is_datab(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference) || ((mode)->sort == irms_internal_boolean))
#  define mode_is_dataM(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference) || ((mode)->code == irm_M))
467
#endif
468
/* Returns true if sm can be converted to lm without loss. */
469
int
Michael Beck's avatar
Michael Beck committed
470
smaller_mode(const ir_mode *sm, const ir_mode *lm)
471
472
473
474
475
476
477
478
479
{
  ANNOUNCE();
  assert(sm);
  assert(lm);

  if (sm == lm) return 1;

  switch(get_mode_sort(sm))
  {
480
    case irms_int_number:
481
482
      switch(get_mode_sort(lm))
      {
483
        case irms_int_number:
484
485
486
487
488
489
490
          /* integers are convertable if
           *   - both have the same sign and lm is the larger one
           *   - lm is the signed one and is at least two bits larger
           *     (one for the sign, one for the highest bit of sm)
           */
          if (mode_is_signed(sm))
          {
491
            if ( mode_is_signed(lm) && (get_mode_size_bits(lm) > get_mode_size_bits(sm)) )
492
493
494
495
              return 1;
          }
          else if (mode_is_signed(lm))
          {
496
            if (get_mode_size_bits(lm) > get_mode_size_bits(sm) + 1)
497
498
              return 1;
          }
499
          else if (get_mode_size_bits(lm) > get_mode_size_bits(sm))
500
501
502
503
504
          {
            return 1;
          }
          break;

505
        case irms_float_number:
506
507
508
509
510
511
512
513
          /* int to float works if the float is large enough */
          return 0;

        default:
          break;
      }
      break;

514
    case irms_float_number:
515
516
      /* XXX currently only the three standard 32,64,80 bit floats
       * are supported which can safely be converted */
517
      if ( (get_mode_sort(lm) == irms_float_number)
518
           && (get_mode_size_bits(lm) > get_mode_size_bits(sm)) )
519
520
521
         return 1;
      break;

522
    case irms_reference:
523
524
525
526
527
528
529
530
531
532
533
       /* do exist machines out there with different pointer lenghts ?*/
      return 0;

    default:
      break;
  }

  /* else */
  return 0;
}

534
/* ** initialization ** */
535
536
537
538
539
void
init_mode (void)
{
  ANNOUNCE();
  /* init flexible array */
540
541
542
  modes      = NEW_ARR_F(ir_mode, irm_max);
  modes_min  = NEW_ARR_F(tarval*, irm_max);
  modes_max  = NEW_ARR_F(tarval*, irm_max);
543
  modes_null = NEW_ARR_F(tarval*, irm_max);
544
  modes_one  = NEW_ARR_F(tarval*, irm_max);
545
546
547
548

  /* initialize predefined modes */
  /* Basic Block */
  mode_BB = &modes[irm_BB];
549
550
551
552
553
554
  mode_BB->name    = id_from_str("BB", 2);
  mode_BB->code    = irm_BB;
  mode_BB->sort    = irms_auxiliary;
  mode_BB->size    = 0;
  mode_BB->align   = 0;
  mode_BB->sign    = 0;
555
  mode_BB->tv_priv = NULL;
556
557
558

  /* eXecution */
  mode_X = &modes[irm_X];
559
560
561
562
563
564
  mode_X->name    = id_from_str("X", 1);
  mode_X->code    = irm_X;
  mode_X->sort    = irms_auxiliary;
  mode_X->size    = 0;
  mode_X->align   = 0;
  mode_X->sign    = 0;
565
  mode_X->tv_priv = NULL;
566
567
568

  /* Memory */
  mode_M = &modes[irm_M];
569
570
571
572
573
574
  mode_M->name    = id_from_str("M", 1);
  mode_M->code    = irm_M;
  mode_M->sort    = irms_auxiliary;
  mode_M->size    = 0;
  mode_M->align   = 0;
  mode_M->sign    = 0;
575
  mode_M->tv_priv = NULL;
576
577
578

  /* Tuple */
  mode_T = &modes[irm_T];
579
580
581
582
583
584
  mode_T->name    = id_from_str("T", 1);
  mode_T->code    = irm_T;
  mode_T->sort    = irms_auxiliary,
  mode_T->size    = 0;
  mode_T->align   = 0;
  mode_T->sign    = 0;
585
  mode_T->tv_priv = NULL;
586
587
588

  /* boolean */
  mode_b = &modes[irm_b];
589
590
591
592
593
594
  mode_b->name    = id_from_str("b", 1);
  mode_b->code    = irm_b;
  mode_b->sort    = irms_internal_boolean;
  mode_b->size    = 0;
  mode_b->align   = 0;
  mode_b->sign    = 0;
595
  mode_b->tv_priv = NULL;
596
597
598

  /* float */
  mode_F = &modes[irm_F];
599
600
601
602
  mode_F->name    = id_from_str("F", 1);
  mode_F->code    = irm_F;
  mode_F->sort    = irms_float_number;
  mode_F->sign    = 1;
603
  mode_F->align   = 4;
604
  mode_F->size    = 32;
605
  mode_F->tv_priv = NULL;
606
607
608
609
610

  set_mode_values(mode_F);

  /* double */
  mode_D = &modes[irm_D];
611
612
613
614
  mode_D->name    = id_from_str("D", 1);
  mode_D->code    = irm_D;
  mode_D->sort    = irms_float_number;
  mode_D->sign    = 1;
615
  mode_D->align   = 4;
616
  mode_D->size    = 64;
617
  mode_D->tv_priv = NULL;
618
619
620
621
622

  set_mode_values(mode_D);

  /* extended */
  mode_E = &modes[irm_E];
623
624
625
626
  mode_E->name    = id_from_str("E", 1);
  mode_E->code    = irm_E;
  mode_E->sort    = irms_float_number;
  mode_E->sign    = 1;
627
  mode_E->align   = 4;
628
  mode_E->size    = 80;
629
  mode_E->tv_priv = NULL;
630
631
632
633
634

  set_mode_values(mode_E);

  /* signed byte */
  mode_Bs = &modes[irm_Bs];
635
636
637
638
  mode_Bs->name    = id_from_str("Bs", 2);
  mode_Bs->code    = irm_Bs;
  mode_Bs->sort    = irms_int_number;
  mode_Bs->sign    = 1;
639
  mode_Bs->align   = 1;
640
  mode_Bs->size    = 8;
641
  mode_Bs->tv_priv = NULL;
642
643
644
645
646

  set_mode_values(mode_Bs);

  /* unsigned byte */
  mode_Bu = &modes[irm_Bu];
647
648
649
650
  mode_Bu->name    = id_from_str("Bu", 2);
  mode_Bu->code    = irm_Bu;
  mode_Bu->sort    = irms_int_number;
  mode_Bu->sign    = 0;
651
  mode_Bu->align   = 1;
652
  mode_Bu->size    = 8;
653
  mode_Bu->tv_priv = NULL;
654
655
656
657
658

  set_mode_values(mode_Bu);

  /* signed short integer */
  mode_Hs = &modes[irm_Hs];
659
660
661
662
  mode_Hs->name    = id_from_str("Hs", 2);
  mode_Hs->code    = irm_Hs;
  mode_Hs->sort    = irms_int_number;
  mode_Hs->sign    = 1;
663
  mode_Hs->align   = 2;
664
  mode_Hs->size    = 16;
665
  mode_Hs->tv_priv = NULL;
666
667
668
669
670

  set_mode_values(mode_Hs);

  /* unsigned short integer */
  mode_Hu = &modes[irm_Hu];
671
672
673
674
  mode_Hu->name    = id_from_str("Hu", 2);
  mode_Hu->code    = irm_Hu;
  mode_Hu->sort    = irms_int_number;
  mode_Hu->sign    = 0;
675
  mode_Hu->align   = 2;
676
  mode_Hu->size    = 16;
677
  mode_Hu->tv_priv = NULL;
678
679
680
681
682

  set_mode_values(mode_Hu);

  /* signed integer */
  mode_Is = &modes[irm_Is];
683
684
685
686
  mode_Is->name    = id_from_str("Is", 2);
  mode_Is->code    = irm_Is;
  mode_Is->sort    = irms_int_number;
  mode_Is->sign    = 1;
687
  mode_Is->align   = 4;
688
  mode_Is->size    = 32;
689
  mode_Is->tv_priv = NULL;
690
691
692
693
694

  set_mode_values(mode_Is);

  /* unsigned integer */
  mode_Iu = &modes[irm_Iu];
695
696
697
698
  mode_Iu->name    = id_from_str("Iu", 2);
  mode_Iu->code    = irm_Iu;
  mode_Iu->sort    = irms_int_number;
  mode_Iu->sign    = 0;
699
  mode_Iu->align   = 4;
700
  mode_Iu->size    = 32;
701
  mode_Iu->tv_priv = NULL;
702
703
704
705
706

  set_mode_values(mode_Iu);

  /* signed long integer */
  mode_Ls = &modes[irm_Ls];
707
708
709
710
  mode_Ls->name    = id_from_str("Ls", 2);
  mode_Ls->code    = irm_Ls;
  mode_Ls->sort    = irms_int_number;
  mode_Ls->sign    = 1;
711
  mode_Ls->align   = 4;
712
  mode_Ls->size    = 64;
713
  mode_Ls->tv_priv = NULL;
714
715
716
717
718

  set_mode_values(mode_Ls);

  /* unsigned long integer */
  mode_Lu = &modes[irm_Lu];
719
720
721
722
  mode_Lu->name    = id_from_str("Lu", 2);
  mode_Lu->code    = irm_Lu;
  mode_Lu->sort    = irms_int_number;
  mode_Lu->sign    = 0;
723
  mode_Lu->align   = 4;
724
  mode_Lu->size    = 64;
725
  mode_Lu->tv_priv = NULL;
726
727
728
729
730

  set_mode_values(mode_Lu);

  /* Character */
  mode_C = &modes[irm_C];
731
732
733
734
  mode_C->name    = id_from_str("C", 1);
  mode_C->code    = irm_C;
  mode_C->sort    = irms_character;
  mode_C->sign    = 0;
735
  mode_C->align   = 1;
736
  mode_C->size    = 8;
737
  mode_C->tv_priv = NULL;
738
739
740
741
742

  set_mode_values(mode_C);

  /* Unicode character */
  mode_U = &modes[irm_U];
743
744
745
746
  mode_U->name    = id_from_str("U", 1);
  mode_U->code    = irm_U;
  mode_U->sort    = irms_character;
  mode_U->sign    = 0;
747
  mode_U->align   = 2;
748
  mode_U->size    = 16;
749
  mode_U->tv_priv = NULL;
750
751
752
753
754

  set_mode_values(mode_U);

  /* pointer */
  mode_P = &modes[irm_P];
755
756
757
758
  mode_P->name    = id_from_str("P", 1);
  mode_P->code    = irm_P;
  mode_P->sort    = irms_reference;
  mode_P->sign    = 0;
759
  mode_P->align   = 4;
760
  mode_P->size    = 32;
761
  mode_P->tv_priv = NULL;
762
763

  num_modes = irm_max;
764
}