1 /* Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 /* ISO/IEC JTC1 SC22 WG14 N1169
27 * Programming languages - C - Extensions to support embedded processors
30 #ifndef _AVRGCC_STDFIX_H
31 #define _AVRGCC_STDFIX_H
33 /* 7.18a.1 Introduction. */
34 /* 7.18a.3 Precision macros. */
36 #include <stdfix-gcc.h>
39 #if __SIZEOF_INT__ == 2
41 typedef signed char int_hr_t
;
42 typedef unsigned char uint_uhr_t
;
44 typedef short int int_r_t
;
45 typedef short unsigned int uint_ur_t
;
47 typedef short int int_hk_t
;
48 typedef short unsigned int uint_uhk_t
;
50 typedef long int int_lr_t
;
51 typedef long unsigned int uint_ulr_t
;
53 typedef long int int_k_t
;
54 typedef long unsigned int uint_uk_t
;
56 typedef long long int int_llr_t
;
57 typedef long long unsigned int uint_ullr_t
;
59 typedef long long int int_lk_t
;
60 typedef long long unsigned int uint_ulk_t
;
62 typedef long long int int_llk_t
;
63 typedef long long unsigned int uint_ullk_t
;
65 #elif __SIZEOF_INT__ == 1 /* -mint8 */
67 typedef signed char int_hr_t
;
68 typedef unsigned char uint_uhr_t
;
70 typedef long int int_r_t
;
71 typedef long unsigned int uint_ur_t
;
73 typedef long int int_hk_t
;
74 typedef long unsigned int uint_uhk_t
;
76 typedef long long int int_lr_t
;
77 typedef long long unsigned int uint_ulr_t
;
79 typedef long long int int_k_t
;
80 typedef long long unsigned int uint_uk_t
;
82 #endif /* __SIZEOF_INT__ == 1, 2 */
85 /* 7.18a.6 The fixed-point intrinsic functions. */
88 /* 7.18a.6.2 The fixed-point absolute value functions. */
90 #define abshr __builtin_avr_abshr
91 #define absr __builtin_avr_absr
92 #define abslr __builtin_avr_abslr
94 #define abshk __builtin_avr_abshk
95 #define absk __builtin_avr_absk
97 #if __SIZEOF_INT__ == 2
99 #define abslk __builtin_avr_abslk
100 #define absllr __builtin_avr_absllr /* GCC Extension */
101 #define absllk __builtin_avr_absllk /* GCC Extension */
103 #endif /* sizeof (int) == 2 */
106 /* 7.18a.6.3 The fixed-point round functions. */
108 /* The Embedded-C paper specifies results only for rounding points
112 As an extension, the following functions work as expected
117 For example, rounding an accum with a rounding point of -1 will
118 result in an even integer value. */
120 #define roundhr __builtin_avr_roundhr
121 #define roundr __builtin_avr_roundr
122 #define roundlr __builtin_avr_roundlr
124 #define rounduhr __builtin_avr_rounduhr
125 #define roundur __builtin_avr_roundur
126 #define roundulr __builtin_avr_roundulr
128 #define roundhk __builtin_avr_roundhk
129 #define roundk __builtin_avr_roundk
131 #define rounduhk __builtin_avr_rounduhk
132 #define rounduk __builtin_avr_rounduk
134 #if __SIZEOF_INT__ == 2
136 #define roundlk __builtin_avr_roundlk
137 #define roundulk __builtin_avr_roundulk
138 #define roundllr __builtin_avr_roundllr /* GCC Extension */
139 #define roundullr __builtin_avr_roundullr /* GCC Extension */
140 #define roundllk __builtin_avr_roundllk /* GCC Extension */
141 #define roundullk __builtin_avr_roundullk /* GCC Extension */
143 #endif /* sizeof (int) == 2 */
146 /* 7.18a.6.4 The fixed-point bit countls functions. */
148 #define countlshr __builtin_avr_countlshr
149 #define countlsr __builtin_avr_countlsr
150 #define countlslr __builtin_avr_countlslr
152 #define countlsuhr __builtin_avr_countlsuhr
153 #define countlsur __builtin_avr_countlsur
154 #define countlsulr __builtin_avr_countlsulr
156 #define countlshk __builtin_avr_countlshk
157 #define countlsk __builtin_avr_countlsk
159 #define countlsuhk __builtin_avr_countlsuhk
160 #define countlsuk __builtin_avr_countlsuk
162 #if __SIZEOF_INT__ == 2
164 #define countlslk __builtin_avr_countlslk
165 #define countlsulk __builtin_avr_countlsulk
166 #define countlsllr __builtin_avr_countlsllr /* GCC Extension */
167 #define countlsullr __builtin_avr_countlsullr /* GCC Extension */
168 #define countlsllk __builtin_avr_countlsllk /* GCC Extension */
169 #define countlsullk __builtin_avr_countlsullk /* GCC Extension */
171 #endif /* sizeof (int) == 2 */
174 /* 7.18a.6.5 The bitwise fixed-point to integer conversion functions. */
176 #define bitshr __builtin_avr_bitshr
177 #define bitsr __builtin_avr_bitsr
178 #define bitslr __builtin_avr_bitslr
180 #define bitsuhr __builtin_avr_bitsuhr
181 #define bitsur __builtin_avr_bitsur
182 #define bitsulr __builtin_avr_bitsulr
184 #define bitshk __builtin_avr_bitshk
185 #define bitsk __builtin_avr_bitsk
187 #define bitsuhk __builtin_avr_bitsuhk
188 #define bitsuk __builtin_avr_bitsuk
190 #if __SIZEOF_INT__ == 2
192 #define bitslk __builtin_avr_bitslk
193 #define bitsulk __builtin_avr_bitsulk
194 #define bitsllr __builtin_avr_bitsllr /* GCC Extension */
195 #define bitsullr __builtin_avr_bitsullr /* GCC Extension */
196 #define bitsllk __builtin_avr_bitsllk /* GCC Extension */
197 #define bitsullk __builtin_avr_bitsullk /* GCC Extension */
199 #endif /* sizeof (int) == 2 */
202 /* 7.18a.6.6 The bitwise integer to fixed-point conversion functions. */
204 #define hrbits __builtin_avr_hrbits
205 #define rbits __builtin_avr_rbits
206 #define lrbits __builtin_avr_lrbits
208 #define uhrbits __builtin_avr_uhrbits
209 #define urbits __builtin_avr_urbits
210 #define ulrbits __builtin_avr_ulrbits
212 #define hkbits __builtin_avr_hkbits
213 #define kbits __builtin_avr_kbits
215 #define uhkbits __builtin_avr_uhkbits
216 #define ukbits __builtin_avr_ukbits
218 #if __SIZEOF_INT__ == 2
220 #define lkbits __builtin_avr_lkbits
221 #define ulkbits __builtin_avr_ulkbits
222 #define llrbits __builtin_avr_llrbits /* GCC Extension */
223 #define ullrbits __builtin_avr_ullrbits /* GCC Extension */
224 #define llkbits __builtin_avr_llkbits /* GCC Extension */
225 #define ullkbits __builtin_avr_ullkbits /* GCC Extension */
227 #endif /* sizeof (int) == 2 */
230 /* 7.18a.6.7 Type-generic fixed-point functions. */
232 #define absfx __builtin_avr_absfx
233 #define roundfx __builtin_avr_roundfx
234 #define countlsfx __builtin_avr_countlsfx
236 #endif /* _AVRGCC_STDFIX_H */