diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2011-11-16 07:33:06 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2011-11-16 07:33:06 +0000 |
| commit | 2139c52d338003ec77afed7dec862e0ad4ceb443 (patch) | |
| tree | 3e7997e6a817356a7e4462f9327c0ebbdb7e0aff /compiler-rt/lib/ppc | |
| parent | ddf1890a5ed78967997720bc35b05b23b000bcf0 (diff) | |
| download | bcm5719-llvm-2139c52d338003ec77afed7dec862e0ad4ceb443.tar.gz bcm5719-llvm-2139c52d338003ec77afed7dec862e0ad4ceb443.zip | |
lib: Finish int_math.h definitions using compiler builtins and eliminate
implementation use of <math.h>.
llvm-svn: 144786
Diffstat (limited to 'compiler-rt/lib/ppc')
| -rw-r--r-- | compiler-rt/lib/ppc/divtc3.c | 39 | ||||
| -rw-r--r-- | compiler-rt/lib/ppc/fixtfdi.c | 3 | ||||
| -rw-r--r-- | compiler-rt/lib/ppc/multc3.c | 13 |
3 files changed, 25 insertions, 30 deletions
diff --git a/compiler-rt/lib/ppc/divtc3.c b/compiler-rt/lib/ppc/divtc3.c index d718d5a231c..29912818631 100644 --- a/compiler-rt/lib/ppc/divtc3.c +++ b/compiler-rt/lib/ppc/divtc3.c @@ -4,14 +4,13 @@ #include "DD.h" #include "../int_math.h" -#include <math.h> -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif /* INFINITY */ +#if !defined(CRT_INFINITY) && defined(HUGE_VAL) +#define CRT_INFINITY HUGE_VAL +#endif /* CRT_INFINITY */ #define makeFinite(x) { \ - (x).s.hi = __builtin_copysign(crt_isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ + (x).s.hi = crt_copysign(crt_isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ (x).s.lo = 0.0; \ } @@ -27,16 +26,16 @@ __divtc3(long double a, long double b, long double c, long double d) DD dDD = { .ld = d }; int ilogbw = 0; - const double logbw = logb(__builtin_fmax( __builtin_fabs(cDD.s.hi), __builtin_fabs(dDD.s.hi) )); + const double logbw = crt_logb(crt_fmax(crt_fabs(cDD.s.hi), crt_fabs(dDD.s.hi) )); if (crt_isfinite(logbw)) { ilogbw = (int)logbw; - cDD.s.hi = scalbn(cDD.s.hi, -ilogbw); - cDD.s.lo = scalbn(cDD.s.lo, -ilogbw); - dDD.s.hi = scalbn(dDD.s.hi, -ilogbw); - dDD.s.lo = scalbn(dDD.s.lo, -ilogbw); + cDD.s.hi = crt_scalbn(cDD.s.hi, -ilogbw); + cDD.s.lo = crt_scalbn(cDD.s.lo, -ilogbw); + dDD.s.hi = crt_scalbn(dDD.s.hi, -ilogbw); + dDD.s.lo = crt_scalbn(dDD.s.lo, -ilogbw); } const long double denom = __gcc_qadd(__gcc_qmul(cDD.ld, cDD.ld), __gcc_qmul(dDD.ld, dDD.ld)); @@ -46,10 +45,10 @@ __divtc3(long double a, long double b, long double c, long double d) DD real = { .ld = __gcc_qdiv(realNumerator, denom) }; DD imag = { .ld = __gcc_qdiv(imagNumerator, denom) }; - real.s.hi = scalbn(real.s.hi, -ilogbw); - real.s.lo = scalbn(real.s.lo, -ilogbw); - imag.s.hi = scalbn(imag.s.hi, -ilogbw); - imag.s.lo = scalbn(imag.s.lo, -ilogbw); + real.s.hi = crt_scalbn(real.s.hi, -ilogbw); + real.s.lo = crt_scalbn(real.s.lo, -ilogbw); + imag.s.hi = crt_scalbn(imag.s.hi, -ilogbw); + imag.s.lo = crt_scalbn(imag.s.lo, -ilogbw); if (crt_isnan(real.s.hi) && crt_isnan(imag.s.hi)) { @@ -60,9 +59,9 @@ __divtc3(long double a, long double b, long double c, long double d) if ((rDD.s.hi == 0.0) && (!crt_isnan(aDD.s.hi) || !crt_isnan(bDD.s.hi))) { - real.s.hi = __builtin_copysign(INFINITY,cDD.s.hi) * aDD.s.hi; + real.s.hi = crt_copysign(CRT_INFINITY,cDD.s.hi) * aDD.s.hi; real.s.lo = 0.0; - imag.s.hi = __builtin_copysign(INFINITY,cDD.s.hi) * bDD.s.hi; + imag.s.hi = crt_copysign(CRT_INFINITY,cDD.s.hi) * bDD.s.hi; imag.s.lo = 0.0; } @@ -71,9 +70,9 @@ __divtc3(long double a, long double b, long double c, long double d) { makeFinite(aDD); makeFinite(bDD); - real.s.hi = INFINITY * (aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi); + real.s.hi = CRT_INFINITY * (aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi); real.s.lo = 0.0; - imag.s.hi = INFINITY * (bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi); + imag.s.hi = CRT_INFINITY * (bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi); imag.s.lo = 0.0; } @@ -82,9 +81,9 @@ __divtc3(long double a, long double b, long double c, long double d) { makeFinite(cDD); makeFinite(dDD); - real.s.hi = __builtin_copysign(0.0,(aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi)); + real.s.hi = crt_copysign(0.0,(aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi)); real.s.lo = 0.0; - imag.s.hi = __builtin_copysign(0.0,(bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi)); + imag.s.hi = crt_copysign(0.0,(bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi)); imag.s.lo = 0.0; } } diff --git a/compiler-rt/lib/ppc/fixtfdi.c b/compiler-rt/lib/ppc/fixtfdi.c index 43bc15fb1c4..56e7b3fbf3e 100644 --- a/compiler-rt/lib/ppc/fixtfdi.c +++ b/compiler-rt/lib/ppc/fixtfdi.c @@ -7,6 +7,7 @@ */ #include "DD.h" +#include "../int_math.h" uint64_t __fixtfdi(long double input) { @@ -64,7 +65,7 @@ uint64_t __fixtfdi(long double input) /* Edge cases handled here: */ /* |x| < 1, result is zero. */ - if (1.0 > __builtin_fabs(x.s.hi)) + if (1.0 > crt_fabs(x.s.hi)) return INT64_C(0); /* x very close to INT64_MIN, care must be taken to see which side we are on. */ diff --git a/compiler-rt/lib/ppc/multc3.c b/compiler-rt/lib/ppc/multc3.c index d04a9017418..edb482b6062 100644 --- a/compiler-rt/lib/ppc/multc3.c +++ b/compiler-rt/lib/ppc/multc3.c @@ -4,20 +4,15 @@ #include "DD.h" #include "../int_math.h" -#include <math.h> - -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif /* INFINITY */ #define makeFinite(x) { \ - (x).s.hi = __builtin_copysign(crt_isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ + (x).s.hi = crt_copysign(crt_isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ (x).s.lo = 0.0; \ } #define zeroNaN() { \ if (crt_isnan((x).s.hi)) { \ - (x).s.hi = __builtin_copysign(0.0, (x).s.hi); \ + (x).s.hi = crt_copysign(0.0, (x).s.hi); \ (x).s.lo = 0.0; \ } \ } @@ -84,9 +79,9 @@ __multc3(long double a, long double b, long double c, long double d) if (recalc) { - real.s.hi = INFINITY * (aDD.s.hi*cDD.s.hi - bDD.s.hi*dDD.s.hi); + real.s.hi = CRT_INFINITY * (aDD.s.hi*cDD.s.hi - bDD.s.hi*dDD.s.hi); real.s.lo = 0.0; - imag.s.hi = INFINITY * (aDD.s.hi*dDD.s.hi + bDD.s.hi*cDD.s.hi); + imag.s.hi = CRT_INFINITY * (aDD.s.hi*dDD.s.hi + bDD.s.hi*cDD.s.hi); imag.s.lo = 0.0; } } |

