1 | //===-- Definitions from stdfix.h -----------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLVM_LIBC_MACROS_STDFIX_MACROS_H |
10 | #define LLVM_LIBC_MACROS_STDFIX_MACROS_H |
11 | |
12 | #ifdef __FRACT_FBIT__ |
13 | // _Fract and _Accum types are available |
14 | #define LIBC_COMPILER_HAS_FIXED_POINT |
15 | #endif // __FRACT_FBIT__ |
16 | |
17 | #ifdef LIBC_COMPILER_HAS_FIXED_POINT |
18 | |
19 | #define fract _Fract |
20 | #define accum _Accum |
21 | #define sat _Sat |
22 | |
23 | // Default values: from ISO/IEC TR 18037:2008 standard - Annex A.3 - Typical |
24 | // desktop processor. |
25 | |
26 | #ifdef __SFRACT_FBIT__ |
27 | #define SFRACT_FBIT __SFRACT_FBIT__ |
28 | #else |
29 | #define SFRACT_FBIT 7 |
30 | #endif // SFRACT_FBIT |
31 | |
32 | #ifdef __SFRACT_MIN__ |
33 | #define SFRACT_MIN __SFRACT_MIN__ |
34 | #else |
35 | #define SFRACT_MIN (-0.5HR - 0.5HR) |
36 | #endif // SFRACT_MIN |
37 | |
38 | #ifdef __SFRACT_MAX__ |
39 | #define SFRACT_MAX __SFRACT_MAX__ |
40 | #else |
41 | #define SFRACT_MAX 0x1.FCp-1HR |
42 | #endif // SFRACT_MAX |
43 | |
44 | #ifdef __SFRACT_EPSILON__ |
45 | #define SFRACT_EPSILON __SFRACT_EPSILON__ |
46 | #else |
47 | #define SFRACT_EPSILON 0x1.0p-7HR |
48 | #endif // SFRACT_EPSILON |
49 | |
50 | #ifdef __USFRACT_FBIT__ |
51 | #define USFRACT_FBIT __USFRACT_FBIT__ |
52 | #else |
53 | #define USFRACT_FBIT 8 |
54 | #endif // USFRACT_FBIT |
55 | |
56 | #define USFRACT_MIN 0.0UHR |
57 | |
58 | #ifdef __USFRACT_MAX__ |
59 | #define USFRACT_MAX __USFRACT_MAX__ |
60 | #else |
61 | #define USFRACT_MAX 0x1.FEp-1UHR |
62 | #endif // USFRACT_MAX |
63 | |
64 | #ifdef __USFRACT_EPSILON__ |
65 | #define USFRACT_EPSILON __USFRACT_EPSILON__ |
66 | #else |
67 | #define USFRACT_EPSILON 0x1.0p-8UHR |
68 | #endif // USFRACT_EPSILON |
69 | |
70 | #ifdef __FRACT_FBIT__ |
71 | #define FRACT_FBIT __FRACT_FBIT__ |
72 | #else |
73 | #define FRACT_FBIT 15 |
74 | #endif // FRACT_FBIT |
75 | |
76 | #ifdef __FRACT_MIN__ |
77 | #define FRACT_MIN __FRACT_MIN__ |
78 | #else |
79 | #define FRACT_MIN (-0.5R - 0.5R) |
80 | #endif // FRACT_MIN |
81 | |
82 | #ifdef __FRACT_MAX__ |
83 | #define FRACT_MAX __FRACT_MAX__ |
84 | #else |
85 | #define FRACT_MAX 0x1.FFFCp-1R |
86 | #endif // FRACT_MAX |
87 | |
88 | #ifdef __FRACT_EPSILON__ |
89 | #define FRACT_EPSILON __FRACT_EPSILON__ |
90 | #else |
91 | #define FRACT_EPSILON 0x1.0p-15R |
92 | #endif // FRACT_EPSILON |
93 | |
94 | #ifdef __UFRACT_FBIT__ |
95 | #define UFRACT_FBIT __UFRACT_FBIT__ |
96 | #else |
97 | #define UFRACT_FBIT 16 |
98 | #endif // UFRACT_FBIT |
99 | |
100 | #define UFRACT_MIN 0.0UR |
101 | |
102 | #ifdef __UFRACT_MAX__ |
103 | #define UFRACT_MAX __UFRACT_MAX__ |
104 | #else |
105 | #define UFRACT_MAX 0x1.FFFEp-1UR |
106 | #endif // UFRACT_MAX |
107 | |
108 | #ifdef __UFRACT_EPSILON__ |
109 | #define UFRACT_EPSILON __UFRACT_EPSILON__ |
110 | #else |
111 | #define UFRACT_EPSILON 0x1.0p-16UR |
112 | #endif // UFRACT_EPSILON |
113 | |
114 | #ifdef __LFRACT_FBIT__ |
115 | #define LFRACT_FBIT __LFRACT_FBIT__ |
116 | #else |
117 | #define LFRACT_FBIT 31 |
118 | #endif // LFRACT_FBIT |
119 | |
120 | #ifdef __LFRACT_MIN__ |
121 | #define LFRACT_MIN __LFRACT_MIN__ |
122 | #else |
123 | #define LFRACT_MIN (-0.5LR - 0.5LR) |
124 | #endif // LFRACT_MIN |
125 | |
126 | #ifdef __LFRACT_MAX__ |
127 | #define LFRACT_MAX __LFRACT_MAX__ |
128 | #else |
129 | #define LFRACT_MAX 0x1.FFFFFFFCp-1LR |
130 | #endif // LFRACT_MAX |
131 | |
132 | #ifdef __LFRACT_EPSILON__ |
133 | #define LFRACT_EPSILON __LFRACT_EPSILON__ |
134 | #else |
135 | #define LFRACT_EPSILON 0x1.0p-31LR |
136 | #endif // LFRACT_EPSILON |
137 | |
138 | #ifdef __ULFRACT_FBIT__ |
139 | #define ULFRACT_FBIT __ULFRACT_FBIT__ |
140 | #else |
141 | #define ULFRACT_FBIT 32 |
142 | #endif // ULFRACT_FBIT |
143 | |
144 | #define ULFRACT_MIN 0.0ULR |
145 | |
146 | #ifdef __ULFRACT_MAX__ |
147 | #define ULFRACT_MAX __ULFRACT_MAX__ |
148 | #else |
149 | #define ULFRACT_MAX 0x1.FFFFFFFEp-1ULR |
150 | #endif // ULFRACT_MAX |
151 | |
152 | #ifdef __ULFRACT_EPSILON__ |
153 | #define ULFRACT_EPSILON __ULFRACT_EPSILON__ |
154 | #else |
155 | #define ULFRACT_EPSILON 0x1.0p-32ULR |
156 | #endif // ULFRACT_EPSILON |
157 | |
158 | #ifdef __SACCUM_FBIT__ |
159 | #define SACCUM_FBIT __SACCUM_FBIT__ |
160 | #else |
161 | #define SACCUM_FBIT 7 |
162 | #endif // SACCUM_FBIT |
163 | |
164 | #ifdef __SACCUM_IBIT__ |
165 | #define SACCUM_IBIT __SACCUM_IBIT__ |
166 | #else |
167 | #define SACCUM_IBIT 8 |
168 | #endif // SACCUM_IBIT |
169 | |
170 | #ifdef __SACCUM_MIN__ |
171 | #define SACCUM_MIN __SACCUM_MIN__ |
172 | #else |
173 | #define SACCUM_MIN (-0x1.0p+7HK - 0x1.0p+7HK) |
174 | #endif // SACCUM_MIN |
175 | |
176 | #ifdef __SACCUM_MAX__ |
177 | #define SACCUM_MAX __SACCUM_MAX__ |
178 | #else |
179 | #define SACCUM_MAX 0x1.FFFCp+7HK |
180 | #endif // SACCUM_MAX |
181 | |
182 | #ifdef __SACCUM_EPSILON__ |
183 | #define SACCUM_EPSILON __SACCUM_EPSILON__ |
184 | #else |
185 | #define SACCUM_EPSILON 0x1.0p-7HK |
186 | #endif // SACCUM_EPSILON |
187 | |
188 | #ifdef __USACCUM_FBIT__ |
189 | #define USACCUM_FBIT __USACCUM_FBIT__ |
190 | #else |
191 | #define USACCUM_FBIT 8 |
192 | #endif // USACCUM_FBIT |
193 | |
194 | #ifdef __USACCUM_IBIT__ |
195 | #define USACCUM_IBIT __USACCUM_IBIT__ |
196 | #else |
197 | #define USACCUM_IBIT 8 |
198 | #endif // USACCUM_IBIT |
199 | |
200 | #define USACCUM_MIN 0.0UHK |
201 | |
202 | #ifdef __USACCUM_MAX__ |
203 | #define USACCUM_MAX __USACCUM_MAX__ |
204 | #else |
205 | #define USACCUM_MAX 0x1.FFFEp+7UHK |
206 | #endif // USACCUM_MAX |
207 | |
208 | #ifdef __USACCUM_EPSILON__ |
209 | #define USACCUM_EPSILON __USACCUM_EPSILON__ |
210 | #else |
211 | #define USACCUM_EPSILON 0x1.0p-8UHK |
212 | #endif // USACCUM_EPSILON |
213 | |
214 | #ifdef __ACCUM_FBIT__ |
215 | #define ACCUM_FBIT __ACCUM_FBIT__ |
216 | #else |
217 | #define ACCUM_FBIT 15 |
218 | #endif // ACCUM_FBIT |
219 | |
220 | #ifdef __ACCUM_IBIT__ |
221 | #define ACCUM_IBIT __ACCUM_IBIT__ |
222 | #else |
223 | #define ACCUM_IBIT 16 |
224 | #endif // ACCUM_IBIT |
225 | |
226 | #ifdef __ACCUM_MIN__ |
227 | #define ACCUM_MIN __ACCUM_MIN__ |
228 | #else |
229 | #define ACCUM_MIN (-0x1.0p+15K - 0x1.0p+15K) |
230 | #endif // ACCUM_MIN |
231 | |
232 | #ifdef __ACCUM_MAX__ |
233 | #define ACCUM_MAX __ACCUM_MAX__ |
234 | #else |
235 | #define ACCUM_MAX 0x1.FFFFFFFCp+15K |
236 | #endif // ACCUM_MAX |
237 | |
238 | #ifdef __ACCUM_EPSILON__ |
239 | #define ACCUM_EPSILON __ACCUM_EPSILON__ |
240 | #else |
241 | #define ACCUM_EPSILON 0x1.0p-15K |
242 | #endif // ACCUM_EPSILON |
243 | |
244 | #ifdef __UACCUM_FBIT__ |
245 | #define UACCUM_FBIT __UACCUM_FBIT__ |
246 | #else |
247 | #define UACCUM_FBIT 16 |
248 | #endif // UACCUM_FBIT |
249 | |
250 | #ifdef __UACCUM_IBIT__ |
251 | #define UACCUM_IBIT __UACCUM_IBIT__ |
252 | #else |
253 | #define UACCUM_IBIT 16 |
254 | #endif // UACCUM_IBIT |
255 | |
256 | #define UACCUM_MIN 0.0UK |
257 | |
258 | #ifdef __UACCUM_MAX__ |
259 | #define UACCUM_MAX __UACCUM_MAX__ |
260 | #else |
261 | #define UACCUM_MAX 0x1.FFFFFFFEp+15UK |
262 | #endif // UACCUM_MAX |
263 | |
264 | #ifdef __UACCUM_EPSILON__ |
265 | #define UACCUM_EPSILON __UACCUM_EPSILON__ |
266 | #else |
267 | #define UACCUM_EPSILON 0x1.0p-16UK |
268 | #endif // UACCUM_EPSILON |
269 | |
270 | #ifdef __LACCUM_FBIT__ |
271 | #define LACCUM_FBIT __LACCUM_FBIT__ |
272 | #else |
273 | #define LACCUM_FBIT 31 |
274 | #endif // LACCUM_FBIT |
275 | |
276 | #ifdef __LACCUM_IBIT__ |
277 | #define LACCUM_IBIT __LACCUM_IBIT__ |
278 | #else |
279 | #define LACCUM_IBIT 32 |
280 | #endif // LACCUM_IBIT |
281 | |
282 | #ifdef __LACCUM_MIN__ |
283 | #define LACCUM_MIN __LACCUM_MIN__ |
284 | #else |
285 | #define LACCUM_MIN (-0x1.0p+31LK - 0x1.0p+31LK) |
286 | #endif // LACCUM_MIN |
287 | |
288 | #ifdef __LACCUM_MAX__ |
289 | #define LACCUM_MAX __LACCUM_MAX__ |
290 | #else |
291 | #define LACCUM_MAX 0x1.FFFFFFFFFFFFFFFCp+31LK |
292 | #endif // LACCUM_MAX |
293 | |
294 | #ifdef __LACCUM_EPSILON__ |
295 | #define LACCUM_EPSILON __LACCUM_EPSILON__ |
296 | #else |
297 | #define LACCUM_EPSILON 0x1.0p-31LK |
298 | #endif // LACCUM_EPSILON |
299 | |
300 | #ifdef __ULACCUM_FBIT__ |
301 | #define ULACCUM_FBIT __ULACCUM_FBIT__ |
302 | #else |
303 | #define ULACCUM_FBIT 32 |
304 | #endif // ULACCUM_FBIT |
305 | |
306 | #ifdef __ULACCUM_IBIT__ |
307 | #define ULACCUM_IBIT __ULACCUM_IBIT__ |
308 | #else |
309 | #define ULACCUM_IBIT 32 |
310 | #endif // ULACCUM_IBIT |
311 | |
312 | #define ULACCUM_MIN 0.0ULK |
313 | |
314 | #ifdef __ULACCUM_MAX__ |
315 | #define ULACCUM_MAX __ULACCUM_MAX__ |
316 | #else |
317 | #define ULACCUM_MAX 0x1.FFFFFFFFFFFFFFFEp+31ULK |
318 | #endif // ULACCUM_MAX |
319 | |
320 | #ifdef __ULACCUM_EPSILON__ |
321 | #define ULACCUM_EPSILON __ULACCUM_EPSILON__ |
322 | #else |
323 | #define ULACCUM_EPSILON 0x1.0p-32ULK |
324 | #endif // ULACCUM_EPSILON |
325 | |
326 | #endif // LIBC_COMPILER_HAS_FIXED_POINT |
327 | |
328 | #endif // LLVM_LIBC_MACROS_STDFIX_MACROS_H |
329 | |