irmode.c 17.4 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
 */
53
54
55
56
static int modes_are_equal(ir_mode *m, ir_mode *n)
{
  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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* * *
 * functions defined in irmode.h
 * * */

/* JNI access functions */
INLINE ir_mode *get_modeT() { ANNOUNCE(); return mode_T; }
INLINE ir_mode *get_modeF() { ANNOUNCE(); return mode_F; }
INLINE ir_mode *get_modeD() { ANNOUNCE(); return mode_D; }
INLINE ir_mode *get_modeE() { ANNOUNCE(); return mode_E; }
INLINE ir_mode *get_modeBs() { ANNOUNCE(); return mode_Bs; }
INLINE ir_mode *get_modeBu() { ANNOUNCE(); return mode_Bu; }
INLINE ir_mode *get_modeHs() { ANNOUNCE(); return mode_Hs; }
INLINE ir_mode *get_modeHu() { ANNOUNCE(); return mode_Hu; }
INLINE ir_mode *get_modeIs() { ANNOUNCE(); return mode_Is; }
INLINE ir_mode *get_modeIu() { ANNOUNCE(); return mode_Iu; }
INLINE ir_mode *get_modeLs() { ANNOUNCE(); return mode_Ls; }
INLINE ir_mode *get_modeLu() { ANNOUNCE(); return mode_Lu; }
INLINE ir_mode *get_modeC() { ANNOUNCE(); return mode_C; }
INLINE ir_mode *get_modeU() { ANNOUNCE(); return mode_U; }
INLINE ir_mode *get_modeb() { ANNOUNCE(); return mode_b; }
INLINE ir_mode *get_modeP() { ANNOUNCE(); return mode_P; }
INLINE ir_mode *get_modeX() { ANNOUNCE(); return mode_X; }
INLINE ir_mode *get_modeM() { ANNOUNCE(); return mode_M; }
INLINE ir_mode *get_modeBB() { ANNOUNCE(); return mode_BB; }

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
209
210
211
212
213
214
215
216
217
218
219
220
/*
 * Creates a new mode.
 */
ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int align, int sign)
{
  ir_mode mode_tmpl, *res;

  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
223
get_mode_modecode(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 *
230
get_mode_ident(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
237
const char *
get_mode_name(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
244
245
246
247
mode_sort
get_mode_sort(ir_mode* mode)
{
  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
251
INLINE int
get_mode_size_bits(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;
}

Götz Lindenmaier's avatar
Götz Lindenmaier committed
257
258
259
260
261
262
263
int get_mode_size_bytes(ir_mode *mode) {
  ANNOUNCE();
  int size = get_mode_size_bits(mode);
  if ((size % 8) != 0) return -1;
  return size / 8;
}

Christian Schäfer's avatar
Christian Schäfer committed
264
int
265
get_mode_align (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
272
273
274
275
276
277

int
get_mode_sign (ir_mode *mode)
{
  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
391
392
int
mode_is_signed (ir_mode *mode)
{
393
394
395
  ANNOUNCE();
  assert(mode);
  return mode->sign;
Christian Schäfer's avatar
Christian Schäfer committed
396
397
}

398
int
Christian Schäfer's avatar
Christian Schäfer committed
399
400
mode_is_float (ir_mode *mode)
{
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
Christian Schäfer's avatar
Christian Schäfer committed
407
408
mode_is_int (ir_mode *mode)
{
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
}

414
int
Christian Schäfer's avatar
Christian Schäfer committed
415
416
mode_is_num (ir_mode *mode)
{
417
418
419
  ANNOUNCE();
  assert(mode);
  return (mode_is_int(mode) || mode_is_float(mode));
Christian Schäfer's avatar
Christian Schäfer committed
420
421
}

422
int
Christian Schäfer's avatar
Christian Schäfer committed
423
424
mode_is_data (ir_mode *mode)
{
425
426
  ANNOUNCE();
  assert(mode);
427
  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
428
429
430
431
432
}

int
mode_is_datab (ir_mode *mode)
{
433
434
  ANNOUNCE();
  assert(mode);
435
  return (mode_is_data(mode) || get_mode_sort(mode) == irms_internal_boolean);
Christian Schäfer's avatar
Christian Schäfer committed
436
437
438
439
440
}

int
mode_is_dataM (ir_mode *mode)
{
441
442
443
  ANNOUNCE();
  assert(mode);
  return (mode_is_data(mode) || get_mode_modecode(mode) == irm_M);
Christian Schäfer's avatar
Christian Schäfer committed
444
}
445
446
#ifdef MODE_ACCESS_DEFINES
#  define mode_is_signed(mode) (mode)->sign
447
448
449
450
451
452
#  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))
453
#endif
454
/* Returns true if sm can be converted to lm without loss. */
455
int
456
457
458
459
460
461
462
463
464
465
smaller_mode(ir_mode *sm, ir_mode *lm)
{
  ANNOUNCE();
  assert(sm);
  assert(lm);

  if (sm == lm) return 1;

  switch(get_mode_sort(sm))
  {
466
    case irms_int_number:
467
468
      switch(get_mode_sort(lm))
      {
469
        case irms_int_number:
470
471
472
473
474
475
476
          /* 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))
          {
477
            if ( mode_is_signed(lm) && (get_mode_size_bits(lm) > get_mode_size_bits(sm)) )
478
479
480
481
              return 1;
          }
          else if (mode_is_signed(lm))
          {
482
            if (get_mode_size_bits(lm) > get_mode_size_bits(sm) + 1)
483
484
              return 1;
          }
485
          else if (get_mode_size_bits(lm) > get_mode_size_bits(sm))
486
487
488
489
490
          {
            return 1;
          }
          break;

491
        case irms_float_number:
492
493
494
495
496
497
498
499
          /* int to float works if the float is large enough */
          return 0;

        default:
          break;
      }
      break;

500
    case irms_float_number:
501
502
      /* XXX currently only the three standard 32,64,80 bit floats
       * are supported which can safely be converted */
503
      if ( (get_mode_sort(lm) == irms_float_number)
504
           && (get_mode_size_bits(lm) > get_mode_size_bits(sm)) )
505
506
507
         return 1;
      break;

508
    case irms_reference:
509
510
511
512
513
514
515
516
517
518
519
       /* do exist machines out there with different pointer lenghts ?*/
      return 0;

    default:
      break;
  }

  /* else */
  return 0;
}

520
/* ** initialization ** */
521
522
523
524
525
void
init_mode (void)
{
  ANNOUNCE();
  /* init flexible array */
526
527
528
  modes      = NEW_ARR_F(ir_mode, irm_max);
  modes_min  = NEW_ARR_F(tarval*, irm_max);
  modes_max  = NEW_ARR_F(tarval*, irm_max);
529
  modes_null = NEW_ARR_F(tarval*, irm_max);
530
  modes_one  = NEW_ARR_F(tarval*, irm_max);
531
532
533
534

  /* initialize predefined modes */
  /* Basic Block */
  mode_BB = &modes[irm_BB];
535
536
537
538
539
540
  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;
541
  mode_BB->tv_priv = NULL;
542
543
544

  /* eXecution */
  mode_X = &modes[irm_X];
545
546
547
548
549
550
  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;
551
  mode_X->tv_priv = NULL;
552
553
554

  /* Memory */
  mode_M = &modes[irm_M];
555
556
557
558
559
560
  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;
561
  mode_M->tv_priv = NULL;
562
563
564

  /* Tuple */
  mode_T = &modes[irm_T];
565
566
567
568
569
570
  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;
571
  mode_T->tv_priv = NULL;
572
573
574

  /* boolean */
  mode_b = &modes[irm_b];
575
576
577
578
579
580
  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;
581
  mode_b->tv_priv = NULL;
582
583
584

  /* float */
  mode_F = &modes[irm_F];
585
586
587
588
  mode_F->name    = id_from_str("F", 1);
  mode_F->code    = irm_F;
  mode_F->sort    = irms_float_number;
  mode_F->sign    = 1;
589
  mode_F->align   = 4;
590
  mode_F->size    = 32;
591
  mode_F->tv_priv = NULL;
592
593
594
595
596

  set_mode_values(mode_F);

  /* double */
  mode_D = &modes[irm_D];
597
598
599
600
  mode_D->name    = id_from_str("D", 1);
  mode_D->code    = irm_D;
  mode_D->sort    = irms_float_number;
  mode_D->sign    = 1;
601
  mode_D->align   = 4;
602
  mode_D->size    = 64;
603
  mode_D->tv_priv = NULL;
604
605
606
607
608

  set_mode_values(mode_D);

  /* extended */
  mode_E = &modes[irm_E];
609
610
611
612
  mode_E->name    = id_from_str("E", 1);
  mode_E->code    = irm_E;
  mode_E->sort    = irms_float_number;
  mode_E->sign    = 1;
613
  mode_E->align   = 4;
614
  mode_E->size    = 80;
615
  mode_E->tv_priv = NULL;
616
617
618
619
620

  set_mode_values(mode_E);

  /* signed byte */
  mode_Bs = &modes[irm_Bs];
621
622
623
624
  mode_Bs->name    = id_from_str("Bs", 2);
  mode_Bs->code    = irm_Bs;
  mode_Bs->sort    = irms_int_number;
  mode_Bs->sign    = 1;
625
  mode_Bs->align   = 1;
626
  mode_Bs->size    = 8;
627
  mode_Bs->tv_priv = NULL;
628
629
630
631
632

  set_mode_values(mode_Bs);

  /* unsigned byte */
  mode_Bu = &modes[irm_Bu];
633
634
635
636
  mode_Bu->name    = id_from_str("Bu", 2);
  mode_Bu->code    = irm_Bu;
  mode_Bu->sort    = irms_int_number;
  mode_Bu->sign    = 0;
637
  mode_Bu->align   = 1;
638
  mode_Bu->size    = 8;
639
  mode_Bu->tv_priv = NULL;
640
641
642
643
644

  set_mode_values(mode_Bu);

  /* signed short integer */
  mode_Hs = &modes[irm_Hs];
645
646
647
648
  mode_Hs->name    = id_from_str("Hs", 2);
  mode_Hs->code    = irm_Hs;
  mode_Hs->sort    = irms_int_number;
  mode_Hs->sign    = 1;
649
  mode_Hs->align   = 2;
650
  mode_Hs->size    = 16;
651
  mode_Hs->tv_priv = NULL;
652
653
654
655
656

  set_mode_values(mode_Hs);

  /* unsigned short integer */
  mode_Hu = &modes[irm_Hu];
657
658
659
660
  mode_Hu->name    = id_from_str("Hu", 2);
  mode_Hu->code    = irm_Hu;
  mode_Hu->sort    = irms_int_number;
  mode_Hu->sign    = 0;
661
  mode_Hu->align   = 2;
662
  mode_Hu->size    = 16;
663
  mode_Hu->tv_priv = NULL;
664
665
666
667
668

  set_mode_values(mode_Hu);

  /* signed integer */
  mode_Is = &modes[irm_Is];
669
670
671
672
  mode_Is->name    = id_from_str("Is", 2);
  mode_Is->code    = irm_Is;
  mode_Is->sort    = irms_int_number;
  mode_Is->sign    = 1;
673
  mode_Is->align   = 4;
674
  mode_Is->size    = 32;
675
  mode_Is->tv_priv = NULL;
676
677
678
679
680

  set_mode_values(mode_Is);

  /* unsigned integer */
  mode_Iu = &modes[irm_Iu];
681
682
683
684
  mode_Iu->name    = id_from_str("Iu", 2);
  mode_Iu->code    = irm_Iu;
  mode_Iu->sort    = irms_int_number;
  mode_Iu->sign    = 0;
685
  mode_Iu->align   = 4;
686
  mode_Iu->size    = 32;
687
  mode_Iu->tv_priv = NULL;
688
689
690
691
692

  set_mode_values(mode_Iu);

  /* signed long integer */
  mode_Ls = &modes[irm_Ls];
693
694
695
696
  mode_Ls->name    = id_from_str("Ls", 2);
  mode_Ls->code    = irm_Ls;
  mode_Ls->sort    = irms_int_number;
  mode_Ls->sign    = 1;
697
  mode_Ls->align   = 4;
698
  mode_Ls->size    = 64;
699
  mode_Ls->tv_priv = NULL;
700
701
702
703
704

  set_mode_values(mode_Ls);

  /* unsigned long integer */
  mode_Lu = &modes[irm_Lu];
705
706
707
708
  mode_Lu->name    = id_from_str("Lu", 2);
  mode_Lu->code    = irm_Lu;
  mode_Lu->sort    = irms_int_number;
  mode_Lu->sign    = 0;
709
  mode_Lu->align   = 4;
710
  mode_Lu->size    = 64;
711
  mode_Lu->tv_priv = NULL;
712
713
714
715
716

  set_mode_values(mode_Lu);

  /* Character */
  mode_C = &modes[irm_C];
717
718
719
720
  mode_C->name    = id_from_str("C", 1);
  mode_C->code    = irm_C;
  mode_C->sort    = irms_character;
  mode_C->sign    = 0;
721
  mode_C->align   = 1;
722
  mode_C->size    = 8;
723
  mode_C->tv_priv = NULL;
724
725
726
727
728

  set_mode_values(mode_C);

  /* Unicode character */
  mode_U = &modes[irm_U];
729
730
731
732
  mode_U->name    = id_from_str("U", 1);
  mode_U->code    = irm_U;
  mode_U->sort    = irms_character;
  mode_U->sign    = 0;
733
  mode_U->align   = 2;
734
  mode_U->size    = 16;
735
  mode_U->tv_priv = NULL;
736
737
738
739
740

  set_mode_values(mode_U);

  /* pointer */
  mode_P = &modes[irm_P];
741
742
743
744
  mode_P->name    = id_from_str("P", 1);
  mode_P->code    = irm_P;
  mode_P->sort    = irms_reference;
  mode_P->sign    = 0;
745
  mode_P->align   = 4;
746
  mode_P->size    = 32;
747
  mode_P->tv_priv = NULL;
748
749

  num_modes = irm_max;
750
}