]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/m68k/m680x0/fpu/s_cexp_template.c
1 /* Complex exponential function. m68k fpu version
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
25 #define CONCATX(a,b) __CONCAT(a,b)
26 #define s(name) M_SUF (name)
27 #define m81(func) __m81_u(s(func))
33 unsigned long ix_cond
;
35 ix_cond
= __m81_test (__imag__ x
);
37 if ((ix_cond
& (__M81_COND_NAN
|__M81_COND_INF
)) == 0)
39 /* Imaginary part is finite. */
40 unsigned long rx_cond
= __m81_test (__real__ x
);
42 if ((rx_cond
& (__M81_COND_NAN
|__M81_COND_INF
)) == 0)
44 const int t
= (int) ((LDBL_MAX_EXP
- 1) * M_LN2l
);
45 long double sin_ix
, cos_ix
, exp_val
;
47 __m81_u (__sincosl
) (__imag__ x
, &sin_ix
, &cos_ix
);
51 long double exp_t
= __m81_u(__ieee754_expl
) (t
);
63 exp_val
= __m81_u(__ieee754_expl
) (__real__ x
);
64 __real__ retval
= exp_val
* cos_ix
;
65 if (ix_cond
& __M81_COND_ZERO
)
66 __imag__ retval
= __imag__ x
;
68 __imag__ retval
= exp_val
* sin_ix
;
72 /* Compute the sign of the result. */
73 long double remainder
, pi_2
;
76 if ((rx_cond
& (__M81_COND_NAN
|__M81_COND_NEG
)) == __M81_COND_NEG
)
77 __real__ retval
= __imag__ retval
= 0.0;
79 __real__ retval
= __imag__ retval
= __real__ x
;
80 __asm ("fmovecr %#0,%0\n\tfscale%.w %#-1,%0" : "=f" (pi_2
));
81 __asm ("fmod%.x %2,%0\n\tfmove%.l %/fpsr,%1"
82 : "=f" (remainder
), "=dm" (quadrant
)
83 : "f" (pi_2
), "0" (__imag__ x
));
84 quadrant
= (quadrant
>> 16) & 0x83;
92 __real__ retval
= -__real__ retval
;
95 __real__ retval
= -__real__ retval
;
97 __imag__ retval
= -__imag__ retval
;
100 if (ix_cond
& __M81_COND_ZERO
&& (rx_cond
& __M81_COND_NAN
) == 0)
101 __imag__ retval
= __imag__ x
;
106 unsigned long rx_cond
= __m81_test (__real__ x
);
108 if (rx_cond
& __M81_COND_INF
)
110 /* Real part is infinite. */
111 if (rx_cond
& __M81_COND_NEG
)
113 __real__ retval
= __imag__ retval
= 0.0;
114 if (ix_cond
& __M81_COND_NEG
)
115 __imag__ retval
= -__imag__ retval
;
119 __real__ retval
= __real__ x
;
120 __imag__ retval
= __imag__ x
- __imag__ x
;
124 __real__ retval
= __imag__ retval
= __imag__ x
- __imag__ x
;
129 declare_mgen_alias (__cexp
, cexp
)