blob: fab47e272a25155ad3a971dada9a85bac393bce0 [file] [log] [blame]
Edward O'Callaghan55836322009-08-07 20:30:09 +00001/* ===-- fixsfdi.c - Implement __fixsfdi -----------------------------------===
2 *
Joerg Sonnenberger91bd6982015-03-11 21:13:56 +00003 * The LLVM Compiler Infrastructure
Edward O'Callaghan55836322009-08-07 20:30:09 +00004 *
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 SINGLE_PRECISION
12#include "fp_lib.h"
Daniel Dunbarfd089992009-06-26 16:47:03 +000013
Tim Northover0d8c9ca2013-01-13 19:18:00 +000014ARM_EABI_FNALIAS(f2lz, fixsfdi)
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 __fixunssfdi(float a);
22
23COMPILER_RT_ABI di_int
24__fixsfdi(float a)
25{
26 if (a < 0.0f) {
27 return -__fixunssfdi(-a);
28 }
29 return __fixunssfdi(a);
30}
31
32#else
33/* Support for systems that don't have hardware floating-point; there are no
34 * flags to set, and we don't want to code-gen to an unknown soft-float
35 * implementation.
36 */
37
Joerg Sonnenberger91bd6982015-03-11 21:13:56 +000038typedef di_int fixint_t;
39typedef du_int fixuint_t;
40#include "fp_fixint_impl.inc"
41
Anton Korobeynikove63da932011-04-19 17:52:09 +000042COMPILER_RT_ABI di_int
Joerg Sonnenberger91bd6982015-03-11 21:13:56 +000043__fixsfdi(fp_t a) {
44 return __fixint(a);
Daniel Dunbarfd089992009-06-26 16:47:03 +000045}
Sergey Dmitroukf3206d62015-04-06 11:54:51 +000046
47#endif