libstdc++: testsuite: Enhance codecvt_unicode with tests for length()
[official-gcc.git] / libgcc / soft-fp / floatbitinthf.c
bloba28d03a1875fafda1780718c1de8e720f299c462
1 /* Software floating-point emulation.
2 Convert a _BitInt to IEEE half.
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 "half.h"
29 #include "bitint.h"
31 #ifdef __BITINT_MAXWIDTH__
32 HFtype
33 __floatbitinthf (const UBILtype *i, SItype iprec)
35 SItype iv;
36 USItype shift = 0;
37 FP_DECL_EX;
38 FP_DECL_H (A);
39 HFtype a;
41 FP_FROM_BITINT (i, iprec, iv, shift, SI);
42 FP_INIT_ROUNDMODE;
43 FP_FROM_INT_H (A, iv, SI_BITS, USItype);
44 if (shift)
46 A_e += shift;
47 if (A_e >= _FP_EXPMAX_H)
49 /* Exponent too big; overflow to infinity. */
50 _FP_OVERFLOW_SEMIRAW (H, 1, A);
51 _FP_PACK_SEMIRAW (H, 1, A);
54 FP_PACK_RAW_H (a, A);
55 FP_HANDLE_EXCEPTIONS;
57 return a;
59 #endif