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