xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/ppc/DD.h (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1 #ifndef COMPILERRT_DD_HEADER
2 #define COMPILERRT_DD_HEADER
3 
4 #include "../int_lib.h"
5 
6 typedef union {
7   long double ld;
8   struct {
9     double hi;
10     double lo;
11   } s;
12 } DD;
13 
14 typedef union {
15   double d;
16   uint64_t x;
17 } doublebits;
18 
19 #define LOWORDER(xy, xHi, xLo, yHi, yLo)                                       \
20   (((((xHi) * (yHi) - (xy)) + (xHi) * (yLo)) + (xLo) * (yHi)) + (xLo) * (yLo))
21 
22 static __inline ALWAYS_INLINE double local_fabs(double x) {
23   doublebits result = {.d = x};
24   result.x &= UINT64_C(0x7fffffffffffffff);
25   return result.d;
26 }
27 
28 static __inline ALWAYS_INLINE double high26bits(double x) {
29   doublebits result = {.d = x};
30   result.x &= UINT64_C(0xfffffffff8000000);
31   return result.d;
32 }
33 
34 static __inline ALWAYS_INLINE int different_sign(double x, double y) {
35   doublebits xsignbit = {.d = x}, ysignbit = {.d = y};
36   int result = (int)(xsignbit.x >> 63) ^ (int)(ysignbit.x >> 63);
37   return result;
38 }
39 
40 long double __gcc_qadd(long double, long double);
41 long double __gcc_qsub(long double, long double);
42 long double __gcc_qmul(long double, long double);
43 long double __gcc_qdiv(long double, long double);
44 
45 #endif // COMPILERRT_DD_HEADER
46