Match: Fold pow calls to ldexp when possible [PR57492]
[official-gcc.git] / libgcc / soft-fp / floatuntidd.c
blobea4108fca215a1ec2ff04bbbb5b313bc1656c611
1 /* Software floating-point emulation.
2 Convert a 128bit unsigned integer to _Decimal64.
4 Copyright (C) 2023 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #include "soft-fp.h"
28 #include "bitint.h"
30 #if defined(__BITINT_MAXWIDTH__) && defined(__SIZEOF_INT128__)
31 extern _Decimal64 __bid_floatbitintdd (const UBILtype *, SItype);
32 extern _Decimal64 __bid_floatunstidd (UTItype);
34 _Decimal64
35 __bid_floatunstidd (UTItype i)
37 UBILtype ib[128 / BIL_TYPE_SIZE];
38 #if BIL_TYPE_SIZE == 128
39 ib[0] = i;
40 #elif BIL_TYPE_SIZE == 64
41 ib[BITINT_END (0, 1)] = i >> 64;
42 ib[BITINT_END (1, 0)] = i;
43 #elif BIL_TYPE_SIZE == 32
44 ib[BITINT_END (0, 3)] = i >> 96;
45 ib[BITINT_END (1, 2)] = i >> 64;
46 ib[BITINT_END (2, 1)] = i >> 32;
47 ib[BITINT_END (3, 0)] = i;
48 #else
49 #error Unsupported UBILtype
50 #endif
51 return __bid_floatbitintdd (ib, 128);
53 #endif