diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 72611b797f2..e12c14d76df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2011-07-11 Rainer Orth + + * config/dfp-bit.c, config/dfp-bit.h: Move to ../libgcc. + * config/t-dfprules: Move to ../libgcc/config. + * config.gcc (i[34567]86-*-linux*, i[34567]86-*-kfreebsd*-gnu, + i[34567]86-*-knetbsd*-gnu, i[34567]86-*-gnu*, + i[34567]86-*-kopensolaris*-gnu): Remove t-dfprules from tmake_file. + (x86_64-*-linux*, x86_64-*-kfreebsd*-gnu, x86_64-*-knetbsd*-gnu): + Likewise. + (i[34567]86-*-cygwin*): Likewise. + (i[34567]86-*-mingw*, x86_64-*-mingw*): Likewise. + (powerpc-*-linux*, powerpc64-*-linux*): Likewise. + * Makefile.in (D32PBIT_FUNCS, D64PBIT_FUNCS, D128PBIT_FUNCS): Remove. + (libgcc.mvars): Remove DFP_ENABLE, DFP_CFLAGS, D32PBIT_FUNCS, + D64PBIT_FUNCS, D128PBIT_FUNCS. + 2011-07-11 Richard Guenther * tree-vrp.c (simplify_conversion_using_ranges): Manually diff --git a/gcc/Makefile.in b/gcc/Makefile.in index f169a9a3574..caef28c822f 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1555,30 +1555,6 @@ TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \ _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \ _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf -D32PBIT_FUNCS = _addsub_sd _div_sd _mul_sd _plus_sd _minus_sd \ - _eq_sd _ne_sd _lt_sd _gt_sd _le_sd _ge_sd \ - _sd_to_si _sd_to_di _sd_to_usi _sd_to_udi \ - _si_to_sd _di_to_sd _usi_to_sd _udi_to_sd \ - _sd_to_sf _sd_to_df _sd_to_xf _sd_to_tf \ - _sf_to_sd _df_to_sd _xf_to_sd _tf_to_sd \ - _sd_to_dd _sd_to_td _unord_sd _conv_sd - -D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \ - _eq_dd _ne_dd _lt_dd _gt_dd _le_dd _ge_dd \ - _dd_to_si _dd_to_di _dd_to_usi _dd_to_udi \ - _si_to_dd _di_to_dd _usi_to_dd _udi_to_dd \ - _dd_to_sf _dd_to_df _dd_to_xf _dd_to_tf \ - _sf_to_dd _df_to_dd _xf_to_dd _tf_to_dd \ - _dd_to_sd _dd_to_td _unord_dd _conv_dd - -D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \ - _eq_td _ne_td _lt_td _gt_td _le_td _ge_td \ - _td_to_si _td_to_di _td_to_usi _td_to_udi \ - _si_to_td _di_to_td _usi_to_td _udi_to_td \ - _td_to_sf _td_to_df _td_to_xf _td_to_tf \ - _sf_to_td _df_to_td _xf_to_td _tf_to_td \ - _td_to_sd _td_to_dd _unord_td _conv_td - # These might cause a divide overflow trap and so are compiled with # unwinder info. LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4 @@ -1941,14 +1917,6 @@ libgcc.mvars: config.status Makefile $(LIB2ADD) $(LIB2ADD_ST) specs \ echo DPBIT_FUNCS = '$(DPBIT_FUNCS)' >> tmp-libgcc.mvars echo TPBIT = '$(TPBIT)' >> tmp-libgcc.mvars echo TPBIT_FUNCS = '$(TPBIT_FUNCS)' >> tmp-libgcc.mvars - echo DFP_ENABLE = '$(DFP_ENABLE)' >> tmp-libgcc.mvars - echo DFP_CFLAGS='$(DFP_CFLAGS)' >> tmp-libgcc.mvars - echo D32PBIT='$(D32PBIT)' >> tmp-libgcc.mvars - echo D32PBIT_FUNCS='$(D32PBIT_FUNCS)' >> tmp-libgcc.mvars - echo D64PBIT='$(D64PBIT)' >> tmp-libgcc.mvars - echo D64PBIT_FUNCS='$(D64PBIT_FUNCS)' >> tmp-libgcc.mvars - echo D128PBIT='$(D128PBIT)' >> tmp-libgcc.mvars - echo D128PBIT_FUNCS='$(D128PBIT_FUNCS)' >> tmp-libgcc.mvars echo GCC_EXTRA_PARTS = '$(GCC_EXTRA_PARTS)' >> tmp-libgcc.mvars echo SHLIB_LINK = '$(subst $(GCC_FOR_TARGET),$$(GCC_FOR_TARGET),$(SHLIB_LINK))' >> tmp-libgcc.mvars echo SHLIB_INSTALL = '$(SHLIB_INSTALL)' >> tmp-libgcc.mvars diff --git a/gcc/config.gcc b/gcc/config.gcc index 1af4e52fe9d..aa27283519f 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1311,7 +1311,7 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i i[34567]86-*-kopensolaris*-gnu) tm_file="${tm_file} i386/gnu-user.h kopensolaris-gnu.h i386/kopensolaris-gnu.h" ;; i[34567]86-*-gnu*) tm_file="$tm_file i386/gnu-user.h gnu.h i386/gnu.h";; esac - tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules" + tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtpc i386/t-crtfm" ;; x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h gnu-user.h glibc-stdint.h \ @@ -1323,7 +1323,7 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu) x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h i386/kfreebsd-gnu64.h" ;; x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;; esac - tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules" + tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc i386/t-crtfm" x86_multilibs="${with_multilib_list}" if test "$x86_multilibs" = "default"; then x86_multilibs="m64,m32" @@ -1458,7 +1458,7 @@ i[34567]86-*-cygwin*) else tmake_dlldir_file="i386/t-dlldir-x" fi - tmake_file="${tmake_file} ${tmake_eh_file} ${tmake_dlldir_file} i386/t-cygming i386/t-cygwin t-dfprules" + tmake_file="${tmake_file} ${tmake_eh_file} ${tmake_dlldir_file} i386/t-cygming i386/t-cygwin" target_gtfiles="\$(srcdir)/config/i386/winnt.c" extra_options="${extra_options} i386/cygming.opt" extra_objs="winnt.o winnt-stubs.o" @@ -1524,7 +1524,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) else tmake_dlldir_file="i386/t-dlldir-x" fi - tmake_file="${tmake_file} ${tmake_eh_file} ${tmake_dlldir_file} i386/t-cygming t-dfprules" + tmake_file="${tmake_file} ${tmake_eh_file} ${tmake_dlldir_file} i386/t-cygming" case ${target} in x86_64-w64-*) tmake_file="${tmake_file} i386/t-mingw-w64" @@ -2114,7 +2114,7 @@ powerpc-*-rtems*) powerpc-*-linux* | powerpc64-*-linux*) tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h rs6000/sysv4.h" extra_options="${extra_options} rs6000/sysv4.opt" - tmake_file="t-dfprules rs6000/t-fprules rs6000/t-ppcos ${tmake_file} rs6000/t-ppccomm" + tmake_file="rs6000/t-fprules rs6000/t-ppcos ${tmake_file} rs6000/t-ppccomm" maybe_biarch=yes case ${target} in powerpc64-*-linux*spe* | powerpc64-*-linux*paired*) diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index a09b88a8c38..cc392378e5b 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,21 @@ +2011-07-11 Rainer Orth + + * dfp-bit.c, dfp-bit.h: New files. + * Makefile.in (D32PBIT_FUNCS, D64PBIT_FUNCS, D128PBIT_FUNCS): New + variables. + ($(d32pbit-o)): Use $(srcdir) to refer to dfp-bit.c + ($(d64pbit-o)): Likewise. + ($(d128pbit-o)): Likewise. + * config/t-dfprules: New file. + * config.host (i[34567]86-*-linux*): Add t-dfprules to tmake_file. + (i[34567]86-*-kfreebsd*-gnu, i[34567]86-*-knetbsd*-gnu, + i[34567]86-*-gnu*, i[34567]86-*-kopensolaris*-gnu): Likewise. + (x86_64-*-linux*): Likewise. + (x86_64-*-kfreebsd*-gnu, x86_64-*-knetbsd*-gnu): Likewise. + (i[34567]86-*-cygwin*): Likewise. + (i[34567]86-*-mingw*, x86_64-*-mingw*): Likewise. + (powerpc-*-linux*, powerpc64-*-linux*): Likewise. + 2011-07-08 Rainer Orth * Makfile.in (LIBGCOV): New variable. diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index e204ef02ac1..8c41ffcf7a6 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -554,6 +554,30 @@ endif libgcc-objects += $(decbits-objects) # Next build individual support functions. +D32PBIT_FUNCS = _addsub_sd _div_sd _mul_sd _plus_sd _minus_sd \ + _eq_sd _ne_sd _lt_sd _gt_sd _le_sd _ge_sd \ + _sd_to_si _sd_to_di _sd_to_usi _sd_to_udi \ + _si_to_sd _di_to_sd _usi_to_sd _udi_to_sd \ + _sd_to_sf _sd_to_df _sd_to_xf _sd_to_tf \ + _sf_to_sd _df_to_sd _xf_to_sd _tf_to_sd \ + _sd_to_dd _sd_to_td _unord_sd _conv_sd + +D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \ + _eq_dd _ne_dd _lt_dd _gt_dd _le_dd _ge_dd \ + _dd_to_si _dd_to_di _dd_to_usi _dd_to_udi \ + _si_to_dd _di_to_dd _usi_to_dd _udi_to_dd \ + _dd_to_sf _dd_to_df _dd_to_xf _dd_to_tf \ + _sf_to_dd _df_to_dd _xf_to_dd _tf_to_dd \ + _dd_to_sd _dd_to_td _unord_dd _conv_dd + +D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \ + _eq_td _ne_td _lt_td _gt_td _le_td _ge_td \ + _td_to_si _td_to_di _td_to_usi _td_to_udi \ + _si_to_td _di_to_td _usi_to_td _udi_to_td \ + _td_to_sf _td_to_df _td_to_xf _td_to_tf \ + _sf_to_td _df_to_td _xf_to_td _tf_to_td \ + _td_to_sd _td_to_dd _unord_td _conv_td + ifeq ($(enable_decimal_float),bid) ifneq ($(D32PBIT),) D32PBIT_FUNCS:=$(filter-out _plus_sd _minus_sd _conv_sd, $(D32PBIT_FUNCS)) @@ -573,7 +597,7 @@ d32pbit-o = $(patsubst %,%$(objext),$(D32PBIT_FUNCS)) ifeq ($(enable_decimal_float),bid) $(d32pbit-o): %$(objext): $(srcdir)/config/libbid/%.c else -$(d32pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c +$(d32pbit-o): %$(objext): $(srcdir)/dfp-bit.c endif $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=32 -c $< libgcc-objects += $(d32pbit-o) @@ -584,7 +608,7 @@ d64pbit-o = $(patsubst %,%$(objext),$(D64PBIT_FUNCS)) ifeq ($(enable_decimal_float),bid) $(d64pbit-o): %$(objext): $(srcdir)/config/libbid/%.c else -$(d64pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c +$(d64pbit-o): %$(objext): $(srcdir)/dfp-bit.c endif $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=64 -c $< libgcc-objects += $(d64pbit-o) @@ -595,7 +619,7 @@ d128pbit-o = $(patsubst %,%$(objext),$(D128PBIT_FUNCS)) ifeq ($(enable_decimal_float),bid) $(d128pbit-o): %$(objext): $(srcdir)/config/libbid/%.c else -$(d128pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c +$(d128pbit-o): %$(objext): $(srcdir)/dfp-bit.c endif $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=128 -c $< libgcc-objects += $(d128pbit-o) diff --git a/libgcc/config.host b/libgcc/config.host index 1b1314f55cd..55f8a510766 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -346,21 +346,21 @@ i[34567]86-*-openbsd*) ;; i[34567]86-*-linux*) extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" - tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm" + tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm t-dfprules" md_unwind_header=i386/linux-unwind.h ;; i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i[34567]86-*-gnu* | i[34567]86-*-kopensolaris*-gnu) extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" - tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm" + tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm t-dfprules" ;; x86_64-*-linux*) extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" - tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm" + tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm t-dfprules" md_unwind_header=i386/linux-unwind.h ;; x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu) extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" - tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm" + tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm t-dfprules" ;; i[34567]86-pc-msdosdjgpp*) ;; @@ -388,14 +388,15 @@ i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae) ;; i[34567]86-*-cygwin*) extra_parts="crtbegin.o crtend.o crtfastmath.o" - tmake_file="i386/t-cygming i386/t-crtfm" + tmake_file="i386/t-cygming i386/t-crtfm t-dfprules" ;; i[34567]86-*-mingw*) extra_parts="crtbegin.o crtend.o crtfastmath.o" - tmake_file="i386/t-cygming i386/t-crtfm" + tmake_file="i386/t-cygming i386/t-crtfm t-dfprules" md_unwind_header=i386/w32-unwind.h ;; x86_64-*-mingw*) + tmake_file=t-dfprules ;; i[34567]86-*-interix3*) ;; @@ -551,7 +552,7 @@ powerpc-*-eabi*) powerpc-*-rtems*) ;; powerpc-*-linux* | powerpc64-*-linux*) - tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ldbl128 t-softfp" + tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ldbl128 t-softfp t-dfprules" md_unwind_header=rs6000/linux-unwind.h ;; powerpc-wrs-vxworks|powerpc-wrs-vxworksae) diff --git a/libgcc/config/t-dfprules b/libgcc/config/t-dfprules new file mode 100644 index 00000000000..6bf6246d8c7 --- /dev/null +++ b/libgcc/config/t-dfprules @@ -0,0 +1,10 @@ +# Use DFP_ENABLE to build decimal floating point support routines for +# all decimal floating point types (32-bit, 64-bit and 128-bit). We +# use `true' for clarity, but any value will do. +# +DFP_ENABLE = true + +# DFP_CFLAGS can be used to pass target-specific CFLAGS when compiling +# dfp-bit.c. This is useful for overriding the definition of macros. +# +# DFP_CFLAGS = -DFOO=bar diff --git a/libgcc/dfp-bit.c b/libgcc/dfp-bit.c new file mode 100644 index 00000000000..48dcb735510 --- /dev/null +++ b/libgcc/dfp-bit.c @@ -0,0 +1,681 @@ +/* This is a software decimal floating point library. + Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +/* This implements IEEE 754 decimal floating point arithmetic, but + does not provide a mechanism for setting the rounding mode, or for + generating or handling exceptions. Conversions between decimal + floating point types and other types depend on C library functions. + + Contributed by Ben Elliston . */ + +#include +#include +/* FIXME: compile with -std=gnu99 to get these from stdlib.h */ +extern float strtof (const char *, char **); +extern long double strtold (const char *, char **); +#include +#include + +#include "dfp-bit.h" + +/* Forward declarations. */ +#if WIDTH == 32 || WIDTH_TO == 32 +void __host_to_ieee_32 (_Decimal32 in, decimal32 *out); +void __ieee_to_host_32 (decimal32 in, _Decimal32 *out); +#endif +#if WIDTH == 64 || WIDTH_TO == 64 +void __host_to_ieee_64 (_Decimal64 in, decimal64 *out); +void __ieee_to_host_64 (decimal64 in, _Decimal64 *out); +#endif +#if WIDTH == 128 || WIDTH_TO == 128 +void __host_to_ieee_128 (_Decimal128 in, decimal128 *out); +void __ieee_to_host_128 (decimal128 in, _Decimal128 *out); +#endif + +/* A pointer to a binary decFloat operation. */ +typedef decFloat* (*dfp_binary_func) + (decFloat *, const decFloat *, const decFloat *, decContext *); + +/* Binary operations. */ + +/* Use a decFloat (decDouble or decQuad) function to perform a DFP + binary operation. */ +static inline decFloat +dfp_binary_op (dfp_binary_func op, decFloat arg_a, decFloat arg_b) +{ + decFloat result; + decContext context; + + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + + /* Perform the operation. */ + op (&result, &arg_a, &arg_b, &context); + + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + { + /* decNumber exception flags we care about here. */ + int ieee_flags; + int dec_flags = DEC_IEEE_854_Division_by_zero | DEC_IEEE_854_Inexact + | DEC_IEEE_854_Invalid_operation | DEC_IEEE_854_Overflow + | DEC_IEEE_854_Underflow; + dec_flags &= context.status; + ieee_flags = DFP_IEEE_FLAGS (dec_flags); + if (ieee_flags != 0) + DFP_HANDLE_EXCEPTIONS (ieee_flags); + } + + return result; +} + +#if WIDTH == 32 +/* The decNumber package doesn't provide arithmetic for decSingle (32 bits); + convert to decDouble, use the operation for that, and convert back. */ +static inline _Decimal32 +d32_binary_op (dfp_binary_func op, _Decimal32 arg_a, _Decimal32 arg_b) +{ + union { _Decimal32 c; decSingle f; } a32, b32, res32; + decDouble a, b, res; + decContext context; + + /* Widen the operands and perform the operation. */ + a32.c = arg_a; + b32.c = arg_b; + decSingleToWider (&a32.f, &a); + decSingleToWider (&b32.f, &b); + res = dfp_binary_op (op, a, b); + + /* Narrow the result, which might result in an underflow or overflow. */ + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + decSingleFromWider (&res32.f, &res, &context); + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + { + /* decNumber exception flags we care about here. */ + int ieee_flags; + int dec_flags = DEC_IEEE_854_Inexact | DEC_IEEE_854_Overflow + | DEC_IEEE_854_Underflow; + dec_flags &= context.status; + ieee_flags = DFP_IEEE_FLAGS (dec_flags); + if (ieee_flags != 0) + DFP_HANDLE_EXCEPTIONS (ieee_flags); + } + + return res32.c; +} +#else +/* decFloat operations are supported for decDouble (64 bits) and + decQuad (128 bits). The bit patterns for the types are the same. */ +static inline DFP_C_TYPE +dnn_binary_op (dfp_binary_func op, DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + union { DFP_C_TYPE c; decFloat f; } a, b, result; + + a.c = arg_a; + b.c = arg_b; + result.f = dfp_binary_op (op, a.f, b.f); + return result.c; +} +#endif + +/* Comparison operations. */ + +/* Use a decFloat (decDouble or decQuad) function to perform a DFP + comparison. */ +static inline CMPtype +dfp_compare_op (dfp_binary_func op, decFloat arg_a, decFloat arg_b) +{ + decContext context; + decFloat res; + int result; + + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + + /* Perform the comparison. */ + op (&res, &arg_a, &arg_b, &context); + + if (DEC_FLOAT_IS_SIGNED (&res)) + result = -1; + else if (DEC_FLOAT_IS_ZERO (&res)) + result = 0; + else if (DEC_FLOAT_IS_NAN (&res)) + result = -2; + else + result = 1; + + return (CMPtype) result; +} + +#if WIDTH == 32 +/* The decNumber package doesn't provide comparisons for decSingle (32 bits); + convert to decDouble, use the operation for that, and convert back. */ +static inline CMPtype +d32_compare_op (dfp_binary_func op, _Decimal32 arg_a, _Decimal32 arg_b) +{ + union { _Decimal32 c; decSingle f; } a32, b32; + decDouble a, b; + + a32.c = arg_a; + b32.c = arg_b; + decSingleToWider (&a32.f, &a); + decSingleToWider (&b32.f, &b); + return dfp_compare_op (op, a, b); +} +#else +/* decFloat comparisons are supported for decDouble (64 bits) and + decQuad (128 bits). The bit patterns for the types are the same. */ +static inline CMPtype +dnn_compare_op (dfp_binary_func op, DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + union { DFP_C_TYPE c; decFloat f; } a, b; + + a.c = arg_a; + b.c = arg_b; + return dfp_compare_op (op, a.f, b.f); +} +#endif + +#if defined(L_conv_sd) +void +__host_to_ieee_32 (_Decimal32 in, decimal32 *out) +{ + memcpy (out, &in, 4); +} + +void +__ieee_to_host_32 (decimal32 in, _Decimal32 *out) +{ + memcpy (out, &in, 4); +} +#endif /* L_conv_sd */ + +#if defined(L_conv_dd) +void +__host_to_ieee_64 (_Decimal64 in, decimal64 *out) +{ + memcpy (out, &in, 8); +} + +void +__ieee_to_host_64 (decimal64 in, _Decimal64 *out) +{ + memcpy (out, &in, 8); +} +#endif /* L_conv_dd */ + +#if defined(L_conv_td) +void +__host_to_ieee_128 (_Decimal128 in, decimal128 *out) +{ + memcpy (out, &in, 16); +} + +void +__ieee_to_host_128 (decimal128 in, _Decimal128 *out) +{ + memcpy (out, &in, 16); +} +#endif /* L_conv_td */ + +#if defined(L_addsub_sd) || defined(L_addsub_dd) || defined(L_addsub_td) +DFP_C_TYPE +DFP_ADD (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + return DFP_BINARY_OP (DEC_FLOAT_ADD, arg_a, arg_b); +} + +DFP_C_TYPE +DFP_SUB (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + return DFP_BINARY_OP (DEC_FLOAT_SUBTRACT, arg_a, arg_b); +} +#endif /* L_addsub */ + +#if defined(L_mul_sd) || defined(L_mul_dd) || defined(L_mul_td) +DFP_C_TYPE +DFP_MULTIPLY (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + return DFP_BINARY_OP (DEC_FLOAT_MULTIPLY, arg_a, arg_b); +} +#endif /* L_mul */ + +#if defined(L_div_sd) || defined(L_div_dd) || defined(L_div_td) +DFP_C_TYPE +DFP_DIVIDE (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + return DFP_BINARY_OP (DEC_FLOAT_DIVIDE, arg_a, arg_b); +} +#endif /* L_div */ + +#if defined (L_eq_sd) || defined (L_eq_dd) || defined (L_eq_td) +CMPtype +DFP_EQ (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + CMPtype stat; + stat = DFP_COMPARE_OP (DEC_FLOAT_COMPARE, arg_a, arg_b); + /* For EQ return zero for true, nonzero for false. */ + return stat != 0; +} +#endif /* L_eq */ + +#if defined (L_ne_sd) || defined (L_ne_dd) || defined (L_ne_td) +CMPtype +DFP_NE (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + int stat; + stat = DFP_COMPARE_OP (DEC_FLOAT_COMPARE, arg_a, arg_b); + /* For NE return zero for true, nonzero for false. */ + if (__builtin_expect (stat == -2, 0)) /* An operand is NaN. */ + return 1; + return stat != 0; +} +#endif /* L_ne */ + +#if defined (L_lt_sd) || defined (L_lt_dd) || defined (L_lt_td) +CMPtype +DFP_LT (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + int stat; + stat = DFP_COMPARE_OP (DEC_FLOAT_COMPARE, arg_a, arg_b); + /* For LT return -1 (<0) for true, 1 for false. */ + return (stat == -1) ? -1 : 1; +} +#endif /* L_lt */ + +#if defined (L_gt_sd) || defined (L_gt_dd) || defined (L_gt_td) +CMPtype +DFP_GT (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + int stat; + stat = DFP_COMPARE_OP (DEC_FLOAT_COMPARE, arg_a, arg_b); + /* For GT return 1 (>0) for true, -1 for false. */ + return (stat == 1) ? 1 : -1; +} +#endif + +#if defined (L_le_sd) || defined (L_le_dd) || defined (L_le_td) +CMPtype +DFP_LE (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + int stat; + stat = DFP_COMPARE_OP (DEC_FLOAT_COMPARE, arg_a, arg_b); + /* For LE return 0 (<= 0) for true, 1 for false. */ + if (__builtin_expect (stat == -2, 0)) /* An operand is NaN. */ + return 1; + return stat == 1; +} +#endif /* L_le */ + +#if defined (L_ge_sd) || defined (L_ge_dd) || defined (L_ge_td) +CMPtype +DFP_GE (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + int stat; + stat = DFP_COMPARE_OP (DEC_FLOAT_COMPARE, arg_a, arg_b); + /* For GE return 1 (>=0) for true, -1 for false. */ + if (__builtin_expect (stat == -2, 0)) /* An operand is NaN. */ + return -1; + return (stat != -1) ? 1 : -1; +} +#endif /* L_ge */ + +#define BUFMAX 128 + +/* Check for floating point exceptions that are relevant for conversions + between decimal float values and handle them. */ +static inline void +dfp_conversion_exceptions (const int status) +{ + /* decNumber exception flags we care about here. */ + int ieee_flags; + int dec_flags = DEC_IEEE_854_Inexact | DEC_IEEE_854_Invalid_operation + | DEC_IEEE_854_Overflow; + dec_flags &= status; + ieee_flags = DFP_IEEE_FLAGS (dec_flags); + if (ieee_flags != 0) + DFP_HANDLE_EXCEPTIONS (ieee_flags); +} + +#if defined (L_sd_to_dd) +/* Use decNumber to convert directly from _Decimal32 to _Decimal64. */ +_Decimal64 +DFP_TO_DFP (_Decimal32 f_from) +{ + union { _Decimal32 c; decSingle f; } from; + union { _Decimal64 c; decDouble f; } to; + + from.c = f_from; + to.f = *decSingleToWider (&from.f, &to.f); + return to.c; +} +#endif + +#if defined (L_sd_to_td) +/* Use decNumber to convert directly from _Decimal32 to _Decimal128. */ +_Decimal128 +DFP_TO_DFP (_Decimal32 f_from) +{ + union { _Decimal32 c; decSingle f; } from; + union { _Decimal128 c; decQuad f; } to; + decDouble temp; + + from.c = f_from; + temp = *decSingleToWider (&from.f, &temp); + to.f = *decDoubleToWider (&temp, &to.f); + return to.c; +} +#endif + +#if defined (L_dd_to_td) +/* Use decNumber to convert directly from _Decimal64 to _Decimal128. */ +_Decimal128 +DFP_TO_DFP (_Decimal64 f_from) +{ + union { _Decimal64 c; decDouble f; } from; + union { _Decimal128 c; decQuad f; } to; + + from.c = f_from; + to.f = *decDoubleToWider (&from.f, &to.f); + return to.c; +} +#endif + +#if defined (L_dd_to_sd) +/* Use decNumber to convert directly from _Decimal64 to _Decimal32. */ +_Decimal32 +DFP_TO_DFP (_Decimal64 f_from) +{ + union { _Decimal32 c; decSingle f; } to; + union { _Decimal64 c; decDouble f; } from; + decContext context; + + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + from.c = f_from; + to.f = *decSingleFromWider (&to.f, &from.f, &context); + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + dfp_conversion_exceptions (context.status); + return to.c; +} +#endif + +#if defined (L_td_to_sd) +/* Use decNumber to convert directly from _Decimal128 to _Decimal32. */ +_Decimal32 +DFP_TO_DFP (_Decimal128 f_from) +{ + union { _Decimal32 c; decSingle f; } to; + union { _Decimal128 c; decQuad f; } from; + decDouble temp; + decContext context; + + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + from.c = f_from; + temp = *decDoubleFromWider (&temp, &from.f, &context); + to.f = *decSingleFromWider (&to.f, &temp, &context); + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + dfp_conversion_exceptions (context.status); + return to.c; +} +#endif + +#if defined (L_td_to_dd) +/* Use decNumber to convert directly from _Decimal128 to _Decimal64. */ +_Decimal64 +DFP_TO_DFP (_Decimal128 f_from) +{ + union { _Decimal64 c; decDouble f; } to; + union { _Decimal128 c; decQuad f; } from; + decContext context; + + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + from.c = f_from; + to.f = *decDoubleFromWider (&to.f, &from.f, &context); + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + dfp_conversion_exceptions (context.status); + return to.c; +} +#endif + +#if defined (L_dd_to_si) || defined (L_td_to_si) \ + || defined (L_dd_to_usi) || defined (L_td_to_usi) +/* Use decNumber to convert directly from decimal float to integer types. */ +INT_TYPE +DFP_TO_INT (DFP_C_TYPE x) +{ + union { DFP_C_TYPE c; decFloat f; } u; + decContext context; + INT_TYPE i; + + decContextDefault (&context, DEC_INIT_DECIMAL128); + context.round = DEC_ROUND_DOWN; + u.c = x; + i = DEC_FLOAT_TO_INT (&u.f, &context, context.round); + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + dfp_conversion_exceptions (context.status); + return i; +} +#endif + +#if defined (L_sd_to_si) || (L_sd_to_usi) +/* Use decNumber to convert directly from decimal float to integer types. */ +INT_TYPE +DFP_TO_INT (_Decimal32 x) +{ + union { _Decimal32 c; decSingle f; } u32; + decDouble f64; + decContext context; + INT_TYPE i; + + decContextDefault (&context, DEC_INIT_DECIMAL128); + context.round = DEC_ROUND_DOWN; + u32.c = x; + f64 = *decSingleToWider (&u32.f, &f64); + i = DEC_FLOAT_TO_INT (&f64, &context, context.round); + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + dfp_conversion_exceptions (context.status); + return i; +} +#endif + +#if defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \ + || defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) +/* decNumber doesn't provide support for conversions to 64-bit integer + types, so do it the hard way. */ +INT_TYPE +DFP_TO_INT (DFP_C_TYPE x) +{ + /* decNumber's decimal* types have the same format as C's _Decimal* + types, but they have different calling conventions. */ + + /* TODO: Decimal float to integer conversions should raise FE_INVALID + if the result value does not fit into the result type. */ + + IEEE_TYPE s; + char buf[BUFMAX]; + char *pos; + decNumber qval, n1, n2; + decContext context; + + /* Use a large context to avoid losing precision. */ + decContextDefault (&context, DEC_INIT_DECIMAL128); + /* Need non-default rounding mode here. */ + context.round = DEC_ROUND_DOWN; + + HOST_TO_IEEE (x, &s); + TO_INTERNAL (&s, &n1); + /* Rescale if the exponent is less than zero. */ + decNumberToIntegralValue (&n2, &n1, &context); + /* Get a value to use for the quantize call. */ + decNumberFromString (&qval, "1.", &context); + /* Force the exponent to zero. */ + decNumberQuantize (&n1, &n2, &qval, &context); + /* Get a string, which at this point will not include an exponent. */ + decNumberToString (&n1, buf); + /* Ignore the fractional part. */ + pos = strchr (buf, '.'); + if (pos) + *pos = 0; + /* Use a C library function to convert to the integral type. */ + return STR_TO_INT (buf, NULL, 10); +} +#endif + +#if defined (L_si_to_dd) || defined (L_si_to_td) \ + || defined (L_usi_to_dd) || defined (L_usi_to_td) +/* Use decNumber to convert directly from integer to decimal float types. */ +DFP_C_TYPE +INT_TO_DFP (INT_TYPE i) +{ + union { DFP_C_TYPE c; decFloat f; } u; + + u.f = *DEC_FLOAT_FROM_INT (&u.f, i); + return u.c; +} +#endif + +#if defined (L_si_to_sd) || defined (L_usi_to_sd) +_Decimal32 +/* Use decNumber to convert directly from integer to decimal float types. */ +INT_TO_DFP (INT_TYPE i) +{ + union { _Decimal32 c; decSingle f; } u32; + decDouble f64; + decContext context; + + decContextDefault (&context, DEC_INIT_DECIMAL128); + f64 = *DEC_FLOAT_FROM_INT (&f64, i); + u32.f = *decSingleFromWider (&u32.f, &f64, &context); + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + dfp_conversion_exceptions (context.status); + return u32.c; +} +#endif + +#if defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) \ + || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td) +/* decNumber doesn't provide support for conversions from 64-bit integer + types, so do it the hard way. */ +DFP_C_TYPE +INT_TO_DFP (INT_TYPE i) +{ + DFP_C_TYPE f; + IEEE_TYPE s; + char buf[BUFMAX]; + decContext context; + + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + + /* Use a C library function to get a floating point string. */ + sprintf (buf, INT_FMT ".", CAST_FOR_FMT(i)); + /* Convert from the floating point string to a decimal* type. */ + FROM_STRING (&s, buf, &context); + IEEE_TO_HOST (s, &f); + + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + dfp_conversion_exceptions (context.status); + + return f; +} +#endif + +#if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \ + || defined (L_sd_to_df) || defined (L_dd_to_df) || defined (L_td_to_df) \ + || ((defined (L_sd_to_xf) || defined (L_dd_to_xf) || defined (L_td_to_xf)) \ + && LONG_DOUBLE_HAS_XF_MODE) \ + || ((defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf)) \ + && LONG_DOUBLE_HAS_TF_MODE) +BFP_TYPE +DFP_TO_BFP (DFP_C_TYPE f) +{ + IEEE_TYPE s; + char buf[BUFMAX]; + + HOST_TO_IEEE (f, &s); + /* Write the value to a string. */ + TO_STRING (&s, buf); + /* Read it as the binary floating point type and return that. */ + return STR_TO_BFP (buf, NULL); +} +#endif + +#if defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) \ + || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) \ + || ((defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)) \ + && LONG_DOUBLE_HAS_XF_MODE) \ + || ((defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)) \ + && LONG_DOUBLE_HAS_TF_MODE) +DFP_C_TYPE +BFP_TO_DFP (BFP_TYPE x) +{ + DFP_C_TYPE f; + IEEE_TYPE s; + char buf[BUFMAX]; + decContext context; + + decContextDefault (&context, CONTEXT_INIT); + DFP_INIT_ROUNDMODE (context.round); + + /* Use a C library function to write the floating point value to a string. */ + sprintf (buf, BFP_FMT, (BFP_VIA_TYPE) x); + + /* Convert from the floating point string to a decimal* type. */ + FROM_STRING (&s, buf, &context); + IEEE_TO_HOST (s, &f); + + if (DFP_EXCEPTIONS_ENABLED && context.status != 0) + { + /* decNumber exception flags we care about here. */ + int ieee_flags; + int dec_flags = DEC_IEEE_854_Inexact | DEC_IEEE_854_Invalid_operation + | DEC_IEEE_854_Overflow | DEC_IEEE_854_Underflow; + dec_flags &= context.status; + ieee_flags = DFP_IEEE_FLAGS (dec_flags); + if (ieee_flags != 0) + DFP_HANDLE_EXCEPTIONS (ieee_flags); + } + + return f; +} +#endif + +#if defined (L_unord_sd) || defined (L_unord_dd) || defined (L_unord_td) +CMPtype +DFP_UNORD (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) +{ + decNumber arg1, arg2; + IEEE_TYPE a, b; + + HOST_TO_IEEE (arg_a, &a); + HOST_TO_IEEE (arg_b, &b); + TO_INTERNAL (&a, &arg1); + TO_INTERNAL (&b, &arg2); + return (decNumberIsNaN (&arg1) || decNumberIsNaN (&arg2)); +} +#endif /* L_unord_sd || L_unord_dd || L_unord_td */ diff --git a/libgcc/dfp-bit.h b/libgcc/dfp-bit.h new file mode 100644 index 00000000000..45b79086bc9 --- /dev/null +++ b/libgcc/dfp-bit.h @@ -0,0 +1,626 @@ +/* Header file for dfp-bit.c. + Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _DFPBIT_H +#define _DFPBIT_H + +#include +#include +#include +#include +#include "tconfig.h" +#include "coretypes.h" +#include "tm.h" + +#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE +#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE +#endif + +/* We need to know the size of long double that the C library supports. + Don't use LIBGCC2_HAS_XF_MODE or LIBGCC2_HAS_TF_MODE here because + some targets set both of those. */ + +#define LONG_DOUBLE_HAS_XF_MODE \ + (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80) + +#define LONG_DOUBLE_HAS_TF_MODE \ + (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128) + +/* Depending on WIDTH, define a number of macros: + + DFP_C_TYPE: type of the arguments to the libgcc functions; + (eg _Decimal32) + + IEEE_TYPE: the corresponding (encoded) IEEE754 type; + (eg decimal32) + + TO_INTERNAL: the name of the decNumber function to convert an + encoded value into the decNumber internal representation; + + TO_ENCODED: the name of the decNumber function to convert an + internally represented decNumber into the encoded + representation. + + FROM_STRING: the name of the decNumber function to read an + encoded value from a string. + + TO_STRING: the name of the decNumber function to write an + encoded value to a string. */ + +#if WIDTH == 32 +#define DFP_C_TYPE _Decimal32 +#define IEEE_TYPE decimal32 +#define HOST_TO_IEEE __host_to_ieee_32 +#define IEEE_TO_HOST __ieee_to_host_32 +#define TO_INTERNAL __decimal32ToNumber +#define TO_ENCODED __decimal32FromNumber +#define FROM_STRING __decimal32FromString +#define TO_STRING __decimal32ToString +#elif WIDTH == 64 +#define DFP_C_TYPE _Decimal64 +#define IEEE_TYPE decimal64 +#define HOST_TO_IEEE __host_to_ieee_64 +#define IEEE_TO_HOST __ieee_to_host_64 +#define TO_INTERNAL __decimal64ToNumber +#define TO_ENCODED __decimal64FromNumber +#define FROM_STRING __decimal64FromString +#define TO_STRING __decimal64ToString +#elif WIDTH == 128 +#define DFP_C_TYPE _Decimal128 +#define IEEE_TYPE decimal128 +#define HOST_TO_IEEE __host_to_ieee_128 +#define IEEE_TO_HOST __ieee_to_host_128 +#define TO_INTERNAL __decimal128ToNumber +#define TO_ENCODED __decimal128FromNumber +#define FROM_STRING __decimal128FromString +#define TO_STRING __decimal128ToString +#else +#error invalid decimal float word width +#endif + +/* We define __DEC_EVAL_METHOD__ to 2, saying that we evaluate all + operations and constants to the range and precision of the _Decimal128 + type. Make it so. */ +#if WIDTH == 32 +#define CONTEXT_INIT DEC_INIT_DECIMAL32 +#elif WIDTH == 64 +#define CONTEXT_INIT DEC_INIT_DECIMAL64 +#elif WIDTH == 128 +#define CONTEXT_INIT DEC_INIT_DECIMAL128 +#endif + +#ifndef DFP_INIT_ROUNDMODE +#define DFP_INIT_ROUNDMODE(A) A = DEC_ROUND_HALF_EVEN +#endif + +#ifdef DFP_EXCEPTIONS_ENABLED +/* Return IEEE exception flags based on decNumber status flags. */ +#define DFP_IEEE_FLAGS(DEC_FLAGS) __extension__ \ +({int _fe_flags = 0; \ + if ((dec_flags & DEC_IEEE_854_Division_by_zero) != 0) \ + _fe_flags |= FE_DIVBYZERO; \ + if ((dec_flags & DEC_IEEE_854_Inexact) != 0) \ + _fe_flags |= FE_INEXACT; \ + if ((dec_flags & DEC_IEEE_854_Invalid_operation) != 0) \ + _fe_flags |= FE_INVALID; \ + if ((dec_flags & DEC_IEEE_854_Overflow) != 0) \ + _fe_flags |= FE_OVERFLOW; \ + if ((dec_flags & DEC_IEEE_854_Underflow) != 0) \ + _fe_flags |= FE_UNDERFLOW; \ + _fe_flags; }) +#else +#define DFP_EXCEPTIONS_ENABLED 0 +#define DFP_IEEE_FLAGS(A) 0 +#define DFP_HANDLE_EXCEPTIONS(A) do {} while (0) +#endif + +/* Conversions between different decimal float types use WIDTH_TO to + determine additional macros to define. */ + +#if defined (L_dd_to_sd) || defined (L_td_to_sd) +#define WIDTH_TO 32 +#elif defined (L_sd_to_dd) || defined (L_td_to_dd) +#define WIDTH_TO 64 +#elif defined (L_sd_to_td) || defined (L_dd_to_td) +#define WIDTH_TO 128 +#endif + +/* If WIDTH_TO is defined, define additional macros: + + DFP_C_TYPE_TO: type of the result of dfp to dfp conversion. + + IEEE_TYPE_TO: the corresponding (encoded) IEEE754 type. + + TO_ENCODED_TO: the name of the decNumber function to convert an + internally represented decNumber into the encoded representation + for the destination. */ + +#if WIDTH_TO == 32 +#define DFP_C_TYPE_TO _Decimal32 +#define IEEE_TYPE_TO decimal32 +#define TO_ENCODED_TO __decimal32FromNumber +#define IEEE_TO_HOST_TO __ieee_to_host_32 +#elif WIDTH_TO == 64 +#define DFP_C_TYPE_TO _Decimal64 +#define IEEE_TYPE_TO decimal64 +#define TO_ENCODED_TO __decimal64FromNumber +#define IEEE_TO_HOST_TO __ieee_to_host_64 +#elif WIDTH_TO == 128 +#define DFP_C_TYPE_TO _Decimal128 +#define IEEE_TYPE_TO decimal128 +#define TO_ENCODED_TO __decimal128FromNumber +#define IEEE_TO_HOST_TO __ieee_to_host_128 +#endif + +/* Conversions between decimal float types and integral types use INT_KIND + to determine the data type and C functions to use. */ + +#if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \ + || defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td) +#define INT_KIND 1 +#elif defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \ + || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) +#define INT_KIND 2 +#elif defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \ + || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td) +#define INT_KIND 3 +#elif defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) \ + || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td) +#define INT_KIND 4 +#endif + +/* If INT_KIND is defined, define additional macros: + + INT_TYPE: The integer data type. + + INT_FMT: The format string for writing the integer to a string. + + CAST_FOR_FMT: Cast variable of INT_KIND to C type for sprintf. + This works for ILP32 and LP64, won't for other type size systems. + + STR_TO_INT: The function to read the integer from a string. */ + +#if INT_KIND == 1 +#define INT_TYPE SItype +#define INT_FMT "%d" +#define CAST_FOR_FMT(A) (int)A +#define STR_TO_INT strtol +#elif INT_KIND == 2 +#define INT_TYPE DItype +#define INT_FMT "%lld" +#define CAST_FOR_FMT(A) (long long)A +#define STR_TO_INT strtoll +#elif INT_KIND == 3 +#define INT_TYPE USItype +#define INT_FMT "%u" +#define CAST_FOR_FMT(A) (unsigned int)A +#define STR_TO_INT strtoul +#elif INT_KIND == 4 +#define INT_TYPE UDItype +#define INT_FMT "%llu" +#define CAST_FOR_FMT(A) (unsigned long long)A +#define STR_TO_INT strtoull +#endif + +/* Conversions between decimal float types and binary float types use + BFP_KIND to determine the data type and C functions to use. */ + +#if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \ + || defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) +#define BFP_KIND 1 +#elif defined (L_sd_to_df) || defined (L_dd_to_df ) || defined (L_td_to_df) \ + || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) +#define BFP_KIND 2 +#elif defined (L_sd_to_xf) || defined (L_dd_to_xf ) || defined (L_td_to_xf) \ + || defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td) +#define BFP_KIND 3 +#elif defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf) \ + || defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td) +#define BFP_KIND 4 +#endif + +/* If BFP_KIND is defined, define additional macros: + + BFP_TYPE: The binary floating point data type. + + BFP_FMT: The format string for writing the value to a string. + The number of decimal digits printed is + ceil (nbits / log2 (10.) + 1) + as described in David Matula's CACM 19(3) 716-723 June 1968 paper. + + BFP_VIA_TYPE: Type to which to cast a variable of BPF_TYPE for a + call to sprintf. + + STR_TO_BFP: The function to read the value from a string. */ + +#if BFP_KIND == 1 +#define BFP_TYPE SFtype +#define BFP_FMT "%.9e" +#define BFP_VIA_TYPE double +#define STR_TO_BFP strtof + +#elif BFP_KIND == 2 +#define BFP_TYPE DFtype +#define BFP_FMT "%.17e" +#define BFP_VIA_TYPE double +#define STR_TO_BFP strtod + +#elif BFP_KIND == 3 +#if LONG_DOUBLE_HAS_XF_MODE +#define BFP_TYPE XFtype +#define BFP_FMT "%.21Le" +#define BFP_VIA_TYPE long double +#define STR_TO_BFP strtold +#endif /* LONG_DOUBLE_HAS_XF_MODE */ + +#elif BFP_KIND == 4 +#if LONG_DOUBLE_HAS_TF_MODE +#define BFP_TYPE TFtype +#if LDBL_MANT_DIG == 106 +#define BFP_FMT "%.33Le" +#elif LDBL_MANT_DIG == 113 +#define BFP_FMT "%.36Le" +#else +#error "unknown long double size, cannot define BFP_FMT" +#endif /* LDBL_MANT_DIG */ +#define STR_TO_BFP strtold +#define BFP_VIA_TYPE long double +#endif /* LONG_DOUBLE_HAS_TF_MODE */ + +#endif /* BFP_KIND */ + +#if WIDTH == 128 || WIDTH_TO == 128 +#include "decimal128.h" +#include "decQuad.h" +#endif +#if WIDTH == 64 || WIDTH_TO == 64 +#include "decimal64.h" +#include "decDouble.h" +#endif +#if WIDTH == 32 || WIDTH_TO == 32 +#include "decimal32.h" +#include "decSingle.h" +#endif +#include "decNumber.h" + +/* Names of arithmetic functions. */ + +#if ENABLE_DECIMAL_BID_FORMAT +#define DPD_BID_NAME(DPD,BID) BID +#else +#define DPD_BID_NAME(DPD,BID) DPD +#endif + +#if WIDTH == 32 +#define DFP_ADD DPD_BID_NAME(__dpd_addsd3,__bid_addsd3) +#define DFP_SUB DPD_BID_NAME(__dpd_subsd3,__bid_subsd3) +#define DFP_MULTIPLY DPD_BID_NAME(__dpd_mulsd3,__bid_mulsd3) +#define DFP_DIVIDE DPD_BID_NAME(__dpd_divsd3,__bid_divsd3) +#define DFP_EQ DPD_BID_NAME(__dpd_eqsd2,__bid_eqsd2) +#define DFP_NE DPD_BID_NAME(__dpd_nesd2,__bid_nesd2) +#define DFP_LT DPD_BID_NAME(__dpd_ltsd2,__bid_ltsd2) +#define DFP_GT DPD_BID_NAME(__dpd_gtsd2,__bid_gtsd2) +#define DFP_LE DPD_BID_NAME(__dpd_lesd2,__bid_lesd2) +#define DFP_GE DPD_BID_NAME(__dpd_gesd2,__bid_gesd2) +#define DFP_UNORD DPD_BID_NAME(__dpd_unordsd2,__bid_unordsd2) +#elif WIDTH == 64 +#define DFP_ADD DPD_BID_NAME(__dpd_adddd3,__bid_adddd3) +#define DFP_SUB DPD_BID_NAME(__dpd_subdd3,__bid_subdd3) +#define DFP_MULTIPLY DPD_BID_NAME(__dpd_muldd3,__bid_muldd3) +#define DFP_DIVIDE DPD_BID_NAME(__dpd_divdd3,__bid_divdd3) +#define DFP_EQ DPD_BID_NAME(__dpd_eqdd2,__bid_eqdd2) +#define DFP_NE DPD_BID_NAME(__dpd_nedd2,__bid_nedd2) +#define DFP_LT DPD_BID_NAME(__dpd_ltdd2,__bid_ltdd2) +#define DFP_GT DPD_BID_NAME(__dpd_gtdd2,__bid_gtdd2) +#define DFP_LE DPD_BID_NAME(__dpd_ledd2,__bid_ledd2) +#define DFP_GE DPD_BID_NAME(__dpd_gedd2,__bid_gedd2) +#define DFP_UNORD DPD_BID_NAME(__dpd_unorddd2,__bid_unorddd2) +#elif WIDTH == 128 +#define DFP_ADD DPD_BID_NAME(__dpd_addtd3,__bid_addtd3) +#define DFP_SUB DPD_BID_NAME(__dpd_subtd3,__bid_subtd3) +#define DFP_MULTIPLY DPD_BID_NAME(__dpd_multd3,__bid_multd3) +#define DFP_DIVIDE DPD_BID_NAME(__dpd_divtd3,__bid_divtd3) +#define DFP_EQ DPD_BID_NAME(__dpd_eqtd2,__bid_eqtd2) +#define DFP_NE DPD_BID_NAME(__dpd_netd2,__bid_netd2) +#define DFP_LT DPD_BID_NAME(__dpd_lttd2,__bid_lttd2) +#define DFP_GT DPD_BID_NAME(__dpd_gttd2,__bid_gttd2) +#define DFP_LE DPD_BID_NAME(__dpd_letd2,__bid_letd2) +#define DFP_GE DPD_BID_NAME(__dpd_getd2,__bid_getd2) +#define DFP_UNORD DPD_BID_NAME(__dpd_unordtd2,__bid_unordtd2) +#endif + +/* Names of decNumber functions for DPD arithmetic. */ + +#if WIDTH == 32 +#define decFloat decDouble +#define DFP_BINARY_OP d32_binary_op +#define DFP_COMPARE_OP d32_compare_op +#define DEC_FLOAT_ADD decDoubleAdd +#define DEC_FLOAT_SUBTRACT decDoubleSubtract +#define DEC_FLOAT_MULTIPLY decDoubleMultiply +#define DEC_FLOAT_DIVIDE decDoubleDivide +#define DEC_FLOAT_COMPARE decDoubleCompare +#define DEC_FLOAT_IS_ZERO decDoubleIsZero +#define DEC_FLOAT_IS_NAN decDoubleIsNaN +#define DEC_FLOAT_IS_SIGNED decDoubleIsSigned +#elif WIDTH == 64 +#define DFP_BINARY_OP dnn_binary_op +#define DFP_COMPARE_OP dnn_compare_op +#define decFloat decDouble +#define DEC_FLOAT_ADD decDoubleAdd +#define DEC_FLOAT_SUBTRACT decDoubleSubtract +#define DEC_FLOAT_MULTIPLY decDoubleMultiply +#define DEC_FLOAT_DIVIDE decDoubleDivide +#define DEC_FLOAT_COMPARE decDoubleCompare +#define DEC_FLOAT_IS_ZERO decDoubleIsZero +#define DEC_FLOAT_IS_NAN decDoubleIsNaN +#define DEC_FLOAT_IS_SIGNED decDoubleIsSigned +#elif WIDTH == 128 +#define DFP_BINARY_OP dnn_binary_op +#define DFP_COMPARE_OP dnn_compare_op +#define decFloat decQuad +#define DEC_FLOAT_ADD decQuadAdd +#define DEC_FLOAT_SUBTRACT decQuadSubtract +#define DEC_FLOAT_MULTIPLY decQuadMultiply +#define DEC_FLOAT_DIVIDE decQuadDivide +#define DEC_FLOAT_COMPARE decQuadCompare +#define DEC_FLOAT_IS_ZERO decQuadIsZero +#define DEC_FLOAT_IS_NAN decQuadIsNaN +#define DEC_FLOAT_IS_SIGNED decQuadIsSigned +#endif + +/* Names of functions to convert between different decimal float types. */ + +#if WIDTH == 32 +#if WIDTH_TO == 64 +#define DFP_TO_DFP DPD_BID_NAME(__dpd_extendsddd2,__bid_extendsddd2) +#elif WIDTH_TO == 128 +#define DFP_TO_DFP DPD_BID_NAME(__dpd_extendsdtd2,__bid_extendsdtd2) +#endif +#elif WIDTH == 64 +#if WIDTH_TO == 32 +#define DFP_TO_DFP DPD_BID_NAME(__dpd_truncddsd2,__bid_truncddsd2) +#elif WIDTH_TO == 128 +#define DFP_TO_DFP DPD_BID_NAME(__dpd_extendddtd2,__bid_extendddtd2) +#endif +#elif WIDTH == 128 +#if WIDTH_TO == 32 +#define DFP_TO_DFP DPD_BID_NAME(__dpd_trunctdsd2,__bid_trunctdsd2) +#elif WIDTH_TO == 64 +#define DFP_TO_DFP DPD_BID_NAME(__dpd_trunctddd2,__bid_trunctddd2) +#endif +#endif + +/* Names of functions to convert between decimal float and integers. */ + +#if WIDTH == 32 +#if INT_KIND == 1 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatsisd,__bid_floatsisd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixsdsi,__bid_fixsdsi) +#define DEC_FLOAT_FROM_INT decDoubleFromInt32 +#define DEC_FLOAT_TO_INT decDoubleToInt32 +#elif INT_KIND == 2 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatdisd,__bid_floatdisd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixsddi,__bid_fixsddi) +#elif INT_KIND == 3 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatunssisd,__bid_floatunssisd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixunssdsi,__bid_fixunssdsi) +#define DEC_FLOAT_FROM_INT decDoubleFromUInt32 +#define DEC_FLOAT_TO_INT decDoubleToUInt32 +#elif INT_KIND == 4 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatunsdisd,__bid_floatunsdisd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixunssddi,__bid_fixunssddi) +#endif +#elif WIDTH == 64 +#define decFloat decDouble +#if INT_KIND == 1 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatsidd,__bid_floatsidd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixddsi,__bid_fixddsi) +#define DEC_FLOAT_FROM_INT decDoubleFromInt32 +#define DEC_FLOAT_TO_INT decDoubleToInt32 +#elif INT_KIND == 2 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatdidd,__bid_floatdidd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixdddi,__bid_fixdddi) +#elif INT_KIND == 3 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatunssidd,__bid_floatunssidd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixunsddsi,__bid_fixunsddsi) +#define DEC_FLOAT_FROM_INT decDoubleFromUInt32 +#define DEC_FLOAT_TO_INT decDoubleToUInt32 +#elif INT_KIND == 4 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatunsdidd,__bid_floatunsdidd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixunsdddi,__bid_fixunsdddi) +#endif +#elif WIDTH == 128 +#define decFloat decQuad +#if INT_KIND == 1 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatsitd,__bid_floatsitd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixtdsi,__bid_fixtdsi) +#define DEC_FLOAT_FROM_INT decQuadFromInt32 +#define DEC_FLOAT_TO_INT decQuadToInt32 +#elif INT_KIND == 2 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatditd,__bid_floatditd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixtddi,__bid_fixtddi) +#elif INT_KIND == 3 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatunssitd,__bid_floatunssitd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixunstdsi,__bid_fixunstdsi) +#define DEC_FLOAT_FROM_INT decQuadFromUInt32 +#define DEC_FLOAT_TO_INT decQuadToUInt32 +#elif INT_KIND == 4 +#define INT_TO_DFP DPD_BID_NAME(__dpd_floatunsditd,__bid_floatunsditd) +#define DFP_TO_INT DPD_BID_NAME(__dpd_fixunstddi,__bid_fixunstddi) +#endif +#endif + +/* Names of functions to convert between decimal float and binary float. */ + +#if WIDTH == 32 +#if BFP_KIND == 1 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsfsd,__bid_extendsfsd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_truncsdsf,__bid_truncsdsf) +#elif BFP_KIND == 2 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_truncdfsd,__bid_truncdfsd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendsddf,__bid_extendsddf) +#elif BFP_KIND == 3 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_truncxfsd,__bid_truncxfsd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendsdxf,__bid_extendsdxf) +#elif BFP_KIND == 4 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_trunctfsd,__bid_trunctfsd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendsdtf,__bid_extendsdtf) +#endif /* BFP_KIND */ + +#elif WIDTH == 64 +#if BFP_KIND == 1 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsfdd,__bid_extendsfdd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_truncddsf,__bid_truncddsf) +#elif BFP_KIND == 2 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_extenddfdd,__bid_extenddfdd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_truncdddf,__bid_truncdddf) +#elif BFP_KIND == 3 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_truncxfdd,__bid_truncxfdd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendddxf,__bid_extendddxf) +#elif BFP_KIND == 4 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_trunctfdd,__bid_trunctfdd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendddtf,__bid_extendddtf) +#endif /* BFP_KIND */ + +#elif WIDTH == 128 +#if BFP_KIND == 1 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsftd,__bid_extendsftd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdsf,__bid_trunctdsf) +#elif BFP_KIND == 2 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_extenddftd,__bid_extenddftd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctddf,__bid_trunctddf) +#elif BFP_KIND == 3 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendxftd,__bid_extendxftd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdxf,__bid_trunctdxf) +#elif BFP_KIND == 4 +#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendtftd,__bid_extendtftd) +#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdtf,__bid_trunctdtf) +#endif /* BFP_KIND */ + +#endif /* WIDTH */ + +/* Some handy typedefs. */ + +typedef float SFtype __attribute__ ((mode (SF))); +typedef float DFtype __attribute__ ((mode (DF))); +#if LONG_DOUBLE_HAS_XF_MODE +typedef float XFtype __attribute__ ((mode (XF))); +#endif /* LONG_DOUBLE_HAS_XF_MODE */ +#if LONG_DOUBLE_HAS_TF_MODE +typedef float TFtype __attribute__ ((mode (TF))); +#endif /* LONG_DOUBLE_HAS_TF_MODE */ + +typedef int SItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); + +/* The type of the result of a decimal float comparison. This must + match `__libgcc_cmp_return__' in GCC for the target. */ + +typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); + +/* Prototypes. */ + +#if defined (L_mul_sd) || defined (L_mul_dd) || defined (L_mul_td) +extern DFP_C_TYPE DFP_MULTIPLY (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_div_sd) || defined (L_div_dd) || defined (L_div_td) +extern DFP_C_TYPE DFP_DIVIDE (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_addsub_sd) || defined (L_addsub_dd) || defined (L_addsub_td) +extern DFP_C_TYPE DFP_ADD (DFP_C_TYPE, DFP_C_TYPE); +extern DFP_C_TYPE DFP_SUB (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_eq_sd) || defined (L_eq_dd) || defined (L_eq_td) +extern CMPtype DFP_EQ (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_ne_sd) || defined (L_ne_dd) || defined (L_ne_td) +extern CMPtype DFP_NE (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_lt_sd) || defined (L_lt_dd) || defined (L_lt_td) +extern CMPtype DFP_LT (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_gt_sd) || defined (L_gt_dd) || defined (L_gt_td) +extern CMPtype DFP_GT (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_le_sd) || defined (L_le_dd) || defined (L_le_td) +extern CMPtype DFP_LE (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_ge_sd) || defined (L_ge_dd) || defined (L_ge_td) +extern CMPtype DFP_GE (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_unord_sd) || defined (L_unord_dd) || defined (L_unord_td) +extern CMPtype DFP_UNORD (DFP_C_TYPE, DFP_C_TYPE); +#endif + +#if defined (L_sd_to_dd) || defined (L_sd_to_td) || defined (L_dd_to_sd) \ + || defined (L_dd_to_td) || defined (L_td_to_sd) || defined (L_td_to_dd) +extern DFP_C_TYPE_TO DFP_TO_DFP (DFP_C_TYPE); +#endif + +#if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \ + || defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \ + || defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \ + || defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) +extern INT_TYPE DFP_TO_INT (DFP_C_TYPE); +#endif + +#if defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td) \ + || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) \ + || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td) \ + || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td) +extern DFP_C_TYPE INT_TO_DFP (INT_TYPE); +#endif + +#if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \ + || defined (L_sd_to_df) || defined (L_dd_to_df) || defined (L_td_to_df) \ + || ((defined (L_sd_to_xf) || defined (L_dd_to_xf) || defined (L_td_to_xf)) \ + && LONG_DOUBLE_HAS_XF_MODE) \ + || ((defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf)) \ + && LONG_DOUBLE_HAS_TF_MODE) +extern BFP_TYPE DFP_TO_BFP (DFP_C_TYPE); +#endif + +#if defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) \ + || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) \ + || ((defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)) \ + && LONG_DOUBLE_HAS_XF_MODE) \ + || ((defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)) \ + && LONG_DOUBLE_HAS_TF_MODE) +extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE); +#endif + +#endif /* _DFPBIT_H */