aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/config/avr/stdfix.h
blob: 38d80e4dc96c32b43eb73d96f81f7398b7d6069e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* Copyright (C) 2007-2014 Free Software Foundation, Inc.

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GCC is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   Under Section 7 of GPL version 3, you are granted additional
   permissions described in the GCC Runtime Library Exception, version
   3.1, as published by the Free Software Foundation.

   You should have received a copy of the GNU General Public License and
   a copy of the GCC Runtime Library Exception along with this program;
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   <http://www.gnu.org/licenses/>.  */

/* ISO/IEC JTC1 SC22 WG14 N1169
 * Date: 2006-04-04
 * ISO/IEC TR 18037
 * Programming languages - C - Extensions to support embedded processors
 */

#ifndef _AVRGCC_STDFIX_H
#define _AVRGCC_STDFIX_H

/* 7.18a.1 Introduction.  */
/* 7.18a.3 Precision macros.  */

#include <stdfix-gcc.h>


#if __SIZEOF_INT__ == 2

typedef signed char int_hr_t;
typedef unsigned char uint_uhr_t;

typedef short int int_r_t;
typedef short unsigned int uint_ur_t;

typedef short int int_hk_t;
typedef short unsigned int uint_uhk_t;

typedef long int int_lr_t;
typedef long unsigned int uint_ulr_t;

typedef long int int_k_t;
typedef long unsigned int uint_uk_t;

typedef long long int int_llr_t;
typedef long long unsigned int uint_ullr_t;

typedef long long int int_lk_t;
typedef long long unsigned int uint_ulk_t;

typedef long long int int_llk_t;
typedef long long unsigned int uint_ullk_t;

#elif __SIZEOF_INT__ == 1  /*  -mint8  */

typedef signed char int_hr_t;
typedef unsigned char uint_uhr_t;

typedef long int int_r_t;
typedef long unsigned int uint_ur_t;

typedef long int int_hk_t;
typedef long unsigned int uint_uhk_t;

typedef long long int int_lr_t;
typedef long long unsigned int uint_ulr_t;

typedef long long int int_k_t;
typedef long long unsigned int uint_uk_t;

#endif /* __SIZEOF_INT__ == 1, 2 */


/* 7.18a.6  The fixed-point intrinsic functions.  */


/* 7.18a.6.2  The fixed-point absolute value functions.  */

#define abshr __builtin_avr_abshr
#define absr  __builtin_avr_absr
#define abslr __builtin_avr_abslr

#define abshk __builtin_avr_abshk
#define absk  __builtin_avr_absk

#if __SIZEOF_INT__ == 2

#define abslk  __builtin_avr_abslk
#define absllr __builtin_avr_absllr  /* GCC Extension */
#define absllk __builtin_avr_absllk  /* GCC Extension */

#endif /* sizeof (int) == 2 */


/* 7.18a.6.3  The fixed-point round functions.  */

/* The Embedded-C paper specifies results only for rounding points

       0 < RP < FBIT
  
   As an extension, the following functions work as expected
   with rounding points

       -IBIT < RP < FBIT
 
   For example, rounding an accum with a rounding point of -1 will
   result in an even integer value.  */

#define roundhr  __builtin_avr_roundhr
#define roundr   __builtin_avr_roundr
#define roundlr  __builtin_avr_roundlr

#define rounduhr __builtin_avr_rounduhr
#define roundur  __builtin_avr_roundur
#define roundulr __builtin_avr_roundulr

#define roundhk  __builtin_avr_roundhk
#define roundk   __builtin_avr_roundk

#define rounduhk __builtin_avr_rounduhk
#define rounduk  __builtin_avr_rounduk

#if __SIZEOF_INT__ == 2

#define roundlk   __builtin_avr_roundlk
#define roundulk  __builtin_avr_roundulk
#define roundllr  __builtin_avr_roundllr  /* GCC Extension */
#define roundullr __builtin_avr_roundullr /* GCC Extension */
#define roundllk  __builtin_avr_roundllk  /* GCC Extension */
#define roundullk __builtin_avr_roundullk /* GCC Extension */

#endif /* sizeof (int) == 2 */


/* 7.18a.6.4  The fixed-point bit countls functions.  */

#define countlshr  __builtin_avr_countlshr
#define countlsr   __builtin_avr_countlsr
#define countlslr  __builtin_avr_countlslr

#define countlsuhr __builtin_avr_countlsuhr
#define countlsur  __builtin_avr_countlsur
#define countlsulr __builtin_avr_countlsulr

#define countlshk  __builtin_avr_countlshk
#define countlsk   __builtin_avr_countlsk

#define countlsuhk __builtin_avr_countlsuhk
#define countlsuk  __builtin_avr_countlsuk

#if __SIZEOF_INT__ == 2

#define countlslk   __builtin_avr_countlslk
#define countlsulk  __builtin_avr_countlsulk
#define countlsllr  __builtin_avr_countlsllr  /* GCC Extension */
#define countlsullr __builtin_avr_countlsullr /* GCC Extension */
#define countlsllk  __builtin_avr_countlsllk  /* GCC Extension */
#define countlsullk __builtin_avr_countlsullk /* GCC Extension */

#endif /* sizeof (int) == 2 */


/* 7.18a.6.5  The bitwise fixed-point to integer conversion functions. */

#define bitshr  __builtin_avr_bitshr
#define bitsr   __builtin_avr_bitsr
#define bitslr  __builtin_avr_bitslr

#define bitsuhr __builtin_avr_bitsuhr
#define bitsur  __builtin_avr_bitsur
#define bitsulr __builtin_avr_bitsulr

#define bitshk  __builtin_avr_bitshk
#define bitsk   __builtin_avr_bitsk

#define bitsuhk __builtin_avr_bitsuhk
#define bitsuk  __builtin_avr_bitsuk

#if __SIZEOF_INT__ == 2

#define bitslk   __builtin_avr_bitslk
#define bitsulk  __builtin_avr_bitsulk
#define bitsllr  __builtin_avr_bitsllr  /* GCC Extension */
#define bitsullr __builtin_avr_bitsullr /* GCC Extension */
#define bitsllk  __builtin_avr_bitsllk  /* GCC Extension */
#define bitsullk __builtin_avr_bitsullk /* GCC Extension */

#endif /* sizeof (int) == 2 */


/* 7.18a.6.6  The bitwise integer to fixed-point conversion functions. */

#define hrbits  __builtin_avr_hrbits
#define rbits   __builtin_avr_rbits
#define lrbits  __builtin_avr_lrbits

#define uhrbits __builtin_avr_uhrbits
#define urbits  __builtin_avr_urbits
#define ulrbits __builtin_avr_ulrbits

#define hkbits  __builtin_avr_hkbits
#define kbits   __builtin_avr_kbits

#define uhkbits __builtin_avr_uhkbits
#define ukbits  __builtin_avr_ukbits

#if __SIZEOF_INT__ == 2

#define lkbits   __builtin_avr_lkbits
#define ulkbits  __builtin_avr_ulkbits
#define llrbits  __builtin_avr_llrbits  /* GCC Extension */
#define ullrbits __builtin_avr_ullrbits /* GCC Extension */
#define llkbits  __builtin_avr_llkbits  /* GCC Extension */
#define ullkbits __builtin_avr_ullkbits /* GCC Extension */

#endif /* sizeof (int) == 2 */


/* 7.18a.6.7  Type-generic fixed-point functions.  */

#define absfx     __builtin_avr_absfx
#define roundfx   __builtin_avr_roundfx
#define countlsfx __builtin_avr_countlsfx

#endif /* _AVRGCC_STDFIX_H */