blob: 4b0bc9e1d051b052e9a34216d5a6b394b7e7f970 [file] [log] [blame]
Edward O'Callaghan4856eef2009-08-05 04:02:56 +00001/* ===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------===
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'Callaghan4856eef2009-08-05 04:02:56 +00007 *
8 * ===----------------------------------------------------------------------===
Edward O'Callaghan4856eef2009-08-05 04:02:56 +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"
Daniel Dunbarfd089992009-06-26 16:47:03 +000013
Chandler Carruth321916a2012-06-22 21:09:15 +000014ARM_EABI_FNALIAS(d2ulz, fixunsdfdi)
Anton Korobeynikov75e3c192011-04-19 17:51:24 +000015
Sergey Dmitroukf3206d62015-04-06 11:54:51 +000016#ifndef __SOFT_FP__
17/* Support for systems that have hardware floating-point; can set the invalid
18 * flag as a side-effect of computation.
19 */
20
21COMPILER_RT_ABI du_int
22__fixunsdfdi(double a)
23{
Derek Schuffde036eb2015-05-01 16:02:16 +000024 if (a <= 0.0) return 0;
Saleem Abdulrasool4c81f0a2015-10-06 04:33:02 +000025 su_int high = a / 4294967296.f; /* a / 0x1p32f; */
26 su_int low = a - (double)high * 4294967296.f; /* high * 0x1p32f; */
Sergey Dmitroukf3206d62015-04-06 11:54:51 +000027 return ((du_int)high << 32) | low;
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
36typedef du_int fixuint_t;
37#include "fp_fixuint_impl.inc"
38
Anton Korobeynikove63da932011-04-19 17:52:09 +000039COMPILER_RT_ABI du_int
Joerg Sonnenberger91bd6982015-03-11 21:13:56 +000040__fixunsdfdi(fp_t a) {
41 return __fixuint(a);
Daniel Dunbarfd089992009-06-26 16:47:03 +000042}
Sergey Dmitroukf3206d62015-04-06 11:54:51 +000043
44#endif