[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / compiler-rt / lib / builtins / fixdfdi.c
bloba48facb68598a5ce0eb3c80e027cf7f3c12757b2
1 //===-- fixdfdi.c - Implement __fixdfdi -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #define DOUBLE_PRECISION
10 #include "fp_lib.h"
12 #ifndef __SOFTFP__
13 // Support for systems that have hardware floating-point; can set the invalid
14 // flag as a side-effect of computation.
16 COMPILER_RT_ABI du_int __fixunsdfdi(double a);
18 COMPILER_RT_ABI di_int __fixdfdi(double a) {
19 if (a < 0.0) {
20 return -__fixunsdfdi(-a);
22 return __fixunsdfdi(a);
25 #else
26 // Support for systems that don't have hardware floating-point; there are no
27 // flags to set, and we don't want to code-gen to an unknown soft-float
28 // implementation.
30 typedef di_int fixint_t;
31 typedef du_int fixuint_t;
32 #include "fp_fixint_impl.inc"
34 COMPILER_RT_ABI di_int __fixdfdi(fp_t a) { return __fixint(a); }
36 #endif
38 #if defined(__ARM_EABI__)
39 #if defined(COMPILER_RT_ARMHF_TARGET)
40 AEABI_RTABI di_int __aeabi_d2lz(fp_t a) { return __fixdfdi(a); }
41 #else
42 COMPILER_RT_ALIAS(__fixdfdi, __aeabi_d2lz)
43 #endif
44 #endif
46 #if defined(__MINGW32__) && defined(__arm__)
47 COMPILER_RT_ALIAS(__fixdfdi, __dtoi64)
48 #endif