testsuite: suppress mangling compatibility aliases
[official-gcc.git] / libgcc / soft-fp / floatbitintxf.c
blob4731eb341d5f982494be8614aa95ad8ad99aba3a
1 /* Software floating-point emulation.
2 Convert a _BitInt to IEEE extended.
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 "extended.h"
29 #include "bitint.h"
31 #ifdef __BITINT_MAXWIDTH__
32 #ifndef TI_BITS
33 /* While mantissa is 64 bits including 1 explicit bit, extended.h uses
34 op-2.h for W_TYPE_SIZE 64 and op-4.h for W_TYPE_SIZE 32, so we have
35 to use 128-bit type here. On most 32-bit architectures TImode isn't
36 supported, so use _BitInt(128) instead. */
37 typedef _BitInt(128) TItype;
38 typedef unsigned _BitInt(128) UTItype;
39 #define TI_BITS 128
40 #endif
42 XFtype
43 __floatbitintxf (const UBILtype *i, SItype iprec)
45 TItype iv;
46 USItype shift = 0;
47 FP_DECL_EX;
48 FP_DECL_E (A);
49 XFtype a;
51 FP_FROM_BITINT (i, iprec, iv, shift, TI);
52 FP_INIT_ROUNDMODE;
53 FP_FROM_INT_E (A, iv, TI_BITS, UTItype);
54 if (shift)
56 A_e += shift;
57 if (A_e >= _FP_EXPMAX_E)
59 /* Exponent too big; overflow to infinity. */
60 #if _FP_W_TYPE_SIZE < 64
61 _FP_OVERFLOW_SEMIRAW (E, 4, A);
62 _FP_PACK_SEMIRAW (E, 4, A);
63 #else
64 _FP_OVERFLOW_SEMIRAW (E, 2, A);
65 _FP_PACK_SEMIRAW (E, 2, A);
66 #endif
69 FP_PACK_RAW_E (a, A);
70 FP_HANDLE_EXCEPTIONS;
72 return a;
74 #endif