summaryrefslogtreecommitdiffstats
path: root/floatbuiltins.h
blob: a7dd6f127e4f10c5ba04f9d220fc64e83f882b95 (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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
// -*-C++-*-

#ifndef FLOATBUILTINS_H
#define FLOATBUILTINS_H

#if defined __clang__

namespace vecmathlib {

inline char builtin_abs(char x) { return __builtin_abs(x); }
inline short builtin_abs(short x) { return __builtin_abs(x); }
inline int builtin_abs(int x) { return __builtin_abs(x); }
inline long builtin_abs(long x) { return __builtin_labs(x); }
#if __SIZEOF_LONG_LONG__
inline long long builtin_abs(long long x) { return __builtin_llabs(x); }
#endif

inline unsigned char builtin_clz(unsigned char x) {
  return __builtin_clzs(x) -
         CHAR_BIT * (sizeof(unsigned short) - sizeof(unsigned char));
}
inline unsigned short builtin_clz(unsigned short x) {
  return __builtin_clzs(x);
}
inline unsigned int builtin_clz(unsigned int x) { return __builtin_clz(x); }
inline unsigned long builtin_clz(unsigned long x) { return __builtin_clzl(x); }
#if __SIZEOF_LONG_LONG__
inline unsigned long long builtin_clz(unsigned long long x) {
  return __builtin_clzll(x);
}
#endif

inline unsigned char builtin_popcount(unsigned char x) {
  return __builtin_popcount(x);
}
inline unsigned short builtin_popcount(unsigned short x) {
  return __builtin_popcount(x);
}
inline unsigned int builtin_popcount(unsigned int x) {
  return __builtin_popcount(x);
}
inline unsigned long builtin_popcount(unsigned long x) {
  return __builtin_popcountl(x);
}
#if __SIZEOF_LONG_LONG__
inline unsigned long long builtin_popcount(unsigned long long x) {
  return __builtin_popcountll(x);
}
#endif

inline float builtin_acos(float x) { return __builtin_acosf(x); }
inline double builtin_acos(double x) { return __builtin_acos(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_acos(long double x) { return __builtin_acosl(x); }
#endif

inline float builtin_acosh(float x) { return __builtin_acoshf(x); }
inline double builtin_acosh(double x) { return __builtin_acosh(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_acosh(long double x) { return __builtin_acoshl(x); }
#endif

inline float builtin_asin(float x) { return __builtin_asinf(x); }
inline double builtin_asin(double x) { return __builtin_asin(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_asin(long double x) { return __builtin_asinl(x); }
#endif

inline float builtin_asinh(float x) { return __builtin_asinhf(x); }
inline double builtin_asinh(double x) { return __builtin_asinh(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_asinh(long double x) { return __builtin_asinhl(x); }
#endif

inline float builtin_atan(float x) { return __builtin_atanf(x); }
inline double builtin_atan(double x) { return __builtin_atan(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_atan(long double x) { return __builtin_atanl(x); }
#endif

inline float builtin_atan2(float x, float y) { return __builtin_atan2f(x, y); }
inline double builtin_atan2(double x, double y) {
  return __builtin_atan2(x, y);
}
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_atan2(long double x, long double y) {
  return __builtin_atan2l(x, y);
}
#endif

inline float builtin_atanh(float x) { return __builtin_atanhf(x); }
inline double builtin_atanh(double x) { return __builtin_atanh(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_atanh(long double x) { return __builtin_atanhl(x); }
#endif

inline float builtin_cbrt(float x) { return __builtin_cbrtf(x); }
inline double builtin_cbrt(double x) { return __builtin_cbrt(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_cbrt(long double x) { return __builtin_cbrtl(x); }
#endif

inline float builtin_ceil(float x) { return __builtin_ceilf(x); }
inline double builtin_ceil(double x) { return __builtin_ceil(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_ceil(long double x) { return __builtin_ceill(x); }
#endif

inline float builtin_copysign(float x, float y) {
  return __builtin_copysignf(x, y);
}
inline double builtin_copysign(double x, double y) {
  return __builtin_copysign(x, y);
}
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_copysign(long double x, long double y) {
  return __builtin_copysignl(x, y);
}
#endif

inline float builtin_cos(float x) { return __builtin_cosf(x); }
inline double builtin_cos(double x) { return __builtin_cos(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_cos(long double x) { return __builtin_cosl(x); }
#endif

inline float builtin_cosh(float x) { return __builtin_coshf(x); }
inline double builtin_cosh(double x) { return __builtin_cosh(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_cosh(long double x) { return __builtin_coshl(x); }
#endif

inline float builtin_exp(float x) { return __builtin_expf(x); }
inline double builtin_exp(double x) { return __builtin_exp(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_exp(long double x) { return __builtin_expl(x); }
#endif

inline float builtin_exp2(float x) { return __builtin_exp2f(x); }
inline double builtin_exp2(double x) { return __builtin_exp2(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_exp2(long double x) { return __builtin_exp2l(x); }
#endif

inline float builtin_expm1(float x) { return __builtin_expm1f(x); }
inline double builtin_expm1(double x) { return __builtin_expm1(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_expm1(long double x) { return __builtin_expm1l(x); }
#endif

inline float builtin_fabs(float x) { return __builtin_fabsf(x); }
inline double builtin_fabs(double x) { return __builtin_fabs(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_fabs(long double x) { return __builtin_fabsl(x); }
#endif

inline float builtin_fdim(float x, float y) { return __builtin_fdimf(x, y); }
inline double builtin_fdim(double x, double y) { return __builtin_fdim(x, y); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_fdim(long double x, long double y) {
  return __builtin_fdiml(x, y);
}
#endif

inline float builtin_floor(float x) { return __builtin_floorf(x); }
inline double builtin_floor(double x) { return __builtin_floor(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_floor(long double x) { return __builtin_floorl(x); }
#endif

inline float builtin_fma(float x, float y, float z) {
  return __builtin_fmaf(x, y, z);
}
inline double builtin_fma(double x, double y, double z) {
  return __builtin_fma(x, y, z);
}
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_fma(long double x, long double y, long double z) {
  return __builtin_fmal(x, y, z);
}
#endif

inline float builtin_fmax(float x, float y) { return __builtin_fmaxf(x, y); }
inline double builtin_fmax(double x, double y) { return __builtin_fmax(x, y); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_fmax(long double x, long double y) {
  return __builtin_fmaxl(x, y);
}
#endif

inline float builtin_fmin(float x, float y) { return __builtin_fminf(x, y); }
inline double builtin_fmin(double x, double y) { return __builtin_fmin(x, y); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_fmin(long double x, long double y) {
  return __builtin_fminl(x, y);
}
#endif

inline float builtin_fmod(float x, float y) { return __builtin_fmodf(x, y); }
inline double builtin_fmod(double x, double y) { return __builtin_fmod(x, y); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_fmod(long double x, long double y) {
  return __builtin_fmodl(x, y);
}
#endif

inline float builtin_frexp(float x, int *r) { return __builtin_frexpf(x, r); }
inline double builtin_frexp(double x, int *r) { return __builtin_frexp(x, r); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_frexp(long double x, int *r) {
  return __builtin_frexpl(x, r);
}
#endif

inline float builtin_hypot(float x, float y) { return __builtin_hypotf(x, y); }
inline double builtin_hypot(double x, double y) {
  return __builtin_hypot(x, y);
}
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_hypot(long double x, long double y) {
  return __builtin_hypotl(x, y);
}
#endif

inline int builtin_ilogb(float x) { return __builtin_ilogbf(x); }
inline int builtin_ilogb(double x) { return __builtin_ilogb(x); }
#if __SIZEOF_LONG_DOUBLE__
inline int builtin_ilogb(long double x) { return __builtin_ilogbl(x); }
#endif

inline int builtin_isfinite(float x) { return __builtin_isfinite(x); }
inline int builtin_isfinite(double x) { return __builtin_isfinite(x); }
#if __SIZEOF_LONG_DOUBLE__
inline int builtin_isfinite(long double x) { return __builtin_isfinite(x); }
#endif

inline int builtin_isinf(float x) { return __builtin_isinf(x); }
inline int builtin_isinf(double x) { return __builtin_isinf(x); }
#if __SIZEOF_LONG_DOUBLE__
inline int builtin_isinf(long double x) { return __builtin_isinf(x); }
#endif

inline int builtin_isnan(float x) { return __builtin_isnan(x); }
inline int builtin_isnan(double x) { return __builtin_isnan(x); }
#if __SIZEOF_LONG_DOUBLE__
inline int builtin_isnan(long double x) { return __builtin_isnan(x); }
#endif

inline int builtin_isnormal(float x) { return __builtin_isnormal(x); }
inline int builtin_isnormal(double x) { return __builtin_isnormal(x); }
#if __SIZEOF_LONG_DOUBLE__
inline int builtin_isnormal(long double x) { return __builtin_isnormal(x); }
#endif

inline float builtin_ldexp(float x, int y) { return __builtin_ldexpf(x, y); }
inline double builtin_ldexp(double x, int y) { return __builtin_ldexp(x, y); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_ldexp(long double x, int y) {
  return __builtin_ldexpl(x, y);
}
#endif

inline long long builtin_llrint(float x) { return __builtin_llrintf(x); }
inline long long builtin_llrint(double x) { return __builtin_llrint(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long long builtin_llrint(long double x) { return __builtin_llrintl(x); }
#endif

inline float builtin_log(float x) { return __builtin_logf(x); }
inline double builtin_log(double x) { return __builtin_log(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_log(long double x) { return __builtin_logl(x); }
#endif

inline float builtin_log10(float x) { return __builtin_log10f(x); }
inline double builtin_log10(double x) { return __builtin_log10(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_log10(long double x) { return __builtin_log10l(x); }
#endif

inline float builtin_log1p(float x) { return __builtin_log1pf(x); }
inline double builtin_log1p(double x) { return __builtin_log1p(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_log1p(long double x) { return __builtin_log1pl(x); }
#endif

inline float builtin_log2(float x) { return __builtin_log2f(x); }
inline double builtin_log2(double x) { return __builtin_log2(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_log2(long double x) { return __builtin_log2l(x); }
#endif

inline long builtin_lrint(float x) { return __builtin_lrintf(x); }
inline long builtin_lrint(double x) { return __builtin_lrint(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long builtin_lrint(long double x) { return __builtin_lrintl(x); }
#endif

inline float builtin_nextafter(float x, float y) {
  return __builtin_nextafterf(x, y);
}
inline double builtin_nextafter(double x, double y) {
  return __builtin_nextafter(x, y);
}
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_nextafter(long double x, long double y) {
  return __builtin_nextafterl(x, y);
}
#endif

inline float builtin_pow(float x, float y) { return __builtin_powf(x, y); }
inline double builtin_pow(double x, double y) { return __builtin_pow(x, y); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_pow(long double x, long double y) {
  return __builtin_powl(x, y);
}
#endif

inline float builtin_remainder(float x, float y) {
  return __builtin_remainderf(x, y);
}
inline double builtin_remainder(double x, double y) {
  return __builtin_remainder(x, y);
}
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_remainder(long double x, long double y) {
  return __builtin_remainderl(x, y);
}
#endif

inline float builtin_rint(float x) { return __builtin_rintf(x); }
inline double builtin_rint(double x) { return __builtin_rint(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_rint(long double x) { return __builtin_rintl(x); }
#endif

inline float builtin_round(float x) { return __builtin_roundf(x); }
inline double builtin_round(double x) { return __builtin_round(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_round(long double x) { return __builtin_roundl(x); }
#endif

inline int builtin_signbit(float x) { return __builtin_signbitf(x); }
inline int builtin_signbit(double x) { return __builtin_signbit(x); }
#if __SIZEOF_LONG_DOUBLE__
inline int builtin_signbit(long double x) { return __builtin_signbitl(x); }
#endif

inline float builtin_sin(float x) { return __builtin_sinf(x); }
inline double builtin_sin(double x) { return __builtin_sin(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_sin(long double x) { return __builtin_sinl(x); }
#endif

inline float builtin_sinh(float x) { return __builtin_sinhf(x); }
inline double builtin_sinh(double x) { return __builtin_sinh(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_sinh(long double x) { return __builtin_sinhl(x); }
#endif

inline float builtin_sqrt(float x) { return __builtin_sqrtf(x); }
inline double builtin_sqrt(double x) { return __builtin_sqrt(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_sqrt(long double x) { return __builtin_sqrtl(x); }
#endif

inline float builtin_tan(float x) { return __builtin_tanf(x); }
inline double builtin_tan(double x) { return __builtin_tan(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_tan(long double x) { return __builtin_tanl(x); }
#endif

inline float builtin_tanh(float x) { return __builtin_tanhf(x); }
inline double builtin_tanh(double x) { return __builtin_tanh(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_tanh(long double x) { return __builtin_tanhl(x); }
#endif

inline float builtin_trunc(float x) { return __builtin_truncf(x); }
inline double builtin_trunc(double x) { return __builtin_trunc(x); }
#if __SIZEOF_LONG_DOUBLE__
inline long double builtin_trunc(long double x) { return __builtin_truncl(x); }
#endif
}

#endif

#endif // #ifndef FLOATBUILTINS_H
OpenPOWER on IntegriCloud