[docs] Update HowToReleaseLLVM documentation.
[llvm-project.git] / compiler-rt / lib / builtins / floatunsidf.c
blob9b3e5fea0e45bfd79ec1167c0b2943a750be053e
1 //===-- lib/floatunsidf.c - uint -> double-precision conversion ---*- C -*-===//
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 //===----------------------------------------------------------------------===//
8 //
9 // This file implements unsigned integer to double-precision conversion for the
10 // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even
11 // mode.
13 //===----------------------------------------------------------------------===//
15 #define DOUBLE_PRECISION
16 #include "fp_lib.h"
18 #include "int_lib.h"
20 COMPILER_RT_ABI fp_t __floatunsidf(su_int a) {
22 const int aWidth = sizeof a * CHAR_BIT;
24 // Handle zero as a special case to protect clz
25 if (a == 0)
26 return fromRep(0);
28 // Exponent of (fp_t)a is the width of abs(a).
29 const int exponent = (aWidth - 1) - clzsi(a);
30 rep_t result;
32 // Shift a into the significand field and clear the implicit bit.
33 const int shift = significandBits - exponent;
34 result = (rep_t)a << shift ^ implicitBit;
36 // Insert the exponent
37 result += (rep_t)(exponent + exponentBias) << significandBits;
38 return fromRep(result);
41 #if defined(__ARM_EABI__)
42 #if defined(COMPILER_RT_ARMHF_TARGET)
43 AEABI_RTABI fp_t __aeabi_ui2d(su_int a) { return __floatunsidf(a); }
44 #else
45 COMPILER_RT_ALIAS(__floatunsidf, __aeabi_ui2d)
46 #endif
47 #endif