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
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
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/>. */
31 #ifdef __BITINT_MAXWIDTH__
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
;
43 __floatbitintxf (const UBILtype
*i
, SItype iprec
)
51 FP_FROM_BITINT (i
, iprec
, iv
, shift
, TI
);
53 FP_FROM_INT_E (A
, iv
, TI_BITS
, UTItype
);
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
);
64 _FP_OVERFLOW_SEMIRAW (E
, 2, A
);
65 _FP_PACK_SEMIRAW (E
, 2, A
);