blob: 31d76df2825578f10f58ddcef19b6abbfe0171a7 [file] [log] [blame]
Edward O'Callaghan55836322009-08-07 20:30:09 +00001/* ===-- fixdfdi.c - Implement __fixdfdi -----------------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
Howard Hinnant5b791f62010-11-16 22:13:33 +00005 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
Edward O'Callaghan55836322009-08-07 20:30:09 +00007 *
8 * ===----------------------------------------------------------------------===
Edward O'Callaghan55836322009-08-07 20:30:09 +00009 */
Daniel Dunbarfd089992009-06-26 16:47:03 +000010
Joerg Sonnenberger91bd6982015-03-11 21:13:56 +000011#define DOUBLE_PRECISION
12#include "fp_lib.h"
Anton Korobeynikov75e3c192011-04-19 17:51:24 +000013
Sergey Dmitroukf3206d62015-04-06 11:54:51 +000014#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
19COMPILER_RT_ABI du_int __fixunsdfdi(double a);
20
21COMPILER_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 Sonnenberger91bd6982015-03-11 21:13:56 +000036typedef di_int fixint_t;
37typedef du_int fixuint_t;
38#include "fp_fixint_impl.inc"
39
Joerg Sonnenberger6e99daa2014-03-01 15:30:50 +000040COMPILER_RT_ABI di_int
Joerg Sonnenberger91bd6982015-03-11 21:13:56 +000041__fixdfdi(fp_t a) {
42 return __fixint(a);
43}
Sergey Dmitroukf3206d62015-04-06 11:54:51 +000044
45#endif
Saleem Abdulrasool36ac5dd2017-05-16 16:41:37 +000046
47#if defined(__ARM_EABI__)
48AEABI_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