brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 6da81f7 Raw
66 lines · c
1//===-- floatdidf.c - Implement __floatdidf -------------------------------===//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// This file implements __floatdidf for the compiler_rt library.10//11//===----------------------------------------------------------------------===//12 13#include "int_lib.h"14 15// Returns: convert a to a double, rounding toward even.16 17// Assumption: double is a IEEE 64 bit floating point type18//             di_int is a 64 bit integral type19 20// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm21// mmmm22 23#ifndef __SOFTFP__24// Support for systems that have hardware floating-point; we'll set the inexact25// flag as a side-effect of this computation.26 27COMPILER_RT_ABI double __floatdidf(di_int a) {28  static const double twop52 = 4503599627370496.0; // 0x1.0p5229  static const double twop32 = 4294967296.0;       // 0x1.0p3230 31  union {32    int64_t x;33    double d;34  } low = {.d = twop52};35 36  const double high = (int32_t)(a >> 32) * twop32;37  low.x |= a & INT64_C(0x00000000ffffffff);38 39  const double result = (high - twop52) + low.d;40  return result;41}42 43#else44// Support for systems that don't have hardware floating-point; there are no45// flags to set, and we don't want to code-gen to an unknown soft-float46// implementation.47 48#define SRC_I6449#define DST_DOUBLE50#include "int_to_fp_impl.inc"51 52COMPILER_RT_ABI double __floatdidf(di_int a) { return __floatXiYf__(a); }53#endif54 55#if defined(__ARM_EABI__)56#if defined(COMPILER_RT_ARMHF_TARGET)57AEABI_RTABI double __aeabi_l2d(di_int a) { return __floatdidf(a); }58#else59COMPILER_RT_ALIAS(__floatdidf, __aeabi_l2d)60#endif61#endif62 63#if defined(__MINGW32__) && defined(__arm__)64COMPILER_RT_ALIAS(__floatdidf, __i64tod)65#endif66