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