OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [fixed-bit.h] - Blame information for rev 736

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 734 jeremybenn
/* This is a software fixed-point library.
2
   Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
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
Under Section 7 of GPL version 3, you are granted additional
17
permissions described in the GCC Runtime Library Exception, version
18
3.1, as published by the Free Software Foundation.
19
 
20
You should have received a copy of the GNU General Public License and
21
a copy of the GCC Runtime Library Exception along with this program;
22
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
<http://www.gnu.org/licenses/>.  */
24
 
25
#ifndef _FIXED_BIT_H
26
#define _FIXED_BIT_H
27
 
28
#ifdef LIBGCC2_GNU_PREFIX
29
#define LIBGCC2_FIXEDBIT_GNU_PREFIX
30
#endif
31
 
32
/* To use this file we need to define one of the following:
33
   QQ_MODE, UQQ_MODE, HQ_MODE, UHQ_MODE, SQ_MODE, USQ_MODE, DQ_MODE, UDQ_MODE,
34
   TQ_MODE, UTQ_MODE, HA_MODE, UHA_MODE, SA_MODE, USA_MODE, DA_MODE, UDA_MODE,
35
   TA_MODE, UTA_MODE.
36
   Then, all operators for this machine mode will be created.
37
 
38
   Or, we need to define FROM_* TO_* for conversions from one mode to another
39
   mode.  The mode could be one of the following:
40
   Fract: QQ, UQQ, HQ, UHQ, SQ, USQ, DQ, UDQ, TQ, UTQ
41
   Accum: HA, UHA, SA, USA, DA, UDA, TA, UTA
42
   Signed integer: QI, HI, SI, DI, TI
43
   Unsigned integer: UQI, UHI, USI, UDI, UTI
44
   Floating-point: SF, DF
45
   Ex: If we define FROM_QQ and TO_SI, the conversion from QQ to SI is
46
   generated.  */
47
 
48
#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
49
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
50
#endif
51
 
52
#ifndef LIBGCC2_HAS_SF_MODE
53
#define LIBGCC2_HAS_SF_MODE (BITS_PER_UNIT == 8)
54
#endif
55
 
56
#ifndef LIBGCC2_HAS_DF_MODE
57
#define LIBGCC2_HAS_DF_MODE \
58
  (BITS_PER_UNIT == 8 \
59
   && (__SIZEOF_DOUBLE__ * __CHAR_BIT__ == 64 \
60
       || LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 64))
61
#endif
62
 
63
typedef          int QItype     __attribute__ ((mode (QI)));
64
typedef unsigned int UQItype    __attribute__ ((mode (QI)));
65
typedef          int HItype     __attribute__ ((mode (HI)));
66
typedef unsigned int UHItype    __attribute__ ((mode (HI)));
67
typedef          _Fract QQtype  __attribute__ ((mode (QQ)));
68
typedef unsigned _Fract UQQtype __attribute__ ((mode (UQQ)));
69
typedef          _Fract HQtype  __attribute__ ((mode (HQ)));
70
typedef unsigned _Fract UHQtype __attribute__ ((mode (UHQ)));
71
typedef          _Fract HAtype  __attribute__ ((mode (HA)));
72
typedef unsigned _Fract UHAtype __attribute__ ((mode (UHA)));
73
#define HAVE_QQ         1
74
#define HAVE_UQQ        1
75
#define HAVE_HQ         1
76
#define HAVE_UHQ        1
77
#define HAVE_HA         1
78
#define HAVE_UHA        1
79
#define HAVE_QI         1
80
#define HAVE_UQI        1
81
#define HAVE_HI         1
82
#define HAVE_UHI        1
83
#if MIN_UNITS_PER_WORD > 1
84
/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1.  */
85
typedef          int SItype     __attribute__ ((mode (SI)));
86
typedef unsigned int USItype    __attribute__ ((mode (SI)));
87
typedef          _Fract SQtype  __attribute__ ((mode (SQ)));
88
typedef unsigned _Fract USQtype __attribute__ ((mode (USQ)));
89
typedef          _Fract SAtype  __attribute__ ((mode (SA)));
90
typedef unsigned _Fract USAtype __attribute__ ((mode (USA)));
91
#define HAVE_SQ         1
92
#define HAVE_USQ        1
93
#define HAVE_SA         1
94
#define HAVE_USA        1
95
#define HAVE_SI         1
96
#define HAVE_USI        1
97
#if LONG_LONG_TYPE_SIZE > 32
98
/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2.  */
99
typedef          int DItype     __attribute__ ((mode (DI)));
100
typedef unsigned int UDItype    __attribute__ ((mode (DI)));
101
typedef          _Fract DQtype  __attribute__ ((mode (DQ)));
102
typedef unsigned _Fract UDQtype __attribute__ ((mode (UDQ)));
103
typedef          _Fract DAtype  __attribute__ ((mode (DA)));
104
typedef unsigned _Fract UDAtype __attribute__ ((mode (UDA)));
105
#define HAVE_DQ         1
106
#define HAVE_UDQ        1
107
#define HAVE_DA         1
108
#define HAVE_UDA        1
109
#define HAVE_DI         1
110
#define HAVE_UDI        1
111
#if MIN_UNITS_PER_WORD > 4
112
/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4.  */
113
typedef          int TItype     __attribute__ ((mode (TI)));
114
typedef unsigned int UTItype    __attribute__ ((mode (TI)));
115
typedef          _Fract TQtype  __attribute__ ((mode (TQ)));
116
typedef unsigned _Fract UTQtype __attribute__ ((mode (UTQ)));
117
typedef          _Fract TAtype  __attribute__ ((mode (TA)));
118
typedef unsigned _Fract UTAtype __attribute__ ((mode (UTA)));
119
#define HAVE_TQ         1
120
#define HAVE_UTQ        1
121
#define HAVE_TA         1
122
#define HAVE_UTA        1
123
#define HAVE_TI         1
124
#define HAVE_UTI        1
125
#endif
126
#endif
127
#endif
128
 
129
#if LIBGCC2_HAS_SF_MODE
130
typedef float SFtype __attribute__ ((mode (SF)));
131
#define HAVE_SF         1
132
#endif
133
#if LIBGCC2_HAS_DF_MODE
134
typedef float DFtype __attribute__ ((mode (DF)));
135
#define HAVE_DF         1
136
#endif
137
 
138
typedef int word_type __attribute__ ((mode (__word__)));
139
 
140
/* Based on modes, we create many defines.  */
141
 
142
#if defined (QQ_MODE) && (HAVE_QQ == 1)
143
#define FIXED_SIZE      1       /* in bytes.  */
144
#define INT_C_TYPE      QItype
145
#define UINT_C_TYPE     UQItype
146
#define DINT_C_TYPE     HItype
147
#define DUINT_C_TYPE    UHItype
148
#define MODE_NAME       QQ
149
#define MODE_NAME_S     qq
150
#define MODE_UNSIGNED   0
151
#endif
152
 
153
#if defined (UQQ_MODE) && (HAVE_UQQ == 1)
154
#define FIXED_SIZE      1       /* in bytes.  */
155
#define INT_C_TYPE      UQItype
156
#define UINT_C_TYPE     UQItype
157
#define DINT_C_TYPE     UHItype
158
#define DUINT_C_TYPE    UHItype
159
#define MODE_NAME       UQQ
160
#define MODE_NAME_S     uqq
161
#define MODE_UNSIGNED   1
162
#endif
163
 
164
#if defined (HQ_MODE) && (HAVE_HQ == 1)
165
#define FIXED_SIZE      2       /* in bytes.  */
166
#define INT_C_TYPE      HItype
167
#define UINT_C_TYPE     UHItype
168
 
169
#if HAVE_SI == 1
170
#define DINT_C_TYPE     SItype
171
#define DUINT_C_TYPE    USItype
172
#else
173
#define HINT_C_TYPE     QItype
174
#define HUINT_C_TYPE    UQItype
175
#endif
176
 
177
#define MODE_NAME       HQ
178
#define MODE_NAME_S     hq
179
#define MODE_UNSIGNED   0
180
#endif
181
 
182
#if defined (UHQ_MODE) && (HAVE_UHQ == 1)
183
#define FIXED_SIZE      2       /* in bytes.  */
184
#define INT_C_TYPE      UHItype
185
#define UINT_C_TYPE     UHItype
186
 
187
#if HAVE_SI == 1
188
#define DINT_C_TYPE     USItype
189
#define DUINT_C_TYPE    USItype
190
#else
191
#define HINT_C_TYPE     UQItype
192
#define HUINT_C_TYPE    UQItype
193
#endif
194
 
195
#define MODE_NAME       UHQ
196
#define MODE_NAME_S     uhq
197
#define MODE_UNSIGNED   1
198
#endif
199
 
200
#if defined (SQ_MODE) && (HAVE_SQ == 1)
201
#define FIXED_SIZE      4       /* in bytes.  */
202
#define INT_C_TYPE      SItype
203
#define UINT_C_TYPE     USItype
204
 
205
#if HAVE_DI == 1
206
#define DINT_C_TYPE     DItype
207
#define DUINT_C_TYPE    UDItype
208
#else
209
#define HINT_C_TYPE     HItype
210
#define HUINT_C_TYPE    UHItype
211
#endif
212
 
213
#define MODE_NAME       SQ
214
#define MODE_NAME_S     sq
215
#define MODE_UNSIGNED   0
216
#endif
217
 
218
#if defined (USQ_MODE) && (HAVE_USQ == 1)
219
#define FIXED_SIZE      4       /* in bytes.  */
220
#define INT_C_TYPE      USItype
221
#define UINT_C_TYPE     USItype
222
 
223
#if HAVE_DI == 1
224
#define DINT_C_TYPE     UDItype
225
#define DUINT_C_TYPE    UDItype
226
#else
227
#define HINT_C_TYPE     UHItype
228
#define HUINT_C_TYPE    UHItype
229
#endif
230
 
231
#define MODE_NAME       USQ
232
#define MODE_NAME_S     usq
233
#define MODE_UNSIGNED   1
234
#endif
235
 
236
#if defined (DQ_MODE) && (HAVE_DQ == 1)
237
#define FIXED_SIZE      8       /* in bytes.  */
238
#define INT_C_TYPE      DItype
239
#define UINT_C_TYPE     UDItype
240
 
241
#if HAVE_TI == 1
242
#define DINT_C_TYPE     TItype
243
#define DUINT_C_TYPE    UTItype
244
#else
245
#define HINT_C_TYPE     SItype
246
#define HUINT_C_TYPE    USItype
247
#endif
248
 
249
#define MODE_NAME       DQ
250
#define MODE_NAME_S     dq
251
#define MODE_UNSIGNED   0
252
#endif
253
 
254
#if defined (UDQ_MODE) && (HAVE_UDQ == 1)
255
#define FIXED_SIZE      8       /* in bytes.  */
256
#define INT_C_TYPE      UDItype
257
#define UINT_C_TYPE     UDItype
258
 
259
#if HAVE_TI == 1
260
#define DINT_C_TYPE     UTItype
261
#define DUINT_C_TYPE    UTItype
262
#else
263
#define HINT_C_TYPE     USItype
264
#define HUINT_C_TYPE    USItype
265
#endif
266
 
267
#define MODE_NAME       UDQ
268
#define MODE_NAME_S     udq
269
#define MODE_UNSIGNED   1
270
#endif
271
 
272
#if defined (TQ_MODE) && (HAVE_TQ == 1)
273
#define FIXED_SIZE      16      /* in bytes.  */
274
#define INT_C_TYPE      TItype
275
#define UINT_C_TYPE     UTItype
276
#define HINT_C_TYPE     DItype
277
#define HUINT_C_TYPE    UDItype
278
#define MODE_NAME       TQ
279
#define MODE_NAME_S     tq
280
#define MODE_UNSIGNED   0
281
#endif
282
 
283
#if defined (UTQ_MODE) && (HAVE_UTQ == 1)
284
#define FIXED_SIZE      16      /* in bytes.  */
285
#define INT_C_TYPE      UTItype
286
#define UINT_C_TYPE     UTItype
287
#define HINT_C_TYPE     UDItype
288
#define HUINT_C_TYPE    UDItype
289
#define MODE_NAME       UTQ
290
#define MODE_NAME_S     utq
291
#define MODE_UNSIGNED   1
292
#endif
293
 
294
#if defined (HA_MODE) && (HAVE_HA == 1)
295
#define FIXED_SIZE      2       /* in bytes.  */
296
#define INT_C_TYPE      HItype
297
#define UINT_C_TYPE     UHItype
298
 
299
#if HAVE_SI == 1
300
#define DINT_C_TYPE     SItype
301
#define DUINT_C_TYPE    USItype
302
#else
303
#define HINT_C_TYPE     QItype
304
#define HUINT_C_TYPE    UQItype
305
#endif
306
 
307
#define MODE_NAME       HA
308
#define MODE_NAME_S     ha
309
#define MODE_UNSIGNED   0
310
#endif
311
 
312
#if defined (UHA_MODE) && (HAVE_UHA == 1)
313
#define FIXED_SIZE      2       /* in bytes.  */
314
#define INT_C_TYPE      UHItype
315
#define UINT_C_TYPE     UHItype
316
 
317
#if HAVE_SI == 1
318
#define DINT_C_TYPE     USItype
319
#define DUINT_C_TYPE    USItype
320
#else
321
#define HINT_C_TYPE     UQItype
322
#define HUINT_C_TYPE    UQItype
323
#endif
324
 
325
#define MODE_NAME       UHA
326
#define MODE_NAME_S     uha
327
#define MODE_UNSIGNED   1
328
#endif
329
 
330
#if defined (SA_MODE) && (HAVE_SA == 1)
331
#define FIXED_SIZE      4       /* in bytes.  */
332
#define INT_C_TYPE      SItype
333
#define UINT_C_TYPE     USItype
334
 
335
#if HAVE_DI == 1
336
#define DINT_C_TYPE     DItype
337
#define DUINT_C_TYPE    UDItype
338
#else
339
#define HINT_C_TYPE     HItype
340
#define HUINT_C_TYPE    UHItype
341
#endif
342
 
343
#define MODE_NAME       SA
344
#define MODE_NAME_S     sa
345
#define MODE_UNSIGNED   0
346
#endif
347
 
348
#if defined (USA_MODE) && (HAVE_USA == 1)
349
#define FIXED_SIZE      4       /* in bytes.  */
350
#define INT_C_TYPE      USItype
351
#define UINT_C_TYPE     USItype
352
 
353
#if HAVE_DI == 1
354
#define DINT_C_TYPE     UDItype
355
#define DUINT_C_TYPE    UDItype
356
#else
357
#define HINT_C_TYPE     UHItype
358
#define HUINT_C_TYPE    UHItype
359
#endif
360
 
361
#define MODE_NAME       USA
362
#define MODE_NAME_S     usa
363
#define MODE_UNSIGNED   1
364
#endif
365
 
366
#if defined (DA_MODE) && (HAVE_DA == 1)
367
#define FIXED_SIZE      8       /* in bytes.  */
368
#define INT_C_TYPE      DItype
369
#define UINT_C_TYPE     UDItype
370
 
371
#if HAVE_TI == 1
372
#define DINT_C_TYPE     TItype
373
#define DUINT_C_TYPE    UTItype
374
#else
375
#define HINT_C_TYPE     SItype
376
#define HUINT_C_TYPE    USItype
377
#endif
378
 
379
#define MODE_NAME       DA
380
#define MODE_NAME_S     da
381
#define MODE_UNSIGNED   0
382
#endif
383
 
384
#if defined (UDA_MODE) && (HAVE_UDA == 1)
385
#define FIXED_SIZE      8       /* in bytes.  */
386
#define INT_C_TYPE      UDItype
387
#define UINT_C_TYPE     UDItype
388
 
389
#if HAVE_TI == 1
390
#define DINT_C_TYPE     UTItype
391
#define DUINT_C_TYPE    UTItype
392
#else
393
#define HINT_C_TYPE     USItype
394
#define HUINT_C_TYPE    USItype
395
#endif
396
 
397
#define MODE_NAME       UDA
398
#define MODE_NAME_S     uda
399
#define MODE_UNSIGNED   1
400
#endif
401
 
402
#if defined (TA_MODE) && (HAVE_TA == 1)
403
#define FIXED_SIZE      16      /* in bytes.  */
404
#define INT_C_TYPE      TItype
405
#define UINT_C_TYPE     UTItype
406
#define HINT_C_TYPE     DItype
407
#define HUINT_C_TYPE    UDItype
408
#define MODE_NAME       TA
409
#define MODE_NAME_S     ta
410
#define MODE_UNSIGNED   0
411
#endif
412
 
413
#if defined (UTA_MODE) && (HAVE_UTA == 1)
414
#define FIXED_SIZE      16      /* in bytes.  */
415
#define INT_C_TYPE      UTItype
416
#define UINT_C_TYPE     UTItype
417
#define HINT_C_TYPE     UDItype
418
#define HUINT_C_TYPE    UDItype
419
#define MODE_NAME       UTA
420
#define MODE_NAME_S     uta
421
#define MODE_UNSIGNED   1
422
#endif
423
 
424
/* The following defines are based on the previous defines.  */
425
 
426
#if defined (HINT_C_TYPE)
427
#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
428
  struct INTstruct {HINT_C_TYPE high, low;};
429
#else
430
  struct INTstruct {HINT_C_TYPE low, high;};
431
#endif
432
 
433
typedef union
434
{
435
  struct INTstruct s;
436
  INT_C_TYPE ll;
437
} INTunion;
438
#endif
439
 
440
#define FIXED_WIDTH     (FIXED_SIZE * BITS_PER_UNIT) /* in bits.  */
441
#define FIXED_C_TYPE1(NAME)     NAME ## type
442
#define FIXED_C_TYPE2(NAME)     FIXED_C_TYPE1(NAME)
443
#define FIXED_C_TYPE    FIXED_C_TYPE2(MODE_NAME)
444
#define FBITS1(NAME)    __ ## NAME ## _FBIT__
445
#define FBITS2(NAME)    FBITS1(NAME)
446
#define FBITS           FBITS2(MODE_NAME)
447
#define IBITS1(NAME)    __ ## NAME ## _IBIT__
448
#define IBITS2(NAME)    IBITS1(NAME)
449
#define IBITS           IBITS2(MODE_NAME)
450
#define I_F_BITS        (FBITS + IBITS)
451
 
452
#ifdef LIBGCC2_FIXEDBIT_GNU_PREFIX
453
#define FIXED_OP(OP,MODE,NUM)   __gnu_ ## OP ## MODE ## NUM
454
#else
455
#define FIXED_OP(OP,MODE,NUM)   __ ## OP ## MODE ## NUM
456
#endif
457
 
458
#define FIXED_SATURATE1_TEMP(NAME)      FIXED_OP(saturate1,NAME,)
459
#define FIXED_SATURATE2_TEMP(NAME)      FIXED_OP(saturate2,NAME,)
460
#define FIXED_MULHELPER_TEMP(NAME)      FIXED_OP(mulhelper,NAME,)
461
#define FIXED_DIVHELPER_TEMP(NAME)      FIXED_OP(divhelper,NAME,)
462
#define FIXED_ASHLHELPER_TEMP(NAME)     FIXED_OP(ashlhelper,NAME,)
463
#define FIXED_ADD_TEMP(NAME)    FIXED_OP(add,NAME,3)
464
#define FIXED_SSADD_TEMP(NAME)  FIXED_OP(ssadd,NAME,3)
465
#define FIXED_USADD_TEMP(NAME)  FIXED_OP(usadd,NAME,3)
466
#define FIXED_SUB_TEMP(NAME)    FIXED_OP(sub,NAME,3)
467
#define FIXED_SSSUB_TEMP(NAME)  FIXED_OP(sssub,NAME,3)
468
#define FIXED_USSUB_TEMP(NAME)  FIXED_OP(ussub,NAME,3)
469
#define FIXED_MUL_TEMP(NAME)    FIXED_OP(mul,NAME,3)
470
#define FIXED_SSMUL_TEMP(NAME)  FIXED_OP(ssmul,NAME,3)
471
#define FIXED_USMUL_TEMP(NAME)  FIXED_OP(usmul,NAME,3)
472
#define FIXED_DIV_TEMP(NAME)    FIXED_OP(div,NAME,3)
473
#define FIXED_UDIV_TEMP(NAME)   FIXED_OP(udiv,NAME,3)
474
#define FIXED_SSDIV_TEMP(NAME)  FIXED_OP(ssdiv,NAME,3)
475
#define FIXED_USDIV_TEMP(NAME)  FIXED_OP(usdiv,NAME,3)
476
#define FIXED_NEG_TEMP(NAME)    FIXED_OP(neg,NAME,2)
477
#define FIXED_SSNEG_TEMP(NAME)  FIXED_OP(ssneg,NAME,2)
478
#define FIXED_USNEG_TEMP(NAME)  FIXED_OP(usneg,NAME,2)
479
#define FIXED_ASHL_TEMP(NAME)   FIXED_OP(ashl,NAME,3)
480
#define FIXED_ASHR_TEMP(NAME)   FIXED_OP(ashr,NAME,3)
481
#define FIXED_LSHR_TEMP(NAME)   FIXED_OP(lshr,NAME,3)
482
#define FIXED_SSASHL_TEMP(NAME) FIXED_OP(ssashl,NAME,3)
483
#define FIXED_USASHL_TEMP(NAME) FIXED_OP(usashl,NAME,3)
484
#define FIXED_CMP_TEMP(NAME)    FIXED_OP(cmp,NAME,2)
485
 
486
#if defined (MODE_NAME)
487
#if defined (DINT_C_TYPE)
488
#define FIXED_SATURATE1 FIXED_SATURATE1_TEMP(MODE_NAME_S)
489
#else
490
#define FIXED_SATURATE2 FIXED_SATURATE2_TEMP(MODE_NAME_S)
491
#endif
492
#define FIXED_MULHELPER FIXED_MULHELPER_TEMP(MODE_NAME_S)
493
#define FIXED_DIVHELPER FIXED_DIVHELPER_TEMP(MODE_NAME_S)
494
#define FIXED_ASHLHELPER        FIXED_ASHLHELPER_TEMP(MODE_NAME_S)
495
#define FIXED_ADD       FIXED_ADD_TEMP(MODE_NAME_S)
496
#define FIXED_SUB       FIXED_SUB_TEMP(MODE_NAME_S)
497
#define FIXED_MUL       FIXED_MUL_TEMP(MODE_NAME_S)
498
#define FIXED_NEG       FIXED_NEG_TEMP(MODE_NAME_S)
499
#define FIXED_ASHL      FIXED_ASHL_TEMP(MODE_NAME_S)
500
#define FIXED_CMP       FIXED_CMP_TEMP(MODE_NAME_S)
501
 
502
/* The following functions are for all fixed-point modes.  */
503
#if defined (DINT_C_TYPE)
504
extern void FIXED_SATURATE1 (DINT_C_TYPE *);
505
#else
506
extern void FIXED_SATURATE2 (INT_C_TYPE *, INT_C_TYPE *);
507
#endif
508
extern FIXED_C_TYPE FIXED_MULHELPER (FIXED_C_TYPE, FIXED_C_TYPE, word_type);
509
extern FIXED_C_TYPE FIXED_DIVHELPER (FIXED_C_TYPE, FIXED_C_TYPE, word_type);
510
extern FIXED_C_TYPE FIXED_ASHLHELPER (FIXED_C_TYPE, word_type, word_type);
511
extern FIXED_C_TYPE FIXED_ADD (FIXED_C_TYPE, FIXED_C_TYPE);
512
extern FIXED_C_TYPE FIXED_SUB (FIXED_C_TYPE, FIXED_C_TYPE);
513
extern FIXED_C_TYPE FIXED_MUL (FIXED_C_TYPE, FIXED_C_TYPE);
514
extern FIXED_C_TYPE FIXED_NEG (FIXED_C_TYPE);
515
extern FIXED_C_TYPE FIXED_ASHL (FIXED_C_TYPE, word_type);
516
extern word_type FIXED_CMP (FIXED_C_TYPE, FIXED_C_TYPE);
517
#endif
518
 
519
#if MODE_UNSIGNED == 0 /* Signed types.  */
520
#define PADDING_BITS    (FIXED_WIDTH - 1 - I_F_BITS)
521
#define NONPADDING_BITS (1 + I_F_BITS)
522
 
523
#if defined (MODE_NAME)
524
#define FIXED_DIV       FIXED_DIV_TEMP(MODE_NAME_S)
525
#define FIXED_ASHR      FIXED_ASHR_TEMP(MODE_NAME_S)
526
#define FIXED_SSADD     FIXED_SSADD_TEMP(MODE_NAME_S)
527
#define FIXED_SSSUB     FIXED_SSSUB_TEMP(MODE_NAME_S)
528
#define FIXED_SSMUL     FIXED_SSMUL_TEMP(MODE_NAME_S)
529
#define FIXED_SSDIV     FIXED_SSDIV_TEMP(MODE_NAME_S)
530
#define FIXED_SSNEG     FIXED_SSNEG_TEMP(MODE_NAME_S)
531
#define FIXED_SSASHL    FIXED_SSASHL_TEMP(MODE_NAME_S)
532
 
533
/* The following functions are for signed fixed-point modes.  */
534
extern FIXED_C_TYPE FIXED_DIV (FIXED_C_TYPE, FIXED_C_TYPE);
535
extern FIXED_C_TYPE FIXED_ASHR (FIXED_C_TYPE, word_type);
536
extern FIXED_C_TYPE FIXED_SSADD (FIXED_C_TYPE, FIXED_C_TYPE);
537
extern FIXED_C_TYPE FIXED_SSSUB (FIXED_C_TYPE, FIXED_C_TYPE);
538
extern FIXED_C_TYPE FIXED_SSMUL (FIXED_C_TYPE, FIXED_C_TYPE);
539
extern FIXED_C_TYPE FIXED_SSDIV (FIXED_C_TYPE, FIXED_C_TYPE);
540
extern FIXED_C_TYPE FIXED_SSNEG (FIXED_C_TYPE);
541
extern FIXED_C_TYPE FIXED_SSASHL (FIXED_C_TYPE, word_type);
542
#endif
543
 
544
#else /* Unsigned types.  */
545
#define PADDING_BITS    (FIXED_WIDTH - I_F_BITS)
546
#define NONPADDING_BITS (I_F_BITS)
547
 
548
#if defined (MODE_NAME)
549
#define FIXED_UDIV      FIXED_UDIV_TEMP(MODE_NAME_S)
550
#define FIXED_LSHR      FIXED_LSHR_TEMP(MODE_NAME_S)
551
#define FIXED_USDIV     FIXED_USDIV_TEMP(MODE_NAME_S)
552
#define FIXED_USADD     FIXED_USADD_TEMP(MODE_NAME_S)
553
#define FIXED_USSUB     FIXED_USSUB_TEMP(MODE_NAME_S)
554
#define FIXED_USMUL     FIXED_USMUL_TEMP(MODE_NAME_S)
555
#define FIXED_USNEG     FIXED_USNEG_TEMP(MODE_NAME_S)
556
#define FIXED_USASHL    FIXED_USASHL_TEMP(MODE_NAME_S)
557
 
558
/* The following functions are for unsigned fixed-point modes.  */
559
extern FIXED_C_TYPE FIXED_UDIV (FIXED_C_TYPE, FIXED_C_TYPE);
560
extern FIXED_C_TYPE FIXED_LSHR (FIXED_C_TYPE, word_type);
561
extern FIXED_C_TYPE FIXED_USADD (FIXED_C_TYPE, FIXED_C_TYPE);
562
extern FIXED_C_TYPE FIXED_USSUB (FIXED_C_TYPE, FIXED_C_TYPE);
563
extern FIXED_C_TYPE FIXED_USMUL (FIXED_C_TYPE, FIXED_C_TYPE);
564
extern FIXED_C_TYPE FIXED_USDIV (FIXED_C_TYPE, FIXED_C_TYPE);
565
extern FIXED_C_TYPE FIXED_USNEG (FIXED_C_TYPE);
566
extern FIXED_C_TYPE FIXED_USASHL (FIXED_C_TYPE, word_type);
567
#endif
568
 
569
#endif /* End of testing MODE_UNSIGNED.  */
570
 
571
/* This define is to check if this mode have any padding bits.  */
572
#define HAVE_PADDING_BITS       (PADDING_BITS > 0)
573
 
574
/* ------------------------------------------------------------------------ */
575
/* The following defines are for conversions.  */
576
 
577
#if defined (FROM_QI) && HAVE_QI == 1
578
#define FROM_TYPE               1       /* Signed integer.  */
579
#define FROM_INT_C_TYPE         QItype
580
#define FROM_SINT_C_TYPE        QItype
581
#define FROM_UINT_C_TYPE        UQItype
582
#define FROM_MODE_NAME_S        qi
583
#define FROM_INT_SIZE           1       /* in bytes.  */
584
 
585
#elif defined (FROM_HI) && HAVE_HI == 1
586
#define FROM_TYPE               1       /* Signed integer.  */
587
#define FROM_INT_C_TYPE         HItype
588
#define FROM_SINT_C_TYPE        HItype
589
#define FROM_UINT_C_TYPE        UHItype
590
#define FROM_MODE_NAME_S        hi
591
#define FROM_INT_SIZE           2       /* in bytes.  */
592
 
593
#elif defined (FROM_SI) && HAVE_SI == 1
594
#define FROM_TYPE               1       /* Signed integer.  */
595
#define FROM_INT_C_TYPE         SItype
596
#define FROM_SINT_C_TYPE        SItype
597
#define FROM_UINT_C_TYPE        USItype
598
#define FROM_MODE_NAME_S        si
599
#define FROM_INT_SIZE           4       /* in bytes.  */
600
 
601
#elif defined (FROM_DI) && HAVE_DI == 1
602
#define FROM_TYPE               1       /* Signed integer.  */
603
#define FROM_INT_C_TYPE         DItype
604
#define FROM_SINT_C_TYPE        DItype
605
#define FROM_UINT_C_TYPE        UDItype
606
#define FROM_MODE_NAME_S        di
607
#define FROM_INT_SIZE           8       /* in bytes.  */
608
 
609
#elif defined (FROM_TI) && HAVE_TI == 1
610
#define FROM_TYPE               1       /* Signed integer.  */
611
#define FROM_INT_C_TYPE         TItype
612
#define FROM_SINT_C_TYPE        TItype
613
#define FROM_UINT_C_TYPE        UTItype
614
#define FROM_MODE_NAME_S        ti
615
#define FROM_INT_SIZE           16      /* in bytes.  */
616
 
617
#elif defined (FROM_UQI) && HAVE_UQI == 1
618
#define FROM_TYPE               2       /* Unsigned integer.  */
619
#define FROM_INT_C_TYPE         QItype
620
#define FROM_SINT_C_TYPE        QItype
621
#define FROM_UINT_C_TYPE        UQItype
622
#define FROM_MODE_NAME_S        qi
623
#define FROM_INT_SIZE           1       /* in bytes.  */
624
 
625
#elif defined (FROM_UHI) && HAVE_UHI == 1
626
#define FROM_TYPE               2       /* Unsigned integer.  */
627
#define FROM_INT_C_TYPE         UHItype
628
#define FROM_SINT_C_TYPE        HItype
629
#define FROM_UINT_C_TYPE        UHItype
630
#define FROM_MODE_NAME_S        hi
631
#define FROM_INT_SIZE           2       /* in bytes.  */
632
 
633
#elif defined (FROM_USI) && HAVE_USI == 1
634
#define FROM_TYPE               2       /* Unsigned integer.  */
635
#define FROM_INT_C_TYPE         USItype
636
#define FROM_SINT_C_TYPE        SItype
637
#define FROM_UINT_C_TYPE        USItype
638
#define FROM_MODE_NAME_S        si
639
#define FROM_INT_SIZE           4       /* in bytes.  */
640
 
641
#elif defined (FROM_UDI) && HAVE_UDI == 1
642
#define FROM_TYPE               2       /* Unsigned integer.  */
643
#define FROM_INT_C_TYPE         UDItype
644
#define FROM_SINT_C_TYPE        DItype
645
#define FROM_UINT_C_TYPE        UDItype
646
#define FROM_MODE_NAME_S        di
647
#define FROM_INT_SIZE           8       /* in bytes.  */
648
 
649
#elif defined (FROM_UTI) && HAVE_UTI == 1
650
#define FROM_TYPE               2       /* Unsigned integer.  */
651
#define FROM_INT_C_TYPE         UTItype
652
#define FROM_SINT_C_TYPE        TItype
653
#define FROM_UINT_C_TYPE        UTItype
654
#define FROM_MODE_NAME_S        ti
655
#define FROM_INT_SIZE           16      /* in bytes.  */
656
 
657
#elif defined (FROM_SF) && HAVE_SF == 1
658
#define FROM_TYPE               3       /* Floating-point.  */
659
#define FROM_FLOAT_C_TYPE       SFtype
660
#define FROM_MODE_NAME_S        sf
661
 
662
#elif defined (FROM_DF) && HAVE_DF == 1
663
#define FROM_TYPE               3       /* Floating-point.  */
664
#define FROM_FLOAT_C_TYPE       DFtype
665
#define FROM_MODE_NAME_S        df
666
 
667
#elif defined (FROM_QQ) && HAVE_QQ == 1
668
#define FROM_TYPE               4       /* Fixed-point.  */
669
#define FROM_MODE_NAME          QQ
670
#define FROM_MODE_NAME_S        qq
671
#define FROM_INT_C_TYPE         QItype
672
#define FROM_SINT_C_TYPE        QItype
673
#define FROM_UINT_C_TYPE        UQItype
674
#define FROM_MODE_UNSIGNED      0
675
#define FROM_FIXED_SIZE         1       /* in bytes.  */
676
 
677
#elif defined (FROM_HQ) && HAVE_HQ == 1
678
#define FROM_TYPE               4       /* Fixed-point.  */
679
#define FROM_MODE_NAME          HQ
680
#define FROM_MODE_NAME_S        hq
681
#define FROM_INT_C_TYPE         HItype
682
#define FROM_SINT_C_TYPE        HItype
683
#define FROM_UINT_C_TYPE        UHItype
684
#define FROM_MODE_UNSIGNED      0
685
#define FROM_FIXED_SIZE         2       /* in bytes.  */
686
 
687
#elif defined (FROM_SQ) && HAVE_SQ == 1
688
#define FROM_TYPE               4       /* Fixed-point.  */
689
#define FROM_MODE_NAME          SQ
690
#define FROM_MODE_NAME_S        sq
691
#define FROM_INT_C_TYPE         SItype
692
#define FROM_SINT_C_TYPE        SItype
693
#define FROM_UINT_C_TYPE        USItype
694
#define FROM_MODE_UNSIGNED      0
695
#define FROM_FIXED_SIZE         4       /* in bytes.  */
696
 
697
#elif defined (FROM_DQ) && HAVE_DQ == 1
698
#define FROM_TYPE               4       /* Fixed-point.  */
699
#define FROM_MODE_NAME          DQ
700
#define FROM_MODE_NAME_S        dq
701
#define FROM_INT_C_TYPE         DItype
702
#define FROM_SINT_C_TYPE        DItype
703
#define FROM_UINT_C_TYPE        UDItype
704
#define FROM_MODE_UNSIGNED      0
705
#define FROM_FIXED_SIZE         8       /* in bytes.  */
706
 
707
#elif defined (FROM_TQ) && HAVE_TQ == 1
708
#define FROM_TYPE               4       /* Fixed-point.  */
709
#define FROM_MODE_NAME          TQ
710
#define FROM_MODE_NAME_S        tq
711
#define FROM_INT_C_TYPE         TItype
712
#define FROM_SINT_C_TYPE        TItype
713
#define FROM_UINT_C_TYPE        UTItype
714
#define FROM_MODE_UNSIGNED      0
715
#define FROM_FIXED_SIZE         16      /* in bytes.  */
716
 
717
#elif defined (FROM_UQQ) && HAVE_UQQ == 1
718
#define FROM_TYPE               4       /* Fixed-point.  */
719
#define FROM_MODE_NAME          UQQ
720
#define FROM_MODE_NAME_S        uqq
721
#define FROM_INT_C_TYPE         UQItype
722
#define FROM_SINT_C_TYPE        QItype
723
#define FROM_UINT_C_TYPE        UQItype
724
#define FROM_MODE_UNSIGNED      1
725
#define FROM_FIXED_SIZE         1       /* in bytes.  */
726
 
727
#elif defined (FROM_UHQ) && HAVE_UHQ == 1
728
#define FROM_TYPE               4       /* Fixed-point.  */
729
#define FROM_MODE_NAME          UHQ
730
#define FROM_MODE_NAME_S        uhq
731
#define FROM_INT_C_TYPE         UHItype
732
#define FROM_SINT_C_TYPE        HItype
733
#define FROM_UINT_C_TYPE        UHItype
734
#define FROM_MODE_UNSIGNED      1
735
#define FROM_FIXED_SIZE         2       /* in bytes.  */
736
 
737
#elif defined (FROM_USQ) && HAVE_USQ == 1
738
#define FROM_TYPE               4       /* Fixed-point.  */
739
#define FROM_MODE_NAME          USQ
740
#define FROM_MODE_NAME_S        usq
741
#define FROM_INT_C_TYPE         USItype
742
#define FROM_SINT_C_TYPE        SItype
743
#define FROM_UINT_C_TYPE        USItype
744
#define FROM_MODE_UNSIGNED      1
745
#define FROM_FIXED_SIZE         4       /* in bytes.  */
746
 
747
#elif defined (FROM_UDQ) && HAVE_UDQ == 1
748
#define FROM_TYPE               4       /* Fixed-point.  */
749
#define FROM_MODE_NAME          UDQ
750
#define FROM_MODE_NAME_S        udq
751
#define FROM_INT_C_TYPE         UDItype
752
#define FROM_SINT_C_TYPE        DItype
753
#define FROM_UINT_C_TYPE        UDItype
754
#define FROM_MODE_UNSIGNED      1
755
#define FROM_FIXED_SIZE         8       /* in bytes.  */
756
 
757
#elif defined (FROM_UTQ) && HAVE_UTQ == 1
758
#define FROM_TYPE               4       /* Fixed-point.  */
759
#define FROM_MODE_NAME          UTQ
760
#define FROM_MODE_NAME_S        utq
761
#define FROM_INT_C_TYPE         UTItype
762
#define FROM_SINT_C_TYPE        TItype
763
#define FROM_UINT_C_TYPE        UTItype
764
#define FROM_MODE_UNSIGNED      1
765
#define FROM_FIXED_SIZE         16      /* in bytes.  */
766
 
767
#elif defined (FROM_HA) && HAVE_HA == 1
768
#define FROM_TYPE               4       /* Fixed-point.  */
769
#define FROM_MODE_NAME          HA
770
#define FROM_MODE_NAME_S        ha
771
#define FROM_INT_C_TYPE         HItype
772
#define FROM_SINT_C_TYPE        HItype
773
#define FROM_UINT_C_TYPE        UHItype
774
#define FROM_MODE_UNSIGNED      0
775
#define FROM_FIXED_SIZE         2       /* in bytes.  */
776
 
777
#elif defined (FROM_SA) && HAVE_SA == 1
778
#define FROM_TYPE               4       /* Fixed-point.  */
779
#define FROM_MODE_NAME          SA
780
#define FROM_MODE_NAME_S        sa
781
#define FROM_INT_C_TYPE         SItype
782
#define FROM_SINT_C_TYPE        SItype
783
#define FROM_UINT_C_TYPE        USItype
784
#define FROM_MODE_UNSIGNED      0
785
#define FROM_FIXED_SIZE         4       /* in bytes.  */
786
 
787
#elif defined (FROM_DA) && HAVE_DA == 1
788
#define FROM_TYPE               4       /* Fixed-point.  */
789
#define FROM_MODE_NAME          DA
790
#define FROM_MODE_NAME_S        da
791
#define FROM_INT_C_TYPE         DItype
792
#define FROM_SINT_C_TYPE        DItype
793
#define FROM_UINT_C_TYPE        UDItype
794
#define FROM_MODE_UNSIGNED      0
795
#define FROM_FIXED_SIZE         8       /* in bytes.  */
796
 
797
#elif defined (FROM_TA) && HAVE_TA == 1
798
#define FROM_TYPE               4       /* Fixed-point.  */
799
#define FROM_MODE_NAME          TA
800
#define FROM_MODE_NAME_S        ta
801
#define FROM_INT_C_TYPE         TItype
802
#define FROM_SINT_C_TYPE        TItype
803
#define FROM_UINT_C_TYPE        UTItype
804
#define FROM_MODE_UNSIGNED      0
805
#define FROM_FIXED_SIZE         16      /* in bytes.  */
806
 
807
#elif defined (FROM_UHA) && HAVE_UHA == 1
808
#define FROM_TYPE               4       /* Fixed-point.  */
809
#define FROM_MODE_NAME          UHA
810
#define FROM_MODE_NAME_S        uha
811
#define FROM_INT_C_TYPE         UHItype
812
#define FROM_SINT_C_TYPE        HItype
813
#define FROM_UINT_C_TYPE        UHItype
814
#define FROM_MODE_UNSIGNED      1
815
#define FROM_FIXED_SIZE         2       /* in bytes.  */
816
 
817
#elif defined (FROM_USA) && HAVE_USA == 1
818
#define FROM_TYPE               4       /* Fixed-point.  */
819
#define FROM_MODE_NAME          USA
820
#define FROM_MODE_NAME_S        usa
821
#define FROM_INT_C_TYPE         USItype
822
#define FROM_SINT_C_TYPE        SItype
823
#define FROM_UINT_C_TYPE        USItype
824
#define FROM_MODE_UNSIGNED      1
825
#define FROM_FIXED_SIZE         4       /* in bytes.  */
826
 
827
#elif defined (FROM_UDA) && HAVE_UDA == 1
828
#define FROM_TYPE               4       /* Fixed-point.  */
829
#define FROM_MODE_NAME          UDA
830
#define FROM_MODE_NAME_S        uda
831
#define FROM_INT_C_TYPE         UDItype
832
#define FROM_SINT_C_TYPE        DItype
833
#define FROM_UINT_C_TYPE        UDItype
834
#define FROM_MODE_UNSIGNED      1
835
#define FROM_FIXED_SIZE         8       /* in bytes.  */
836
 
837
#elif defined (FROM_UTA) && HAVE_UTA == 1
838
#define FROM_TYPE               4       /* Fixed-point.  */
839
#define FROM_MODE_NAME          UTA
840
#define FROM_MODE_NAME_S        uta
841
#define FROM_INT_C_TYPE         UTItype
842
#define FROM_SINT_C_TYPE        TItype
843
#define FROM_UINT_C_TYPE        UTItype
844
#define FROM_MODE_UNSIGNED      1
845
#define FROM_FIXED_SIZE         16      /* in bytes.  */
846
 
847
#endif
848
 
849
#if defined (TO_QI) && HAVE_QI == 1 && !defined (FROM_QI)
850
#define TO_TYPE                 1       /* Signed integer.  */
851
#define TO_INT_C_TYPE           QItype
852
#define TO_SINT_C_TYPE          QItype
853
#define TO_UINT_C_TYPE          UQItype
854
#define TO_MODE_NAME_S          qi
855
 
856
#elif defined (TO_HI) && HAVE_HI == 1 && !defined (FROM_HI)
857
#define TO_TYPE                 1       /* Signed integer.  */
858
#define TO_INT_C_TYPE           HItype
859
#define TO_SINT_C_TYPE          HItype
860
#define TO_UINT_C_TYPE          UHItype
861
#define TO_MODE_NAME_S          hi
862
 
863
#elif defined (TO_SI) && HAVE_SI == 1 && !defined (FROM_SI)
864
#define TO_TYPE                 1       /* Signed integer.  */
865
#define TO_INT_C_TYPE           SItype
866
#define TO_SINT_C_TYPE          SItype
867
#define TO_UINT_C_TYPE          USItype
868
#define TO_MODE_NAME_S          si
869
 
870
#elif defined (TO_DI) && HAVE_DI == 1 && !defined (FROM_DI)
871
#define TO_TYPE                 1       /* Signed integer.  */
872
#define TO_INT_C_TYPE           DItype
873
#define TO_SINT_C_TYPE          DItype
874
#define TO_UINT_C_TYPE          UDItype
875
#define TO_MODE_NAME_S          di
876
 
877
#elif defined (TO_TI) && HAVE_TI == 1 && !defined (FROM_TI)
878
#define TO_TYPE                 1       /* Signed integer.  */
879
#define TO_INT_C_TYPE           TItype
880
#define TO_SINT_C_TYPE          TItype
881
#define TO_UINT_C_TYPE          UTItype
882
#define TO_MODE_NAME_S          ti
883
 
884
#elif defined (TO_UQI) && HAVE_UQI == 1 && !defined (FROM_UQI)
885
#define TO_TYPE                 2       /* Unsigned integer.  */
886
#define TO_INT_C_TYPE           UQItype
887
#define TO_SINT_C_TYPE          QItype
888
#define TO_UINT_C_TYPE          UQItype
889
#define TO_MODE_NAME_S          qi
890
 
891
#elif defined (TO_UHI) && HAVE_UHI == 1 && !defined (FROM_UHI)
892
#define TO_TYPE                 2       /* Unsigned integer.  */
893
#define TO_INT_C_TYPE           UHItype
894
#define TO_SINT_C_TYPE          HItype
895
#define TO_UINT_C_TYPE          UHItype
896
#define TO_MODE_NAME_S          hi
897
 
898
#elif defined (TO_USI) && HAVE_USI == 1 && !defined (FROM_USI)
899
#define TO_TYPE                 2       /* Unsigned integer.  */
900
#define TO_INT_C_TYPE           USItype
901
#define TO_SINT_C_TYPE          SItype
902
#define TO_UINT_C_TYPE          USItype
903
#define TO_MODE_NAME_S          si
904
 
905
#elif defined (TO_UDI) && HAVE_UDI == 1 && !defined (FROM_UDI)
906
#define TO_TYPE                 2       /* Unsigned integer.  */
907
#define TO_INT_C_TYPE           UDItype
908
#define TO_SINT_C_TYPE          DItype
909
#define TO_UINT_C_TYPE          UDItype
910
#define TO_MODE_NAME_S          di
911
 
912
#elif defined (TO_UTI) && HAVE_UTI == 1 && !defined (FROM_UTI)
913
#define TO_TYPE                 2       /* Unsigned integer.  */
914
#define TO_INT_C_TYPE           UTItype
915
#define TO_SINT_C_TYPE          TItype
916
#define TO_UINT_C_TYPE          UTItype
917
#define TO_MODE_NAME_S          ti
918
 
919
#elif defined (TO_SF) && HAVE_SF == 1 && !defined (FROM_SF)
920
#define TO_TYPE                 3       /* Floating-point.  */
921
#define TO_FLOAT_C_TYPE         SFtype
922
#define TO_MODE_NAME_S          sf
923
 
924
#elif defined (TO_DF) && HAVE_DF == 1 && !defined (FROM_DF)
925
#define TO_TYPE                 3       /* Floating-point.  */
926
#define TO_FLOAT_C_TYPE         DFtype
927
#define TO_MODE_NAME_S          df
928
 
929
#elif defined (TO_QQ) && HAVE_QQ == 1 && !defined (FROM_QQ)
930
#define TO_TYPE                 4       /* Fixed-point.  */
931
#define TO_MODE_NAME            QQ
932
#define TO_MODE_NAME_S          qq
933
#define TO_INT_C_TYPE           QItype
934
#define TO_SINT_C_TYPE          QItype
935
#define TO_UINT_C_TYPE          UQItype
936
#define TO_MODE_UNSIGNED        0
937
#define TO_FIXED_SIZE           1       /* in bytes.  */
938
 
939
#elif defined (TO_HQ) && HAVE_HQ == 1 && !defined (FROM_HQ)
940
#define TO_TYPE                 4       /* Fixed-point.  */
941
#define TO_MODE_NAME            HQ
942
#define TO_MODE_NAME_S          hq
943
#define TO_INT_C_TYPE           HItype
944
#define TO_SINT_C_TYPE          HItype
945
#define TO_UINT_C_TYPE          UHItype
946
#define TO_MODE_UNSIGNED        0
947
#define TO_FIXED_SIZE           2       /* in bytes.  */
948
 
949
#elif defined (TO_SQ) && HAVE_SQ == 1 && !defined (FROM_SQ)
950
#define TO_TYPE                 4       /* Fixed-point.  */
951
#define TO_MODE_NAME            SQ
952
#define TO_MODE_NAME_S          sq
953
#define TO_INT_C_TYPE           SItype
954
#define TO_SINT_C_TYPE          SItype
955
#define TO_UINT_C_TYPE          USItype
956
#define TO_MODE_UNSIGNED        0
957
#define TO_FIXED_SIZE           4       /* in bytes.  */
958
 
959
#elif defined (TO_DQ) && HAVE_DQ == 1 && !defined (FROM_DQ)
960
#define TO_TYPE                 4       /* Fixed-point.  */
961
#define TO_MODE_NAME            DQ
962
#define TO_MODE_NAME_S          dq
963
#define TO_INT_C_TYPE           DItype
964
#define TO_SINT_C_TYPE          DItype
965
#define TO_UINT_C_TYPE          UDItype
966
#define TO_MODE_UNSIGNED        0
967
#define TO_FIXED_SIZE           8       /* in bytes.  */
968
 
969
#elif defined (TO_TQ) && HAVE_TQ == 1 && !defined (FROM_TQ)
970
#define TO_TYPE                 4       /* Fixed-point.  */
971
#define TO_MODE_NAME            TQ
972
#define TO_MODE_NAME_S          tq
973
#define TO_INT_C_TYPE           TItype
974
#define TO_SINT_C_TYPE          TItype
975
#define TO_UINT_C_TYPE          UTItype
976
#define TO_MODE_UNSIGNED        0
977
#define TO_FIXED_SIZE           16      /* in bytes.  */
978
 
979
#elif defined (TO_UQQ) && HAVE_UQQ == 1 && !defined (FROM_UQQ)
980
#define TO_TYPE                 4       /* Fixed-point.  */
981
#define TO_MODE_NAME            UQQ
982
#define TO_MODE_NAME_S          uqq
983
#define TO_INT_C_TYPE           UQItype
984
#define TO_SINT_C_TYPE          QItype
985
#define TO_UINT_C_TYPE          UQItype
986
#define TO_MODE_UNSIGNED        1
987
#define TO_FIXED_SIZE           1       /* in bytes.  */
988
 
989
#elif defined (TO_UHQ) && HAVE_UHQ == 1 && !defined (FROM_UHQ)
990
#define TO_TYPE                 4       /* Fixed-point.  */
991
#define TO_MODE_NAME            UHQ
992
#define TO_MODE_NAME_S          uhq
993
#define TO_INT_C_TYPE           UHItype
994
#define TO_SINT_C_TYPE          HItype
995
#define TO_UINT_C_TYPE          UHItype
996
#define TO_MODE_UNSIGNED        1
997
#define TO_FIXED_SIZE           2       /* in bytes.  */
998
 
999
#elif defined (TO_USQ) && HAVE_USQ == 1 && !defined (FROM_USQ)
1000
#define TO_TYPE                 4       /* Fixed-point.  */
1001
#define TO_MODE_NAME            USQ
1002
#define TO_MODE_NAME_S          usq
1003
#define TO_INT_C_TYPE           USItype
1004
#define TO_SINT_C_TYPE          SItype
1005
#define TO_UINT_C_TYPE          USItype
1006
#define TO_MODE_UNSIGNED        1
1007
#define TO_FIXED_SIZE           4       /* in bytes.  */
1008
 
1009
#elif defined (TO_UDQ) && HAVE_UDQ == 1 && !defined (FROM_UDQ)
1010
#define TO_TYPE                 4       /* Fixed-point.  */
1011
#define TO_MODE_NAME            UDQ
1012
#define TO_MODE_NAME_S          udq
1013
#define TO_INT_C_TYPE           UDItype
1014
#define TO_SINT_C_TYPE          DItype
1015
#define TO_UINT_C_TYPE          UDItype
1016
#define TO_MODE_UNSIGNED        1
1017
#define TO_FIXED_SIZE           8       /* in bytes.  */
1018
 
1019
#elif defined (TO_UTQ) && HAVE_UTQ == 1 && !defined (FROM_UTQ)
1020
#define TO_TYPE                 4       /* Fixed-point.  */
1021
#define TO_MODE_NAME            UTQ
1022
#define TO_MODE_NAME_S          utq
1023
#define TO_INT_C_TYPE           UTItype
1024
#define TO_SINT_C_TYPE          TItype
1025
#define TO_UINT_C_TYPE          UTItype
1026
#define TO_MODE_UNSIGNED        1
1027
#define TO_FIXED_SIZE           16      /* in bytes.  */
1028
 
1029
#elif defined (TO_HA) && HAVE_HA == 1 && !defined (FROM_HA)
1030
#define TO_TYPE                 4       /* Fixed-point.  */
1031
#define TO_MODE_NAME            HA
1032
#define TO_MODE_NAME_S          ha
1033
#define TO_INT_C_TYPE           HItype
1034
#define TO_SINT_C_TYPE          HItype
1035
#define TO_UINT_C_TYPE          UHItype
1036
#define TO_MODE_UNSIGNED        0
1037
#define TO_FIXED_SIZE           2       /* in bytes.  */
1038
 
1039
#elif defined (TO_SA) && HAVE_SA == 1 && !defined (FROM_SA)
1040
#define TO_TYPE                 4       /* Fixed-point.  */
1041
#define TO_MODE_NAME            SA
1042
#define TO_MODE_NAME_S          sa
1043
#define TO_INT_C_TYPE           SItype
1044
#define TO_SINT_C_TYPE          SItype
1045
#define TO_UINT_C_TYPE          USItype
1046
#define TO_MODE_UNSIGNED        0
1047
#define TO_FIXED_SIZE           4       /* in bytes.  */
1048
 
1049
#elif defined (TO_DA) && HAVE_DA == 1 && !defined (FROM_DA)
1050
#define TO_TYPE                 4       /* Fixed-point.  */
1051
#define TO_MODE_NAME            DA
1052
#define TO_MODE_NAME_S          da
1053
#define TO_INT_C_TYPE           DItype
1054
#define TO_SINT_C_TYPE          DItype
1055
#define TO_UINT_C_TYPE          UDItype
1056
#define TO_MODE_UNSIGNED        0
1057
#define TO_FIXED_SIZE           8       /* in bytes.  */
1058
 
1059
#elif defined (TO_TA) && HAVE_TA == 1 && !defined (FROM_TA)
1060
#define TO_TYPE                 4       /* Fixed-point.  */
1061
#define TO_MODE_NAME            TA
1062
#define TO_MODE_NAME_S          ta
1063
#define TO_INT_C_TYPE           TItype
1064
#define TO_SINT_C_TYPE          TItype
1065
#define TO_UINT_C_TYPE          UTItype
1066
#define TO_MODE_UNSIGNED        0
1067
#define TO_FIXED_SIZE           16      /* in bytes.  */
1068
 
1069
#elif defined (TO_UHA) && HAVE_UHA == 1 && !defined (FROM_UHA)
1070
#define TO_TYPE                 4       /* Fixed-point.  */
1071
#define TO_MODE_NAME            UHA
1072
#define TO_MODE_NAME_S          uha
1073
#define TO_INT_C_TYPE           UHItype
1074
#define TO_SINT_C_TYPE          HItype
1075
#define TO_UINT_C_TYPE          UHItype
1076
#define TO_MODE_UNSIGNED        1
1077
#define TO_FIXED_SIZE           2       /* in bytes.  */
1078
 
1079
#elif defined (TO_USA) && HAVE_USA == 1 && !defined (FROM_USA)
1080
#define TO_TYPE                 4       /* Fixed-point.  */
1081
#define TO_MODE_NAME            USA
1082
#define TO_MODE_NAME_S          usa
1083
#define TO_INT_C_TYPE           USItype
1084
#define TO_SINT_C_TYPE          SItype
1085
#define TO_UINT_C_TYPE          USItype
1086
#define TO_MODE_UNSIGNED        1
1087
#define TO_FIXED_SIZE           4       /* in bytes.  */
1088
 
1089
#elif defined (TO_UDA) && HAVE_UDA == 1 && !defined (FROM_UDA)
1090
#define TO_TYPE                 4       /* Fixed-point.  */
1091
#define TO_MODE_NAME            UDA
1092
#define TO_MODE_NAME_S          uda
1093
#define TO_INT_C_TYPE           UDItype
1094
#define TO_SINT_C_TYPE          DItype
1095
#define TO_UINT_C_TYPE          UDItype
1096
#define TO_MODE_UNSIGNED        1
1097
#define TO_FIXED_SIZE           8       /* in bytes.  */
1098
 
1099
#elif defined (TO_UTA) && HAVE_UTA == 1 && !defined (FROM_UTA)
1100
#define TO_TYPE                 4       /* Fixed-point.  */
1101
#define TO_MODE_NAME            UTA
1102
#define TO_MODE_NAME_S          uta
1103
#define TO_INT_C_TYPE           UTItype
1104
#define TO_SINT_C_TYPE          TItype
1105
#define TO_UINT_C_TYPE          UTItype
1106
#define TO_MODE_UNSIGNED        1
1107
#define TO_FIXED_SIZE           16      /* in bytes.  */
1108
 
1109
#endif
1110
 
1111
#if defined (FROM_MODE_NAME_S) && defined (TO_MODE_NAME_S)
1112
 
1113
#if FROM_TYPE == 1      /* Signed integer.  */
1114
#define FROM_INT_WIDTH          (FROM_INT_SIZE * BITS_PER_UNIT)
1115
#endif
1116
 
1117
#if FROM_TYPE == 2      /* Unsigned integer.  */
1118
#define FROM_INT_WIDTH          (FROM_INT_SIZE * BITS_PER_UNIT)
1119
#endif
1120
 
1121
#if FROM_TYPE == 4      /* Fixed-point.  */
1122
#define FROM_FIXED_C_TYPE       FIXED_C_TYPE2(FROM_MODE_NAME)
1123
#define FROM_FBITS              FBITS2(FROM_MODE_NAME)
1124
#define FROM_FIXED_WIDTH        (FROM_FIXED_SIZE * BITS_PER_UNIT)
1125
#define FROM_FBITS              FBITS2(FROM_MODE_NAME)
1126
#define FROM_IBITS              IBITS2(FROM_MODE_NAME)
1127
#define FROM_I_F_BITS           (FROM_FBITS + FROM_IBITS)
1128
 
1129
#if FROM_MODE_UNSIGNED == 0 /* Signed types.  */
1130
#define FROM_PADDING_BITS       (FROM_FIXED_WIDTH - 1 - FROM_I_F_BITS)
1131
#define FROM_NONPADDING_BITS    (1 + FROM_I_F_BITS)
1132
#else /* Unsigned types.  */
1133
#define FROM_PADDING_BITS       (FROM_FIXED_WIDTH - FROM_I_F_BITS)
1134
#define FROM_NONPADDING_BITS    (FROM_I_F_BITS)
1135
#endif
1136
#define FROM_HAVE_PADDING_BITS  (FROM_PADDING_BITS > 0)
1137
#endif /* FROM_TYPE == 4  */
1138
 
1139
#if TO_TYPE == 4        /* Fixed-point.  */
1140
#define TO_FIXED_C_TYPE         FIXED_C_TYPE2(TO_MODE_NAME)
1141
#define TO_FBITS                FBITS2(TO_MODE_NAME)
1142
#define TO_FIXED_WIDTH          (TO_FIXED_SIZE * BITS_PER_UNIT)
1143
#define TO_FBITS                FBITS2(TO_MODE_NAME)
1144
#define TO_IBITS                IBITS2(TO_MODE_NAME)
1145
#define TO_I_F_BITS             (TO_FBITS + TO_IBITS)
1146
 
1147
#if TO_MODE_UNSIGNED == 0 /* Signed types.  */
1148
#define TO_PADDING_BITS         (TO_FIXED_WIDTH - 1 - TO_I_F_BITS)
1149
#define TO_NONPADDING_BITS      (1 + TO_I_F_BITS)
1150
#else /* Unsigned types.  */
1151
#define TO_PADDING_BITS         (TO_FIXED_WIDTH - TO_I_F_BITS)
1152
#define TO_NONPADDING_BITS      (TO_I_F_BITS)
1153
#endif
1154
#define TO_HAVE_PADDING_BITS    (TO_PADDING_BITS > 0)
1155
#endif /* TO_TYPE == 4  */
1156
 
1157
#ifdef LIBGCC2_FIXEDBIT_GNU_PREFIX
1158
#define FIXED_CONVERT_OP(OP,FROM,TO)    __gnu_ ## OP ## FROM ## TO
1159
#define FIXED_CONVERT_OP2(OP,FROM,TO)   __gnu_ ## OP ## FROM ## TO ## 2
1160
#else
1161
#define FIXED_CONVERT_OP(OP,FROM,TO)    __ ## OP ## FROM ## TO
1162
#define FIXED_CONVERT_OP2(OP,FROM,TO)   __ ## OP ## FROM ## TO ## 2
1163
#endif
1164
#define FRACT_TEMP(N1,N2)               FIXED_CONVERT_OP(fract,N1,N2)
1165
#define FRACT2_TEMP(N1,N2)              FIXED_CONVERT_OP2(fract,N1,N2)
1166
#define SATFRACT_TEMP(N1,N2)            FIXED_CONVERT_OP(satfract,N1,N2)
1167
#define SATFRACT2_TEMP(N1,N2)           FIXED_CONVERT_OP2(satfract,N1,N2)
1168
#define FRACTUNS_TEMP(N1,N2)            FIXED_CONVERT_OP(fractuns,N1,N2)
1169
#define SATFRACTUNS_TEMP(N1,N2)         FIXED_CONVERT_OP(satfractuns,N1,N2)
1170
 
1171
/* Define conversions from fixed-point to fixed-point.  */
1172
#if FROM_TYPE == 4 && TO_TYPE == 4
1173
 
1174
#if FROM_FIXED_SIZE > TO_FIXED_SIZE
1175
#define BIG_SINT_C_TYPE FROM_SINT_C_TYPE
1176
#define BIG_UINT_C_TYPE FROM_UINT_C_TYPE
1177
#define BIG_WIDTH       FROM_FIXED_WIDTH
1178
#else
1179
#define BIG_SINT_C_TYPE TO_SINT_C_TYPE
1180
#define BIG_UINT_C_TYPE TO_UINT_C_TYPE
1181
#define BIG_WIDTH       TO_FIXED_WIDTH
1182
#endif
1183
 
1184
/* Check if FROM* and TO* are in the same machine class.  */
1185
#if ((FROM_MODE_UNSIGNED == TO_MODE_UNSIGNED) \
1186
     && ((FROM_IBITS == 0) == (TO_IBITS == 0)))
1187
/* Same modes: append '2' to conversion function names */
1188
#define FRACT           FRACT2_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1189
#define SATFRACT        SATFRACT2_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1190
#else
1191
/* Different modes: don't append '2' to conversion function names */
1192
#define FRACT           FRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1193
#define SATFRACT        SATFRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1194
#endif
1195
 
1196
extern TO_FIXED_C_TYPE FRACT (FROM_FIXED_C_TYPE);
1197
extern TO_FIXED_C_TYPE SATFRACT (FROM_FIXED_C_TYPE);
1198
#endif /* FROM_TYPE == 4 && TO_TYPE == 4  */
1199
 
1200
/* Define conversions from fixed-point to signed integer.  */
1201
#if FROM_TYPE == 4 && TO_TYPE == 1
1202
#define FRACT           FRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1203
extern TO_INT_C_TYPE    FRACT (FROM_FIXED_C_TYPE);
1204
#endif /* FROM_TYPE == 4 && TO_TYPE == 1  */
1205
 
1206
/* Define conversions from fixed-point to unsigned integer.  */
1207
#if FROM_TYPE == 4 && TO_TYPE == 2
1208
#define FRACTUNS        FRACTUNS_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1209
extern TO_INT_C_TYPE    FRACTUNS (FROM_FIXED_C_TYPE);
1210
#endif /* FROM_TYPE == 4 && TO_TYPE == 2  */
1211
 
1212
/* Define conversions from fixed-point to floating-point.  */
1213
#if FROM_TYPE == 4 && TO_TYPE == 3
1214
#define BASE1(NUM)      0x1.0p ## NUM
1215
#define BASE2(NUM)      BASE1(NUM)
1216
#define BASE            BASE2(FROM_FBITS)
1217
#define FRACT           FRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1218
extern TO_FLOAT_C_TYPE  FRACT (FROM_FIXED_C_TYPE);
1219
#endif /* FROM_TYPE == 4 && TO_TYPE == 3  */
1220
 
1221
/* Define conversions from signed integer to fixed-point.  */
1222
#if FROM_TYPE == 1 && TO_TYPE == 4
1223
 
1224
#if FROM_INT_SIZE > TO_FIXED_SIZE
1225
#define BIG_SINT_C_TYPE FROM_SINT_C_TYPE
1226
#define BIG_UINT_C_TYPE FROM_UINT_C_TYPE
1227
#define BIG_WIDTH       FROM_INT_WIDTH
1228
#else
1229
#define BIG_SINT_C_TYPE TO_SINT_C_TYPE
1230
#define BIG_UINT_C_TYPE TO_UINT_C_TYPE
1231
#define BIG_WIDTH       TO_FIXED_WIDTH
1232
#endif
1233
 
1234
#define FRACT           FRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1235
#define SATFRACT        SATFRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1236
extern TO_FIXED_C_TYPE  FRACT (FROM_INT_C_TYPE);
1237
extern TO_FIXED_C_TYPE  SATFRACT (FROM_INT_C_TYPE);
1238
#endif /* FROM_TYPE == 1 && TO_TYPE == 4  */
1239
 
1240
/* Define conversions from unsigned integer to fixed-point.  */
1241
#if FROM_TYPE == 2 && TO_TYPE == 4
1242
 
1243
#if FROM_INT_SIZE > TO_FIXED_SIZE
1244
#define BIG_SINT_C_TYPE FROM_SINT_C_TYPE
1245
#define BIG_UINT_C_TYPE FROM_UINT_C_TYPE
1246
#define BIG_WIDTH       FROM_INT_WIDTH
1247
#else
1248
#define BIG_SINT_C_TYPE TO_SINT_C_TYPE
1249
#define BIG_UINT_C_TYPE TO_UINT_C_TYPE
1250
#define BIG_WIDTH       TO_FIXED_WIDTH
1251
#endif
1252
 
1253
#define FRACTUNS        FRACTUNS_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1254
#define SATFRACTUNS     SATFRACTUNS_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1255
extern TO_FIXED_C_TYPE  FRACTUNS (FROM_INT_C_TYPE);
1256
extern TO_FIXED_C_TYPE  SATFRACTUNS (FROM_INT_C_TYPE);
1257
#endif /* FROM_TYPE == 2 && TO_TYPE == 4  */
1258
 
1259
/* Define conversions from floating-point to fixed-point.  */
1260
#if FROM_TYPE == 3 && TO_TYPE == 4
1261
 
1262
#define BASE1(NUM)      (0x1.0p ## NUM)
1263
#define BASE2(NUM)      BASE1(NUM)
1264
#define BASE            BASE2(TO_FBITS)
1265
 
1266
#define FIXED_MAX1(NUM1,NUM2)   (0x1.0p ## NUM1 - 0x1.0p- ## NUM2)
1267
#define FIXED_MAX2(NUM1,NUM2)   FIXED_MAX1(NUM1,NUM2)
1268
#define FIXED_MAX       FIXED_MAX2(TO_IBITS,TO_FBITS)
1269
 
1270
#define FIXED_MIN1(NUM) (-0x1.0p ## NUM)
1271
#define FIXED_MIN2(NUM) FIXED_MIN1(NUM)
1272
#if TO_MODE_UNSIGNED == 0
1273
#define FIXED_MIN       FIXED_MIN2(TO_IBITS)
1274
#else
1275
#define FIXED_MIN       0.0
1276
#endif
1277
 
1278
#define FRACT           FRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1279
#define SATFRACT        SATFRACT_TEMP(FROM_MODE_NAME_S,TO_MODE_NAME_S)
1280
extern TO_FIXED_C_TYPE  FRACT (FROM_FLOAT_C_TYPE);
1281
extern TO_FIXED_C_TYPE  SATFRACT (FROM_FLOAT_C_TYPE);
1282
#endif /* FROM_TYPE == 3 && TO_TYPE == 4  */
1283
 
1284
#endif /* defined (FROM_MODE_NAME_S) && defined (TO_MODE_NAME_S)  */
1285
 
1286
#endif  /* _FIXED_BIT_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.