Edward O'Callaghan | 5583632 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 1 | /* ===-- fixdfdi.c - Implement __fixdfdi -----------------------------------=== |
| 2 | * |
| 3 | * The LLVM Compiler Infrastructure |
| 4 | * |
Howard Hinnant | 5b791f6 | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 5 | * This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | * Source Licenses. See LICENSE.TXT for details. |
Edward O'Callaghan | 5583632 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 7 | * |
| 8 | * ===----------------------------------------------------------------------=== |
Edward O'Callaghan | 5583632 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 9 | */ |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 10 | |
Joerg Sonnenberger | 91bd698 | 2015-03-11 21:13:56 +0000 | [diff] [blame] | 11 | #define DOUBLE_PRECISION |
| 12 | #include "fp_lib.h" |
Anton Korobeynikov | 75e3c19 | 2011-04-19 17:51:24 +0000 | [diff] [blame] | 13 | |
Sergey Dmitrouk | f3206d6 | 2015-04-06 11:54:51 +0000 | [diff] [blame] | 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 __fixunsdfdi(double a); |
| 20 | |
| 21 | COMPILER_RT_ABI di_int |
| 22 | __fixdfdi(double a) |
| 23 | { |
| 24 | if (a < 0.0) { |
| 25 | return -__fixunsdfdi(-a); |
| 26 | } |
| 27 | return __fixunsdfdi(a); |
| 28 | } |
| 29 | |
| 30 | #else |
| 31 | /* Support for systems that don't have hardware floating-point; there are no |
| 32 | * flags to set, and we don't want to code-gen to an unknown soft-float |
| 33 | * implementation. |
| 34 | */ |
| 35 | |
Joerg Sonnenberger | 91bd698 | 2015-03-11 21:13:56 +0000 | [diff] [blame] | 36 | typedef di_int fixint_t; |
| 37 | typedef du_int fixuint_t; |
| 38 | #include "fp_fixint_impl.inc" |
| 39 | |
Joerg Sonnenberger | 6e99daa | 2014-03-01 15:30:50 +0000 | [diff] [blame] | 40 | COMPILER_RT_ABI di_int |
Joerg Sonnenberger | 91bd698 | 2015-03-11 21:13:56 +0000 | [diff] [blame] | 41 | __fixdfdi(fp_t a) { |
| 42 | return __fixint(a); |
| 43 | } |
Sergey Dmitrouk | f3206d6 | 2015-04-06 11:54:51 +0000 | [diff] [blame] | 44 | |
| 45 | #endif |
Saleem Abdulrasool | 36ac5dd | 2017-05-16 16:41:37 +0000 | [diff] [blame] | 46 | |
| 47 | #if defined(__ARM_EABI__) |
| 48 | AEABI_RTABI di_int |
| 49 | #if defined(__SOFT_FP__) |
| 50 | __aeabi_d2lz(fp_t a) { |
| 51 | #else |
| 52 | __aeabi_d2lz(double a) { |
| 53 | #endif |
| 54 | return __fixdfdi(a); |
| 55 | } |
| 56 | #endif |
| 57 | |