49 lines · c
1//===-- fixsfdi.c - Implement __fixsfdi -----------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#define SINGLE_PRECISION10#include "fp_lib.h"11 12#ifndef __SOFTFP__13// Support for systems that have hardware floating-point; can set the invalid14// flag as a side-effect of computation.15 16COMPILER_RT_ABI du_int __fixunssfdi(float a);17 18COMPILER_RT_ABI di_int __fixsfdi(float a) {19 if (a < 0.0f) {20 return -__fixunssfdi(-a);21 }22 return __fixunssfdi(a);23}24 25#else26// Support for systems that don't have hardware floating-point; there are no27// flags to set, and we don't want to code-gen to an unknown soft-float28// implementation.29 30typedef di_int fixint_t;31typedef du_int fixuint_t;32#include "fp_fixint_impl.inc"33 34COMPILER_RT_ABI di_int __fixsfdi(fp_t a) { return __fixint(a); }35 36#endif37 38#if defined(__ARM_EABI__)39#if defined(COMPILER_RT_ARMHF_TARGET)40AEABI_RTABI di_int __aeabi_f2lz(fp_t a) { return __fixsfdi(a); }41#else42COMPILER_RT_ALIAS(__fixsfdi, __aeabi_f2lz)43#endif44#endif45 46#if defined(__MINGW32__) && defined(__arm__)47COMPILER_RT_ALIAS(__fixsfdi, __stoi64)48#endif49