Home | History | Annotate | Line # | Download | only in builtins
fixunsdfdi.c revision 1.2
      1 /* ===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------===
      2  *
      3  *                     The LLVM Compiler Infrastructure
      4  *
      5  * This file is dual licensed under the MIT and the University of Illinois Open
      6  * Source Licenses. See LICENSE.TXT for details.
      7  *
      8  * ===----------------------------------------------------------------------===
      9  */
     10 
     11 #define DOUBLE_PRECISION
     12 #include "fp_lib.h"
     13 
     14 #ifndef __SOFT_FP__
     15 /* Support for systems that have hardware floating-point; can set the invalid
     16  * flag as a side-effect of computation.
     17  */
     18 
     19 COMPILER_RT_ABI du_int
     20 __fixunsdfdi(double a)
     21 {
     22     if (a <= 0.0) return 0;
     23     su_int high = a / 4294967296.f;               /* a / 0x1p32f; */
     24     su_int low = a - (double)high * 4294967296.f; /* high * 0x1p32f; */
     25     return ((du_int)high << 32) | low;
     26 }
     27 
     28 #else
     29 /* Support for systems that don't have hardware floating-point; there are no
     30  * flags to set, and we don't want to code-gen to an unknown soft-float
     31  * implementation.
     32  */
     33 
     34 typedef du_int fixuint_t;
     35 #include "fp_fixuint_impl.inc"
     36 
     37 COMPILER_RT_ABI du_int
     38 __fixunsdfdi(fp_t a) {
     39     return __fixuint(a);
     40 }
     41 
     42 #endif
     43 
     44 #if defined(__ARM_EABI__)
     45 AEABI_RTABI du_int
     46 #if defined(__SOFT_FP__)
     47 __aeabi_d2ulz(fp_t a) {
     48 #else
     49 __aeabi_d2ulz(double a) {
     50 #endif
     51   return __fixunsdfdi(a);
     52 }
     53 #endif
     54 
     55