diff options
author | Jing Yu <jingyu@google.com> | 2010-07-22 14:03:48 -0700 |
---|---|---|
committer | Jing Yu <jingyu@google.com> | 2010-07-22 14:03:48 -0700 |
commit | b094d6c4bf572654a031ecc4afe675154c886dc5 (patch) | |
tree | 89394c56b05e13a5413ee60237d65b0214fd98e2 /gcc-4.4.3/libgcc | |
parent | dc34721ac3bf7e3c406fba8cfe9d139393345ec5 (diff) | |
download | toolchain_gcc-b094d6c4bf572654a031ecc4afe675154c886dc5.tar.gz toolchain_gcc-b094d6c4bf572654a031ecc4afe675154c886dc5.tar.bz2 toolchain_gcc-b094d6c4bf572654a031ecc4afe675154c886dc5.zip |
commit gcc-4.4.3 which is used to build gcc-4.4.3 Android toolchain in master.
The source is based on fsf gcc-4.4.3 and contains local patches which
are recorded in gcc-4.4.3/README.google.
Change-Id: Id8c6d6927df274ae9749196a1cc24dbd9abc9887
Diffstat (limited to 'gcc-4.4.3/libgcc')
205 files changed, 240106 insertions, 0 deletions
diff --git a/gcc-4.4.3/libgcc/ChangeLog b/gcc-4.4.3/libgcc/ChangeLog new file mode 100644 index 000000000..81c337489 --- /dev/null +++ b/gcc-4.4.3/libgcc/ChangeLog @@ -0,0 +1,649 @@ +2010-01-21 Release Manager + + * GCC 4.4.3 released. + +2009-10-15 Release Manager + + * GCC 4.4.2 released. + +2009-07-22 Release Manager + + * GCC 4.4.1 released. + +2009-04-21 Release Manager + + * GCC 4.4.0 released. + +2009-04-17 Aurelien Jarno <aurelien@aurel32.net> + + * config.host: Add i386/${host_address}/t-fprules-softfp to + tmake_file for i[34567]86-*-kfreebsd*-gnu, x86_64-*-kfreebsd*-gnu*. + +2009-04-09 Nick Clifton <nickc@redhat.com> + + * config/ia64/tf-signs.c: Change copyright header to refer to + version 3 of the GNU General Public License with version 3.1 + of the GCC Runtime Library Exception and to point readers at + the COPYING3 and COPYING3.RUNTIME files and the FSF's license + web page. + * config/i386/32/tf-signs.c: Likewise. + * config/libbid/_addsub_dd.c: Likewise. + * config/libbid/_addsub_sd.c: Likewise. + * config/libbid/_addsub_td.c: Likewise. + * config/libbid/_dd_to_df.c: Likewise. + * config/libbid/_dd_to_di.c: Likewise. + * config/libbid/_dd_to_sd.c: Likewise. + * config/libbid/_dd_to_sf.c: Likewise. + * config/libbid/_dd_to_si.c: Likewise. + * config/libbid/_dd_to_td.c: Likewise. + * config/libbid/_dd_to_tf.c: Likewise. + * config/libbid/_dd_to_udi.c: Likewise. + * config/libbid/_dd_to_usi.c: Likewise. + * config/libbid/_dd_to_xf.c: Likewise. + * config/libbid/_df_to_dd.c: Likewise. + * config/libbid/_df_to_sd.c: Likewise. + * config/libbid/_df_to_td.c: Likewise. + * config/libbid/_di_to_dd.c: Likewise. + * config/libbid/_di_to_sd.c: Likewise. + * config/libbid/_di_to_td.c: Likewise. + * config/libbid/_div_dd.c: Likewise. + * config/libbid/_div_sd.c: Likewise. + * config/libbid/_div_td.c: Likewise. + * config/libbid/_eq_dd.c: Likewise. + * config/libbid/_eq_sd.c: Likewise. + * config/libbid/_eq_td.c: Likewise. + * config/libbid/_ge_dd.c: Likewise. + * config/libbid/_ge_sd.c: Likewise. + * config/libbid/_ge_td.c: Likewise. + * config/libbid/_gt_dd.c: Likewise. + * config/libbid/_gt_sd.c: Likewise. + * config/libbid/_gt_td.c: Likewise. + * config/libbid/_isinfd128.c: Likewise. + * config/libbid/_isinfd32.c: Likewise. + * config/libbid/_isinfd64.c: Likewise. + * config/libbid/_le_dd.c: Likewise. + * config/libbid/_le_sd.c: Likewise. + * config/libbid/_le_td.c: Likewise. + * config/libbid/_lt_dd.c: Likewise. + * config/libbid/_lt_sd.c: Likewise. + * config/libbid/_lt_td.c: Likewise. + * config/libbid/_mul_dd.c: Likewise. + * config/libbid/_mul_sd.c: Likewise. + * config/libbid/_mul_td.c: Likewise. + * config/libbid/_ne_dd.c: Likewise. + * config/libbid/_ne_sd.c: Likewise. + * config/libbid/_ne_td.c: Likewise. + * config/libbid/_sd_to_dd.c: Likewise. + * config/libbid/_sd_to_df.c: Likewise. + * config/libbid/_sd_to_di.c: Likewise. + * config/libbid/_sd_to_sf.c: Likewise. + * config/libbid/_sd_to_si.c: Likewise. + * config/libbid/_sd_to_td.c: Likewise. + * config/libbid/_sd_to_tf.c: Likewise. + * config/libbid/_sd_to_udi.c: Likewise. + * config/libbid/_sd_to_usi.c: Likewise. + * config/libbid/_sd_to_xf.c: Likewise. + * config/libbid/_sf_to_dd.c: Likewise. + * config/libbid/_sf_to_sd.c: Likewise. + * config/libbid/_sf_to_td.c: Likewise. + * config/libbid/_si_to_dd.c: Likewise. + * config/libbid/_si_to_sd.c: Likewise. + * config/libbid/_si_to_td.c: Likewise. + * config/libbid/_td_to_dd.c: Likewise. + * config/libbid/_td_to_df.c: Likewise. + * config/libbid/_td_to_di.c: Likewise. + * config/libbid/_td_to_sd.c: Likewise. + * config/libbid/_td_to_sf.c: Likewise. + * config/libbid/_td_to_si.c: Likewise. + * config/libbid/_td_to_tf.c: Likewise. + * config/libbid/_td_to_udi.c: Likewise. + * config/libbid/_td_to_usi.c: Likewise. + * config/libbid/_td_to_xf.c: Likewise. + * config/libbid/_tf_to_dd.c: Likewise. + * config/libbid/_tf_to_sd.c: Likewise. + * config/libbid/_tf_to_td.c: Likewise. + * config/libbid/_udi_to_dd.c: Likewise. + * config/libbid/_udi_to_sd.c: Likewise. + * config/libbid/_udi_to_td.c: Likewise. + * config/libbid/_unord_dd.c: Likewise. + * config/libbid/_unord_sd.c: Likewise. + * config/libbid/_unord_td.c: Likewise. + * config/libbid/_usi_to_dd.c: Likewise. + * config/libbid/_usi_to_sd.c: Likewise. + * config/libbid/_usi_to_td.c: Likewise. + * config/libbid/_xf_to_dd.c: Likewise. + * config/libbid/_xf_to_sd.c: Likewise. + * config/libbid/_xf_to_td.c: Likewise. + * config/libbid/bid128.c: Likewise. + * config/libbid/bid128_2_str.h: Likewise. + * config/libbid/bid128_2_str_macros.h: Likewise. + * config/libbid/bid128_2_str_tables.c: Likewise. + * config/libbid/bid128_add.c: Likewise. + * config/libbid/bid128_compare.c: Likewise. + * config/libbid/bid128_div.c: Likewise. + * config/libbid/bid128_fma.c: Likewise. + * config/libbid/bid128_logb.c: Likewise. + * config/libbid/bid128_minmax.c: Likewise. + * config/libbid/bid128_mul.c: Likewise. + * config/libbid/bid128_next.c: Likewise. + * config/libbid/bid128_noncomp.c: Likewise. + * config/libbid/bid128_quantize.c: Likewise. + * config/libbid/bid128_rem.c: Likewise. + * config/libbid/bid128_round_integral.c: Likewise. + * config/libbid/bid128_scalb.c: Likewise. + * config/libbid/bid128_sqrt.c: Likewise. + * config/libbid/bid128_string.c: Likewise. + * config/libbid/bid128_to_int16.c: Likewise. + * config/libbid/bid128_to_int32.c: Likewise. + * config/libbid/bid128_to_int64.c: Likewise. + * config/libbid/bid128_to_int8.c: Likewise. + * config/libbid/bid128_to_uint16.c: Likewise. + * config/libbid/bid128_to_uint32.c: Likewise. + * config/libbid/bid128_to_uint64.c: Likewise. + * config/libbid/bid128_to_uint8.c: Likewise. + * config/libbid/bid32_to_bid128.c: Likewise. + * config/libbid/bid32_to_bid64.c: Likewise. + * config/libbid/bid64_add.c: Likewise. + * config/libbid/bid64_compare.c: Likewise. + * config/libbid/bid64_div.c: Likewise. + * config/libbid/bid64_fma.c: Likewise. + * config/libbid/bid64_logb.c: Likewise. + * config/libbid/bid64_minmax.c: Likewise. + * config/libbid/bid64_mul.c: Likewise. + * config/libbid/bid64_next.c: Likewise. + * config/libbid/bid64_noncomp.c: Likewise. + * config/libbid/bid64_quantize.c: Likewise. + * config/libbid/bid64_rem.c: Likewise. + * config/libbid/bid64_round_integral.c: Likewise. + * config/libbid/bid64_scalb.c: Likewise. + * config/libbid/bid64_sqrt.c: Likewise. + * config/libbid/bid64_string.c: Likewise. + * config/libbid/bid64_to_bid128.c: Likewise. + * config/libbid/bid64_to_int16.c: Likewise. + * config/libbid/bid64_to_int32.c: Likewise. + * config/libbid/bid64_to_int64.c: Likewise. + * config/libbid/bid64_to_int8.c: Likewise. + * config/libbid/bid64_to_uint16.c: Likewise. + * config/libbid/bid64_to_uint32.c: Likewise. + * config/libbid/bid64_to_uint64.c: Likewise. + * config/libbid/bid64_to_uint8.c: Likewise. + * config/libbid/bid_b2d.h: Likewise. + * config/libbid/bid_binarydecimal.c: Likewise. + * config/libbid/bid_conf.h: Likewise. + * config/libbid/bid_convert_data.c: Likewise. + * config/libbid/bid_decimal_data.c: Likewise. + * config/libbid/bid_decimal_globals.c: Likewise. + * config/libbid/bid_div_macros.h: Likewise. + * config/libbid/bid_dpd.c: Likewise. + * config/libbid/bid_flag_operations.c: Likewise. + * config/libbid/bid_from_int.c: Likewise. + * config/libbid/bid_functions.h: Likewise. + * config/libbid/bid_gcc_intrinsics.h: Likewise. + * config/libbid/bid_inline_add.h: Likewise. + * config/libbid/bid_internal.h: Likewise. + * config/libbid/bid_round.c: Likewise. + * config/libbid/bid_sqrt_macros.h: Likewise. + +2009-04-09 Jakub Jelinek <jakub@redhat.com> + + * Makefile.in: Change copyright header to refer to version + 3 of the GNU General Public License and to point readers at the + COPYING3 file and the FSF's license web page. + * config.host: Likewise. + +2009-02-12 Uros Bizjak <ubizjak@gmail.com> + + * config.host (ia64*-*-linux*): Add t-softfp to tmake_file. + * config/ia64/tf-signs.c (__copysigntf3, __fabstf2): Prototype. + +2009-02-12 H.J. Lu <hongjiu.lu@intel.com> + + * config.host (ia64*-*-linux*): Add ia64/t-fprules-softfp and + ia64/t-softfp-compat to tmake_file. + + * Makefile.in (gen-hide-list): Ignore .*_compat and .*@.*. + + * config/ia64/__divxf3.asm: New. + * config/ia64/_fixtfdi.asm: Likewise. + * config/ia64/_fixunstfdi.asm: Likewise. + * config/ia64/_floatditf.asm: Likewise. + * config/ia64/t-fprules-softfp: Likewise. + * config/ia64/t-softfp-compat: Likewise. + * config/ia64/tf-signs.c: Likewise. + +2009-01-18 Ben Elliston <bje@au.ibm.com> + + * config/i386/32/tf-signs.c (__copysigntf3, __fabstf2): Prototype. + +2009-01-16 Ben Elliston <bje@au.ibm.com> + + * config.host (i[34567]86-*-linux*, x86_64-*-linux*): Add t-softfp + to tmake_file. + +2009-01-13 Ben Elliston <bje@au.ibm.com> + + * config/t-softfp: New file. + * config.host (powerpc64-*-linux*, powerpc64-*-gnu*): Add t-softfp. + (powerpc-*-linux*spe*, powerpc-*-linux*): Likewise. + +2009-01-05 Joel Sherrill <joel.sherrill@oarcorp.com> + + * config.host: Add m32r*-*-rtems*. + +2008-12-01 Joel Sherrill <joel.sherrill@oarcorp.com> + + * config.host: Add m32c*-*-rtems*. + +2008-11-20 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + PR bootstrap/33100 + * configure.ac (i?86-*-solaris2.1[0-9]*): Only include + i386/t-crtstuff if linker supports ZERO terminator unwind entries. + * configure: Regenerate. + * config.host (i[34567]86-*-solaris2*): Move i386/t-sol2 in + tmake_file here from gcc/config.gcc. + Move extra_parts here from gcc/config.gcc. + * config/i386/t-sol2: Move here from gcc/config/i386. + Use gcc_srcdir instead of srcdir. + +2008-11-18 Adam Nemet <anemet@caviumnetworks.com> + + * config.host (mipsisa64r2-*-elf* | mipsisa64r2el-*-elf*): New + case. + +2008-11-09 Thomas Schwinge <tschwinge@gnu.org> + + * config.host <t-tls>: Also enable for GNU/kFreeBSD and GNU/kNetBSD. + +2008-10-08 Thomas Schwinge <tschwinge@gnu.org> + + * config.host: Fold `*-*-gnu*' cases into the Linux ones. + +2008-09-03 Hari Sandanagobalane <hariharan@picochip.com> + + Add picoChip port. + * config.host: Add picochip-*-*. + +2008-08-06 Bob Wilson <bob.wilson@acm.org> + + * config.host: Match more processor names for Xtensa. + +2008-07-08 H.J. Lu <hongjiu.lu@intel.com> + + * config/i386/64/t-softfp-compat: Update comments. + +2008-07-07 H.J. Lu <hongjiu.lu@intel.com> + + * config/i386/64/_divtc3-compat.c: Moved to ... + * config/i386/64/_divtc3.c: Here. + + * config/i386/64/_multc3-compat.c: Moved to ... + * config/i386/64/_multc3.c: Here. + + * config/i386/64/_powitf2-compat.c: Moved to ... + * config/i386/64/_powitf2.c: Here. + + * config/i386/64/t-softfp-compat (libgcc2-tf-compats): Add + .c suffix instead of -compat.c. + +2008-07-05 Uros Bizjak <ubizjak@gmail.com> + + * config/i386/32/sfp-machine.h (_FP_MUL_MEAT_S): Remove. + (_FP_MUL_MEAT_D): Ditto. + (_FP_DIV_MEAT_S): Ditto. + (_FP_DIV_MEAT_D): Ditto. + +2008-07-03 Richard Sandiford <rdsandiford@googlemail.com> + + * Makefile.in: Add support for __sync_* libgcc functions. + +2008-07-03 H.J. Lu <hongjiu.lu@intel.com> + + * shared-object.mk ($(base)_s$(objext)): Remove -DSHARED. + +2008-07-02 H.J. Lu <hongjiu.lu@intel.com> + + PR boostrap/36702 + * config.host: Only include 32bit t-fprules-softfp for Darwin/x86 + and Linux/x86. Include 64bit t-softfp-compat for Linux/x86. + + * config/i386/64/t-fprules-softfp: Moved to ... + * config/i386/64/t-softfp-compat: This. New. + +2008-07-02 Uros Bizjak <ubizjak@gmail.com> + + * config/i386/32/sfp-machine.h (FP_HANDLE_EXCEPTIONS) [FP_EX_INVALID]: + Initialize f with 0.0. + +2008-07-02 H.J. Lu <hongjiu.lu@intel.com> + + PR target/36669 + * shared-object.mk ($(base)_s$(objext)): Add -DSHARED. + + * config/i386/64/_divtc3-compat.c: New. + * config/i386/64/_multc3-compat.c: Likewise. + * config/i386/64/_powitf2-compat.c: Likewise. + * config/i386/64/eqtf2.c: Likewise. + * config/i386/64/getf2.c: Likewise. + * config/i386/64/letf2.c: Likewise. + * config/i386/64/t-fprules-softfp: Likewise. + +2008-07-02 H.J. Lu <hongjiu.lu@intel.com> + + * config.host: Add i386/${host_address}/t-fprules-softfp to + tmake_file for i[34567]86-*-darwin*, x86_64-*-darwin*, + i[34567]86-*-linux*, x86_64-*-linux*. + + * configure.ac: Set host_address to 64 or 32 for x86. + * configure: Regenerated. + + * Makefile.in (config.status): Also depend on + $(srcdir)/config.host. + + * config/i386/32/t-fprules-softfp: New. + * config/i386/32/tf-signs.c: Likewise. + + * config/i386/64/sfp-machine.h: New. Moved from gcc. + +2008-07-02 H.J. Lu <hongjiu.lu@intel.com> + Uros Bizjak <ubizjak@gmail.com> + + * config/i386/32/sfp-machine.h: New. + +2008-06-26 Nathan Froyd <froydnj@codesourcery.com> + + * config/rs6000/t-ppccomm: Remove rules that conflict with + auto-generated rules. + +2008-06-17 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + + * configure.ac: sinclude override.m4. + * configure: Regenerate. + +2008-06-11 Bernhard Fischer <aldot@gcc.gnu.org> + + * configure: Regenerate. + +2008-06-10 Joseph Myers <joseph@codesourcery.com> + + * Makefile.in (DECNUMINC): Remove + -I$(MULTIBUILDTOP)../../libdecnumber. + * gstdint.h: New. + +2008-06-07 Joseph Myers <joseph@codesourcery.com> + + * config.host (strongarm*-*-*, ep9312*-*-*, xscale-*-*, + parisc*-*-*, m680[012]0-*-*, *-*-linux*libc1*, *-*-linux*aout*, + alpha*-*-unicosmk*, strongarm*-*-freebsd*, ep9312-*-elf, + arm*-*-kaos*, cris-*-aout, parisc*64*-*-linux*, parisc*-*-linux*, + hppa1.1-*-pro*, hppa1.1-*-osf*, hppa1.1-*-bsd*, + i[34567]86-sequent-ptx4*, i[34567]86-sequent-sysv4*, + i[34567]86-*-beoself*, i[34567]86-*-beos*, i[34567]86-*-sco3.2v5*, + i[34567]86-*-sysv5*, i[34567]86-*-sysv4*, i[34567]86-*-uwin*, + i[34567]86-*-kaos*, m68020-*-elf*, m68010-*-netbsdelf*, + mips-wrs-windiss, mt-*-elf, powerpc-*-beos*, powerpc-*-chorusos*, + powerpc-wrs-windiss*, powerpcle-*-sysv*, powerpc-*-kaos*, + powerpcle-*-kaos*, sh*-*-kaos*, sparc-*-sysv4*, strongarm-*-elf*, + strongarm-*-pe, strongarm-*-kaos*, vax-*-bsd*, vax-*-sysv*, + vax-*-ultrix*, xscale-*-elf, xscale-*-coff): Remove. + +2008-05-25 Arthur Loiret <arthur.loiret@u-psud.fr> + + * config.host (sh2[lbe]*-*-linux*): Allow target. + +2008-04-30 Nathan Froyd <froydnj@codesourcery.com> + + * config/rs6000/t-ppccomm: Add build rules for new files. + (LIB2ADD_ST): New variable. + +2008-04-07 Andy Hutchinson <hutchinsonandy@aim.com> + + PR target/34210 + PR target/35508 + * config.host (avr-*-*): Add avr cpu_type and avr tmake_file. + * config/t-avr: New file. Build 16bit libgcc functions. + +2008-03-02 Jakub Jelinek <jakub@redhat.com> + + PR target/35401 + * config/t-slibgcc-darwin: Make install-leaf dependent on + install-darwin-libgcc-stubs instead of install. + +2008-01-25 Joseph Myers <joseph@codesourcery.com> + + * config.host (tic4x-*-*, c4x-*-rtems*, tic4x-*-rtems*, c4x-*, + tic4x-*, h8300-*-rtemscoff*, ns32k-*-netbsdelf*, ns32k-*-netbsd*, + sh-*-rtemscoff*): Remove cases. + +2007-12-27 Richard Sandiford <rsandifo@nildram.co.uk> + + * Makefile.in (all): Use install-leaf rather than install. + (install): Split most of the rule into... + (install-leaf): ...this new one. + +2007-12-19 Etsushi Kato <ek.kato@gmail.com> + Paolo Bonzini <bonzini@gnu.org> + + PR target/30572 + * Makefile.in: Use @shlib_slibdir@ substitution to get + correct install name on darwin. + * config/t-slibgcc-darwin: Use @shlib_slibdir@ for -install_name. + +2007-12-15 Hans-Peter Nilsson <hp@axis.com> + + * config.host (crisv32-*-elf, crisv32-*-none): New, same as + cris-*-elf and cris-*-none. + (crisv32-*-linux*): Similar, as cris-*-linux*. + +2007-11-20 Rask Ingemann Lambertsen <rask@sygehus.dk> + + * config.host (ia64*-*-elf*): Build ia64 specific libgcc parts. + +2007-10-27 H.J. Lu <hongjiu.lu@intel.com> + + PR regression/33926 + * configure.ac: Replace have_cc_tls with gcc_cv_have_cc_tls. + * configure: Regenerated. + +2007-09-27 H.J. Lu <hongjiu.lu@intel.com> + + * Makefile.in (dfp-filenames): Replace decimal_globals, + decimal_data, binarydecimal and convert_data with + bid_decimal_globals, bid_decimal_data, bid_binarydecimal + and bid_convert_data, respectively. + +2007-09-17 Chao-ying Fu <fu@mips.com> + Nigel Stephens <nigel@mips.com> + + * fixed-obj.mk: New file to support fine-grain fixed-point functions. + * Makefile.in (fixed_point): Define. + Check if fixed_point is yes to build support functions. + * configure.ac: Check for fixed_point support. + * configure: Regenerated. + * gen-fixed.sh: New file to generate lists of fixed-point labels, + funcs, modes, from, to. + +2007-09-11 Janis Johnson <janis187@us.ibm.com + + * Makefile.in (dfp-filenames): Add bid128_noncomp. + +2007-09-10 Janis Johnson <janis187@us.ibm.com> + + * Makefile.in (dfp-filenames): Remove decUtility, add + decDouble, decPacked, decQuad, decSingle. + +2007-08-27 Hans Kester <hans.kester@ellips.nl> + + * config.host : Add x86_64-elf target. + +2007-07-06 H.J. Lu <hongjiu.lu@intel.com> + + * configure.ac (set_have_cc_tls): Add a missing =. + * configure: Regenerated. + +2007-07-06 H.J. Lu <hongjiu.lu@intel.com> + + * config.host (tmake_file): Add t-tls for i[34567]86-*-linux* + and x86_64-*-linux*. + + * config/t-tls: New file. + + * Makefile.in (INTERNAL_CFLAGS): Add @set_have_cc_tls@. + + * configure.ac: Include ../config/enable.m4 and + ../config/tls.m4. Use GCC_CHECK_CC_TLS to check if assembler + supports TLS and substitute set_have_cc_tls. + * configure: Regenerated. + +2007-07-04 H.J. Lu <hongjiu.lu@intel.com> + + * Makefile.in: Use libbid for DFP when BID is enabled. + +2007-06-14 Danny Smith <dannysmith@users.sourceforge.net> + + * config.host(*-cygwin* |*-mingw* ): Add crtbegin.o, crtend.o to + extra_parts. Add config/i386/t-cygming to tmake_file. + * config/i386/t-cygming: New file with rules for crtbegin.o, crtend.o. + +2007-05-29 Zuxy Meng <zuxy.meng@gmail.com> + Danny Smith <dannysmith@users.sourceforge.net> + + PR target/29498 + * config.host (i[34567]86-*-cygwin* | i[34567]86-*-mingw*) Add + crtfastmath.o to extra_parts. Add i386/t-crtfm to tmake_file. + * config/i386/t-crtfm: Compile crtfastmath.o with + -minline-all-stringops. + +2007-05-10 Richard Sandiford <richard@codesourcery.com> + + * config.host (sparc-wrs-vxworks): New target. + +2007-04-14 Kazu Hirata <kazu@codesourcery.com> + + * config.host: Recognize fido. + +2007-04-04 Janis Johnson <janis187@us.ibm.com> + + * configure: Check host, not target, for decimal float support. + +2007-04-03 Uros Bizjak <ubizjak@gmail.com> + + * config/i386/t-crtpc: New file. + * config.host (i[34567]86-*-linux*): Add i386/t-crtpc to tm-file. + (x86_64-*-linux*): Ditto. + +2007-02-30 Kai Tietz <kai.tietz@onevision.com> + + * config.host (x86_64-*-mingw*): New target. + +2007-03-23 Michael Meissner <michael.meissner@amd.com> + H.J. Lu <hongjiu.lu@intel.com> + + * Makefile.in (enable_decimal_float): New. + (DECNUMINC): Add + -I$(srcdir)/../libdecnumber/$(enable_decimal_float). + (dec-objects): Move decimal32, decimal64 and decimal128 to ... + (decbits-filenames): This. + (decbits-objects): New. + (libgcc-objects): Add $(decbits-objects). + + * configure.ac: Support * --enable-decimal-float={no,yes,bid,dpd}. + Substitute enable_decimal_float. + * configure: Regenerated. + +2007-03-19 Hans-Peter Nilsson <hp@axis.com> + + * config.host (cris-*-elf | cris-*-none): Set extra_parts. + +2007-03-12 Brooks Moses <brooks.moses@codesourcery.com> + + * Makefile.in (install-info): New dummy target. + +2007-03-05 Bernd Schmidt <bernd.schmidt@analog.com> + + * config.host (bfin*-linux-uclibc*): Set extra_parts. + +2007-03-01 Brooks Moses <brooks.moses@codesourcery.com> + + * Makefile.in: Add install-html and install-pdf dummy + targets. + +2007-02-05 Roger Sayle <roger@eyesopen.com> + Daniel Jacobowitz <dan@codesourcery.com> + + * Makefile.in <LIBUNWIND>: Make libgcc_s.so depend on libunwind.so. + (libgcc_s.so): Append -B./ to CFLAGS for $(SHLIB_LINK). + (libunwind.so): Likewise for $(SHLIBUNWIND_LINK). + +2007-01-29 Janis Johnson <janis187@us.ibm.com> + + * Makefile.in (dec-filenames): Add decExcept. + +2007-01-28 Daniel Jacobowitz <dan@codesourcery.com> + + PR bootstrap/30469 + * Makefile.in (CFLAGS): Forcibly remove -fprofile-generate and + -fprofile-use. + +2007-01-25 Daniel Jacobowitz <dan@codesourcery.com> + + * configure.ac: Add --enable-version-specific-runtime-libs. + Correct $slibdir default. + * configure: Regenerated. + +2007-01-23 Joseph Myers <joseph@codesourcery.com> + + * config/rs6000/t-ldbl128: Always use -mlong-double-128. + +2007-01-21 Andrew Pinski <pinskia@gmail.com> + + PR target/30519 + * config.host (alpha*-*-linux*): Set extra_parts. + +2007-01-09 Kaz Kojima <kkojima@gcc.gnu.org> + + * config/sh/t-linux: New. + * config.host (sh*-*-linux*): Set tmake_file. + +2007-01-05 Daniel Jacobowitz <dan@codesourcery.com> + + * Makefile.in (install): Handle multilibs. + +2007-01-04 Brooks Moses <brooks.moses@codesourcery.com> + + * Makefile.in: Added .PHONY entry for documentation targets. + +2007-01-04 Brooks Moses <brooks.moses@codesourcery.com> + + * Makefile.in: Add empty info, html, dvi, pdf targets. + +2007-01-04 Mike Stump <mrs@apple.com> + + * Makefile.in (MAKEINFO): Remove. + (PERL): Likewise. + +2007-01-04 Paolo Bonzini <bonzini@gnu.org> + + * configure.ac: Add GCC_TOPLEV_SUBDIRS. + * configure: Regenerate. + * Makefile.in (host_subdir): Substitute it. + (gcc_objdir): Use it. + +2007-01-04 Daniel Jacobowitz <dan@codesourcery.com> + + * config.host (ia64*-*-linux*): Set tmake_file. + +2007-01-04 Daniel Jacobowitz <dan@codesourcery.com> + + * Makefile.in (version): Define. + +2007-01-03 Daniel Jacobowitz <dan@codesourcery.com> + Paolo Bonzini <bonzini@gnu.org> + + * Makefile.in, config/i386/t-darwin, config/i386/t-darwin64, + config/i386/t-nwld, config/rs6000/t-darwin, config/rs6000/t-ldbl128, + config/i386/t-crtfm, config/alpha/t-crtfm, config/ia64/t-ia64, + config/sparc/t-crtfm, config/t-slibgcc-darwin, + config/rs6000/t-ppccomm, config.host, configure.ac, empty.mk, + shared-object.mk, siditi-object.mk, static-object.mk: New files. + * configure: Generated. diff --git a/gcc-4.4.3/libgcc/Makefile.in b/gcc-4.4.3/libgcc/Makefile.in new file mode 100644 index 000000000..a7b3d829d --- /dev/null +++ b/gcc-4.4.3/libgcc/Makefile.in @@ -0,0 +1,971 @@ +# Makefile.in + +# Copyright (C) 2005, 2006, 2009 Free Software Foundation +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify it under the +# terms of the GNU Library General Public License as published by the Free +# Software Foundation; either version 3 of the License, 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. +# +# You should have received a copy of the GNU General Public License along +# with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. +# + +libgcc_topdir = @libgcc_topdir@ +host_subdir = @host_subdir@ + +gcc_srcdir = $(libgcc_topdir)/gcc +gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc + +srcdir = @srcdir@ + +prefix = @prefix@ + +exec_prefix = @exec_prefix@ +libdir = @libdir@ +shlib_slibdir = @slibdir@ + +SHELL = @SHELL@ + +enable_shared = @enable_shared@ +decimal_float = @decimal_float@ +enable_decimal_float = @enable_decimal_float@ +fixed_point = @fixed_point@ + +host_noncanonical = @host_noncanonical@ + +# List of extra object files that should be compiled for this target machine. +# The rules for compiling them should be in the t-* file for the machine. +EXTRA_PARTS = @extra_parts@ + +# Multilib support variables. +MULTISRCTOP = +MULTIBUILDTOP = +MULTIDIRS = +MULTISUBDIR = +MULTIDO = true +MULTICLEAN = true + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +mkinstalldirs = $(SHELL) $(libgcc_topdir)/mkinstalldirs + +objext = .o + +AR = @AR@ +AR_FLAGS = rc + +CC = @CC@ +CFLAGS = @CFLAGS@ +RANLIB = @RANLIB@ +LN_S = @LN_S@ + +PWD_COMMAND = $${PWDCMD-pwd} + +# Flags to pass to a recursive make. +FLAGS_TO_PASS = \ + "AR=$(AR)" \ + "AR_FLAGS=$(AR_FLAGS)" \ + "CC=$(CC)" \ + "CFLAGS=$(CFLAGS)" \ + "DESTDIR=$(DESTDIR)" \ + "EXTRA_OFILES=$(EXTRA_OFILES)" \ + "HDEFINES=$(HDEFINES)" \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LOADLIBES=$(LOADLIBES)" \ + "RANLIB=$(RANLIB)" \ + "SHELL=$(SHELL)" \ + "prefix=$(prefix)" \ + "exec_prefix=$(exec_prefix)" \ + "libdir=$(libdir)" \ + "libsubdir=$(libsubdir)" \ + "tooldir=$(tooldir)" + +# Dependencies for "all" are set later in the file. +all: all-multi + # Now that we have built all the objects, we need to copy + # them back to the GCC directory. Too many things (other + # in-tree libraries, and DejaGNU) know about the layout + # of the build tree, for now. + $(MAKE) install-leaf DESTDIR=$(gcc_objdir) \ + slibdir= libsubdir= MULTIOSDIR=$(MULTIDIR) + +.PHONY: all-multi +all-multi: + # If this is the top-level multilib, build all the other + # multilibs. + @: $(MAKE) ; exec $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all + +.PHONY: check installcheck +check: +installcheck: + +.PHONY: all clean + +clean: + -rm -f config.h stamp-h stmp-ldirs libgcc.map + -rm -f *$(objext) + -rm -f *.dep + -rm -f *.a + -rm -f libunwind$(SHLIB_EXT) + -rm -f libgcc_s* + @$(MULTICLEAN) multi-clean DO=clean +distclean: clean + @$(MULTICLEAN) multi-clean DO=distclean + -rm -f *~ Makefile config.cache config.status multilib.out + -rm -f config.log +maintainer-clean realclean: distclean + +Makefile: $(srcdir)/Makefile.in config.status + CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status + +# Depending on Makefile makes sure that config.status has been re-run +# if needed. This prevents problems with parallel builds. +config.h: stamp-h ; @true +stamp-h: $(srcdir)/config.in config.status Makefile + CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status + +config.status: $(srcdir)/configure $(srcdir)/config.host + $(SHELL) ./config.status --recheck + +include $(gcc_objdir)/libgcc.mvars + +# Flags to pass to recursive makes. + +AR_FOR_TARGET = $(AR) +AR_FLAGS_FOR_TARGET = +AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc +AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x +AWK = @AWK@ +GCC_FOR_TARGET = $(CC) +LIPO = @LIPO@ +LIPO_FOR_TARGET = $(LIPO) +MACHMODE_H = machmode.h mode-classes.def insn-modes.h +NM = @NM@ +NM_FOR_TARGET = $(NM) +RANLIB_FOR_TARGET = $(RANLIB) +STRIP = @STRIP@ +STRIP_FOR_TARGET = $(STRIP) + +# Directory in which the compiler finds libraries etc. +libsubdir = $(libdir)/gcc/$(host_noncanonical)/$(version) +# Used to install the shared libgcc. +slibdir = @slibdir@ + +export AR_FOR_TARGET +export AR_CREATE_FOR_TARGET +export AR_FLAGS_FOR_TARGET +export AR_EXTRACT_FOR_TARGET +export AWK +export DESTDIR +export GCC_FOR_TARGET +export INCLUDES +export INSTALL_DATA +export LIB1ASMSRC +export LIBGCC2_CFLAGS +export LIPO_FOR_TARGET +export MACHMODE_H +export NM_FOR_TARGET +export STRIP_FOR_TARGET +export RANLIB_FOR_TARGET +export libsubdir +export slibdir + +version := $(shell $(CC) -dumpversion) + +ifeq ($(decimal_float),yes) +ifeq ($(enable_decimal_float),bid) +DECNUMINC = -I$(srcdir)/config/libbid -DENABLE_DECIMAL_BID_FORMAT +else +DECNUMINC = -I$(srcdir)/../libdecnumber/$(enable_decimal_float) \ + -I$(srcdir)/../libdecnumber +endif +else +DECNUMINC = +endif + +# Specify the directories to be searched for header files. +# Both . and srcdir are used, in that order, +# so that *config.h will be found in the compilation +# subdirectory rather than in the source directory. +# -I$(@D) and -I$(srcdir)/$(@D) cause the subdirectory of the file +# currently being compiled, in both source trees, to be examined as well. +INCLUDES = -I. -I$(@D) -I$(gcc_objdir) \ + -I$(srcdir) -I$(srcdir)/$(@D) -I$(srcdir)/../gcc \ + -I$(srcdir)/../include $(DECNUMINC) + +# Forcibly remove any profiling-related flags. There is no point +# in supporting profiled bootstrap in this library. +override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS)) + +# CFLAGS first is not perfect; normally setting CFLAGS should override any +# options in LIBGCC2_CFLAGS. But LIBGCC2_CFLAGS may contain -g0, and CFLAGS +# will usually contain -g, so for the moment CFLAGS goes first. We must +# include CFLAGS - that's where multilib options live. +INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \ + $(INCLUDES) @set_have_cc_tls@ + +MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory) +MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory) + +MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); fi) +inst_libdir = $(libsubdir)$(MULTISUBDIR) +inst_slibdir = $(slibdir)$(MULTIOSSUBDIR) + +gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS) +compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep +gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps) +gcc_s_compile = $(gcc_compile) -DSHARED + +objects = $(filter %$(objext),$^) + +# Collect any host-specific information from Makefile fragments. +tmake_file = @tmake_file@ +include $(srcdir)/empty.mk $(tmake_file) + +# Only handle shared libraries if both: +# - the user requested them +# - we know how to build them +ifeq ($(SHLIB_LINK),) + enable_shared := no +endif + +ifeq ($(enable_shared),yes) + iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/shared-object.mk,$(iter-items)) + + install-shared = install-shared + + ifneq ($(LIBUNWIND),) + install-libunwind = install-libunwind + endif + +# For -fvisibility=hidden. We need both a -fvisibility=hidden on +# the command line, and a #define to prevent libgcc2.h etc from +# overriding that with #pragmas. +vis_hide = @vis_hide@ + +ifneq (,$(vis_hide)) + +# If we have -fvisibility=hidden, then we need to generate hide +# lists for object files implemented in assembly. +ASM_HIDDEN_OP = @asm_hidden_op@ + +define gen-hide-list +$(NM) -pg $< | \ + $(AWK) 'NF == 3 && $$2 !~ /^[UN]$$/ && $$3 !~ /.*_compat/ \ + && $$3 !~ /.*@.*/ \ + { print "\t$(ASM_HIDDEN_OP)", $$3 }' > $@T +mv -f $@T $@ +endef +else +gen-hide-list = echo > $@ +endif + +else +# Not enable_shared. +iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items)) +vis_hide = +gen-hide-list = echo > \$@ +endif + +ifneq ($(EXTRA_PARTS),) + extra-parts = libgcc-extra-parts + INSTALL_PARTS = $(EXTRA_PARTS) +else +ifneq ($(GCC_EXTRA_PARTS),) + extra-parts = gcc-extra-parts + INSTALL_PARTS = $(GCC_EXTRA_PARTS) +endif +endif + +# Library members defined in libgcc2.c. +lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \ + _clear_cache _enable_execute_stack _trampoline __main _absvsi2 \ + _absvdi2 _addvsi3 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \ + _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 \ + _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2 \ + _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2 \ + _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 \ + _divtc3 _bswapsi2 _bswapdi2 + +# The floating-point conversion routines that involve a single-word integer. +# XX stands for the integer mode. +swfloatfuncs = $(patsubst %,_fixuns%XX,sf df xf) + +# Likewise double-word routines. +dwfloatfuncs = $(patsubst %,_fix%XX,sf df xf tf) \ + $(patsubst %,_fixuns%XX,sf df xf tf) \ + $(patsubst %,_floatXX%,sf df xf tf) \ + $(patsubst %,_floatunXX%,sf df xf tf) + +ifeq ($(LIB2_SIDITI_CONV_FUNCS),) + lib2funcs += $(subst XX,si,$(swfloatfuncs)) + lib2funcs += $(subst XX,di,$(dwfloatfuncs)) +endif + +# 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 + +# Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are +# defined as optimized assembly code in LIB1ASMFUNCS or as C code +# in LIB2FUNCS_EXCLUDE. +lib2funcs := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS),$(lib2funcs)) +LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \ + $(LIB2_DIVMOD_FUNCS)) + +# Build "libgcc1" (assembly) components. +ifeq ($(enable_shared),yes) + +lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS)) +$(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC) %.vis + $(gcc_compile) -DL$* -xassembler-with-cpp \ + -c $(gcc_srcdir)/config/$(LIB1ASMSRC) -include $*.vis +$(patsubst %,%.vis,$(LIB1ASMFUNCS)): %.vis: %_s$(objext) + $(gen-hide-list) +libgcc-objects += $(lib1asmfuncs-o) + +lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS)) +$(lib1asmfuncs-s-o): %_s$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC) + $(gcc_s_compile) -DL$* -xassembler-with-cpp \ + -c $(gcc_srcdir)/config/$(LIB1ASMSRC) +libgcc-s-objects += $(lib1asmfuncs-s-o) + +else + +lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS)) +$(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC) + $(gcc_compile) -DL$* -xassembler-with-cpp \ + -c $(gcc_srcdir)/config/$(LIB1ASMSRC) +libgcc-objects += $(lib1asmfuncs-o) + +endif + +# Build lib2funcs. For the static library also include LIB2FUNCS_ST. +lib2funcs-o = $(patsubst %,%$(objext),$(lib2funcs) $(LIB2FUNCS_ST)) +$(lib2funcs-o): %$(objext): $(gcc_srcdir)/libgcc2.c + $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \ + $(vis_hide) +libgcc-objects += $(lib2funcs-o) + +ifeq ($(enable_shared),yes) +lib2funcs-s-o = $(patsubst %,%_s$(objext),$(lib2funcs)) +$(lib2funcs-s-o): %_s$(objext): $(gcc_srcdir)/libgcc2.c + $(gcc_s_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c +libgcc-s-objects += $(lib2funcs-s-o) +endif + +ifneq ($(LIB2_SIDITI_CONV_FUNCS),) +# Build libgcc2.c for each conversion function, with a specific +# L<func> definition and LIBGCC2_UNITS_PER_WORD setting. The DImode +# functions are built with a wordsize of 4; the TImode functions are +# built with the same labels, but a wordsize of 8. + +sifuncs = $(subst XX,si,$(swfloatfuncs)) +difuncs = $(subst XX,di,$(dwfloatfuncs)) +tifuncs = $(subst XX,ti,$(dwfloatfuncs)) + +iter-items := $(sifuncs) $(difuncs) $(tifuncs) +iter-labels := $(sifuncs) $(difuncs) $(difuncs) +iter-sizes := $(patsubst %,4,$(sifuncs) $(difuncs)) $(patsubst %,8,$(tifuncs)) + +include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/siditi-object.mk,$(iter-items)) + +libgcc-objects += $(patsubst %,%$(objext),$(sifuncs) $(difuncs) $(tifuncs)) +ifeq ($(enable_shared),yes) +libgcc-s-objects += $(patsubst %,%_s$(objext),$(sifuncs) $(difuncs) $(tifuncs)) +endif +endif + +# Build LIB2_DIVMOD_FUNCS. +lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS)) +$(lib2-divmod-o): %$(objext): $(gcc_srcdir)/libgcc2.c + $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \ + -fexceptions -fnon-call-exceptions $(vis_hide) +libgcc-objects += $(lib2-divmod-o) + +ifeq ($(enable_shared),yes) +lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS)) +$(lib2-divmod-s-o): %_s$(objext): $(gcc_srcdir)/libgcc2.c + $(gcc_s_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \ + -fexceptions -fnon-call-exceptions +libgcc-s-objects += $(lib2-divmod-s-o) +endif + +# $(FPBIT) et al. are pathnames relative to the GCC build +# directory; the supporting files are made by the GCC +# Makefile. +# FIXME: Soon we will be able to move this logic into this directory. + +ifneq ($(fpbit-in-libgcc),yes) +FPBIT:=$(if $(FPBIT),$(gcc_objdir)/$(FPBIT),) +DPBIT:=$(if $(DPBIT),$(gcc_objdir)/$(DPBIT),) +TPBIT:=$(if $(TPBIT),$(gcc_objdir)/$(TPBIT),) +endif + +ifeq ($(TPBIT),) +# _sf_to_tf and _df_to_tf require tp-bit.c being compiled in. +FPBIT_FUNCS := $(filter-out _sf_to_tf,$(FPBIT_FUNCS)) +DPBIT_FUNCS := $(filter-out _df_to_tf,$(DPBIT_FUNCS)) +endif + +# Build FPBIT. +ifneq ($(FPBIT),) +fpbit-o = $(patsubst %,%$(objext),$(FPBIT_FUNCS)) +$(fpbit-o): %$(objext): $(FPBIT) + $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(FPBIT) $(vis_hide) +libgcc-objects += $(fpbit-o) + +ifeq ($(enable_shared),yes) +fpbit-s-o = $(patsubst %,%_s$(objext),$(FPBIT_FUNCS)) +$(fpbit-s-o): %_s$(objext): $(FPBIT) + $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(FPBIT) +libgcc-s-objects += $(fpbit-s-o) +endif +endif + +# Build DPBIT. +ifneq ($(DPBIT),) +dpbit-o = $(patsubst %,%$(objext),$(DPBIT_FUNCS)) +$(dpbit-o): %$(objext): $(DPBIT) + $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(DPBIT) $(vis_hide) +libgcc-objects += $(dpbit-o) + +ifeq ($(enable_shared),yes) +dpbit-s-o = $(patsubst %,%_s$(objext),$(DPBIT_FUNCS)) +$(dpbit-s-o): %_s$(objext): $(DPBIT) + $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(DPBIT) +libgcc-s-objects += $(dpbit-s-o) +endif +endif + +# Build TPBIT. +ifneq ($(TPBIT),) +tpbit-o = $(patsubst %,%$(objext),$(TPBIT_FUNCS)) +$(tpbit-o): %$(objext): $(TPBIT) + $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(TPBIT) $(vis_hide) +libgcc-objects += $(tpbit-o) + +ifeq ($(enable_shared),yes) +tpbit-s-o = $(patsubst %,%_s$(objext),$(TPBIT_FUNCS)) +$(tpbit-s-o): %_s$(objext): $(TPBIT) + $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(TPBIT) +libgcc-s-objects += $(tpbit-s-o) +endif +endif + +# Build decimal floating point support. +ifeq ($(decimal_float),yes) + +# If $DFP_ENABLE is set, then we want all data type sizes. +ifneq ($(DFP_ENABLE),) +D32PBIT = 1 +D64PBIT = 1 +D128PBIT = 1 +endif + +dfp-filenames = +ifneq ($(D32PBIT)$(D64PBIT)$(D128PBIT),) +ifeq ($(enable_decimal_float),bid) +dfp-filenames += bid_decimal_globals bid_decimal_data \ + bid_binarydecimal bid_convert_data \ + _isinfd32 _isinfd64 _isinfd128 bid64_noncomp \ + bid128_noncomp bid128_fma bid_round bid_from_int \ + bid64_add bid128_add bid64_div bid128_div \ + bid64_mul bid128_mul bid64_compare bid128_compare \ + bid128 bid32_to_bid64 bid32_to_bid128 bid64_to_bid128 \ + bid64_to_int32 bid64_to_int64 \ + bid64_to_uint32 bid64_to_uint64 \ + bid128_to_int32 bid128_to_int64 \ + bid128_to_uint32 bid128_to_uint64 +else +dfp-filenames += decContext decNumber decExcept decRound decLibrary decDouble decPacked decQuad decSingle +endif +endif + +dfp-objects = $(patsubst %,%$(objext),$(dfp-filenames)) +ifeq ($(enable_decimal_float),bid) +$(dfp-objects): %$(objext): $(srcdir)/config/libbid/%.c +else +$(dfp-objects): %$(objext): $(srcdir)/../libdecnumber/%.c +endif + $(gcc_compile) -c $< +libgcc-objects += $(dfp-objects) + +decbits-filenames = +ifneq ($(enable_decimal_float),bid) +ifneq ($(D32PBIT),) +decbits-filenames += decimal32 +endif + +ifneq ($(D64PBIT),) +decbits-filenames += decimal64 +endif + +ifneq ($(D128PBIT),) +decbits-filenames += decimal128 +endif +endif + +decbits-objects = $(patsubst %,%$(objext),$(decbits-filenames)) +ifeq ($(enable_decimal_float),bid) +$(decbits-objects): %$(objext): $(srcdir)/config/libbid/%.c +else +$(decbits-objects): %$(objext): $(srcdir)/../libdecnumber/$(enable_decimal_float)/%.c +endif + $(gcc_compile) -c $< +libgcc-objects += $(decbits-objects) + +# Next build individual support functions. +ifeq ($(enable_decimal_float),bid) +ifneq ($(D32PBIT),) +D32PBIT_FUNCS:=$(filter-out _plus_sd _minus_sd _conv_sd, $(D32PBIT_FUNCS)) +endif + +ifneq ($(D64PBIT),) +D64PBIT_FUNCS:=$(filter-out _plus_dd _minus_dd _conv_dd, $(D64PBIT_FUNCS)) +endif + +ifneq ($(D128PBIT),) +D128PBIT_FUNCS:=$(filter-out _plus_td _minus_td _conv_td, $(D128PBIT_FUNCS)) +endif +endif + +ifneq ($(D32PBIT),) +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 +endif + $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=32 -c $< +libgcc-objects += $(d32pbit-o) +endif + +ifneq ($(D64PBIT),) +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 +endif + $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=64 -c $< +libgcc-objects += $(d64pbit-o) +endif + +ifneq ($(D128PBIT),) +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 +endif + $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=128 -c $< +libgcc-objects += $(d128pbit-o) +endif + +endif + +ifeq ($(LIBGCC_SYNC),yes) +libgcc-sync-size-funcs := $(foreach op, add sub or and xor nand, \ + sync_fetch_and_$(op) \ + sync_$(op)_and_fetch) \ + sync_bool_compare_and_swap \ + sync_val_compare_and_swap \ + sync_lock_test_and_set + +libgcc-sync-size-funcs := $(foreach prefix, $(libgcc-sync-size-funcs), \ + $(foreach suffix, 1 2 4 8 16, \ + $(prefix)_$(suffix))) + +libgcc-sync-size-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-size-funcs)) +$(libgcc-sync-size-funcs-o): %$(objext): $(gcc_srcdir)/config/sync.c + $(gcc_compile) $(LIBGCC_SYNC_CFLAGS) \ + -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \ + -DSIZE=`echo "$*" | sed 's/.*_//'` \ + -c $(gcc_srcdir)/config/sync.c $(vis_hide) +libgcc-objects += $(libgcc-sync-size-funcs-o) + +libgcc-sync-funcs := sync_synchronize + +libgcc-sync-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-funcs)) +$(libgcc-sync-funcs-o): %$(objext): $(gcc_srcdir)/config/sync.c + $(gcc_compile) $(LIBGCC_SYNC_CFLAGS) \ + -DL$* \ + -c $(gcc_srcdir)/config/sync.c $(vis_hide) +libgcc-objects += $(libgcc-sync-funcs-o) + +ifeq ($(enable_shared),yes) +libgcc-sync-size-funcs-s-o = $(patsubst %,%_s$(objext), \ + $(libgcc-sync-size-funcs)) +$(libgcc-sync-size-funcs-s-o): %_s$(objext): $(gcc_srcdir)/config/sync.c + $(gcc_s_compile) $(LIBGCC_SYNC_CFLAGS) \ + -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \ + -DSIZE=`echo "$*" | sed 's/.*_//'` \ + -c $(gcc_srcdir)/config/sync.c +libgcc-s-objects += $(libgcc-sync-size-funcs-s-o) + +libgcc-sync-funcs-s-o = $(patsubst %,%_s$(objext),$(libgcc-sync-funcs)) +$(libgcc-sync-funcs-s-o): %_s$(objext): $(gcc_srcdir)/config/sync.c + $(gcc_s_compile) $(LIBGCC_SYNC_CFLAGS) \ + -DL$* \ + -c $(gcc_srcdir)/config/sync.c +libgcc-s-objects += $(libgcc-sync-funcs-s-o) +endif +endif + +# Build fixed-point support. +ifeq ($(fixed_point),yes) + +# Generate permutations of function name and mode +fixed-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith labels) +fixed-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith funcs) +fixed-modes := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith modes) + +# Generate the rules for each arithmetic function +iter-items := $(fixed-funcs) +iter-labels := $(fixed-labels) +iter-from := $(fixed-modes) +iter-to := $(fixed-modes) +include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items)) + +# Add arithmetic functions to list of objects to be built +libgcc-objects += $(patsubst %,%$(objext),$(fixed-funcs)) +ifeq ($(enable_shared),yes) +libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-funcs)) +endif + +# Convert from or to fractional +fixed-conv-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv funcs) +fixed-conv-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv labels) +fixed-conv-from := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv from) +fixed-conv-to := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv to) + +# Generate the make rules for each conversion function +iter-items := $(fixed-conv-funcs) +iter-labels := $(fixed-conv-labels) +iter-from := $(fixed-conv-from) +iter-to := $(fixed-conv-to) +include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items)) + +# Add conversion functions to list of objects to be built +libgcc-objects += $(patsubst %,%$(objext),$(fixed-conv-funcs)) +ifeq ($(enable_shared),yes) +libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-conv-funcs)) +endif + +endif + +# Build LIB2ADD and LIB2ADD_ST. +ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),) +$(error Unsupported files in LIB2ADD or LIB2ADD_ST.) +endif + +libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD)))) +libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST)))) + +c_flags := +iter-items := $(LIB2ADD) $(LIB2ADD_ST) +include $(iterator) + +ifeq ($(enable_shared),yes) +libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADD)))) +endif + +# Build LIB2ADDEH, LIB2ADDEHSTATIC, and LIB2ADDEHSHARED. If we don't have +# libgcc_eh.a, only LIB2ADDEH matters. If we do, only LIB2ADDEHSTATIC and +# LIB2ADDEHSHARED matter. (Usually all three are identical.) + +c_flags := -fexceptions + +ifeq ($(enable_shared),yes) + +libgcc-eh-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEHSTATIC)))) +libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADDEHSHARED)))) + +iter-items := $(sort $(LIB2ADDEHSTATIC) $(LIB2ADDEHSHARED)) +include $(iterator) + +else +# Not shared. LIB2ADDEH are added to libgcc.a. + +libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEH)))) + +iter-items := $(LIB2ADDEH) +include $(iterator) + +endif + +# Build LIBUNWIND. + +c_flags := -fexceptions + +libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND)))) + +ifeq ($(enable_shared),yes) +libunwind-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIBUNWIND)))) +endif + +iter-items := $(LIBUNWIND) +include $(iterator) + +# Build libgcov components. +libgcov-objects = $(patsubst %,%$(objext),$(LIBGCOV)) +$(libgcov-objects): %$(objext): $(gcc_srcdir)/libgcov.c + $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcov.c + +dyn-ipa.o: %$(objext): $(gcc_srcdir)/libgcov.c + $(gcc_compile) -c $(gcc_srcdir)/dyn-ipa.c + + +# Static libraries. +libgcc.a: $(libgcc-objects) +libgcov.a: $(libgcov-objects) dyn-ipa$(objext) +libunwind.a: $(libunwind-objects) +libgcc_eh.a: $(libgcc-eh-objects) + +libgcc.a libgcov.a libunwind.a libgcc_eh.a: + -rm -f $@ + + objects="$(objects)"; \ + if test -z "$$objects"; then \ + echo 'int __libgcc_eh_dummy;' > eh_dummy.c; \ + $(gcc_compile_bare) $(vis_hide) -c eh_dummy.c \ + -o eh_dummy$(objext); \ + objects=eh_dummy$(objext); \ + fi; \ + $(AR_CREATE_FOR_TARGET) $@ $$objects + + $(RANLIB) $@ + +all: libgcc.a libgcov.a + +ifneq ($(LIBUNWIND),) +all: libunwind.a +libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) +endif + +ifeq ($(enable_shared),yes) +all: libgcc_eh.a libgcc_s$(SHLIB_EXT) +ifneq ($(LIBUNWIND),) +all: libunwind$(SHLIB_EXT) +endif +endif + +ifeq ($(enable_shared),yes) + +# Map-file generation. +ifneq ($(SHLIB_MKMAP),) +libgcc.map: $(SHLIB_MKMAP) $(SHLIB_MAPFILES) $(libgcc-s-objects) + { $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \ + cat $(SHLIB_MAPFILES) \ + | sed -e '/^[ ]*#/d' \ + -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \ + | $(gcc_compile_bare) -E -xassembler-with-cpp -; \ + } | $(AWK) -f $(SHLIB_MKMAP) $(SHLIB_MKMAP_OPTS) > tmp-$@ + mv tmp-$@ $@ +libgcc_s$(SHLIB_EXT): libgcc.map +mapfile = libgcc.map +endif + +libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts) + # @multilib_flags@ is still needed because this may use + # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly. + # @multilib_dir@ is not really necessary, but sometimes it has + # more uses than just a directory name. + $(mkinstalldirs) $(MULTIDIR) + $(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \ + @multilib_dir@,$(MULTIDIR),$(subst \ + @shlib_objs@,$(objects),$(subst \ + @shlib_base_name@,libgcc_s,$(subst \ + @shlib_map_file@,$(mapfile),$(subst \ + @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \ + @shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK)))))))) + +libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts) + # @multilib_flags@ is still needed because this may use + # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly. + # @multilib_dir@ is not really necessary, but sometimes it has + # more uses than just a directory name. + $(mkinstalldirs) $(MULTIDIR) + $(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \ + @multilib_dir@,$(MULTIDIR),$(subst \ + @shlib_objs@,$(objects),$(subst \ + @shlib_base_name@,libunwind,$(subst \ + @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_LINK)))))) + +endif + +# Build the standard GCC startfiles and endfiles. +ALL_CRT_CFLAGS = $(CFLAGS) $(CRTSTUFF_CFLAGS) $(INCLUDES) +crt_compile = $(CC) $(ALL_CRT_CFLAGS) -o $@ $(compile_deps) + +ifeq ($(CUSTOM_CRTSTUFF),) +crtbegin$(objext): $(gcc_srcdir)/crtstuff.c + $(crt_compile) $(CRTSTUFF_T_CFLAGS) \ + -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN + +crtend$(objext): $(gcc_srcdir)/crtstuff.c + $(crt_compile) $(CRTSTUFF_T_CFLAGS) \ + -c $(gcc_srcdir)/crtstuff.c -DCRT_END + +# These are versions of crtbegin and crtend for shared libraries. +crtbeginS$(objext): $(gcc_srcdir)/crtstuff.c + $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \ + -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O + +crtendS$(objext): $(gcc_srcdir)/crtstuff.c + $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \ + -c $(gcc_srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O + +# This is a version of crtbegin for -static links. +crtbeginT.o: $(gcc_srcdir)/crtstuff.c + $(crt_compile) $(CRTSTUFF_T_CFLAGS) \ + -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O +endif + +# Build extra startfiles in the libgcc directory. +.PHONY: libgcc-extra-parts +libgcc-extra-parts: $(EXTRA_PARTS) +ifneq ($(GCC_EXTRA_PARTS),) +ifneq ($(sort $(EXTRA_PARTS)),$(GCC_EXTRA_PARTS)) + # If the gcc directory specifies which extra parts to + # build for this target, and the libgcc configuration also + # specifies, make sure they match. This can be removed + # when the gcc directory no longer holds libgcc configuration; + # it is useful when migrating a target. + @echo "Configuration mismatch!" + @echo "Extra parts from gcc directory: $(GCC_EXTRA_PARTS)" + @echo "Extra parts from libgcc: $(EXTRA_PARTS)" + exit 1 +endif +endif + + # Early copyback; see "all" above for the rationale. The + # early copy is necessary so that the gcc -B options find + # the right startup files when linking shared libgcc. + $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR) + parts="$(EXTRA_PARTS)"; \ + for file in $$parts; do \ + rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \ + $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/; \ + done + +# Build extra startfiles in the gcc directory, for unconverted +# targets. +.PHONY: gcc-extra-parts +gcc-extra-parts: + # Recursively invoke make in the GCC directory to build any + # startfiles (for now). We must do this just once, passing + # it all the GCC_EXTRA_PARTS as simultaneous goal targets, + # so that rules which cannot execute simultaneously are properly + # serialized. We indirect through T_TARGET in case any multilib + # directories contain an equals sign, to prevent make from + # interpreting any of the goals as variable assignments. + + # We must use cd && make rather than make -C, or else the stage + # number will be embedded in debug information. + + T=`$(PWD_COMMAND)`/ \ + && cd $(gcc_objdir) \ + && $(MAKE) GCC_FOR_TARGET="$(CC)" \ + MULTILIB_CFLAGS="$(CFLAGS)" \ + T=$$T \ + T_TARGET="$(patsubst %,$${T}%,$(GCC_EXTRA_PARTS))" \ + T_TARGET + + # Early copyback; see "all" above for the rationale. The + # early copy is necessary so that the gcc -B options find + # the right startup files when linking shared libgcc. + $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR) + parts="$(GCC_EXTRA_PARTS)"; \ + for file in $$parts; do \ + rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \ + $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/; \ + done + +all: $(extra-parts) + +# Documentation targets (empty). +.PHONY: info html dvi pdf install-info install-html install-pdf + +info: +install-info: +html: +install-html: +dvi: +pdf: +install-pdf: + +# Install rules. These do not depend on "all", so that they can be invoked +# recursively from it. +install-libunwind: + $(mkinstalldirs) $(DESTDIR)$(inst_slibdir) + + # NOTE: Maybe this should go into $(inst_libdir), but this + # is where the old mklibgcc.in put it. + $(INSTALL_DATA) libunwind.a $(DESTDIR)$(inst_slibdir)/ + chmod 644 $(DESTDIR)$(inst_slibdir)/libunwind.a + $(RANLIB) $(DESTDIR)$(inst_slibdir)/libunwind.a + + $(subst @multilib_dir@,$(MULTIDIR),$(subst \ + @shlib_base_name@,libunwind,$(subst \ + @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_INSTALL)))) + +install-shared: + $(mkinstalldirs) $(DESTDIR)$(inst_libdir) + + $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ + chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a + $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a + + $(subst @multilib_dir@,$(MULTIDIR),$(subst \ + @shlib_base_name@,libgcc_s,$(subst \ + @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL)))) + +install-leaf: $(install-shared) $(install-libunwind) + $(mkinstalldirs) $(DESTDIR)$(inst_libdir) + + $(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/ + chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a + $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a + $(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/ + chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a + $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a + + parts="$(INSTALL_PARTS)"; \ + for file in $$parts; do \ + rm -f $(DESTDIR)$(inst_libdir)/$$file; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(inst_libdir)/; \ + done + +install: install-leaf + @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install + +.PHONY: install install-shared install-libunwind + +# Don't export variables to the environment, in order to not confuse +# configure. +.NOEXPORT: + +include $(srcdir)/empty.mk $(wildcard *.dep) + +# TODO QUEUE: +# Garbage collect in gcc/: +# $(LIBGCC) settings in t-* are now unused +# +# Remove use of $(gcc_srcdir). Source files referenced using $(gcc_srcdir) +# should move into the libgcc directory. + diff --git a/gcc-4.4.3/libgcc/config.host b/gcc-4.4.3/libgcc/config.host new file mode 100644 index 000000000..55af65160 --- /dev/null +++ b/gcc-4.4.3/libgcc/config.host @@ -0,0 +1,608 @@ +# libgcc host-specific configuration file. +# Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +# 2008, 2009 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. + +#You should have received a copy of the GNU General Public License +#along with GCC; see the file COPYING3. If not see +#<http://www.gnu.org/licenses/>. + +# This is the libgcc host-specific configuration file +# where a configuration type is mapped to different system-specific +# definitions and files. This is invoked by the autoconf-generated +# configure script. Putting it in a separate shell file lets us skip +# running autoconf when modifying host-specific information. + +# This file bears an obvious resemblance to gcc/config.gcc. The cases +# should be kept similar, to ease moving library-specific settings +# from config.gcc to this file. That is also why tmake_file is +# left as tmake_file, rather than hmake_file, even though this library +# switches on ${host}. + +# This file switches on the shell variable ${host}, and also uses the +# following shell variables: +# +# with_* Various variables as set by configure. + +# This file sets the following shell variables for use by the +# autoconf-generated configure script: +# +# asm_hidden_op The assembler pseudo-op to use for hide +# lists for object files implemented in +# assembly (with -fvisibility=hidden for C). +# The default is ".hidden". +# cpu_type The name of the cpu, if different from the first +# chunk of the canonical host name. +# extra_parts List of extra object files that should be compiled +# for this target machine. This may be overridden +# by setting EXTRA_PARTS in a tmake_file fragment. +# If either is set, EXTRA_PARTS and +# EXTRA_MULTILIB_PARTS inherited from the GCC +# subdirectory will be ignored. +# tmake_file A list of machine-description-specific +# makefile-fragments, if different from +# "$cpu_type/t-$cpu_type". + +asm_hidden_op=.hidden +extra_parts= +tmake_file= + +# Set default cpu_type so it can be updated in each machine entry. +cpu_type=`echo ${host} | sed 's/-.*$//'` +case ${host} in +m32c*-*-*) + cpu_type=m32c + ;; +alpha*-*-*) + cpu_type=alpha + ;; +am33_2.0-*-linux*) + cpu_type=mn10300 + ;; +arm*-*-*) + cpu_type=arm + ;; +avr-*-*) + cpu_type=avr + ;; +bfin*-*) + cpu_type=bfin + ;; +fido-*-*) + cpu_type=m68k + ;; +frv*) cpu_type=frv + ;; +i[34567]86-*-*) + cpu_type=i386 + ;; +x86_64-*-*) + cpu_type=i386 + ;; +ia64-*-*) + ;; +hppa*-*-*) + cpu_type=pa + ;; +m32r*-*-*) + cpu_type=m32r + ;; +m68k-*-*) + ;; +mips*-*-*) + cpu_type=mips + ;; +powerpc*-*-*) + cpu_type=rs6000 + ;; +rs6000*-*-*) + ;; +score*-*-*) + cpu_type=score + ;; +sparc64*-*-*) + cpu_type=sparc + ;; +sparc*-*-*) + cpu_type=sparc + ;; +spu*-*-*) + cpu_type=spu + ;; +s390*-*-*) + cpu_type=s390 + ;; +# Note the 'l'; we need to be able to match e.g. "shle" or "shl". +sh[123456789lbe]*-*-*) + cpu_type=sh + ;; +esac + +# Common parts for widely ported systems. +case ${host} in +*-*-darwin*) + asm_hidden_op=.private_extern + tmake_file="t-darwin ${cpu_type}/t-darwin t-slibgcc-darwin" + ;; +*-*-freebsd[12] | *-*-freebsd[12].* | *-*-freebsd*aout*) + # This is the place-holder for the generic a.out configuration + # of FreeBSD. No actual configuration resides here since + # there was only ever a bare-bones ix86 configuration for + # a.out and it exists solely in the machine-specific section. + # This place-holder must exist to avoid dropping into + # the generic ELF configuration of FreeBSD (i.e. it must be + # ordered before that section). + ;; +*-*-freebsd*) + # This is the generic ELF configuration of FreeBSD. Later + # machine-specific sections may refine and add to this + # configuration. + ;; +*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu*) + extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o" + ;; +*-*-netbsd*) + ;; +*-*-openbsd*) + ;; +*-*-rtems*) + ;; +*-*-vxworks*) + ;; +*-*-elf) + ;; +esac + +case ${host} in +# Support site-specific machine types. +*local*) + rest=`echo ${host} | sed -e "s/$cpu_type-//"` + if test -f $srcdir/config/${cpu_type}/t-$rest + then tmake_file=${cpu_type}/t-$rest + fi + ;; +alpha*-*-linux* | alpha*-*-gnu*) + tmake_file="${tmake_file} alpha/t-crtfm" + extra_parts="$extra_parts crtfastmath.o" + ;; +alpha*-*-freebsd*) + ;; +alpha*-*-netbsd*) + ;; +alpha*-*-openbsd*) + ;; +alpha*-dec-osf[45]*) + ;; +alpha64-dec-*vms*) + ;; +alpha*-dec-*vms*) + ;; +arc-*-elf*) + ;; +arm-*-coff* | armel-*-coff*) + ;; +arm-semi-aof | armel-semi-aof) + ;; +arm-wrs-vxworks) + ;; +arm*-*-freebsd*) + ;; +arm*-*-netbsdelf*) + ;; +arm*-*-netbsd*) + ;; +arm*-*-linux*) # ARM GNU/Linux with ELF + ;; +arm*-*-uclinux*) # ARM ucLinux + ;; +arm*-*-ecos-elf) + ;; +arm*-*-eabi* | arm*-*-symbianelf* ) + ;; +arm*-*-rtems*) + ;; +arm*-*-elf) + ;; +arm*-wince-pe*) + ;; +arm-*-pe*) + ;; +avr-*-rtems*) + ;; +avr-*-*) + # Make HImode functions for AVR + tmake_file=${cpu_type}/t-avr + ;; +bfin*-elf*) + ;; +bfin*-uclinux*) + ;; +bfin*-linux-uclibc*) + # No need to build crtbeginT.o on uClibc systems. Should probably + # be moved to the OS specific section above. + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o" + ;; +bfin*-*) + ;; +crisv32-*-elf | crisv32-*-none | cris-*-elf | cris-*-none) + extra_parts="crtbegin.o crtend.o" + ;; +cris-*-linux* | crisv32-*-linux*) + ;; +crx-*-elf) + ;; +fido-*-elf) + ;; +fr30-*-elf) + ;; +frv-*-elf) + ;; +frv-*-*linux*) + ;; +h8300-*-rtems*) + ;; +h8300-*-elf*) + ;; +h8300-*-*) + ;; +hppa*64*-*-linux*) + ;; +hppa*-*-linux*) + ;; +hppa[12]*-*-hpux10*) + ;; +hppa*64*-*-hpux11*) + ;; +hppa[12]*-*-hpux11*) + ;; +i[34567]86-*-darwin*) + ;; +x86_64-*-darwin*) + tmake_file="t-darwin ${cpu_type}/t-darwin64 t-slibgcc-darwin" + ;; +i[34567]86-*-elf*) + ;; +x86_64-*-elf*) + ;; +i[34567]86-*-aout*) + ;; +i[34567]86-*-freebsd*) + ;; +x86_64-*-freebsd*) + ;; +i[34567]86-*-netbsdelf*) + ;; +i[34567]86-*-netbsd*) + ;; +x86_64-*-netbsd*) + ;; +i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123]) + ;; +i[34567]86-*-openbsd*) + ;; +i[34567]86-*-coff*) + ;; +i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i[34567]86-*-gnu*) + extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" + tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm" + ;; +x86_64-*-linux* | 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" + ;; +i[34567]86-pc-msdosdjgpp*) + ;; +i[34567]86-*-lynxos*) + ;; +i[3456x]86-*-netware*) + case /${with_ld} in + */nwld) + tmake_file="${tmake_file} i386/t-nwld" + ;; + esac + ;; +i[34567]86-*-nto-qnx*) + ;; +i[34567]86-*-rtems*) + ;; +i[34567]86-*-solaris2*) + tmake_file="${tmake_file} i386/t-sol2" + case ${host} in + *-*-solaris2.1[0-9]*) + # Solaris 2.10 provides crt1.o, crti.o, crtn.o, and gcrt1.o as + # part of the base system. + extra_parts="gmon.o crtbegin.o crtend.o" + ;; + *) + extra_parts="crt1.o crti.o crtn.o gcrt1.o gmon.o crtbegin.o crtend.o" + ;; + esac + ;; +i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae) + ;; +i[34567]86-*-pe) + ;; +i[34567]86-*-cygwin* | i[34567]86-*-mingw*) + extra_parts="crtbegin.o crtend.o crtfastmath.o" + tmake_file="i386/t-cygming i386/t-crtfm" + ;; +x86_64-*-mingw*) + ;; +i[34567]86-*-interix3*) + ;; +ia64*-*-elf*) + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtfastmath.o" + tmake_file="ia64/t-ia64" + ;; +ia64*-*-freebsd*) + ;; +ia64*-*-linux*) + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtfastmath.o" + tmake_file="ia64/t-ia64 t-softfp ia64/t-fprules-softfp ia64/t-softfp-compat" + ;; +ia64*-*-hpux*) + ;; +iq2000*-*-elf*) + ;; +m32r-*-elf*|m32r-*-rtems*) + ;; +m32rle-*-elf*) + ;; +m32r-*-linux*) + ;; +m32rle-*-linux*) + ;; +m68hc11-*-*|m6811-*-*) + ;; +m68hc12-*-*|m6812-*-*) + ;; +m68k-*-aout*) + ;; +m68k-*-coff*) + ;; +m68k-*-elf*) + ;; +m68k*-*-netbsdelf*) + ;; +m68k*-*-openbsd*) + ;; +m68k-*-uclinux*) # Motorola m68k/ColdFire running uClinux with uClibc + ;; +m68k-*-linux*) # Motorola m68k's running GNU/Linux + # with ELF format using glibc 2 + # aka the GNU/Linux C library 6. + ;; +m68k-*-rtems*) + ;; +mcore-*-elf) + ;; +mcore-*-pe*) + ;; +mips-sgi-irix[56]*) + ;; +mips*-*-netbsd*) # NetBSD/mips, either endian. + ;; +mips64*-*-linux*) + ;; +mips*-*-linux*) # Linux MIPS, either endian. + ;; +mips*-*-openbsd*) + ;; +mipsisa32-*-elf* | mipsisa32el-*-elf*) + ;; +mipsisa32r2-*-elf* | mipsisa32r2el-*-elf*) + ;; +mipsisa64-*-elf* | mipsisa64el-*-elf*) + ;; +mipsisa64r2-*-elf* | mipsisa64r2el-*-elf*) + ;; +mipsisa64sr71k-*-elf*) + ;; +mipsisa64sb1-*-elf* | mipsisa64sb1el-*-elf*) + ;; +mips-*-elf* | mipsel-*-elf*) + ;; +mips64-*-elf* | mips64el-*-elf*) + ;; +mips64vr-*-elf* | mips64vrel-*-elf*) + ;; +mips64orion-*-elf* | mips64orionel-*-elf*) + ;; +mips*-*-rtems*) + ;; +mips-wrs-vxworks) + ;; +mipstx39-*-elf* | mipstx39el-*-elf*) + ;; +mmix-knuth-mmixware) + ;; +mn10300-*-*) + ;; +pdp11-*-bsd) + ;; +pdp11-*-*) + ;; +picochip-*-*) + ;; +powerpc64-*-linux*) + tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ldbl128 t-softfp" + ;; +powerpc64-*-gnu*) + tmake_file="${tmake_file} rs6000/t-ldbl128 t-softfp" + ;; +powerpc-*-darwin*) + ;; +powerpc64-*-darwin*) + ;; +powerpc*-*-freebsd*) + ;; +powerpc-*-netbsd*) + ;; +powerpc-*-eabispe*) + ;; +powerpc-*-eabisimaltivec*) + ;; +powerpc-*-eabisim*) + ;; +powerpc-*-elf*) + ;; +powerpc-*-eabialtivec*) + ;; +powerpc-*-eabi*) + ;; +powerpc-*-rtems*) + ;; +powerpc-*-linux*altivec*) + tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ldbl128" + ;; +powerpc-*-linux*spe*) + tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ldbl128 t-softfp" + ;; +powerpc-*-linux*) + tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ldbl128 t-softfp" + ;; +powerpc-*-gnu-gnualtivec*) + tmake_file="${tmake_file} rs6000/t-ldbl128" + ;; +powerpc-*-gnu*) + tmake_file="${tmake_file} rs6000/t-ldbl128" + ;; +powerpc-wrs-vxworks|powerpc-wrs-vxworksae) + ;; +powerpc-*-lynxos*) + ;; +powerpcle-*-elf*) + ;; +powerpcle-*-eabisim*) + ;; +powerpcle-*-eabi*) + ;; +rs6000-ibm-aix4.[12]* | powerpc-ibm-aix4.[12]*) + ;; +rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*) + ;; +rs6000-ibm-aix5.1.* | powerpc-ibm-aix5.1.*) + ;; +rs6000-ibm-aix[56789].* | powerpc-ibm-aix[56789].*) + ;; +s390-*-linux*) + ;; +s390x-*-linux*) + ;; +s390x-ibm-tpf*) + ;; +score-*-elf) + ;; +sh-*-elf* | sh[12346l]*-*-elf* | \ +sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \ + sh-*-linux* | sh[2346lbe]*-*-linux* | \ + sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \ + sh64-*-netbsd* | sh64l*-*-netbsd*) + case ${host} in + sh*-*-linux*) + tmake_file="${tmake_file} sh/t-linux" + ;; + esac + ;; +sh-*-rtems*) + ;; +sh-wrs-vxworks) + ;; +sh-*-*) + ;; +sparc-*-netbsdelf*) + ;; +sparc64-*-openbsd*) + ;; +sparc-*-elf*) + ;; +sparc-*-linux*) # SPARC's running GNU/Linux, libc6 + extra_parts="$extra_parts crtfastmath.o" + tmake_file="${tmake_file} sparc/t-crtfm" + ;; +sparc-*-rtems*) + ;; +sparc64-*-solaris2* | sparcv9-*-solaris2*) + ;; +sparc-*-solaris2*) + ;; +sparc64-*-elf*) + ;; +sparc-wrs-vxworks) + ;; +sparc64-*-freebsd*|ultrasparc-*-freebsd*) + ;; +sparc64-*-linux*) # 64-bit SPARC's running GNU/Linux + extra_parts="$extra_parts crtfastmath.o" + tmake_file="${tmake_file} sparc/t-crtfm" + ;; +sparc64-*-netbsd*) + ;; +spu-*-elf*) + ;; +v850e1-*-*) + ;; +v850e-*-*) + ;; +v850-*-*) + ;; +vax-*-netbsdelf*) + ;; +vax-*-netbsd*) + ;; +vax-*-openbsd*) + ;; +xstormy16-*-elf) + ;; +xtensa*-*-elf*) + ;; +xtensa*-*-linux*) + ;; +am33_2.0-*-linux*) + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o" + ;; +m32c-*-elf*|m32c-*-rtems*) + ;; +*) + echo "*** Configuration ${host} not supported" 1>&2 + exit 1 + ;; +esac + +case ${host} in +i[34567]86-*-linux* | x86_64-*-linux* | \ + i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | \ + i[34567]86-*-gnu*) + tmake_file="${tmake_file} t-tls" + ;; +esac + +case ${host} in +i[34567]86-*-darwin* | x86_64-*-darwin* | \ + i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \ + i[34567]86-*-linux* | x86_64-*-linux*) + if test "${host_address}" = 32; then + tmake_file="${tmake_file} t-softfp i386/${host_address}/t-fprules-softfp" + fi + ;; +esac + +case ${host} in +i[34567]86-*-linux* | x86_64-*-linux*) + # Provide backward binary compatibility for 64bit Linux/x86. + if test "${host_address}" = 64; then + tmake_file="${tmake_file} i386/${host_address}/t-softfp-compat" + fi + ;; +esac diff --git a/gcc-4.4.3/libgcc/config/alpha/t-crtfm b/gcc-4.4.3/libgcc/config/alpha/t-crtfm new file mode 100644 index 000000000..48c21d88f --- /dev/null +++ b/gcc-4.4.3/libgcc/config/alpha/t-crtfm @@ -0,0 +1,6 @@ +# FIXME drow/20061228 - I have preserved this -frandom-seed option +# while migrating this rule from the GCC directory, but I do not +# know why it is necessary if no other crt file uses it. +crtfastmath.o: $(gcc_srcdir)/config/alpha/crtfastmath.c + $(gcc_compile) -frandom-seed=gcc-crtfastmath -c \ + $(gcc_srcdir)/config/alpha/crtfastmath.c diff --git a/gcc-4.4.3/libgcc/config/avr/t-avr b/gcc-4.4.3/libgcc/config/avr/t-avr new file mode 100644 index 000000000..ee5707241 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/avr/t-avr @@ -0,0 +1,19 @@ +# Extra 16-bit integer functions.
+intfuncs16 = _absvXX2 _addvXX3 _subvXX3 _mulvXX3 _negvXX2 _ffsXX2 _clzXX2 \
+ _ctzXX2 _popcountXX2 _parityXX2
+hiintfuncs16 = $(subst XX,hi,$(intfuncs16))
+siintfuncs16 = $(subst XX,si,$(intfuncs16))
+
+iter-items := $(hiintfuncs16)
+iter-labels := $(siintfuncs16)
+iter-sizes := $(patsubst %,2,$(siintfuncs16)) $(patsubst %,2,$(hiintfuncs16))
+
+
+include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/siditi-object.mk,$(iter-items))
+libgcc-objects += $(patsubst %,%$(objext),$(hiintfuncs16))
+
+ifeq ($(enable_shared),yes)
+libgcc-s-objects += $(patsubst %,%_s$(objext),$(hiintfuncs16))
+endif
+
+
diff --git a/gcc-4.4.3/libgcc/config/i386/32/sfp-machine.h b/gcc-4.4.3/libgcc/config/i386/32/sfp-machine.h new file mode 100644 index 000000000..746ae7c12 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/32/sfp-machine.h @@ -0,0 +1,209 @@ +#define _FP_W_TYPE_SIZE 32 +#define _FP_W_TYPE unsigned int +#define _FP_WS_TYPE signed int +#define _FP_I_TYPE int + +/* The type of the result of a floating point comparison. This must + match `__libgcc_cmp_return__' in GCC for the target. */ +typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); +#define CMPtype __gcc_CMPtype + +#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \ + __asm__ ("add{l} {%11,%3|%3,%11}\n\t" \ + "adc{l} {%9,%2|%2,%9}\n\t" \ + "adc{l} {%7,%1|%1,%7}\n\t" \ + "adc{l} {%5,%0|%0,%5}" \ + : "=r" ((USItype) (r3)), \ + "=&r" ((USItype) (r2)), \ + "=&r" ((USItype) (r1)), \ + "=&r" ((USItype) (r0)) \ + : "%0" ((USItype) (x3)), \ + "g" ((USItype) (y3)), \ + "%1" ((USItype) (x2)), \ + "g" ((USItype) (y2)), \ + "%2" ((USItype) (x1)), \ + "g" ((USItype) (y1)), \ + "%3" ((USItype) (x0)), \ + "g" ((USItype) (y0))) +#define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \ + __asm__ ("add{l} {%8,%2|%2,%8}\n\t" \ + "adc{l} {%6,%1|%1,%6}\n\t" \ + "adc{l} {%4,%0|%0,%4}" \ + : "=r" ((USItype) (r2)), \ + "=&r" ((USItype) (r1)), \ + "=&r" ((USItype) (r0)) \ + : "%0" ((USItype) (x2)), \ + "g" ((USItype) (y2)), \ + "%1" ((USItype) (x1)), \ + "g" ((USItype) (y1)), \ + "%2" ((USItype) (x0)), \ + "g" ((USItype) (y0))) + +/* FIXME: Change last operand constraint + from "im" to "g" when reload works properly. */ +#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \ + __asm__ ("sub{l} {%11,%3|%3,%11}\n\t" \ + "sbb{l} {%9,%2|%2,%9}\n\t" \ + "sbb{l} {%7,%1|%1,%7}\n\t" \ + "sbb{l} {%5,%0|%0,%5}" \ + : "=r" ((USItype) (r3)), \ + "=&r" ((USItype) (r2)), \ + "=&r" ((USItype) (r1)), \ + "=&r" ((USItype) (r0)) \ + : "0" ((USItype) (x3)), \ + "g" ((USItype) (y3)), \ + "1" ((USItype) (x2)), \ + "g" ((USItype) (y2)), \ + "2" ((USItype) (x1)), \ + "g" ((USItype) (y1)), \ + "3" ((USItype) (x0)), \ + "im" ((USItype) (y0))) +#define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \ + __asm__ ("sub{l} {%8,%2|%2,%8}\n\t" \ + "sbb{l} {%6,%1|%1,%6}\n\t" \ + "sbb{l} {%4,%0|%0,%4}" \ + : "=r" ((USItype) (r2)), \ + "=&r" ((USItype) (r1)), \ + "=&r" ((USItype) (r0)) \ + : "0" ((USItype) (x2)), \ + "g" ((USItype) (y2)), \ + "1" ((USItype) (x1)), \ + "g" ((USItype) (y1)), \ + "2" ((USItype) (x0)), \ + "g" ((USItype) (y0))) + + +#define _FP_MUL_MEAT_Q(R,X,Y) \ + _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) + +#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y) + +#define _FP_NANFRAC_S _FP_QNANBIT_S +#define _FP_NANFRAC_D _FP_QNANBIT_D, 0 +/* Even if XFmode is 12byte, we have to pad it to + 16byte since soft-fp emulation is done in 16byte. */ +#define _FP_NANFRAC_E _FP_QNANBIT_E, 0, 0, 0 +#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0 +#define _FP_NANSIGN_S 1 +#define _FP_NANSIGN_D 1 +#define _FP_NANSIGN_E 1 +#define _FP_NANSIGN_Q 1 + +#define _FP_KEEPNANFRACP 1 + +/* Here is something Intel misdesigned: the specs don't define + the case where we have two NaNs with same mantissas, but + different sign. Different operations pick up different NaNs. */ +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ + do { \ + if (_FP_FRAC_GT_##wc(X, Y) \ + || (_FP_FRAC_EQ_##wc(X,Y) && (OP == '+' || OP == '*'))) \ + { \ + R##_s = X##_s; \ + _FP_FRAC_COPY_##wc(R,X); \ + } \ + else \ + { \ + R##_s = Y##_s; \ + _FP_FRAC_COPY_##wc(R,Y); \ + } \ + R##_c = FP_CLS_NAN; \ + } while (0) + +#define FP_EX_INVALID 0x01 +#define FP_EX_DENORM 0x02 +#define FP_EX_DIVZERO 0x04 +#define FP_EX_OVERFLOW 0x08 +#define FP_EX_UNDERFLOW 0x10 +#define FP_EX_INEXACT 0x20 + +struct fenv +{ + unsigned short int __control_word; + unsigned short int __unused1; + unsigned short int __status_word; + unsigned short int __unused2; + unsigned short int __tags; + unsigned short int __unused3; + unsigned int __eip; + unsigned short int __cs_selector; + unsigned int __opcode:11; + unsigned int __unused4:5; + unsigned int __data_offset; + unsigned short int __data_selector; + unsigned short int __unused5; +}; + +#define FP_HANDLE_EXCEPTIONS \ + do { \ + if (_fex & FP_EX_INVALID) \ + { \ + float f = 0.0; \ + __asm__ __volatile__ ("fdiv %0" : "+t" (f)); \ + __asm__ __volatile__ ("fwait"); \ + } \ + if (_fex & FP_EX_DIVZERO) \ + { \ + float f = 1.0, g = 0.0; \ + __asm__ __volatile__ ("fdivp" : "=t" (f) \ + : "0" (f), "u" (g) \ + : "st(1)"); \ + __asm__ __volatile__ ("fwait"); \ + } \ + if (_fex & FP_EX_OVERFLOW) \ + { \ + struct fenv temp; \ + __asm__ __volatile__ ("fnstenv %0" : "=m" (temp)); \ + temp.__status_word |= FP_EX_OVERFLOW; \ + __asm__ __volatile__ ("fldenv %0" : : "m" (temp)); \ + __asm__ __volatile__ ("fwait"); \ + } \ + if (_fex & FP_EX_UNDERFLOW) \ + { \ + struct fenv temp; \ + __asm__ __volatile__ ("fnstenv %0" : "=m" (temp)); \ + temp.__status_word |= FP_EX_UNDERFLOW; \ + __asm__ __volatile__ ("fldenv %0" : : "m" (temp)); \ + __asm__ __volatile__ ("fwait"); \ + } \ + if (_fex & FP_EX_INEXACT) \ + { \ + struct fenv temp; \ + __asm__ __volatile__ ("fnstenv %0" : "=m" (temp)); \ + temp.__status_word |= FP_EX_INEXACT; \ + __asm__ __volatile__ ("fldenv %0" : : "m" (temp)); \ + __asm__ __volatile__ ("fwait"); \ + } \ + } while (0) + +#define FP_RND_NEAREST 0 +#define FP_RND_ZERO 0xc00 +#define FP_RND_PINF 0x800 +#define FP_RND_MINF 0x400 + +#define _FP_DECL_EX \ + unsigned short _fcw __attribute__ ((unused)) = FP_RND_NEAREST + +#define FP_INIT_ROUNDMODE \ + do { \ + __asm__ ("fnstcw %0" : "=m" (_fcw)); \ + } while (0) + +#define FP_ROUNDMODE (_fcw & 0xc00) + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 + +#define __BYTE_ORDER __LITTLE_ENDIAN + +/* Define ALIASNAME as a strong alias for NAME. */ +#if defined __MACH__ +/* Mach-O doesn't support aliasing. If these functions ever return + anything but CMPtype we need to revisit this... */ +#define strong_alias(name, aliasname) \ + CMPtype aliasname (TFtype a, TFtype b) { return name(a, b); } +#else +# define strong_alias(name, aliasname) _strong_alias(name, aliasname) +# define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/32/t-fprules-softfp b/gcc-4.4.3/libgcc/config/i386/32/t-fprules-softfp new file mode 100644 index 000000000..8e7f3233b --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/32/t-fprules-softfp @@ -0,0 +1,8 @@ +# Filter out TImode functions +tifunctions = fixtfti.c fixunstfti.c floattitf.c floatuntitf.c +tifunctions := $(addprefix $(gcc_srcdir)/config/soft-fp/, $(tifunctions)) + +LIB2ADD := $(filter-out $(tifunctions), $(LIB2ADD)) + +# Provide fallbacks for __builtin_copysignq and __builtin_fabsq. +LIB2ADD += $(srcdir)/config/i386/32/tf-signs.c diff --git a/gcc-4.4.3/libgcc/config/i386/32/tf-signs.c b/gcc-4.4.3/libgcc/config/i386/32/tf-signs.c new file mode 100644 index 000000000..2bc1a855c --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/32/tf-signs.c @@ -0,0 +1,62 @@ +/* Copyright (C) 2008, 2009 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 +<http://www.gnu.org/licenses/>. */ + +union _FP_UNION_Q +{ + __float128 flt; + struct + { + unsigned long frac0 : 32; + unsigned long frac1 : 32; + unsigned long frac2 : 32; + unsigned long frac3 : 16; + unsigned exp : 15; + unsigned sign : 1; + } bits __attribute__((packed)); +}; + +__float128 __copysigntf3 (__float128, __float128); +__float128 __fabstf2 (__float128); + +__float128 +__copysigntf3 (__float128 a, __float128 b) +{ + union _FP_UNION_Q A, B; + + A.flt = a; + B.flt = b; + A.bits.sign = B.bits.sign; + + return A.flt; +} + +__float128 +__fabstf2 (__float128 a) +{ + union _FP_UNION_Q A; + + A.flt = a; + A.bits.sign = 0; + + return A.flt; +} diff --git a/gcc-4.4.3/libgcc/config/i386/64/_divtc3.c b/gcc-4.4.3/libgcc/config/i386/64/_divtc3.c new file mode 100644 index 000000000..57ee350b7 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/_divtc3.c @@ -0,0 +1,14 @@ +#ifdef SHARED +#define __divtc3 __divtc3_shared +#endif + +#define L_divtc3 +#include "libgcc2.c" + +#ifdef SHARED +#undef __divtc3 +extern __typeof__ (__divtc3_shared) __divtc3_compat __attribute__((alias ("__divtc3_shared"))); + +asm (".symver __divtc3_compat,__divtc3@GCC_4.0.0"); +asm (".symver __divtc3_shared,__divtc3@@GCC_4.3.0"); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/64/_multc3.c b/gcc-4.4.3/libgcc/config/i386/64/_multc3.c new file mode 100644 index 000000000..49141a938 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/_multc3.c @@ -0,0 +1,14 @@ +#ifdef SHARED +#define __multc3 __multc3_shared +#endif + +#define L_multc3 +#include "libgcc2.c" + +#ifdef SHARED +#undef __multc3 +extern __typeof__ (__multc3_shared) __multc3_compat __attribute__((alias ("__multc3_shared"))); + +asm (".symver __multc3_compat,__multc3@GCC_4.0.0"); +asm (".symver __multc3_shared,__multc3@@GCC_4.3.0"); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/64/_powitf2.c b/gcc-4.4.3/libgcc/config/i386/64/_powitf2.c new file mode 100644 index 000000000..3bc3c904d --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/_powitf2.c @@ -0,0 +1,14 @@ +#ifdef SHARED +#define __powitf2 __powitf2_shared +#endif + +#define L_powitf2 +#include "libgcc2.c" + +#ifdef SHARED +#undef __powitf2 +extern __typeof__ (__powitf2_shared) __powitf2_compat __attribute__((alias ("__powitf2_shared"))); + +asm (".symver __powitf2_compat,__powitf2@GCC_4.0.0"); +asm (".symver __powitf2_shared,__powitf2@@GCC_4.3.0"); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/64/eqtf2.c b/gcc-4.4.3/libgcc/config/i386/64/eqtf2.c new file mode 100644 index 000000000..d9baba689 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/eqtf2.c @@ -0,0 +1,13 @@ +#ifdef SHARED +#define __netf2 __netf2_shared +#endif + +#include "config/soft-fp/eqtf2.c" + +#ifdef SHARED +#undef __netf2 +strong_alias (__netf2_shared, __netf2_compat); + +asm (".symver __netf2_compat,__netf2@GCC_3.0"); +asm (".symver __netf2_shared,__netf2@@GCC_4.3.0"); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/64/getf2.c b/gcc-4.4.3/libgcc/config/i386/64/getf2.c new file mode 100644 index 000000000..30885cc0c --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/getf2.c @@ -0,0 +1,13 @@ +#ifdef SHARED +#define __gttf2 __gttf2_shared +#endif + +#include "config/soft-fp/getf2.c" + +#ifdef SHARED +#undef __gttf2 +strong_alias (__gttf2_shared, __gttf2_compat); + +asm (".symver __gttf2_compat,__gttf2@GCC_3.0"); +asm (".symver __gttf2_shared,__gttf2@@GCC_4.3.0"); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/64/letf2.c b/gcc-4.4.3/libgcc/config/i386/64/letf2.c new file mode 100644 index 000000000..231f981c8 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/letf2.c @@ -0,0 +1,13 @@ +#ifdef SHARED +#define __lttf2 __lttf2_shared +#endif + +#include "config/soft-fp/letf2.c" + +#ifdef SHARED +#undef __lttf2 +strong_alias (__lttf2_shared, __lttf2_compat); + +asm (".symver __lttf2_compat,__lttf2@GCC_3.0"); +asm (".symver __lttf2_shared,__lttf2@@GCC_4.3.0"); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/64/sfp-machine.h b/gcc-4.4.3/libgcc/config/i386/64/sfp-machine.h new file mode 100644 index 000000000..190e3cb0e --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/sfp-machine.h @@ -0,0 +1,143 @@ +#define _FP_W_TYPE_SIZE 64 +#define _FP_W_TYPE unsigned long +#define _FP_WS_TYPE signed long +#define _FP_I_TYPE long + +typedef int TItype __attribute__ ((mode (TI))); +typedef unsigned int UTItype __attribute__ ((mode (TI))); + +#define TI_BITS (__CHAR_BIT__ * (int)sizeof(TItype)) + +/* The type of the result of a floating point comparison. This must + match `__libgcc_cmp_return__' in GCC for the target. */ +typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); +#define CMPtype __gcc_CMPtype + +#define _FP_MUL_MEAT_Q(R,X,Y) \ + _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) + +#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y) + +#define _FP_NANFRAC_S _FP_QNANBIT_S +#define _FP_NANFRAC_D _FP_QNANBIT_D +#define _FP_NANFRAC_E _FP_QNANBIT_E, 0 +#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0 +#define _FP_NANSIGN_S 1 +#define _FP_NANSIGN_D 1 +#define _FP_NANSIGN_E 1 +#define _FP_NANSIGN_Q 1 + +#define _FP_KEEPNANFRACP 1 + +/* Here is something Intel misdesigned: the specs don't define + the case where we have two NaNs with same mantissas, but + different sign. Different operations pick up different NaNs. */ +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ + do { \ + if (_FP_FRAC_GT_##wc(X, Y) \ + || (_FP_FRAC_EQ_##wc(X,Y) && (OP == '+' || OP == '*'))) \ + { \ + R##_s = X##_s; \ + _FP_FRAC_COPY_##wc(R,X); \ + } \ + else \ + { \ + R##_s = Y##_s; \ + _FP_FRAC_COPY_##wc(R,Y); \ + } \ + R##_c = FP_CLS_NAN; \ + } while (0) + +#define FP_EX_INVALID 0x01 +#define FP_EX_DENORM 0x02 +#define FP_EX_DIVZERO 0x04 +#define FP_EX_OVERFLOW 0x08 +#define FP_EX_UNDERFLOW 0x10 +#define FP_EX_INEXACT 0x20 + +struct fenv +{ + unsigned short int __control_word; + unsigned short int __unused1; + unsigned short int __status_word; + unsigned short int __unused2; + unsigned short int __tags; + unsigned short int __unused3; + unsigned int __eip; + unsigned short int __cs_selector; + unsigned int __opcode:11; + unsigned int __unused4:5; + unsigned int __data_offset; + unsigned short int __data_selector; + unsigned short int __unused5; +}; + +#define FP_HANDLE_EXCEPTIONS \ + do { \ + if (_fex & FP_EX_INVALID) \ + { \ + float f = 0.0; \ + __asm__ __volatile__ ("divss %0, %0 " : : "x" (f)); \ + } \ + if (_fex & FP_EX_DIVZERO) \ + { \ + float f = 1.0, g = 0.0; \ + __asm__ __volatile__ ("divss %1, %0" : : "x" (f), "x" (g)); \ + } \ + if (_fex & FP_EX_OVERFLOW) \ + { \ + struct fenv temp; \ + __asm__ __volatile__ ("fnstenv %0" : "=m" (temp)); \ + temp.__status_word |= FP_EX_OVERFLOW; \ + __asm__ __volatile__ ("fldenv %0" : : "m" (temp)); \ + __asm__ __volatile__ ("fwait"); \ + } \ + if (_fex & FP_EX_UNDERFLOW) \ + { \ + struct fenv temp; \ + __asm__ __volatile__ ("fnstenv %0" : "=m" (temp)); \ + temp.__status_word |= FP_EX_UNDERFLOW; \ + __asm__ __volatile__ ("fldenv %0" : : "m" (temp)); \ + __asm__ __volatile__ ("fwait"); \ + } \ + if (_fex & FP_EX_INEXACT) \ + { \ + struct fenv temp; \ + __asm__ __volatile__ ("fnstenv %0" : "=m" (temp)); \ + temp.__status_word |= FP_EX_INEXACT; \ + __asm__ __volatile__ ("fldenv %0" : : "m" (temp)); \ + __asm__ __volatile__ ("fwait"); \ + } \ + } while (0) + +#define FP_RND_NEAREST 0 +#define FP_RND_ZERO 0xc00 +#define FP_RND_PINF 0x800 +#define FP_RND_MINF 0x400 + +#define _FP_DECL_EX \ + unsigned short _fcw __attribute__ ((unused)) = FP_RND_NEAREST + +#define FP_INIT_ROUNDMODE \ + do { \ + __asm__ ("fnstcw %0" : "=m" (_fcw)); \ + } while (0) + +#define FP_ROUNDMODE (_fcw & 0xc00) + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 + +#define __BYTE_ORDER __LITTLE_ENDIAN + +/* Define ALIASNAME as a strong alias for NAME. */ +#if defined __MACH__ +/* Mach-O doesn't support aliasing. If these functions ever return + anything but CMPtype we need to revisit this... */ +#define strong_alias(name, aliasname) \ + CMPtype aliasname (TFtype a, TFtype b) { return name(a, b); } +#else +# define strong_alias(name, aliasname) _strong_alias(name, aliasname) +# define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); +#endif diff --git a/gcc-4.4.3/libgcc/config/i386/64/t-softfp-compat b/gcc-4.4.3/libgcc/config/i386/64/t-softfp-compat new file mode 100644 index 000000000..afaa526ae --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/64/t-softfp-compat @@ -0,0 +1,15 @@ +# When TFmode was first added to x86-64 in gcc 4.3.0, some TFmode +# support functions got improper versions by accident. Here we +# correct the version and provide backward binary compatibility. + +# Filter out the following TFmode functions. +tf-compats = getf2.c letf2.c eqtf2.c +tf-functions := $(addprefix $(gcc_srcdir)/config/soft-fp/, $(tf-compats)) +LIB2ADD := $(filter-out $(tf-functions), $(LIB2ADD)) +LIB2ADD += $(addprefix $(srcdir)/config/i386/64/, $(tf-compats)) + +# Replace _divtc3, _multc3 and _powitf2. +libgcc2-tf-functions = _divtc3 _multc3 _powitf2 +LIB2FUNCS_EXCLUDE += $(libgcc2-tf-functions) +libgcc2-tf-compats = $(addsuffix .c, $(libgcc2-tf-functions)) +LIB2ADD += $(addprefix $(srcdir)/config/i386/64/, $(libgcc2-tf-compats)) diff --git a/gcc-4.4.3/libgcc/config/i386/t-crtfm b/gcc-4.4.3/libgcc/config/i386/t-crtfm new file mode 100644 index 000000000..6e89296b2 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/t-crtfm @@ -0,0 +1,5 @@ +# This is an endfile, Use -minline-all-stringops to ensure +# that __builtin_memset doesn't refer to the lib function memset(). +crtfastmath.o: $(gcc_srcdir)/config/i386/crtfastmath.c + $(gcc_compile) -msse -minline-all-stringops -c \ + $(gcc_srcdir)/config/i386/crtfastmath.c diff --git a/gcc-4.4.3/libgcc/config/i386/t-crtpc b/gcc-4.4.3/libgcc/config/i386/t-crtpc new file mode 100644 index 000000000..c231ce195 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/t-crtpc @@ -0,0 +1,8 @@ +crtprec32.o: $(gcc_srcdir)/config/i386/crtprec.c + $(gcc_compile) -D__PREC=32 -c $< + +crtprec64.o: $(gcc_srcdir)/config/i386/crtprec.c + $(gcc_compile) -D__PREC=64 -c $< + +crtprec80.o: $(gcc_srcdir)/config/i386/crtprec.c + $(gcc_compile) -D__PREC=80 -c $< diff --git a/gcc-4.4.3/libgcc/config/i386/t-cygming b/gcc-4.4.3/libgcc/config/i386/t-cygming new file mode 100644 index 000000000..048cadbd5 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/t-cygming @@ -0,0 +1,11 @@ +CUSTOM_CRTSTUFF = yes + +crtbegin.o: $(gcc_srcdir)/config/i386/cygming-crtbegin.c + $(crt_compile) -fno-omit-frame-pointer -c \ + $(gcc_srcdir)/config/i386/cygming-crtbegin.c + +# We intentionally use a implementation-reserved init priority of 0, +# so allow the warning. +crtend.o: $(gcc_srcdir)/config/i386/cygming-crtend.c + $(crt_compile) -fno-omit-frame-pointer -Wno-error -c \ + $(gcc_srcdir)/config/i386/cygming-crtend.c diff --git a/gcc-4.4.3/libgcc/config/i386/t-darwin b/gcc-4.4.3/libgcc/config/i386/t-darwin new file mode 100644 index 000000000..4578f74c3 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/t-darwin @@ -0,0 +1 @@ +SHLIB_VERPFX = $(gcc_srcdir)/config/i386/darwin-libgcc diff --git a/gcc-4.4.3/libgcc/config/i386/t-darwin64 b/gcc-4.4.3/libgcc/config/i386/t-darwin64 new file mode 100644 index 000000000..4578f74c3 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/t-darwin64 @@ -0,0 +1 @@ +SHLIB_VERPFX = $(gcc_srcdir)/config/i386/darwin-libgcc diff --git a/gcc-4.4.3/libgcc/config/i386/t-nwld b/gcc-4.4.3/libgcc/config/i386/t-nwld new file mode 100644 index 000000000..408587273 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/t-nwld @@ -0,0 +1,31 @@ +# Build a shared libgcc library for NetWare. + +SHLIB_EXT = .nlm +SHLIB_NAME = @shlib_base_name@.nlm +SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@ +SHLIB_DEF = $(gcc_srcdir)/config/i386/netware-libgcc.def +SHLIB_MAP = $(gcc_srcdir)/config/i386/netware-libgcc.exp +SHLIB_SRC = $(gcc_srcdir)/config/i386/netware-libgcc.c + +SHLIB_LINK = set -e; \ + cat $(SHLIB_DEF) >@shlib_base_name@.def; \ + echo "name $(SHLIB_NAME)" >>@shlib_base_name@.def; \ + echo "version $(version)" | sed "s!\.!,!g" >>@shlib_base_name@.def; \ + touch build; \ + echo "build $$(expr $$(<build) + 0)" >>@shlib_base_name@.def; \ + echo "export @$(SHLIB_MAP)" >>@shlib_base_name@.def; \ + if mpkxdc -n -p @shlib_base_name@.xdc; \ + then echo "xdcdata @shlib_base_name@.xdc" >>@shlib_base_name@.def; \ + else echo "WARNING: $(SHLIB_NAME) built without XDC data will not work well." 1>&2; \ + fi; \ + $(CC) $(LIBGCC2_CFLAGS) -o $(SHLIB_NAME) \ + $(SHLIB_SRC) -posix -static-libgcc -lnetware \ + -Wl,--Map,--map-info,full,--strip-all,--def-file,@shlib_base_name@.def; \ + rm -f @shlib_base_name@.imp; $(LN_S) $(SHLIB_MAP) @shlib_base_name@.imp; \ + rm -f libgcc.imp; $(LN_S) @shlib_base_name@.imp libgcc.imp; \ + expr $$(<build) + 1 >build + +SHLIB_INSTALL = \ + $(SHELL) $(srcdir)/mkinstalldirs $(slibdir)$(SHLIB_SLIBDIR_QUAL); \ + $(INSTALL_DATA) $(SHLIB_NAME) $(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_NAME); \ + $(INSTALL_DATA) @shlib_base_name@.imp $(DESTDIR)$(libsubdir)/ diff --git a/gcc-4.4.3/libgcc/config/i386/t-sol2 b/gcc-4.4.3/libgcc/config/i386/t-sol2 new file mode 100644 index 000000000..24b7c7c10 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/i386/t-sol2 @@ -0,0 +1,34 @@ +# gmon build rule: +$(T)gmon.o: $(gcc_srcdir)/config/i386/gmon-sol2.c $(GCC_PASSES) $(CONFIG_H) + $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) \ + -c $(gcc_srcdir)/config/i386/gmon-sol2.c -o $(T)gmon.o + +# Assemble startup files. +# Apparently Sun believes that assembler files don't need comments, because no +# single ASCII character is valid (tried them all). So we manually strip out +# the comments with sed. This bug may only be in the Early Access releases. +$(T)gcrt1.o: $(gcc_srcdir)/config/i386/sol2-gc1.asm $(GCC_PASSES) + sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-gc1.asm >gcrt1.s + $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)gcrt1.o gcrt1.s +$(T)crt1.o: $(gcc_srcdir)/config/i386/sol2-c1.asm $(GCC_PASSES) + sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-c1.asm >crt1.s + $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crt1.o crt1.s +$(T)crti.o: $(gcc_srcdir)/config/i386/sol2-ci.asm $(GCC_PASSES) + sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-ci.asm >crti.s + $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crti.o crti.s +$(T)crtn.o: $(gcc_srcdir)/config/i386/sol2-cn.asm $(GCC_PASSES) + sed -e '/^!/d' <$(gcc_srcdir)/config/i386/sol2-cn.asm >crtn.s + $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crtn.o crtn.s + +# We need to use -fPIC when we are using gcc to compile the routines in +# crtstuff.c. This is only really needed when we are going to use gcc/g++ +# to produce a shared library, but since we don't know ahead of time when +# we will be doing that, we just always use -fPIC when compiling the +# routines in crtstuff.c. +# +# We must also enable optimization to avoid having any code appear after +# the call & alignment statement, but before we switch back to the +# .text section. + +CRTSTUFF_T_CFLAGS = -fPIC -O2 +TARGET_LIBGCC2_CFLAGS = -fPIC diff --git a/gcc-4.4.3/libgcc/config/ia64/__divxf3.asm b/gcc-4.4.3/libgcc/config/ia64/__divxf3.asm new file mode 100644 index 000000000..f741bdaf9 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/__divxf3.asm @@ -0,0 +1,11 @@ +#ifdef SHARED +#define __divtf3 __divtf3_compat +#endif + +#define L__divxf3 +#include "config/ia64/lib1funcs.asm" + +#ifdef SHARED +#undef __divtf3 +.symver __divtf3_compat, __divtf3@GCC_3.0 +#endif diff --git a/gcc-4.4.3/libgcc/config/ia64/_fixtfdi.asm b/gcc-4.4.3/libgcc/config/ia64/_fixtfdi.asm new file mode 100644 index 000000000..4d13c808c --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/_fixtfdi.asm @@ -0,0 +1,11 @@ +#ifdef SHARED +#define __fixtfti __fixtfti_compat +#endif + +#define L_fixtfdi +#include "config/ia64/lib1funcs.asm" + +#ifdef SHARED +#undef __fixtfti +.symver __fixtfti_compat, __fixtfti@GCC_3.0 +#endif diff --git a/gcc-4.4.3/libgcc/config/ia64/_fixunstfdi.asm b/gcc-4.4.3/libgcc/config/ia64/_fixunstfdi.asm new file mode 100644 index 000000000..b722d9e90 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/_fixunstfdi.asm @@ -0,0 +1,11 @@ +#ifdef SHARED +#define __fixunstfti __fixunstfti_compat +#endif + +#define L_fixunstfdi +#include "config/ia64/lib1funcs.asm" + +#ifdef SHARED +#undef __fixunstfti +.symver __fixunstfti_compat, __fixunstfti@GCC_3.0 +#endif diff --git a/gcc-4.4.3/libgcc/config/ia64/_floatditf.asm b/gcc-4.4.3/libgcc/config/ia64/_floatditf.asm new file mode 100644 index 000000000..21d770281 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/_floatditf.asm @@ -0,0 +1,11 @@ +#ifdef SHARED +#define __floattitf __floattitf_compat +#endif + +#define L_floatditf +#include "config/ia64/lib1funcs.asm" + +#ifdef SHARED +#undef __floattitf +.symver __floattitf_compat, __floattitf@GCC_3.0 +#endif diff --git a/gcc-4.4.3/libgcc/config/ia64/t-fprules-softfp b/gcc-4.4.3/libgcc/config/ia64/t-fprules-softfp new file mode 100644 index 000000000..90acc376e --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/t-fprules-softfp @@ -0,0 +1,2 @@ +# Provide fallbacks for __builtin_copysignq and __builtin_fabsq. +LIB2ADD += $(srcdir)/config/ia64/tf-signs.c diff --git a/gcc-4.4.3/libgcc/config/ia64/t-ia64 b/gcc-4.4.3/libgcc/config/ia64/t-ia64 new file mode 100644 index 000000000..d9c7566cf --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/t-ia64 @@ -0,0 +1,18 @@ +CUSTOM_CRTSTUFF = yes + +# Assemble startup files. +crtbegin.o: $(gcc_srcdir)/config/ia64/crtbegin.asm + $(CC) $(compile_deps) -I. -I$(gcc_objdir) -c -x assembler-with-cpp \ + -o $@ $(gcc_srcdir)/config/ia64/crtbegin.asm +crtend.o: $(gcc_srcdir)/config/ia64/crtend.asm + $(CC) $(compile_deps) -I. -I$(gcc_objdir) -c -x assembler-with-cpp \ + -o $@ $(gcc_srcdir)/config/ia64/crtend.asm +crtbeginS.o: $(gcc_srcdir)/config/ia64/crtbegin.asm + $(CC) $(compile_deps) -I. -I$(gcc_objdir) -c -x assembler-with-cpp \ + -o $@ -DSHARED $(gcc_srcdir)/config/ia64/crtbegin.asm +crtendS.o: $(gcc_srcdir)/config/ia64/crtend.asm + $(CC) $(compile_deps) -I. -I$(gcc_objdir) -c -x assembler-with-cpp \ + -o $@ -DSHARED $(gcc_srcdir)/config/ia64/crtend.asm + +crtfastmath.o: $(gcc_srcdir)/config/ia64/crtfastmath.c + $(gcc_compile) -c $(gcc_srcdir)/config/ia64/crtfastmath.c diff --git a/gcc-4.4.3/libgcc/config/ia64/t-softfp-compat b/gcc-4.4.3/libgcc/config/ia64/t-softfp-compat new file mode 100644 index 000000000..d3dad68c4 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/t-softfp-compat @@ -0,0 +1,7 @@ +# Filter out the following TImode functions and provide backward binary +# compatibility. +# Replace __dvxf3 _fixtfdi _fixunstfdi _floatditf +libgcc1-tf-functions = __divxf3 _fixtfdi _fixunstfdi _floatditf +LIB1ASMFUNCS := $(filter-out $(libgcc1-tf-functions), $(LIB1ASMFUNCS)) +libgcc1-tf-compats = $(addsuffix .asm, $(libgcc1-tf-functions)) +LIB2ADD += $(addprefix $(srcdir)/config/ia64/, $(libgcc1-tf-compats)) diff --git a/gcc-4.4.3/libgcc/config/ia64/tf-signs.c b/gcc-4.4.3/libgcc/config/ia64/tf-signs.c new file mode 100644 index 000000000..bbcae503e --- /dev/null +++ b/gcc-4.4.3/libgcc/config/ia64/tf-signs.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2008, 2009 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 +<http://www.gnu.org/licenses/>. */ + +union _FP_UNION_Q +{ + __float128 flt; + struct + { + unsigned long frac1 : 64; + unsigned long frac0 : 48; + unsigned exp : 15; + unsigned sign : 1; + } bits __attribute__((packed)); +}; + +__float128 __copysigntf3 (__float128, __float128); +__float128 __fabstf2 (__float128); + +__float128 +__copysigntf3 (__float128 a, __float128 b) +{ + union _FP_UNION_Q A, B; + + A.flt = a; + B.flt = b; + A.bits.sign = B.bits.sign; + + return A.flt; +} + +__float128 +__fabstf2 (__float128 a) +{ + union _FP_UNION_Q A; + + A.flt = a; + A.bits.sign = 0; + + return A.flt; +} diff --git a/gcc-4.4.3/libgcc/config/libbid/ChangeLog b/gcc-4.4.3/libgcc/config/libbid/ChangeLog new file mode 100644 index 000000000..7ae07b4e1 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/ChangeLog @@ -0,0 +1,383 @@ +2010-01-21 Release Manager + + * GCC 4.4.3 released. + +2009-10-15 Release Manager + + * GCC 4.4.2 released. + +2009-07-22 Release Manager + + * GCC 4.4.1 released. + +2009-04-21 Release Manager + + * GCC 4.4.0 released. + +2007-09-27 H.J. Lu <hongjiu.lu@intel.com> + + * bid128_fromstring.c: Removed. + + * bid_dpd.c: New from libbid 2007-09-26. + * bid128_to_int16.c: Likewise. + * bid128_to_int8.c: Likewise. + * bid128_to_uint8.c: Likewise. + * bid128_to_uint16.c: Likewise. + * bid64_to_int16.c: Likewise. + * bid64_to_int8.c: Likewise. + * bid64_to_uint16.c: Likewise. + * bid64_to_uint8.c: Likewise. + + * bid128_2_str.h: Updated from libbid 2007-09-26. + * bid128_2_str_macros.h: Likewise. + * bid128_2_str_tables.c: Likewise. + * bid128_add.c: Likewise. + * bid128.c: Likewise. + * bid128_compare.c: Likewise. + * bid128_div.c: Likewise. + * bid128_fma.c: Likewise. + * bid128_logb.c: Likewise. + * bid128_minmax.c: Likewise. + * bid128_mul.c: Likewise. + * bid128_next.c: Likewise. + * bid128_noncomp.c: Likewise. + * bid128_quantize.c: Likewise. + * bid128_rem.c: Likewise. + * bid128_round_integral.c: Likewise. + * bid128_scalb.c: Likewise. + * bid128_sqrt.c: Likewise. + * bid128_string.c: Likewise. + * bid128_to_int32.c: Likewise. + * bid128_to_int64.c: Likewise. + * bid128_to_uint32.c: Likewise. + * bid128_to_uint64.c: Likewise. + * bid32_to_bid128.c: Likewise. + * bid32_to_bid64.c: Likewise. + * bid64_add.c: Likewise. + * bid64_compare.c: Likewise. + * bid64_div.c: Likewise. + * bid64_fma.c: Likewise. + * bid64_logb.c: Likewise. + * bid64_minmax.c: Likewise. + * bid64_mul.c: Likewise. + * bid64_next.c: Likewise. + * bid64_noncomp.c: Likewise. + * bid64_quantize.c: Likewise. + * bid64_rem.c: Likewise. + * bid64_round_integral.c: Likewise. + * bid64_scalb.c: Likewise. + * bid64_sqrt.c: Likewise. + * bid64_string.c: Likewise. + * bid64_to_bid128.c: Likewise. + * bid64_to_int32.c: Likewise. + * bid64_to_int64.c: Likewise. + * bid64_to_uint32.c: Likewise. + * bid64_to_uint64.c: Likewise. + * bid_b2d.h: Likewise. + * bid_binarydecimal.c: Likewise. + * bid_conf.h: Likewise. + * bid_convert_data.c: Likewise. + * bid_decimal_data.c: Likewise. + * bid_decimal_globals.c: Likewise. + * bid_div_macros.h: Likewise. + * bid_flag_operations.c: Likewise. + * bid_from_int.c: Likewise. + * bid_functions.h: Likewise. + * bid_gcc_intrinsics.h: Likewise. + * bid_inline_add.h: Likewise. + * bid_internal.h: Likewise. + * bid_round.c: Likewise. + * bid_sqrt_macros.h: Likewise. + * _addsub_dd.c: Likewise. + * _addsub_sd.c: Likewise. + * _addsub_td.c: Likewise. + * _dd_to_df.c: Likewise. + * _dd_to_di.c: Likewise. + * _dd_to_sd.c: Likewise. + * _dd_to_sf.c: Likewise. + * _dd_to_si.c: Likewise. + * _dd_to_td.c: Likewise. + * _dd_to_tf.c: Likewise. + * _dd_to_udi.c: Likewise. + * _dd_to_usi.c: Likewise. + * _dd_to_xf.c: Likewise. + * _df_to_dd.c: Likewise. + * _df_to_sd.c: Likewise. + * _df_to_td.c: Likewise. + * _di_to_dd.c: Likewise. + * _di_to_sd.c: Likewise. + * _di_to_td.c: Likewise. + * _div_dd.c: Likewise. + * _div_sd.c: Likewise. + * _div_td.c: Likewise. + * _eq_dd.c: Likewise. + * _eq_sd.c: Likewise. + * _eq_td.c: Likewise. + * _ge_dd.c: Likewise. + * _ge_sd.c: Likewise. + * _ge_td.c: Likewise. + * _gt_dd.c: Likewise. + * _gt_sd.c: Likewise. + * _gt_td.c: Likewise. + * _isinfd128.c: Likewise. + * _isinfd32.c: Likewise. + * _isinfd64.c: Likewise. + * _le_dd.c: Likewise. + * _le_sd.c: Likewise. + * _le_td.c: Likewise. + * _lt_dd.c: Likewise. + * _lt_sd.c: Likewise. + * _lt_td.c: Likewise. + * _mul_dd.c: Likewise. + * _mul_sd.c: Likewise. + * _mul_td.c: Likewise. + * _ne_dd.c: Likewise. + * _ne_sd.c: Likewise. + * _ne_td.c: Likewise. + * _sd_to_dd.c: Likewise. + * _sd_to_df.c: Likewise. + * _sd_to_di.c: Likewise. + * _sd_to_sf.c: Likewise. + * _sd_to_si.c: Likewise. + * _sd_to_td.c: Likewise. + * _sd_to_tf.c: Likewise. + * _sd_to_udi.c: Likewise. + * _sd_to_usi.c: Likewise. + * _sd_to_xf.c: Likewise. + * _sf_to_dd.c: Likewise. + * _sf_to_sd.c: Likewise. + * _sf_to_td.c: Likewise. + * _si_to_dd.c: Likewise. + * _si_to_sd.c: Likewise. + * _si_to_td.c: Likewise. + * _td_to_dd.c: Likewise. + * _td_to_df.c: Likewise. + * _td_to_di.c: Likewise. + * _td_to_sd.c: Likewise. + * _td_to_sf.c: Likewise. + * _td_to_si.c: Likewise. + * _td_to_tf.c: Likewise. + * _td_to_udi.c: Likewise. + * _td_to_usi.c: Likewise. + * _td_to_xf.c: Likewise. + * _tf_to_dd.c: Likewise. + * _tf_to_sd.c: Likewise. + * _tf_to_td.c: Likewise. + * _udi_to_dd.c: Likewise. + * _udi_to_sd.c: Likewise. + * _udi_to_td.c: Likewise. + * _unord_dd.c: Likewise. + * _unord_sd.c: Likewise. + * _unord_td.c: Likewise. + * _usi_to_dd.c: Likewise. + * _usi_to_sd.c: Likewise. + * _usi_to_td.c: Likewise. + * _xf_to_dd.c: Likewise. + * _xf_to_sd.c: Likewise. + * _xf_to_td.c: Likewise. + +2007-09-27 H.J. Lu <hongjiu.lu@intel.com> + + * b2d.h: Renamed to ... + * bid_b2d.h: This. + + * bid128_to_string.c: Renamed to ... + * bid128_string.c: This. + + * bid_intrinsics.h: Renamed to ... + * bid_gcc_intrinsics.h: This. + + * bid_string.c: Renamed to ... + * bid64_string.c: This. + + * binarydecimal.c: Renamed to ... + * bid_decimal_globals.c: This. + + * convert_data.c: Renamed to ... + * bid_convert_data.c: This. + + * decimal_data.c: Renamed to ... + * bid_decimal_data.c: This. + + * decimal_globals.c: Renamed to ... + * bid_decimal_globals.c: This. + + * div_macros.h: Renamed to ... + * bid_div_macros.h: This. + + * inline_bid_add.h: Renamed to ... + * bid_inline_add.h: This. + + * sqrt_macros.h: Renamed to ... + * bid_sqrt_macros.h: This. + +2007-07-06 H.J. Lu <hongjiu.lu@intel.com> + + Updated from Intel BID library: + * bid_conf.h (BID_THREAD): Defined only if both HAVE_CC_TLS + and USE_TLS are defined. + +2007-07-05 H.J. Lu <hongjiu.lu@intel.com> + + Updated from Intel BID library: + * bid_conf.h (BID_THREAD): Defined. + (__bid_IDEC_glbround): Add BID_THREAD in declaration. + (__bid_IDEC_glbflags): Likewise. + + * decimal_globals.c (__bid_IDEC_glbround): Add BID_THREAD in + declaration. + (__bid_IDEC_glbflags): Likewise. + +2007-07-04 Marius Cornea <marius.cornea@intel.com> + H.J. Lu <hongjiu.lu@intel.com> + + * _addsub_dd.c: New file from Intel BID library. + * _addsub_sd.c: Likewise. + * _addsub_td.c: Likewise. + * _dd_to_df.c: Likewise. + * _dd_to_di.c: Likewise. + * _dd_to_sd.c: Likewise. + * _dd_to_sf.c: Likewise. + * _dd_to_si.c: Likewise. + * _dd_to_td.c: Likewise. + * _dd_to_tf.c: Likewise. + * _dd_to_udi.c: Likewise. + * _dd_to_usi.c: Likewise. + * _dd_to_xf.c: Likewise. + * _df_to_dd.c: Likewise. + * _df_to_sd.c: Likewise. + * _df_to_td.c: Likewise. + * _di_to_dd.c: Likewise. + * _di_to_sd.c: Likewise. + * _di_to_td.c: Likewise. + * _div_dd.c: Likewise. + * _div_sd.c: Likewise. + * _div_td.c: Likewise. + * _eq_dd.c: Likewise. + * _eq_sd.c: Likewise. + * _eq_td.c: Likewise. + * _ge_dd.c: Likewise. + * _ge_sd.c: Likewise. + * _ge_td.c: Likewise. + * _gt_dd.c: Likewise. + * _gt_sd.c: Likewise. + * _gt_td.c: Likewise. + * _isinfd128.c: Likewise. + * _isinfd32.c: Likewise. + * _isinfd64.c: Likewise. + * _le_dd.c: Likewise. + * _le_sd.c: Likewise. + * _le_td.c: Likewise. + * _lt_dd.c: Likewise. + * _lt_sd.c: Likewise. + * _lt_td.c: Likewise. + * _mul_dd.c: Likewise. + * _mul_sd.c: Likewise. + * _mul_td.c: Likewise. + * _ne_dd.c: Likewise. + * _ne_sd.c: Likewise. + * _ne_td.c: Likewise. + * _sd_to_dd.c: Likewise. + * _sd_to_df.c: Likewise. + * _sd_to_di.c: Likewise. + * _sd_to_sf.c: Likewise. + * _sd_to_si.c: Likewise. + * _sd_to_td.c: Likewise. + * _sd_to_tf.c: Likewise. + * _sd_to_udi.c: Likewise. + * _sd_to_usi.c: Likewise. + * _sd_to_xf.c: Likewise. + * _sf_to_dd.c: Likewise. + * _sf_to_sd.c: Likewise. + * _sf_to_td.c: Likewise. + * _si_to_dd.c: Likewise. + * _si_to_sd.c: Likewise. + * _si_to_td.c: Likewise. + * _td_to_dd.c: Likewise. + * _td_to_df.c: Likewise. + * _td_to_di.c: Likewise. + * _td_to_sd.c: Likewise. + * _td_to_sf.c: Likewise. + * _td_to_si.c: Likewise. + * _td_to_tf.c: Likewise. + * _td_to_udi.c: Likewise. + * _td_to_usi.c: Likewise. + * _td_to_xf.c: Likewise. + * _tf_to_dd.c: Likewise. + * _tf_to_sd.c: Likewise. + * _tf_to_td.c: Likewise. + * _udi_to_dd.c: Likewise. + * _udi_to_sd.c: Likewise. + * _udi_to_td.c: Likewise. + * _unord_dd.c: Likewise. + * _unord_sd.c: Likewise. + * _unord_td.c: Likewise. + * _usi_to_dd.c: Likewise. + * _usi_to_sd.c: Likewise. + * _usi_to_td.c: Likewise. + * _xf_to_dd.c: Likewise. + * _xf_to_sd.c: Likewise. + * _xf_to_td.c: Likewise. + +2007-07-04 Marius Cornea <marius.cornea@intel.com> + + * b2d.h: New file from Intel BID library. + * bid128_2_str.h: Likewise. + * bid128_2_str_macros.h: Likewise. + * bid128_2_str_tables.c: Likewise. + * bid128_add.c: Likewise. + * bid128.c: Likewise. + * bid128_compare.c: Likewise. + * bid128_div.c: Likewise. + * bid128_fma.c: Likewise. + * bid128_fromstring.c: Likewise. + * bid128_logb.c: Likewise. + * bid128_minmax.c: Likewise. + * bid128_mul.c: Likewise. + * bid128_next.c: Likewise. + * bid128_noncomp.c: Likewise. + * bid128_quantize.c: Likewise. + * bid128_rem.c: Likewise. + * bid128_round_integral.c: Likewise. + * bid128_scalb.c: Likewise. + * bid128_sqrt.c: Likewise. + * bid128_to_int32.c: Likewise. + * bid128_to_int64.c: Likewise. + * bid128_to_string.c: Likewise. + * bid128_to_uint32.c: Likewise. + * bid128_to_uint64.c: Likewise. + * bid32_to_bid128.c: Likewise. + * bid32_to_bid64.c: Likewise. + * bid64_add.c: Likewise. + * bid64_compare.c: Likewise. + * bid64_div.c: Likewise. + * bid64_fma.c: Likewise. + * bid64_logb.c: Likewise. + * bid64_minmax.c: Likewise. + * bid64_mul.c: Likewise. + * bid64_next.c: Likewise. + * bid64_noncomp.c: Likewise. + * bid64_quantize.c: Likewise. + * bid64_rem.c: Likewise. + * bid64_round_integral.c: Likewise. + * bid64_scalb.c: Likewise. + * bid64_sqrt.c: Likewise. + * bid64_to_bid128.c: Likewise. + * bid64_to_int32.c: Likewise. + * bid64_to_int64.c: Likewise. + * bid64_to_uint32.c: Likewise. + * bid64_to_uint64.c: Likewise. + * bid_conf.h: Likewise. + * bid_flag_operations.c: Likewise. + * bid_from_int.c: Likewise. + * bid_functions.h: Likewise. + * bid_internal.h: Likewise. + * bid_round.c: Likewise. + * bid_string.c: Likewise. + * binarydecimal.c: Likewise. + * convert_data.c: Likewise. + * decimal_data.c: Likewise. + * decimal_globals.c: Likewise. + * div_macros.h: Likewise. + * inline_bid_add.h: Likewise. + * sqrt_macros.h: Likewise. diff --git a/gcc-4.4.3/libgcc/config/libbid/_addsub_dd.c b/gcc-4.4.3/libgcc/config/libbid/_addsub_dd.c new file mode 100644 index 000000000..ef5f778d4 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_addsub_dd.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_adddd3 (_Decimal64 x, _Decimal64 y) { + union decimal64 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid64_add (ux.i, uy.i); + return (res.d); +} + +_Decimal64 +__bid_subdd3 (_Decimal64 x, _Decimal64 y) { + union decimal64 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid64_sub (ux.i, uy.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_addsub_sd.c b/gcc-4.4.3/libgcc/config/libbid/_addsub_sd.c new file mode 100644 index 000000000..5224e57fa --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_addsub_sd.c @@ -0,0 +1,54 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_addsd3 (_Decimal32 x, _Decimal32 y) { + UINT64 x64, y64, res64; + union decimal32 ux, uy, res; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res64 = __bid64_add (x64, y64); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} + +_Decimal32 +__bid_subsd3 (_Decimal32 x, _Decimal32 y) { + UINT64 x64, y64, res64; + union decimal32 ux, uy, res; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res64 = __bid64_sub (x64, y64); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_addsub_td.c b/gcc-4.4.3/libgcc/config/libbid/_addsub_td.c new file mode 100644 index 000000000..f37aeafcc --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_addsub_td.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_addtd3 (_Decimal128 x, _Decimal128 y) { + union decimal128 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid128_add (ux.i, uy.i); + return (res.d); +} + +_Decimal128 +__bid_subtd3 (_Decimal128 x, _Decimal128 y) { + union decimal128 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid128_sub (ux.i, uy.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_df.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_df.c new file mode 100644 index 000000000..af08295a0 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_df.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +DFtype +__bid_truncdddf (_Decimal64 x) { + DFtype res; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_binary64 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_di.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_di.c new file mode 100644 index 000000000..a89c19923 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_di.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +DItype +__bid_fixdddi (_Decimal64 x) { + DItype res = 0xbaddbaddbaddbaddull; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_int64_xint (ux.i); + + return (res); +} + + diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_sd.c new file mode 100644 index 000000000..e81cccd33 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_truncddsd2 (_Decimal64 x) { + union decimal32 res; + union decimal64 ux; + + ux.d = x; + res.i = __bid64_to_bid32 (ux.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_sf.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_sf.c new file mode 100644 index 000000000..5fd560b27 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_sf.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +SFtype +__bid_truncddsf (_Decimal64 x) { + SFtype res; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_binary32 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_si.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_si.c new file mode 100644 index 000000000..5780739c8 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_si.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +SItype +__bid_fixddsi (_Decimal64 x) { + SItype res = 0xbaddbadd; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_int32_xint (ux.i); + + return (res); +} + + diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_td.c new file mode 100644 index 000000000..cb13ee67a --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_td.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_extendddtd2 (_Decimal64 x) { + union decimal128 res; + union decimal64 ux; + + ux.d = x; + res.i = __bid64_to_bid128 (ux.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_tf.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_tf.c new file mode 100644 index 000000000..fa6be8774 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_tf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_TF_MODE || BID_HAS_TF_MODE +TFtype +__bid_extendddtf (_Decimal64 x) { + union float128 res; + union decimal64 ux; + + ux.d = x; + res.i = __bid64_to_binary128 (ux.i); + return (res.f); +} +#endif diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_udi.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_udi.c new file mode 100644 index 000000000..b39909d0a --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_udi.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +UDItype +__bid_fixunsdddi (_Decimal64 x) { + UDItype res = 0xbaddbaddbaddbaddull; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_uint64_xint (ux.i); + + if (res == 0x8000000000000000ull) res = 0; // for NaNs too + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_usi.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_usi.c new file mode 100644 index 000000000..e0fd8bb9d --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_usi.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +USItype +__bid_fixunsddsi (_Decimal64 x) { + USItype res = 0xbaddbadd; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_uint32_xint (ux.i); + + if (res == 0x80000000) res = 0; // for NaNs too + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_dd_to_xf.c b/gcc-4.4.3/libgcc/config/libbid/_dd_to_xf.c new file mode 100644 index 000000000..fb0dce67d --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_dd_to_xf.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +XFtype +__bid_extendddxf (_Decimal64 x) { + XFtype res; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_binary80 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_df_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_df_to_dd.c new file mode 100644 index 000000000..4e7ccdd43 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_df_to_dd.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_extenddfdd (DFtype x) { + union decimal64 res; + res.i = __binary64_to_bid64 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_df_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_df_to_sd.c new file mode 100644 index 000000000..8be9859c7 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_df_to_sd.c @@ -0,0 +1,34 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_truncdfsd (DFtype x) { + union decimal32 res; + + res.i = __binary64_to_bid32 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_df_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_df_to_td.c new file mode 100644 index 000000000..896646afd --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_df_to_td.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_extenddftd (DFtype x) { + union decimal128 res; + res.i = __binary64_to_bid128 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_di_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_di_to_dd.c new file mode 100644 index 000000000..4f4f1617c --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_di_to_dd.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_floatdidd (DItype x) { + union decimal64 res; + + res.i = __bid64_from_int64 (x); + return (res.d); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_di_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_di_to_sd.c new file mode 100644 index 000000000..603392441 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_di_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_floatdisd (DItype x) { + union decimal32 res; + UINT64 res64; + + res64 = __bid64_from_int64 (x); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_di_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_di_to_td.c new file mode 100644 index 000000000..0cadeb4d9 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_di_to_td.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_floatditd (DItype x) { + union decimal128 res; + + res.i = __bid128_from_int64 (x); + return (res.d); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_div_dd.c b/gcc-4.4.3/libgcc/config/libbid/_div_dd.c new file mode 100644 index 000000000..324087455 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_div_dd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_divdd3 (_Decimal64 x, _Decimal64 y) { + union decimal64 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid64_div (ux.i, uy.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_div_sd.c b/gcc-4.4.3/libgcc/config/libbid/_div_sd.c new file mode 100644 index 000000000..2a37a9b82 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_div_sd.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_divsd3 (_Decimal32 x, _Decimal32 y) { + UINT64 x64, y64, res64; + union decimal32 ux, uy, res; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res64 = __bid64_div (x64, y64); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_div_td.c b/gcc-4.4.3/libgcc/config/libbid/_div_td.c new file mode 100644 index 000000000..165e2009f --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_div_td.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_divtd3 (_Decimal128 x, _Decimal128 y) { + union decimal128 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid128_div (ux.i, uy.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_eq_dd.c b/gcc-4.4.3/libgcc/config/libbid/_eq_dd.c new file mode 100644 index 000000000..8d189f4a3 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_eq_dd.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_eqdd2 (_Decimal64 x, _Decimal64 y) { + CMPtype res; + union decimal64 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid64_quiet_equal (ux.i, uy.i); + if (res == 0) + res = 1; + else + res = 0; + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_eq_sd.c b/gcc-4.4.3/libgcc/config/libbid/_eq_sd.c new file mode 100644 index 000000000..d94ac8376 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_eq_sd.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_eqsd2 (_Decimal32 x, _Decimal32 y) { + CMPtype res; + UINT64 x64, y64; + union decimal32 ux, uy; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res = __bid64_quiet_equal (x64, y64); + if (res == 0) + res = 1; + else + res = 0; + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_eq_td.c b/gcc-4.4.3/libgcc/config/libbid/_eq_td.c new file mode 100644 index 000000000..d48a0ceeb --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_eq_td.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_eqtd2 (_Decimal128 x, _Decimal128 y) { + CMPtype res; + union decimal128 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid128_quiet_equal (ux.i, uy.i); + if (res == 0) + res = 1; + else + res = 0; + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_ge_dd.c b/gcc-4.4.3/libgcc/config/libbid/_ge_dd.c new file mode 100644 index 000000000..461c0e522 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_ge_dd.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_gedd2 (_Decimal64 x, _Decimal64 y) { + CMPtype res; + union decimal64 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid64_quiet_greater_equal (ux.i, uy.i); + if (res == 0) res = -1; + + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_ge_sd.c b/gcc-4.4.3/libgcc/config/libbid/_ge_sd.c new file mode 100644 index 000000000..4781ddc35 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_ge_sd.c @@ -0,0 +1,42 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_gesd2 (_Decimal32 x, _Decimal32 y) { + CMPtype res; + UINT64 x64, y64; + union decimal32 ux, uy; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res = __bid64_quiet_greater_equal (x64, y64); + if (res == 0) res = -1; + + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_ge_td.c b/gcc-4.4.3/libgcc/config/libbid/_ge_td.c new file mode 100644 index 000000000..9f16619d7 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_ge_td.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_getd2 (_Decimal128 x, _Decimal128 y) { + CMPtype res; + union decimal128 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid128_quiet_greater_equal (ux.i, uy.i); + if (res == 0) res = -1; + + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_gt_dd.c b/gcc-4.4.3/libgcc/config/libbid/_gt_dd.c new file mode 100644 index 000000000..078faad8d --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_gt_dd.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_gtdd2 (_Decimal64 x, _Decimal64 y) { + CMPtype res; + union decimal64 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid64_quiet_greater (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_gt_sd.c b/gcc-4.4.3/libgcc/config/libbid/_gt_sd.c new file mode 100644 index 000000000..03f6a9396 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_gt_sd.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_gtsd2 (_Decimal32 x, _Decimal32 y) { + CMPtype res; + UINT64 x64, y64; + union decimal32 ux, uy; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res = __bid64_quiet_greater (x64, y64); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_gt_td.c b/gcc-4.4.3/libgcc/config/libbid/_gt_td.c new file mode 100644 index 000000000..528886e2e --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_gt_td.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_gttd2 (_Decimal128 x, _Decimal128 y) { + CMPtype res; + union decimal128 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid128_quiet_greater (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_isinfd128.c b/gcc-4.4.3/libgcc/config/libbid/_isinfd128.c new file mode 100644 index 000000000..10448dcbb --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_isinfd128.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +int +isinfd128 (_Decimal128 x) { + int res; + union decimal128 ux; + + ux.d = x; + res = __bid128_isInf (ux.i); + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_isinfd32.c b/gcc-4.4.3/libgcc/config/libbid/_isinfd32.c new file mode 100644 index 000000000..bed78aefe --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_isinfd32.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +int +isinfd32 (_Decimal32 x) { + int res; + UINT64 x64; + union decimal32 ux; + + ux.d = x; + x64 = __bid32_to_bid64 (ux.i); + res = __bid64_isInf (x64); + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_isinfd64.c b/gcc-4.4.3/libgcc/config/libbid/_isinfd64.c new file mode 100644 index 000000000..7de1d1932 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_isinfd64.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +int +isinfd64 (_Decimal64 x) { + int res; + union decimal64 ux; + + ux.d = x; + res = __bid64_isInf (ux.i); + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_le_dd.c b/gcc-4.4.3/libgcc/config/libbid/_le_dd.c new file mode 100644 index 000000000..32f0d96cd --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_le_dd.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_ledd2 (_Decimal64 x, _Decimal64 y) { + CMPtype res; + union decimal64 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid64_quiet_less_equal (ux.i, uy.i); + if (res != 0) + res = -1; + else + res = 1; + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_le_sd.c b/gcc-4.4.3/libgcc/config/libbid/_le_sd.c new file mode 100644 index 000000000..565632ba0 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_le_sd.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_lesd2 (_Decimal32 x, _Decimal32 y) { + CMPtype res; + UINT64 x64, y64; + union decimal32 ux, uy; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res = __bid64_quiet_less_equal (x64, y64); + if (res != 0) + res = -1; + else + res = 1; + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_le_td.c b/gcc-4.4.3/libgcc/config/libbid/_le_td.c new file mode 100644 index 000000000..1fefc8e80 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_le_td.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_letd2 (_Decimal128 x, _Decimal128 y) { + CMPtype res; + union decimal128 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid128_quiet_less_equal (ux.i, uy.i); + if (res != 0) + res = -1; + else + res = 1; + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_lt_dd.c b/gcc-4.4.3/libgcc/config/libbid/_lt_dd.c new file mode 100644 index 000000000..868890d72 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_lt_dd.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_ltdd2 (_Decimal64 x, _Decimal64 y) { + CMPtype res; + union decimal64 ux, uy; + + ux.d = x; + uy.d = y; + res = -__bid64_quiet_less (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_lt_sd.c b/gcc-4.4.3/libgcc/config/libbid/_lt_sd.c new file mode 100644 index 000000000..5810f6a01 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_lt_sd.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_ltsd2 (_Decimal32 x, _Decimal32 y) { + CMPtype res; + UINT64 x64, y64; + union decimal32 ux, uy; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res = -__bid64_quiet_less (x64, y64); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_lt_td.c b/gcc-4.4.3/libgcc/config/libbid/_lt_td.c new file mode 100644 index 000000000..1a31b32a9 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_lt_td.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_lttd2 (_Decimal128 x, _Decimal128 y) { + CMPtype res; + union decimal128 ux, uy; + + ux.d = x; + uy.d = y; + res = -__bid128_quiet_less (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_mul_dd.c b/gcc-4.4.3/libgcc/config/libbid/_mul_dd.c new file mode 100644 index 000000000..d0082f701 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_mul_dd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_muldd3 (_Decimal64 x, _Decimal64 y) { + union decimal64 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid64_mul (ux.i, uy.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_mul_sd.c b/gcc-4.4.3/libgcc/config/libbid/_mul_sd.c new file mode 100644 index 000000000..73b11e952 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_mul_sd.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_mulsd3 (_Decimal32 x, _Decimal32 y) { + UINT64 x64, y64, res64; + union decimal32 ux, uy, res; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res64 = __bid64_mul (x64, y64); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_mul_td.c b/gcc-4.4.3/libgcc/config/libbid/_mul_td.c new file mode 100644 index 000000000..0c2983c2a --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_mul_td.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_multd3 (_Decimal128 x, _Decimal128 y) { + union decimal128 ux, uy, res; + + ux.d = x; + uy.d = y; + res.i = __bid128_mul (ux.i, uy.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_ne_dd.c b/gcc-4.4.3/libgcc/config/libbid/_ne_dd.c new file mode 100644 index 000000000..3b62f0d78 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_ne_dd.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_nedd2 (_Decimal64 x, _Decimal64 y) { + CMPtype res; + union decimal64 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid64_quiet_not_equal (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_ne_sd.c b/gcc-4.4.3/libgcc/config/libbid/_ne_sd.c new file mode 100644 index 000000000..1b311ba68 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_ne_sd.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_nesd2 (_Decimal32 x, _Decimal32 y) { + CMPtype res; + UINT64 x64, y64; + union decimal32 ux, uy; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res = __bid64_quiet_not_equal (x64, y64); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_ne_td.c b/gcc-4.4.3/libgcc/config/libbid/_ne_td.c new file mode 100644 index 000000000..9f2c5dab3 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_ne_td.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_netd2 (_Decimal128 x, _Decimal128 y) { + CMPtype res; + union decimal128 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid128_quiet_not_equal (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_dd.c new file mode 100644 index 000000000..0d03b484a --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_dd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_extendsddd2 (_Decimal32 x) { + union decimal64 res; + union decimal32 ux; + + ux.d = x; + res.i = __bid32_to_bid64 (ux.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_df.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_df.c new file mode 100644 index 000000000..8e864f5aa --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_df.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +DFtype +__bid_extendsddf (_Decimal32 x) { + DFtype res; + union decimal32 ux; + + ux.d = x; + res = __bid32_to_binary64 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_di.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_di.c new file mode 100644 index 000000000..7e83b4c7e --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_di.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +DItype +__bid_fixsddi (_Decimal32 x) { + DItype res = 0xbaddbaddbaddbaddull; + UINT64 x64; + union decimal32 ux; + + ux.d = x; + x64 = __bid32_to_bid64 (ux.i); + res = __bid64_to_int64_xint (x64); + + return (res); +} + + diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_sf.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_sf.c new file mode 100644 index 000000000..645bec29d --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_sf.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +SFtype +__bid_truncsdsf (_Decimal32 x) { + SFtype res; + union decimal32 ux; + + ux.d = x; + res = __bid32_to_binary32 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_si.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_si.c new file mode 100644 index 000000000..55d7402ca --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_si.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +SItype +__bid_fixsdsi (_Decimal32 x) { + SItype res = 0xbaddbadd; + UINT64 x64; + union decimal32 ux; + + ux.d = x; + x64 = __bid32_to_bid64 (ux.i); + res = __bid64_to_int32_xint (x64); + + return (res); +} + + diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_td.c new file mode 100644 index 000000000..e2c955d24 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_td.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_extendsdtd2 (_Decimal32 x) { + union decimal128 res; + union decimal32 ux; + + ux.d = x; + res.i = __bid32_to_bid128 (ux.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_tf.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_tf.c new file mode 100644 index 000000000..2b1109afe --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_tf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_TF_MODE || BID_HAS_TF_MODE +TFtype +__bid_extendsdtf (_Decimal32 x) { + union float128 res; + union decimal32 ux; + + ux.d = x; + res.i = __bid32_to_binary128 (ux.i); + return (res.f); +} +#endif diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_udi.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_udi.c new file mode 100644 index 000000000..0c3840082 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_udi.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +UDItype +__bid_fixunssddi (_Decimal32 x) { + UDItype res = 0xbaddbaddbaddbaddull; + UINT64 x64; + union decimal32 ux; + + ux.d = x; + x64 = __bid32_to_bid64 (ux.i); + res = __bid64_to_uint64_xint (x64); + + if (res == 0x8000000000000000ull) res = 0; // for NaNs too + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_usi.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_usi.c new file mode 100644 index 000000000..742cae857 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_usi.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +USItype +__bid_fixunssdsi (_Decimal32 x) { + USItype res = 0xbaddbadd; + UINT64 x64; + union decimal32 ux; + + ux.d = x; + x64 = __bid32_to_bid64 (ux.i); + res = __bid64_to_uint32_xint (x64); + + if (res == 0x80000000) res = 0; // for NaNs too + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_sd_to_xf.c b/gcc-4.4.3/libgcc/config/libbid/_sd_to_xf.c new file mode 100644 index 000000000..23c06d2a0 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sd_to_xf.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +XFtype +__bid_extendsdxf (_Decimal32 x) { + XFtype res; + union decimal32 ux; + + ux.d = x; + res = __bid32_to_binary80 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sf_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_sf_to_dd.c new file mode 100644 index 000000000..15fc298c2 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sf_to_dd.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_extendsfdd (SFtype x) { + union decimal64 res; + res.i = __binary32_to_bid64 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sf_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_sf_to_sd.c new file mode 100644 index 000000000..465ced0ea --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sf_to_sd.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_extendsfsd (SFtype x) { + union decimal32 res; + res.i = __binary32_to_bid32 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_sf_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_sf_to_td.c new file mode 100644 index 000000000..a1fe5b9c4 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_sf_to_td.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_extendsftd (SFtype x) { + union decimal128 res; + res.i = __binary32_to_bid128 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_si_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_si_to_dd.c new file mode 100644 index 000000000..0487ec8d5 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_si_to_dd.c @@ -0,0 +1,34 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_floatsidd (SItype x) { + union decimal64 res; + + res.i = __bid64_from_int32 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_si_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_si_to_sd.c new file mode 100644 index 000000000..6f1b97135 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_si_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_floatsisd (SItype x) { + union decimal32 res; + UINT64 res64; + + res64 = __bid64_from_int32 (x); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_si_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_si_to_td.c new file mode 100644 index 000000000..f78b73ee7 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_si_to_td.c @@ -0,0 +1,34 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_floatsitd (SItype x) { + union decimal128 res; + + res.i = __bid128_from_int32 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_dd.c new file mode 100644 index 000000000..5535b8427 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_dd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_trunctddd2 (_Decimal128 x) { + union decimal128 ux; + union decimal64 res; + + ux.d = x; + res.i = __bid128_to_bid64 (ux.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_df.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_df.c new file mode 100644 index 000000000..1b9c646a5 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_df.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +DFtype +__bid_trunctddf (_Decimal128 x) { + DFtype res; + union decimal128 ux; + + ux.d = x; + res = __bid128_to_binary64 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_di.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_di.c new file mode 100644 index 000000000..2c54cf026 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_di.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +DItype +__bid_fixtddi (_Decimal128 x) { + DItype res = 0xbaddbaddbaddbaddull; + union decimal128 ux; + + ux.d = x; + res = __bid128_to_int64_xint (ux.i); + + return (res); +} + + diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_sd.c new file mode 100644 index 000000000..30cf94232 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_trunctdsd2 (_Decimal128 x) { + union decimal128 ux; + union decimal32 res; + + ux.d = x; + res.i = __bid128_to_bid32 (ux.i); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_sf.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_sf.c new file mode 100644 index 000000000..d0cf871fb --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_sf.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +SFtype +__bid_trunctdsf (_Decimal128 x) { + SFtype res; + union decimal128 ux; + + ux.d = x; + res = __bid128_to_binary32 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_si.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_si.c new file mode 100644 index 000000000..8d0c70c3f --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_si.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +SItype +__bid_fixtdsi (_Decimal128 x) { + union decimal128 ux; + SItype res = 0xbaddbadd; + + ux.d = x; + res = __bid128_to_int32_xint (ux.i); + + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_tf.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_tf.c new file mode 100644 index 000000000..ff66312df --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_tf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_TF_MODE || BID_HAS_TF_MODE +TFtype +__bid_trunctdtf (_Decimal128 x) { + union float128 res; + union decimal128 ux; + + ux.d = x; + res.i = __bid128_to_binary128 (ux.i); + return (res.f); +} +#endif diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_udi.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_udi.c new file mode 100644 index 000000000..305f1a81f --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_udi.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +UDItype +__bid_fixunstddi (_Decimal128 x) { + UDItype res = 0xbaddbaddbaddbaddull; + union decimal128 ux; + + ux.d = x; + + res = __bid128_to_uint64_xint (ux.i); + + if (res == 0x8000000000000000ull) res = 0; // for NaNs too + return (res); +} + + diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_usi.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_usi.c new file mode 100644 index 000000000..9c69c6510 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_usi.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +USItype +__bid_fixunstdsi (_Decimal128 x) { + USItype res = 0xbaddbadd; + union decimal128 ux; + + ux.d = x; + res = __bid128_to_uint32_xint (ux.i); + + if (res == 0x80000000) res = 0; // for NaNs too + return (res); +} + + diff --git a/gcc-4.4.3/libgcc/config/libbid/_td_to_xf.c b/gcc-4.4.3/libgcc/config/libbid/_td_to_xf.c new file mode 100644 index 000000000..c57987396 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_td_to_xf.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +XFtype +__bid_trunctdxf (_Decimal128 x) { + XFtype res; + union decimal128 ux; + + ux.d = x; + res = __bid128_to_binary80 (ux.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_tf_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_tf_to_dd.c new file mode 100644 index 000000000..70686013a --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_tf_to_dd.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_TF_MODE || BID_HAS_TF_MODE +_Decimal64 +__bid_trunctfdd (TFtype x) { + union decimal64 res; + union float128 ux; + + ux.f = x; + res.i = __binary128_to_bid64 (ux.i); + return (res.d); +} +#endif diff --git a/gcc-4.4.3/libgcc/config/libbid/_tf_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_tf_to_sd.c new file mode 100644 index 000000000..c5462f6a5 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_tf_to_sd.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_TF_MODE || BID_HAS_TF_MODE +_Decimal32 +__bid_trunctfsd (TFtype x) { + union decimal32 res; + union float128 ux; + + ux.f = x; + res.i = __binary128_to_bid32 (ux.i); + return (res.d); +} +#endif diff --git a/gcc-4.4.3/libgcc/config/libbid/_tf_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_tf_to_td.c new file mode 100644 index 000000000..df503ac54 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_tf_to_td.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_TF_MODE || BID_HAS_TF_MODE +_Decimal128 +__bid_extendtftd (TFtype x) { + union decimal128 res; + union float128 ux; + + ux.f = x; + res.i = __binary128_to_bid128 (ux.i); + return (res.d); +} +#endif diff --git a/gcc-4.4.3/libgcc/config/libbid/_udi_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_udi_to_dd.c new file mode 100644 index 000000000..166d13619 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_udi_to_dd.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_floatunsdidd (UDItype x) { + union decimal64 res; + + res.i = __bid64_from_uint64 (x); + return (res.d); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_udi_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_udi_to_sd.c new file mode 100644 index 000000000..56873cf7d --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_udi_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_floatunsdisd (UDItype x) { + union decimal32 res; + UINT64 res64; + + res64 = __bid64_from_uint64 (x); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_udi_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_udi_to_td.c new file mode 100644 index 000000000..dac5d8f10 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_udi_to_td.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_floatunsditd (UDItype x) { + union decimal128 res; + + res.i = __bid128_from_uint64 (x); + return (res.d); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_unord_dd.c b/gcc-4.4.3/libgcc/config/libbid/_unord_dd.c new file mode 100644 index 000000000..8828edebc --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_unord_dd.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_unorddd2 (_Decimal64 x, _Decimal64 y) { + CMPtype res; + union decimal64 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid64_quiet_unordered (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_unord_sd.c b/gcc-4.4.3/libgcc/config/libbid/_unord_sd.c new file mode 100644 index 000000000..c5595447d --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_unord_sd.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_unordsd2 (_Decimal32 x, _Decimal32 y) { + CMPtype res; + UINT64 x64, y64; + union decimal32 ux, uy; + + ux.d = x; + uy.d = y; + x64 = __bid32_to_bid64 (ux.i); + y64 = __bid32_to_bid64 (uy.i); + res = __bid64_quiet_unordered (x64, y64); + return (res); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_unord_td.c b/gcc-4.4.3/libgcc/config/libbid/_unord_td.c new file mode 100644 index 000000000..f45dceb8a --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_unord_td.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +CMPtype +__bid_unordtd2 (_Decimal128 x, _Decimal128 y) { + CMPtype res; + union decimal128 ux, uy; + + ux.d = x; + uy.d = y; + res = __bid128_quiet_unordered (ux.i, uy.i); + return (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_usi_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_usi_to_dd.c new file mode 100644 index 000000000..71796effd --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_usi_to_dd.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_floatunssidd (USItype x) { + union decimal64 res; + + res.i = __bid64_from_uint32 (x); + return (res.d); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_usi_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_usi_to_sd.c new file mode 100644 index 000000000..42c0ac4e3 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_usi_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_floatunssisd (USItype x) { + union decimal32 res; + UINT64 res64; + + res64 = __bid64_from_uint32 (x); + res.i = __bid64_to_bid32 (res64); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_usi_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_usi_to_td.c new file mode 100644 index 000000000..afc9087ad --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_usi_to_td.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_floatunssitd (USItype x) { + union decimal128 res; + + res.i = __bid128_from_uint32 (x); + return (res.d); +} + diff --git a/gcc-4.4.3/libgcc/config/libbid/_xf_to_dd.c b/gcc-4.4.3/libgcc/config/libbid/_xf_to_dd.c new file mode 100644 index 000000000..f8ae78e98 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_xf_to_dd.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal64 +__bid_truncxfdd (XFtype x) { + union decimal64 res; + res.i = __binary80_to_bid64 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_xf_to_sd.c b/gcc-4.4.3/libgcc/config/libbid/_xf_to_sd.c new file mode 100644 index 000000000..d5924fa1c --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_xf_to_sd.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal32 +__bid_truncxfsd (XFtype x) { + union decimal32 res; + res.i = __binary80_to_bid32 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/_xf_to_td.c b/gcc-4.4.3/libgcc/config/libbid/_xf_to_td.c new file mode 100644 index 000000000..7d2f27842 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/_xf_to_td.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +_Decimal128 +__bid_extendxftd (XFtype x) { + union decimal128 res; + res.i = __binary80_to_bid128 (x); + return (res.d); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/bid128.c b/gcc-4.4.3/libgcc/config/libbid/bid128.c new file mode 100644 index 000000000..617340962 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/bid128.c @@ -0,0 +1,4333 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_internal.h" + +// the first entry of nr_digits[i - 1] (where 1 <= i <= 113), indicates +// the number of decimal digits needed to represent a binary number with i bits; +// however, if a binary number of i bits may require either k or k + 1 decimal +// digits, then the first entry of nr_digits[i - 1] is 0; in this case if the +// number is less than the value represented by the second and third entries +// concatenated, then the number of decimal digits k is the fourth entry, else +// the number of decimal digits is the fourth entry plus 1 +DEC_DIGITS nr_digits[] = { // only the first entry is used if it is not 0 + {1, 0x0000000000000000ULL, 0x000000000000000aULL, 1} + , // 1-bit n < 10^1 + {1, 0x0000000000000000ULL, 0x000000000000000aULL, 1} + , // 2-bit n < 10^1 + {1, 0x0000000000000000ULL, 0x000000000000000aULL, 1} + , // 3-bit n < 10^1 + {0, 0x0000000000000000ULL, 0x000000000000000aULL, 1} + , // 4-bit n ? 10^1 + {2, 0x0000000000000000ULL, 0x0000000000000064ULL, 2} + , // 5-bit n < 10^2 + {2, 0x0000000000000000ULL, 0x0000000000000064ULL, 2} + , // 6-bit n < 10^2 + {0, 0x0000000000000000ULL, 0x0000000000000064ULL, 2} + , // 7-bit n ? 10^2 + {3, 0x0000000000000000ULL, 0x00000000000003e8ULL, 3} + , // 8-bit n < 10^3 + {3, 0x0000000000000000ULL, 0x00000000000003e8ULL, 3} + , // 9-bit n < 10^3 + {0, 0x0000000000000000ULL, 0x00000000000003e8ULL, 3} + , // 10-bit n ? 10^3 + {4, 0x0000000000000000ULL, 0x0000000000002710ULL, 4} + , // 11-bit n < 10^4 + {4, 0x0000000000000000ULL, 0x0000000000002710ULL, 4} + , // 12-bit n < 10^4 + {4, 0x0000000000000000ULL, 0x0000000000002710ULL, 4} + , // 13-bit n < 10^4 + {0, 0x0000000000000000ULL, 0x0000000000002710ULL, 4} + , // 14-bit n ? 10^4 + {5, 0x0000000000000000ULL, 0x00000000000186a0ULL, 5} + , // 15-bit n < 10^5 + {5, 0x0000000000000000ULL, 0x00000000000186a0ULL, 5} + , // 16-bit n < 10^5 + {0, 0x0000000000000000ULL, 0x00000000000186a0ULL, 5} + , // 17-bit n ? 10^5 + {6, 0x0000000000000000ULL, 0x00000000000f4240ULL, 6} + , // 18-bit n < 10^6 + {6, 0x0000000000000000ULL, 0x00000000000f4240ULL, 6} + , // 19-bit n < 10^6 + {0, 0x0000000000000000ULL, 0x00000000000f4240ULL, 6} + , // 20-bit n ? 10^6 + {7, 0x0000000000000000ULL, 0x0000000000989680ULL, 7} + , // 21-bit n < 10^7 + {7, 0x0000000000000000ULL, 0x0000000000989680ULL, 7} + , // 22-bit n < 10^7 + {7, 0x0000000000000000ULL, 0x0000000000989680ULL, 7} + , // 23-bit n < 10^7 + {0, 0x0000000000000000ULL, 0x0000000000989680ULL, 7} + , // 24-bit n ? 10^7 + {8, 0x0000000000000000ULL, 0x0000000005f5e100ULL, 8} + , // 25-bit n < 10^8 + {8, 0x0000000000000000ULL, 0x0000000005f5e100ULL, 8} + , // 26-bit n < 10^8 + {0, 0x0000000000000000ULL, 0x0000000005f5e100ULL, 8} + , // 27-bit n ? 10^8 + {9, 0x0000000000000000ULL, 0x000000003b9aca00ULL, 9} + , // 28-bit n < 10^9 + {9, 0x0000000000000000ULL, 0x000000003b9aca00ULL, 9} + , // 29-bit n < 10^9 + {0, 0x0000000000000000ULL, 0x000000003b9aca00ULL, 9} + , // 30-bit n ? 10^9 + {10, 0x0000000000000000ULL, 0x00000002540be400ULL, 10} + , // 31-bit n < 10^10 + {10, 0x0000000000000000ULL, 0x00000002540be400ULL, 10} + , // 32-bit n < 10^10 + {10, 0x0000000000000000ULL, 0x00000002540be400ULL, 10} + , // 33-bit n < 10^10 + {0, 0x0000000000000000ULL, 0x00000002540be400ULL, 10} + , // 34-bit n ? 10^10 + {11, 0x0000000000000000ULL, 0x000000174876e800ULL, 11} + , // 35-bit n < 10^11 + {11, 0x0000000000000000ULL, 0x000000174876e800ULL, 11} + , // 36-bit n < 10^11 + {0, 0x0000000000000000ULL, 0x000000174876e800ULL, 11} + , // 37-bit n ? 10^11 + {12, 0x0000000000000000ULL, 0x000000e8d4a51000ULL, 12} + , // 38-bit n < 10^12 + {12, 0x0000000000000000ULL, 0x000000e8d4a51000ULL, 12} + , // 39-bit n < 10^12 + {0, 0x0000000000000000ULL, 0x000000e8d4a51000ULL, 12} + , // 40-bit n ? 10^12 + {13, 0x0000000000000000ULL, 0x000009184e72a000ULL, 13} + , // 41-bit n < 10^13 + {13, 0x0000000000000000ULL, 0x000009184e72a000ULL, 13} + , // 42-bit n < 10^13 + {13, 0x0000000000000000ULL, 0x000009184e72a000ULL, 13} + , // 43-bit n < 10^13 + {0, 0x0000000000000000ULL, 0x000009184e72a000ULL, 13} + , // 44-bit n ? 10^13 + {14, 0x0000000000000000ULL, 0x00005af3107a4000ULL, 14} + , // 45-bit n < 10^14 + {14, 0x0000000000000000ULL, 0x00005af3107a4000ULL, 14} + , // 46-bit n < 10^14 + {0, 0x0000000000000000ULL, 0x00005af3107a4000ULL, 14} + , // 47-bit n ? 10^14 + {15, 0x0000000000000000ULL, 0x00038d7ea4c68000ULL, 15} + , // 48-bit n < 10^15 + {15, 0x0000000000000000ULL, 0x00038d7ea4c68000ULL, 15} + , // 49-bit n < 10^15 + {0, 0x0000000000000000ULL, 0x00038d7ea4c68000ULL, 15} + , // 50-bit n ? 10^15 + {16, 0x0000000000000000ULL, 0x002386f26fc10000ULL, 16} + , // 51-bit n < 10^16 + {16, 0x0000000000000000ULL, 0x002386f26fc10000ULL, 16} + , // 52-bit n < 10^16 + {16, 0x0000000000000000ULL, 0x002386f26fc10000ULL, 16} + , // 53-bit n < 10^16 + {0, 0x0000000000000000ULL, 0x002386f26fc10000ULL, 16} + , // 54-bit n ? 10^16 + {17, 0x0000000000000000ULL, 0x016345785d8a0000ULL, 17} + , // 55-bit n < 10^17 + {17, 0x0000000000000000ULL, 0x016345785d8a0000ULL, 17} + , // 56-bit n < 10^17 + {0, 0x0000000000000000ULL, 0x016345785d8a0000ULL, 17} + , // 57-bit n ? 10^17 + {18, 0x0000000000000000ULL, 0x0de0b6b3a7640000ULL, 18} + , // 58-bit n < 10^18 + {18, 0x0000000000000000ULL, 0x0de0b6b3a7640000ULL, 18} + , // 59-bit n < 10^18 + {0, 0x0000000000000000ULL, 0x0de0b6b3a7640000ULL, 18} + , // 60-bit n ? 10^18 + {19, 0x0000000000000000ULL, 0x8ac7230489e80000ULL, 19} + , // 61-bit n < 10^19 + {19, 0x0000000000000000ULL, 0x8ac7230489e80000ULL, 19} + , // 62-bit n < 10^19 + {19, 0x0000000000000000ULL, 0x8ac7230489e80000ULL, 19} + , // 63-bit n < 10^19 + {0, 0x0000000000000000ULL, 0x8ac7230489e80000ULL, 19} + , // 64-bit n ? 10^19 + {20, 0x0000000000000005ULL, 0x6bc75e2d63100000ULL, 20} + , // 65-bit n < 10^20 + {20, 0x0000000000000005ULL, 0x6bc75e2d63100000ULL, 20} + , // 66-bit n < 10^20 + {0, 0x0000000000000005ULL, 0x6bc75e2d63100000ULL, 20} + , // 67-bit n ? 10^20 + {21, 0x0000000000000036ULL, 0x35c9adc5dea00000ULL, 21} + , // 68-bit n < 10^21 + {21, 0x0000000000000036ULL, 0x35c9adc5dea00000ULL, 21} + , // 69-bit n < 10^21 + {0, 0x0000000000000036ULL, 0x35c9adc5dea00000ULL, 21} + , // 70-bit n ? 10^21 + {22, 0x000000000000021eULL, 0x19e0c9bab2400000ULL, 22} + , // 71-bit n < 10^22 + {22, 0x000000000000021eULL, 0x19e0c9bab2400000ULL, 22} + , // 72-bit n < 10^22 + {22, 0x000000000000021eULL, 0x19e0c9bab2400000ULL, 22} + , // 73-bit n < 10^22 + {0, 0x000000000000021eULL, 0x19e0c9bab2400000ULL, 22} + , // 74-bit n ? 10^22 + {23, 0x000000000000152dULL, 0x02c7e14af6800000ULL, 23} + , // 75-bit n < 10^23 + {23, 0x000000000000152dULL, 0x02c7e14af6800000ULL, 23} + , // 76-bit n < 10^23 + {0, 0x000000000000152dULL, 0x02c7e14af6800000ULL, 23} + , // 77-bit n ? 10^23 + {24, 0x000000000000d3c2ULL, 0x1bcecceda1000000ULL, 24} + , // 78-bit n < 10^24 + {24, 0x000000000000d3c2ULL, 0x1bcecceda1000000ULL, 24} + , // 79-bit n < 10^24 + {0, 0x000000000000d3c2ULL, 0x1bcecceda1000000ULL, 24} + , // 80-bit n ? 10^24 + {25, 0x0000000000084595ULL, 0x161401484a000000ULL, 25} + , // 81-bit n < 10^25 + {25, 0x0000000000084595ULL, 0x161401484a000000ULL, 25} + , // 82-bit n < 10^25 + {25, 0x0000000000084595ULL, 0x161401484a000000ULL, 25} + , // 83-bit n < 10^25 + {0, 0x0000000000084595ULL, 0x161401484a000000ULL, 25} + , // 84-bit n ? 10^25 + {26, 0x000000000052b7d2ULL, 0xdcc80cd2e4000000ULL, 26} + , // 85-bit n < 10^26 + {26, 0x000000000052b7d2ULL, 0xdcc80cd2e4000000ULL, 26} + , // 86-bit n < 10^26 + {0, 0x000000000052b7d2ULL, 0xdcc80cd2e4000000ULL, 26} + , // 87-bit n ? 10^26 + {27, 0x00000000033b2e3cULL, 0x9fd0803ce8000000ULL, 27} + , // 88-bit n < 10^27 + {27, 0x00000000033b2e3cULL, 0x9fd0803ce8000000ULL, 27} + , // 89-bit n < 10^27 + {0, 0x00000000033b2e3cULL, 0x9fd0803ce8000000ULL, 27} + , // 90-bit n ? 10^27 + {28, 0x00000000204fce5eULL, 0x3e25026110000000ULL, 28} + , // 91-bit n < 10^28 + {28, 0x00000000204fce5eULL, 0x3e25026110000000ULL, 28} + , // 92-bit n < 10^28 + {28, 0x00000000204fce5eULL, 0x3e25026110000000ULL, 28} + , // 93-bit n < 10^28 + {0, 0x00000000204fce5eULL, 0x3e25026110000000ULL, 28} + , // 94-bit n ? 10^28 + {29, 0x00000001431e0faeULL, 0x6d7217caa0000000ULL, 29} + , // 95-bit n < 10^29 + {29, 0x00000001431e0faeULL, 0x6d7217caa0000000ULL, 29} + , // 96-bit n < 10^29 + {0, 0x00000001431e0faeULL, 0x6d7217caa0000000ULL, 29} + , // 97-bit n ? 10^29 + {30, 0x0000000c9f2c9cd0ULL, 0x4674edea40000000ULL, 30} + , // 98-bit n < 10^30 + {30, 0x0000000c9f2c9cd0ULL, 0x4674edea40000000ULL, 30} + , // 99-bit n < 10^30 + {0, 0x0000000c9f2c9cd0ULL, 0x4674edea40000000ULL, 30} + , // 100-bit n ? 10^30 + {31, 0x0000007e37be2022ULL, 0xc0914b2680000000ULL, 31} + , // 101-bit n < 10^31 + {31, 0x0000007e37be2022ULL, 0xc0914b2680000000ULL, 31} + , // 102-bit n < 10^31 + {0, 0x0000007e37be2022ULL, 0xc0914b2680000000ULL, 31} + , // 103-bit n ? 10^31 + {32, 0x000004ee2d6d415bULL, 0x85acef8100000000ULL, 32} + , // 104-bit n < 10^32 + {32, 0x000004ee2d6d415bULL, 0x85acef8100000000ULL, 32} + , // 105-bit n < 10^32 + {32, 0x000004ee2d6d415bULL, 0x85acef8100000000ULL, 32} + , // 106-bit n < 10^32 + {0, 0x000004ee2d6d415bULL, 0x85acef8100000000ULL, 32} + , // 107-bit n ? 10^32 + {33, 0x0000314dc6448d93ULL, 0x38c15b0a00000000ULL, 33} + , // 108-bit n < 10^33 + {33, 0x0000314dc6448d93ULL, 0x38c15b0a00000000ULL, 33} + , // 109-bit n < 10^33 + {0, 0x0000314dc6448d93ULL, 0x38c15b0a00000000ULL, 33} + , // 100-bit n ? 10^33 + {34, 0x0001ed09bead87c0ULL, 0x378d8e6400000000ULL, 34} + , // 111-bit n < 10^34 + {34, 0x0001ed09bead87c0ULL, 0x378d8e6400000000ULL, 34} + , // 112-bit n < 10^34 + {0, 0x0001ed09bead87c0ULL, 0x378d8e6400000000ULL, 34} // 113-bit n ? 10^34 +//{ 35, 0x0013426172c74d82ULL, 0x2b878fe800000000ULL, 35 } // 114-bit n < 10^35 +}; + +// midpoint64[i - 1] = 1/2 * 10^i = 5 * 10^(i-1), 1 <= i <= 19 +UINT64 midpoint64[] = { + 0x0000000000000005ULL, // 1/2 * 10^1 = 5 * 10^0 + 0x0000000000000032ULL, // 1/2 * 10^2 = 5 * 10^1 + 0x00000000000001f4ULL, // 1/2 * 10^3 = 5 * 10^2 + 0x0000000000001388ULL, // 1/2 * 10^4 = 5 * 10^3 + 0x000000000000c350ULL, // 1/2 * 10^5 = 5 * 10^4 + 0x000000000007a120ULL, // 1/2 * 10^6 = 5 * 10^5 + 0x00000000004c4b40ULL, // 1/2 * 10^7 = 5 * 10^6 + 0x0000000002faf080ULL, // 1/2 * 10^8 = 5 * 10^7 + 0x000000001dcd6500ULL, // 1/2 * 10^9 = 5 * 10^8 + 0x000000012a05f200ULL, // 1/2 * 10^10 = 5 * 10^9 + 0x0000000ba43b7400ULL, // 1/2 * 10^11 = 5 * 10^10 + 0x000000746a528800ULL, // 1/2 * 10^12 = 5 * 10^11 + 0x0000048c27395000ULL, // 1/2 * 10^13 = 5 * 10^12 + 0x00002d79883d2000ULL, // 1/2 * 10^14 = 5 * 10^13 + 0x0001c6bf52634000ULL, // 1/2 * 10^15 = 5 * 10^14 + 0x0011c37937e08000ULL, // 1/2 * 10^16 = 5 * 10^15 + 0x00b1a2bc2ec50000ULL, // 1/2 * 10^17 = 5 * 10^16 + 0x06f05b59d3b20000ULL, // 1/2 * 10^18 = 5 * 10^17 + 0x4563918244f40000ULL // 1/2 * 10^19 = 5 * 10^18 +}; + +// midpoint128[i - 20] = 1/2 * 10^i = 5 * 10^(i-1), 20 <= i <= 38 +UINT128 midpoint128[] = { // the 64-bit word order is L, H + {{0xb5e3af16b1880000ULL, 0x0000000000000002ULL} + } + , // 1/2 * 10^20 = 5 * 10^19 + {{0x1ae4d6e2ef500000ULL, 0x000000000000001bULL} + } + , // 1/2 * 10^21 = 5 * 10^20 + {{0x0cf064dd59200000ULL, 0x000000000000010fULL} + } + , // 1/2 * 10^22 = 5 * 10^21 + {{0x8163f0a57b400000ULL, 0x0000000000000a96ULL} + } + , // 1/2 * 10^23 = 5 * 10^22 + {{0x0de76676d0800000ULL, 0x00000000000069e1ULL} + } + , // 1/2 * 10^24 = 5 * 10^23 + {{0x8b0a00a425000000ULL, 0x00000000000422caULL} + } + , // 1/2 * 10^25 = 5 * 10^24 + {{0x6e64066972000000ULL, 0x0000000000295be9ULL} + } + , // 1/2 * 10^26 = 5 * 10^25 + {{0x4fe8401e74000000ULL, 0x00000000019d971eULL} + } + , // 1/2 * 10^27 = 5 * 10^26 + {{0x1f12813088000000ULL, 0x000000001027e72fULL} + } + , // 1/2 * 10^28 = 5 * 10^27 + {{0x36b90be550000000ULL, 0x00000000a18f07d7ULL} + } + , // 1/2 * 10^29 = 5 * 10^28 + {{0x233a76f520000000ULL, 0x000000064f964e68ULL} + } + , // 1/2 * 10^30 = 5 * 10^29 + {{0x6048a59340000000ULL, 0x0000003f1bdf1011ULL} + } + , // 1/2 * 10^31 = 5 * 10^30 + {{0xc2d677c080000000ULL, 0x0000027716b6a0adULL} + } + , // 1/2 * 10^32 = 5 * 10^31 + {{0x9c60ad8500000000ULL, 0x000018a6e32246c9ULL} + } + , // 1/2 * 10^33 = 5 * 10^32 + {{0x1bc6c73200000000ULL, 0x0000f684df56c3e0ULL} + } + , // 1/2 * 10^34 = 5 * 10^33 + {{0x15c3c7f400000000ULL, 0x0009a130b963a6c1ULL} + } + , // 1/2 * 10^35 = 5 * 10^34 + {{0xd9a5cf8800000000ULL, 0x00604be73de4838aULL} + } + , // 1/2 * 10^36 = 5 * 10^35 + {{0x807a1b5000000000ULL, 0x03c2f7086aed236cULL} + } + , // 1/2 * 10^37 = 5 * 10^36 + {{0x04c5112000000000ULL, 0x259da6542d43623dULL} + } // 1/2 * 10^38 = 5 * 10^37 +}; + +// midpoint192[i - 39] = 1/2 * 10^i = 5 * 10^(i-1), 39 <= i <= 58 +UINT192 midpoint192[] = { // the 64-bit word order is L, M, H + {{0x2fb2ab4000000000ULL, 0x78287f49c4a1d662ULL, 0x0000000000000001ULL} + } + , + // 1/2 * 10^39 = 5 * 10^38 + {{0xdcfab08000000000ULL, 0xb194f8e1ae525fd5ULL, 0x000000000000000eULL} + } + , + // 1/2 * 10^40 = 5 * 10^39 + {{0xa1cae50000000000ULL, 0xefd1b8d0cf37be5aULL, 0x0000000000000092ULL} + } + , + // 1/2 * 10^41 = 5 * 10^40 + {{0x51ecf20000000000ULL, 0x5e313828182d6f8aULL, 0x00000000000005bdULL} + } + , + // 1/2 * 10^42 = 5 * 10^41 + {{0x3341740000000000ULL, 0xadec3190f1c65b67ULL, 0x0000000000003965ULL} + } + , + // 1/2 * 10^43 = 5 * 10^42 + {{0x008e880000000000ULL, 0xcb39efa971bf9208ULL, 0x0000000000023df8ULL} + } + , + // 1/2 * 10^44 = 5 * 10^43 + {{0x0591500000000000ULL, 0xf0435c9e717bb450ULL, 0x0000000000166bb7ULL} + } + , + // 1/2 * 10^45 = 5 * 10^44 + {{0x37ad200000000000ULL, 0x62a19e306ed50b20ULL, 0x0000000000e0352fULL} + } + , + // 1/2 * 10^46 = 5 * 10^45 + {{0x2cc3400000000000ULL, 0xda502de454526f42ULL, 0x0000000008c213d9ULL} + } + , + // 1/2 * 10^47 = 5 * 10^46 + {{0xbfa0800000000000ULL, 0x8721caeb4b385895ULL, 0x000000005794c682ULL} + } + , + // 1/2 * 10^48 = 5 * 10^47 + {{0x7c45000000000000ULL, 0x4751ed30f03375d9ULL, 0x000000036bcfc119ULL} + } + , + // 1/2 * 10^49 = 5 * 10^48 + {{0xdab2000000000000ULL, 0xc93343e962029a7eULL, 0x00000022361d8afcULL} + } + , + // 1/2 * 10^50 = 5 * 10^49 + {{0x8af4000000000000ULL, 0xdc00a71dd41a08f4ULL, 0x000001561d276ddfULL} + } + , + // 1/2 * 10^51 = 5 * 10^50 + {{0x6d88000000000000ULL, 0x9806872a4904598dULL, 0x00000d5d238a4abeULL} + } + , + // 1/2 * 10^52 = 5 * 10^51 + {{0x4750000000000000ULL, 0xf04147a6da2b7f86ULL, 0x000085a36366eb71ULL} + } + , + // 1/2 * 10^53 = 5 * 10^52 + {{0xc920000000000000ULL, 0x628ccc8485b2fb3eULL, 0x00053861e2053273ULL} + } + , + // 1/2 * 10^54 = 5 * 10^53 + {{0xdb40000000000000ULL, 0xd97ffd2d38fdd073ULL, 0x003433d2d433f881ULL} + } + , + // 1/2 * 10^55 = 5 * 10^54 + {{0x9080000000000000ULL, 0x7effe3c439ea2486ULL, 0x020a063c4a07b512ULL} + } + , + // 1/2 * 10^56 = 5 * 10^55 + {{0xa500000000000000ULL, 0xf5fee5aa43256d41ULL, 0x14643e5ae44d12b8ULL} + } + , + // 1/2 * 10^57 = 5 * 10^56 + {{0x7200000000000000ULL, 0x9bf4f8a69f764490ULL, 0xcbea6f8ceb02bb39ULL} + } + // 1/2 * 10^58 = 5 * 10^57 +}; + +// midpoint256[i - 59] = 1/2 * 10^i = 5 * 10^(i-1), 59 <= i <= 68 +UINT256 midpoint256[] = { // the 64-bit word order is LL, LH, HL, HH + {{0x7400000000000000ULL, 0x1791b6823a9eada4ULL, + 0xf7285b812e1b5040ULL, 0x0000000000000007ULL} + } + , // 1/2 * 10^59 = 5 * 10^58 + {{0x8800000000000000ULL, 0xebb121164a32c86cULL, + 0xa793930bcd112280ULL, 0x000000000000004fULL} + } + , // 1/2 * 10^60 = 5 * 10^59 + {{0x5000000000000000ULL, 0x34eb4adee5fbd43dULL, + 0x8bc3be7602ab5909ULL, 0x000000000000031cULL} + } + , // 1/2 * 10^61 = 5 * 10^60 + {{0x2000000000000000ULL, 0x1130ecb4fbd64a65ULL, + 0x75a5709c1ab17a5cULL, 0x0000000000001f1dULL} + } + , // 1/2 * 10^62 = 5 * 10^61 + {{0x4000000000000000ULL, 0xabe93f11d65ee7f3ULL, + 0x987666190aeec798ULL, 0x0000000000013726ULL} + } + , // 1/2 * 10^63 = 5 * 10^62 + {{0x8000000000000000ULL, 0xb71c76b25fb50f80ULL, + 0xf49ffcfa6d53cbf6ULL, 0x00000000000c2781ULL} + } + , // 1/2 * 10^64 = 5 * 10^63 + {{0x0000000000000000ULL, 0x271ca2f7bd129b05ULL, + 0x8e3fe1c84545f7a3ULL, 0x0000000000798b13ULL} + } + , // 1/2 * 10^65 = 5 * 10^64 + {{0x0000000000000000ULL, 0x871e5dad62ba0e32ULL, + 0x8e7ed1d2b4bbac5fULL, 0x0000000004bf6ec3ULL} + } + , // 1/2 * 10^66 = 5 * 10^65 + {{0x0000000000000000ULL, 0x472fa8c5db448df4ULL, + 0x90f4323b0f54bbbbULL, 0x000000002f7a53a3ULL} + } + , // 1/2 * 10^67 = 5 * 10^66 + {{0x0000000000000000ULL, 0xc7dc97ba90ad8b88ULL, + 0xa989f64e994f5550ULL, 0x00000001dac74463ULL} + } + , // 1/2 * 10^68 = 5 * 10^67 + {{0x0000000000000000ULL, 0xce9ded49a6c77350ULL, + 0x9f639f11fd195527ULL, 0x000000128bc8abe4ULL} + } + , // 1/2 * 10^69 = 5 * 10^68 + {{0x0000000000000000ULL, 0x122b44e083ca8120ULL, + 0x39e436b3e2fd538eULL, 0x000000b975d6b6eeULL} + } + , // 1/2 * 10^70 = 5 * 10^69 + {{0x0000000000000000ULL, 0xb5b0b0c525e90b40ULL, + 0x42ea2306dde5438cULL, 0x0000073e9a63254eULL} + } + , // 1/2 * 10^71 = 5 * 10^70 + {{0x0000000000000000ULL, 0x18e6e7b37b1a7080ULL, + 0x9d255e44aaf4a37fULL, 0x0000487207df750eULL} + } + , // 1/2 * 10^72 = 5 * 10^71 + {{0x0000000000000000ULL, 0xf9050d02cf086500ULL, + 0x2375aeaead8e62f6ULL, 0x0002d4744eba9292ULL} + } + , // 1/2 * 10^73 = 5 * 10^72 + {{0x0000000000000000ULL, 0xba32821c1653f200ULL, + 0x6298d2d2c78fdda5ULL, 0x001c4c8b1349b9b5ULL} + } + , // 1/2 * 10^74 = 5 * 10^73 + {{0x0000000000000000ULL, 0x45f91518df477400ULL, + 0xd9f83c3bcb9ea879ULL, 0x011afd6ec0e14115ULL} + } + , // 1/2 * 10^75 = 5 * 10^74 + {{0x0000000000000000ULL, 0xbbbad2f8b8ca8800ULL, + 0x83b25a55f43294bcULL, 0x0b0de65388cc8adaULL} + } + , // 1/2 * 10^76 = 5 * 10^75 + {{0x0000000000000000ULL, 0x554c3db737e95000ULL, + 0x24f7875b89f9cf5fULL, 0x6e8aff4357fd6c89ULL} + } // 1/2 * 10^77 = 5 * 10^76 +}; + +// ten2k64[i] = 10^i, 0 <= i <= 19 +UINT64 ten2k64[] = { + 0x0000000000000001ULL, // 10^0 + 0x000000000000000aULL, // 10^1 + 0x0000000000000064ULL, // 10^2 + 0x00000000000003e8ULL, // 10^3 + 0x0000000000002710ULL, // 10^4 + 0x00000000000186a0ULL, // 10^5 + 0x00000000000f4240ULL, // 10^6 + 0x0000000000989680ULL, // 10^7 + 0x0000000005f5e100ULL, // 10^8 + 0x000000003b9aca00ULL, // 10^9 + 0x00000002540be400ULL, // 10^10 + 0x000000174876e800ULL, // 10^11 + 0x000000e8d4a51000ULL, // 10^12 + 0x000009184e72a000ULL, // 10^13 + 0x00005af3107a4000ULL, // 10^14 + 0x00038d7ea4c68000ULL, // 10^15 + 0x002386f26fc10000ULL, // 10^16 + 0x016345785d8a0000ULL, // 10^17 + 0x0de0b6b3a7640000ULL, // 10^18 + 0x8ac7230489e80000ULL // 10^19 (20 digits) +}; + + +// ten2k128[i - 20] = 10^i, 20 <= i <= 38 +UINT128 ten2k128[] = { // the 64-bit word order is L, H + {{0x6bc75e2d63100000ULL, 0x0000000000000005ULL} + } + , // 10^20 + {{0x35c9adc5dea00000ULL, 0x0000000000000036ULL} + } + , // 10^21 + {{0x19e0c9bab2400000ULL, 0x000000000000021eULL} + } + , // 10^22 + {{0x02c7e14af6800000ULL, 0x000000000000152dULL} + } + , // 10^23 + {{0x1bcecceda1000000ULL, 0x000000000000d3c2ULL} + } + , // 10^24 + {{0x161401484a000000ULL, 0x0000000000084595ULL} + } + , // 10^25 + {{0xdcc80cd2e4000000ULL, 0x000000000052b7d2ULL} + } + , // 10^26 + {{0x9fd0803ce8000000ULL, 0x00000000033b2e3cULL} + } + , // 10^27 + {{0x3e25026110000000ULL, 0x00000000204fce5eULL} + } + , // 10^28 + {{0x6d7217caa0000000ULL, 0x00000001431e0faeULL} + } + , // 10^29 + {{0x4674edea40000000ULL, 0x0000000c9f2c9cd0ULL} + } + , // 10^30 + {{0xc0914b2680000000ULL, 0x0000007e37be2022ULL} + } + , // 10^31 + {{0x85acef8100000000ULL, 0x000004ee2d6d415bULL} + } + , // 10^32 + {{0x38c15b0a00000000ULL, 0x0000314dc6448d93ULL} + } + , // 10^33 + {{0x378d8e6400000000ULL, 0x0001ed09bead87c0ULL} + } + , // 10^34 + {{0x2b878fe800000000ULL, 0x0013426172c74d82ULL} + } + , // 10^35 + {{0xb34b9f1000000000ULL, 0x00c097ce7bc90715ULL} + } + , // 10^36 + {{0x00f436a000000000ULL, 0x0785ee10d5da46d9ULL} + } + , // 10^37 + {{0x098a224000000000ULL, 0x4b3b4ca85a86c47aULL} + } // 10^38 (39 digits) +}; + +// might split into ten2k192[] and ten2k256[] + +// ten2k256[i - 39] = 10^i, 39 <= i <= 68 +UINT256 ten2k256[] = { // the 64-bit word order is LL, LH, HL, HH + {{0x5f65568000000000ULL, 0xf050fe938943acc4ULL, + 0x0000000000000002ULL, 0x0000000000000000ULL} + } + , // 10^39 + {{0xb9f5610000000000ULL, 0x6329f1c35ca4bfabULL, + 0x000000000000001dULL, 0x0000000000000000ULL} + } + , // 10^40 + {{0x4395ca0000000000ULL, 0xdfa371a19e6f7cb5ULL, + 0x0000000000000125ULL, 0x0000000000000000ULL} + } + , // 10^41 + {{0xa3d9e40000000000ULL, 0xbc627050305adf14ULL, + 0x0000000000000b7aULL, 0x0000000000000000ULL} + } + , // 10^42 + {{0x6682e80000000000ULL, 0x5bd86321e38cb6ceULL, + 0x00000000000072cbULL, 0x0000000000000000ULL} + } + , // 10^43 + {{0x011d100000000000ULL, 0x9673df52e37f2410ULL, + 0x0000000000047bf1ULL, 0x0000000000000000ULL} + } + , // 10^44 + {{0x0b22a00000000000ULL, 0xe086b93ce2f768a0ULL, + 0x00000000002cd76fULL, 0x0000000000000000ULL} + } + , // 10^45 + {{0x6f5a400000000000ULL, 0xc5433c60ddaa1640ULL, + 0x0000000001c06a5eULL, 0x0000000000000000ULL} + } + , // 10^46 + {{0x5986800000000000ULL, 0xb4a05bc8a8a4de84ULL, + 0x00000000118427b3ULL, 0x0000000000000000ULL} + } + , // 10^47 + {{0x7f41000000000000ULL, 0x0e4395d69670b12bULL, + 0x00000000af298d05ULL, 0x0000000000000000ULL} + } + , // 10^48 + {{0xf88a000000000000ULL, 0x8ea3da61e066ebb2ULL, + 0x00000006d79f8232ULL, 0x0000000000000000ULL} + } + , // 10^49 + {{0xb564000000000000ULL, 0x926687d2c40534fdULL, + 0x000000446c3b15f9ULL, 0x0000000000000000ULL} + } + , // 10^50 + {{0x15e8000000000000ULL, 0xb8014e3ba83411e9ULL, + 0x000002ac3a4edbbfULL, 0x0000000000000000ULL} + } + , // 10^51 + {{0xdb10000000000000ULL, 0x300d0e549208b31aULL, + 0x00001aba4714957dULL, 0x0000000000000000ULL} + } + , // 10^52 + {{0x8ea0000000000000ULL, 0xe0828f4db456ff0cULL, + 0x00010b46c6cdd6e3ULL, 0x0000000000000000ULL} + } + , // 10^53 + {{0x9240000000000000ULL, 0xc51999090b65f67dULL, + 0x000a70c3c40a64e6ULL, 0x0000000000000000ULL} + } + , // 10^54 + {{0xb680000000000000ULL, 0xb2fffa5a71fba0e7ULL, + 0x006867a5a867f103ULL, 0x0000000000000000ULL} + } + , // 10^55 + {{0x2100000000000000ULL, 0xfdffc78873d4490dULL, + 0x04140c78940f6a24ULL, 0x0000000000000000ULL} + } + , // 10^56 + {{0x4a00000000000000ULL, 0xebfdcb54864ada83ULL, + 0x28c87cb5c89a2571ULL, 0x0000000000000000ULL} + } + , // 10^57 (58 digits) + {{0xe400000000000000ULL, 0x37e9f14d3eec8920ULL, + 0x97d4df19d6057673ULL, 0x0000000000000001ULL} + } + , // 10^58 + {{0xe800000000000000ULL, 0x2f236d04753d5b48ULL, + 0xee50b7025c36a080ULL, 0x000000000000000fULL} + } + , // 10^59 + {{0x1000000000000000ULL, 0xd762422c946590d9ULL, + 0x4f2726179a224501ULL, 0x000000000000009fULL} + } + , // 10^60 + {{0xa000000000000000ULL, 0x69d695bdcbf7a87aULL, + 0x17877cec0556b212ULL, 0x0000000000000639ULL} + } + , // 10^61 + {{0x4000000000000000ULL, 0x2261d969f7ac94caULL, + 0xeb4ae1383562f4b8ULL, 0x0000000000003e3aULL} + } + , // 10^62 + {{0x8000000000000000ULL, 0x57d27e23acbdcfe6ULL, + 0x30eccc3215dd8f31ULL, 0x0000000000026e4dULL} + } + , // 10^63 + {{0x0000000000000000ULL, 0x6e38ed64bf6a1f01ULL, + 0xe93ff9f4daa797edULL, 0x0000000000184f03ULL} + } + , // 10^64 + {{0x0000000000000000ULL, 0x4e3945ef7a25360aULL, + 0x1c7fc3908a8bef46ULL, 0x0000000000f31627ULL} + } + , // 10^65 + {{0x0000000000000000ULL, 0x0e3cbb5ac5741c64ULL, + 0x1cfda3a5697758bfULL, 0x00000000097edd87ULL} + } + , // 10^66 + {{0x0000000000000000ULL, 0x8e5f518bb6891be8ULL, + 0x21e864761ea97776ULL, 0x000000005ef4a747ULL} + } + , // 10^67 + {{0x0000000000000000ULL, 0x8fb92f75215b1710ULL, + 0x5313ec9d329eaaa1ULL, 0x00000003b58e88c7ULL} + } + , // 10^68 + {{0x0000000000000000ULL, 0x9d3bda934d8ee6a0ULL, + 0x3ec73e23fa32aa4fULL, 0x00000025179157c9ULL} + } + , // 10^69 + {{0x0000000000000000ULL, 0x245689c107950240ULL, + 0x73c86d67c5faa71cULL, 0x00000172ebad6ddcULL} + } + , // 10^70 + {{0x0000000000000000ULL, 0x6b61618a4bd21680ULL, + 0x85d4460dbbca8719ULL, 0x00000e7d34c64a9cULL} + } + , // 10^71 + {{0x0000000000000000ULL, 0x31cdcf66f634e100ULL, + 0x3a4abc8955e946feULL, 0x000090e40fbeea1dULL} + } + , // 10^72 + {{0x0000000000000000ULL, 0xf20a1a059e10ca00ULL, + 0x46eb5d5d5b1cc5edULL, 0x0005a8e89d752524ULL} + } + , // 10^73 + {{0x0000000000000000ULL, 0x746504382ca7e400ULL, + 0xc531a5a58f1fbb4bULL, 0x003899162693736aULL} + } + , // 10^74 + {{0x0000000000000000ULL, 0x8bf22a31be8ee800ULL, + 0xb3f07877973d50f2ULL, 0x0235fadd81c2822bULL} + } + , // 10^75 + {{0x0000000000000000ULL, 0x7775a5f171951000ULL, + 0x0764b4abe8652979ULL, 0x161bcca7119915b5ULL} + } + , // 10^76 + {{0x0000000000000000ULL, 0xaa987b6e6fd2a000ULL, + 0x49ef0eb713f39ebeULL, 0xdd15fe86affad912ULL} + } // 10^77 +}; + +// ten2mk128[k - 1] = 10^(-k) * 2^exp (k), where 1 <= k <= 34 and +// exp (k) = shiftright128[k - 1] + 128 +UINT128 ten2mk128[] = { + {{0x999999999999999aULL, 0x1999999999999999ULL} + } + , // 10^(-1) * 2^128 + {{0x28f5c28f5c28f5c3ULL, 0x028f5c28f5c28f5cULL} + } + , // 10^(-2) * 2^128 + {{0x9db22d0e56041894ULL, 0x004189374bc6a7efULL} + } + , // 10^(-3) * 2^128 + {{0x4af4f0d844d013aaULL, 0x00346dc5d6388659ULL} + } + , // 10^(-4) * 2^131 + {{0x08c3f3e0370cdc88ULL, 0x0029f16b11c6d1e1ULL} + } + , // 10^(-5) * 2^134 + {{0x6d698fe69270b06dULL, 0x00218def416bdb1aULL} + } + , // 10^(-6) * 2^137 + {{0xaf0f4ca41d811a47ULL, 0x0035afe535795e90ULL} + } + , // 10^(-7) * 2^141 + {{0xbf3f70834acdaea0ULL, 0x002af31dc4611873ULL} + } + , // 10^(-8) * 2^144 + {{0x65cc5a02a23e254dULL, 0x00225c17d04dad29ULL} + } + , // 10^(-9) * 2^147 + {{0x6fad5cd10396a214ULL, 0x0036f9bfb3af7b75ULL} + } + , // 10^(-10) * 2^151 + {{0xbfbde3da69454e76ULL, 0x002bfaffc2f2c92aULL} + } + , // 10^(-11) * 2^154 + {{0x32fe4fe1edd10b92ULL, 0x00232f33025bd422ULL} + } + , // 10^(-12) * 2^157 + {{0x84ca19697c81ac1cULL, 0x00384b84d092ed03ULL} + } + , // 10^(-13) * 2^161 + {{0x03d4e1213067bce4ULL, 0x002d09370d425736ULL} + } + , // 10^(-14) * 2^164 + {{0x3643e74dc052fd83ULL, 0x0024075f3dceac2bULL} + } + , // 10^(-15) * 2^167 + {{0x56d30baf9a1e626bULL, 0x0039a5652fb11378ULL} + } + , // 10^(-16) * 2^171 + {{0x12426fbfae7eb522ULL, 0x002e1dea8c8da92dULL} + } + , // 10^(-17) * 2^174 + {{0x41cebfcc8b9890e8ULL, 0x0024e4bba3a48757ULL} + } + , // 10^(-18) * 2^177 + {{0x694acc7a78f41b0dULL, 0x003b07929f6da558ULL} + } + , // 10^(-19) * 2^181 + {{0xbaa23d2ec729af3eULL, 0x002f394219248446ULL} + } + , // 10^(-20) * 2^184 + {{0xfbb4fdbf05baf298ULL, 0x0025c768141d369eULL} + } + , // 10^(-21) * 2^187 + {{0x2c54c931a2c4b759ULL, 0x003c7240202ebdcbULL} + } + , // 10^(-22) * 2^191 + {{0x89dd6dc14f03c5e1ULL, 0x00305b66802564a2ULL} + } + , // 10^(-23) * 2^194 + {{0xd4b1249aa59c9e4eULL, 0x0026af8533511d4eULL} + } + , // 10^(-24) * 2^197 + {{0x544ea0f76f60fd49ULL, 0x003de5a1ebb4fbb1ULL} + } + , // 10^(-25) * 2^201 + {{0x76a54d92bf80caa1ULL, 0x00318481895d9627ULL} + } + , // 10^(-26) * 2^204 + {{0x921dd7a89933d54eULL, 0x00279d346de4781fULL} + } + , // 10^(-27) * 2^207 + {{0x8362f2a75b862215ULL, 0x003f61ed7ca0c032ULL} + } + , // 10^(-28) * 2^211 + {{0xcf825bb91604e811ULL, 0x0032b4bdfd4d668eULL} + } + , // 10^(-29) * 2^214 + {{0x0c684960de6a5341ULL, 0x00289097fdd7853fULL} + } + , // 10^(-30) * 2^217 + {{0x3d203ab3e521dc34ULL, 0x002073accb12d0ffULL} + } + , // 10^(-31) * 2^220 + {{0x2e99f7863b696053ULL, 0x0033ec47ab514e65ULL} + } + , // 10^(-32) * 2^224 + {{0x587b2c6b62bab376ULL, 0x002989d2ef743eb7ULL} + } + , // 10^(-33) * 2^227 + {{0xad2f56bc4efbc2c5ULL, 0x00213b0f25f69892ULL} + } + , // 10^(-34) * 2^230 +}; + + +// shiftright128[] contains the right shift count to obtain C2* from the top +// 128 bits of the 128x128-bit product C2 * Kx +int shiftright128[] = { + 0, // 128 - 128 + 0, // 128 - 128 + 0, // 128 - 128 + + 3, // 131 - 128 + 6, // 134 - 128 + 9, // 137 - 128 + 13, // 141 - 128 + 16, // 144 - 128 + 19, // 147 - 128 + 23, // 151 - 128 + 26, // 154 - 128 + 29, // 157 - 128 + 33, // 161 - 128 + 36, // 164 - 128 + 39, // 167 - 128 + 43, // 171 - 128 + 46, // 174 - 128 + 49, // 177 - 128 + 53, // 181 - 128 + 56, // 184 - 128 + 59, // 187 - 128 + 63, // 191 - 128 + + 66, // 194 - 128 + 69, // 197 - 128 + 73, // 201 - 128 + 76, // 204 - 128 + 79, // 207 - 128 + 83, // 211 - 128 + 86, // 214 - 128 + 89, // 217 - 128 + 92, // 220 - 128 + 96, // 224 - 128 + 99, // 227 - 128 + 102 // 230 - 128 +}; + + +// maskhigh128[] contains the mask to apply to the top 128 bits of the +// 128x128-bit product in order to obtain the high bits of f2* +// the 64-bit word order is L, H +UINT64 maskhigh128[] = { + 0x0000000000000000ULL, // 0 = 128 - 128 bits + 0x0000000000000000ULL, // 0 = 128 - 128 bits + 0x0000000000000000ULL, // 0 = 128 - 128 bits + 0x0000000000000007ULL, // 3 = 131 - 128 bits + 0x000000000000003fULL, // 6 = 134 - 128 bits + 0x00000000000001ffULL, // 9 = 137 - 128 bits + 0x0000000000001fffULL, // 13 = 141 - 128 bits + 0x000000000000ffffULL, // 16 = 144 - 128 bits + 0x000000000007ffffULL, // 19 = 147 - 128 bits + 0x00000000007fffffULL, // 23 = 151 - 128 bits + 0x0000000003ffffffULL, // 26 = 154 - 128 bits + 0x000000001fffffffULL, // 29 = 157 - 128 bits + 0x00000001ffffffffULL, // 33 = 161 - 128 bits + 0x0000000fffffffffULL, // 36 = 164 - 128 bits + 0x0000007fffffffffULL, // 39 = 167 - 128 bits + 0x000007ffffffffffULL, // 43 = 171 - 128 bits + 0x00003fffffffffffULL, // 46 = 174 - 128 bits + 0x0001ffffffffffffULL, // 49 = 177 - 128 bits + 0x001fffffffffffffULL, // 53 = 181 - 128 bits + 0x00ffffffffffffffULL, // 56 = 184 - 128 bits + 0x07ffffffffffffffULL, // 59 = 187 - 128 bits + 0x7fffffffffffffffULL, // 63 = 191 - 128 bits + 0x0000000000000003ULL, // 2 = 194 - 192 bits + 0x000000000000001fULL, // 5 = 197 - 192 bits + 0x00000000000001ffULL, // 9 = 201 - 192 bits + 0x0000000000000fffULL, // 12 = 204 - 192 bits + 0x0000000000007fffULL, // 15 = 207 - 192 bits + 0x000000000007ffffULL, // 21 = 211 - 192 bits + 0x00000000003fffffULL, // 22 = 214 - 192 bits + 0x0000000001ffffffULL, // 25 = 217 - 192 bits + 0x000000000fffffffULL, // 28 = 220 - 192 bits + 0x00000000ffffffffULL, // 32 = 224 - 192 bits + 0x00000007ffffffffULL, // 35 = 227 - 192 bits + 0x0000003fffffffffULL // 38 = 230 - 192 bits +}; + + +// onehalf128[] contains the high bits of 1/2 positioned correctly for +// comparison with the high bits of f2* +// the 64-bit word order is L, H +UINT64 onehalf128[] = { + 0x0000000000000000ULL, // 0 bits + 0x0000000000000000ULL, // 0 bits + 0x0000000000000000ULL, // 0 bits + 0x0000000000000004ULL, // 3 bits + 0x0000000000000020ULL, // 6 bits + 0x0000000000000100ULL, // 9 bits + 0x0000000000001000ULL, // 13 bits + 0x0000000000008000ULL, // 16 bits + 0x0000000000040000ULL, // 19 bits + 0x0000000000400000ULL, // 23 bits + 0x0000000002000000ULL, // 26 bits + 0x0000000010000000ULL, // 29 bits + 0x0000000100000000ULL, // 33 bits + 0x0000000800000000ULL, // 36 bits + 0x0000004000000000ULL, // 39 bits + 0x0000040000000000ULL, // 43 bits + 0x0000200000000000ULL, // 46 bits + 0x0001000000000000ULL, // 49 bits + 0x0010000000000000ULL, // 53 bits + 0x0080000000000000ULL, // 56 bits + 0x0400000000000000ULL, // 59 bits + 0x4000000000000000ULL, // 63 bits + 0x0000000000000002ULL, // 66 bits + 0x0000000000000010ULL, // 69 bits + 0x0000000000000100ULL, // 73 bits + 0x0000000000000800ULL, // 76 bits + 0x0000000000004000ULL, // 79 bits + 0x0000000000040000ULL, // 83 bits + 0x0000000000200000ULL, // 86 bits + 0x0000000001000000ULL, // 89 bits + 0x0000000008000000ULL, // 92 bits + 0x0000000080000000ULL, // 96 bits + 0x0000000400000000ULL, // 99 bits + 0x0000002000000000ULL // 102 bits +}; + +UINT64 ten2mk64[] = { + 0x199999999999999aULL, // 10^(-1) * 2^ 64 + 0x028f5c28f5c28f5dULL, // 10^(-2) * 2^ 64 + 0x004189374bc6a7f0ULL, // 10^(-3) * 2^ 64 + 0x00346dc5d638865aULL, // 10^(-4) * 2^ 67 + 0x0029f16b11c6d1e2ULL, // 10^(-5) * 2^ 70 + 0x00218def416bdb1bULL, // 10^(-6) * 2^ 73 + 0x0035afe535795e91ULL, // 10^(-7) * 2^ 77 + 0x002af31dc4611874ULL, // 10^(-8) * 2^ 80 + 0x00225c17d04dad2aULL, // 10^(-9) * 2^ 83 + 0x0036f9bfb3af7b76ULL, // 10^(-10) * 2^ 87 + 0x002bfaffc2f2c92bULL, // 10^(-11) * 2^ 90 + 0x00232f33025bd423ULL, // 10^(-12) * 2^ 93 + 0x00384b84d092ed04ULL, // 10^(-13) * 2^ 97 + 0x002d09370d425737ULL, // 10^(-14) * 2^100 + 0x0024075f3dceac2cULL, // 10^(-15) * 2^103 + 0x0039a5652fb11379ULL, // 10^(-16) * 2^107 +}; + +// ten2mk128trunc[] contains T*, the top Ex >= 128 bits of 10^(-k), +// for 1 <= k <= 34 +// the 64-bit word order is L, H +UINT128 ten2mk128trunc[] = { + {{0x9999999999999999ULL, 0x1999999999999999ULL}}, // 10^(-1) * 2^128 + {{0x28f5c28f5c28f5c2ULL, 0x028f5c28f5c28f5cULL}}, // 10^(-2) * 2^128 + {{0x9db22d0e56041893ULL, 0x004189374bc6a7efULL}}, // 10^(-3) * 2^128 + {{0x4af4f0d844d013a9ULL, 0x00346dc5d6388659ULL}}, // 10^(-4) * 2^131 + {{0x08c3f3e0370cdc87ULL, 0x0029f16b11c6d1e1ULL}}, // 10^(-5) * 2^134 + {{0x6d698fe69270b06cULL, 0x00218def416bdb1aULL}}, // 10^(-6) * 2^137 + {{0xaf0f4ca41d811a46ULL, 0x0035afe535795e90ULL}}, // 10^(-7) * 2^141 + {{0xbf3f70834acdae9fULL, 0x002af31dc4611873ULL}}, // 10^(-8) * 2^144 + {{0x65cc5a02a23e254cULL, 0x00225c17d04dad29ULL}}, // 10^(-9) * 2^147 + {{0x6fad5cd10396a213ULL, 0x0036f9bfb3af7b75ULL}}, // 10^(-10) * 2^151 + {{0xbfbde3da69454e75ULL, 0x002bfaffc2f2c92aULL}}, // 10^(-11) * 2^154 + {{0x32fe4fe1edd10b91ULL, 0x00232f33025bd422ULL}}, // 10^(-12) * 2^157 + {{0x84ca19697c81ac1bULL, 0x00384b84d092ed03ULL}}, // 10^(-13) * 2^161 + {{0x03d4e1213067bce3ULL, 0x002d09370d425736ULL}}, // 10^(-14) * 2^164 + {{0x3643e74dc052fd82ULL, 0x0024075f3dceac2bULL}}, // 10^(-15) * 2^167 + {{0x56d30baf9a1e626aULL, 0x0039a5652fb11378ULL}}, // 10^(-16) * 2^171 + {{0x12426fbfae7eb521ULL, 0x002e1dea8c8da92dULL}}, // 10^(-17) * 2^174 + {{0x41cebfcc8b9890e7ULL, 0x0024e4bba3a48757ULL}}, // 10^(-18) * 2^177 + {{0x694acc7a78f41b0cULL, 0x003b07929f6da558ULL}}, // 10^(-19) * 2^181 + {{0xbaa23d2ec729af3dULL, 0x002f394219248446ULL}}, // 10^(-20) * 2^184 + {{0xfbb4fdbf05baf297ULL, 0x0025c768141d369eULL}}, // 10^(-21) * 2^187 + {{0x2c54c931a2c4b758ULL, 0x003c7240202ebdcbULL}}, // 10^(-22) * 2^191 + {{0x89dd6dc14f03c5e0ULL, 0x00305b66802564a2ULL}}, // 10^(-23) * 2^194 + {{0xd4b1249aa59c9e4dULL, 0x0026af8533511d4eULL}}, // 10^(-24) * 2^197 + {{0x544ea0f76f60fd48ULL, 0x003de5a1ebb4fbb1ULL}}, // 10^(-25) * 2^201 + {{0x76a54d92bf80caa0ULL, 0x00318481895d9627ULL}}, // 10^(-26) * 2^204 + {{0x921dd7a89933d54dULL, 0x00279d346de4781fULL}}, // 10^(-27) * 2^207 + {{0x8362f2a75b862214ULL, 0x003f61ed7ca0c032ULL}}, // 10^(-28) * 2^211 + {{0xcf825bb91604e810ULL, 0x0032b4bdfd4d668eULL}}, // 10^(-29) * 2^214 + {{0x0c684960de6a5340ULL, 0x00289097fdd7853fULL}}, // 10^(-30) * 2^217 + {{0x3d203ab3e521dc33ULL, 0x002073accb12d0ffULL}}, // 10^(-31) * 2^220 + {{0x2e99f7863b696052ULL, 0x0033ec47ab514e65ULL}}, // 10^(-32) * 2^224 + {{0x587b2c6b62bab375ULL, 0x002989d2ef743eb7ULL}}, // 10^(-33) * 2^227 + {{0xad2f56bc4efbc2c4ULL, 0x00213b0f25f69892ULL}}, // 10^(-34) * 2^230 +}; + +// ten2mk128M[k - 1] = 10^(-k) * 2^exp (k), where 1 <= k <= 4 and +// exp (k) = shiftright128[k - 1] + 128 +// the 64-bit word order is L, H +UINT128 ten2mk128M[] = { + {{0xcccccccccccccccdULL, 0xccccccccccccccccULL}}, // 10^(-1) * 2^131 + {{0x3d70a3d70a3d70a4ULL, 0xa3d70a3d70a3d70aULL}}, // 10^(-2) * 2^134 + {{0x645a1cac083126eaULL, 0x83126e978d4fdf3bULL}}, // 10^(-3) * 2^137 + {{0xd3c36113404ea4a9ULL, 0xd1b71758e219652bULL}} // 10^(-4) * 2^141 +}; + +// ten2mk128truncM[] contains T*, the top Ex >= 128 bits of 10^(-k), +// for 1 <= k <= 4; the top bits which are 0 are not represented +// the 64-bit word order is L, H +UINT128 ten2mk128truncM[] = { + {{0xccccccccccccccccULL, 0xccccccccccccccccULL}}, // 10^(-1) * 2^131 + {{0x3d70a3d70a3d70a3ULL, 0xa3d70a3d70a3d70aULL}}, // 10^(-2) * 2^134 + {{0x645a1cac083126e9ULL, 0x83126e978d4fdf3bULL}}, // 10^(-3) * 2^137 + {{0xd3c36113404ea4a8ULL, 0xd1b71758e219652bULL}} // 10^(-4) * 2^141 +}; + +// shiftright128M[] contains the right shift count to obtain C2* from the top +// 128 bits of the 128x128-bit product C2 * Kx +int shiftright128M[] = { + 3, // 131 - 128 + 6, // 134 - 128 + 9, // 137 - 128 + 13 // 141 - 128 +}; + +// maskhigh128M[] contains the mask to apply to the top 128 bits of the +// 128x128-bit product in order to obtain the high bits of f* +// the high 64 bits of the mask are 0, so only the low 64 bits are represented +UINT64 maskhigh128M[] = { + 0x0000000000000007ULL, // 3 = 131 - 128 bits + 0x000000000000003fULL, // 6 = 134 - 128 bits + 0x00000000000001ffULL, // 9 = 137 - 128 bits + 0x0000000000001fffULL // 13 = 141 - 128 bits +}; + +// onehalf128M[] contains 1/2 positioned correctly for +// comparison with the high bits of f* +// the high 64 bits are 0, so only the low 64 bits are represented +UINT64 onehalf128M[] = { + 0x0000000000000004ULL, // 3 bits + 0x0000000000000020ULL, // 6 bits + 0x0000000000000100ULL, // 9 bits + 0x0000000000001000ULL // 13 bits +}; + +// ten2mk192M[k - 1] = 10^(-k-4) * 2^exp (k), where 1 <= k <= 19 and +// exp (k) = shiftright128[k - 1] + 128 +// the 64-bit word order is L, M, H +UINT192 ten2mk192M[] = { + {{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, + 0xa7c5ac471b478423ULL}}, + // 10^(-5) * 2^208 + {{0xd7e45803cd141a6aULL, 0xa63f9a49c2c1b10fULL, + 0x8637bd05af6c69b5ULL}}, + // 10^(-6) * 2^211 + {{0x8ca08cd2e1b9c3dcULL, 0x3d32907604691b4cULL, + 0xd6bf94d5e57a42bcULL}}, + // 10^(-7) * 2^215 + {{0x3d4d3d758161697dULL, 0xfdc20d2b36ba7c3dULL, + 0xabcc77118461cefcULL}}, + // 10^(-8) * 2^218 + {{0xfdd7645e011abacaULL, 0x31680a88f8953030ULL, + 0x89705f4136b4a597ULL}}, + // 10^(-9) * 2^221 + {{0x2fbf06fcce912addULL, 0xb573440e5a884d1bULL, + 0xdbe6fecebdedd5beULL}}, + // 10^(-10) * 2^225 + {{0xf2ff38ca3eda88b1ULL, 0xf78f69a51539d748ULL, + 0xafebff0bcb24aafeULL}}, + // 10^(-11) * 2^228 + {{0xf598fa3b657ba08eULL, 0xf93f87b7442e45d3ULL, + 0x8cbccc096f5088cbULL}}, + // 10^(-12) * 2^231 + {{0x88f4c3923bf900e3ULL, 0x2865a5f206b06fb9ULL, + 0xe12e13424bb40e13ULL}}, + // 10^(-13) * 2^235 + {{0x6d909c74fcc733e9ULL, 0x538484c19ef38c94ULL, + 0xb424dc35095cd80fULL}}, + // 10^(-14) * 2^238 + {{0x57a6e390ca38f654ULL, 0x0f9d37014bf60a10ULL, + 0x901d7cf73ab0acd9ULL}}, + // 10^(-15) * 2^241 + {{0xbf716c1add27f086ULL, 0x4c2ebe687989a9b3ULL, + 0xe69594bec44de15bULL}}, + // 10^(-16) * 2^245 + {{0xff8df0157db98d38ULL, 0x09befeb9fad487c2ULL, + 0xb877aa3236a4b449ULL}}, + // 10^(-17) * 2^248 + {{0x32d7f344649470faULL, 0x3aff322e62439fcfULL, + 0x9392ee8e921d5d07ULL}}, + // 10^(-18) * 2^251 + {{0x1e2652070753e7f5ULL, 0x2b31e9e3d06c32e5ULL, + 0xec1e4a7db69561a5ULL}}, + // 10^(-19) * 2^255 + {{0x181ea8059f76532bULL, 0x88f4bb1ca6bcf584ULL, + 0xbce5086492111aeaULL}}, + // 10^(-20) * 2^258 + {{0x467eecd14c5ea8efULL, 0xd3f6fc16ebca5e03ULL, + 0x971da05074da7beeULL}}, + // 10^(-21) * 2^261 + {{0x70cb148213caa7e5ULL, 0x5324c68b12dd6338ULL, + 0xf1c90080baf72cb1ULL}}, + // 10^(-22) * 2^265 + {{0x8d6f439b43088651ULL, 0x75b7053c0f178293ULL, 0xc16d9a0095928a27ULL}} + // 10^(-23) * 2^268 +}; + +// ten2mk192truncM[] contains T*, the top Ex >= 192 bits of 10^(-k), +// for 5 <= k <= 23; the top bits which are 0 are not represented +// the 64-bit word order is L, M, H +UINT192 ten2mk192truncM[] = { + {{0xcddd6e04c0592103ULL, 0x0fcf80dc33721d53ULL, + 0xa7c5ac471b478423ULL}}, + // 10^(-5) * 2^208 + {{0xd7e45803cd141a69ULL, 0xa63f9a49c2c1b10fULL, + 0x8637bd05af6c69b5ULL}}, + // 10^(-6) * 2^211 + {{0x8ca08cd2e1b9c3dbULL, 0x3d32907604691b4cULL, + 0xd6bf94d5e57a42bcULL}}, + // 10^(-7) * 2^215 + {{0x3d4d3d758161697cULL, 0xfdc20d2b36ba7c3dULL, + 0xabcc77118461cefcULL}}, + // 10^(-8) * 2^218 + {{0xfdd7645e011abac9ULL, 0x31680a88f8953030ULL, + 0x89705f4136b4a597ULL}}, + // 10^(-9) * 2^221 + {{0x2fbf06fcce912adcULL, 0xb573440e5a884d1bULL, + 0xdbe6fecebdedd5beULL}}, + // 10^(-10) * 2^225 + {{0xf2ff38ca3eda88b0ULL, 0xf78f69a51539d748ULL, + 0xafebff0bcb24aafeULL}}, + // 10^(-11) * 2^228 + {{0xf598fa3b657ba08dULL, 0xf93f87b7442e45d3ULL, + 0x8cbccc096f5088cbULL}}, + // 10^(-12) * 2^231 + {{0x88f4c3923bf900e2ULL, 0x2865a5f206b06fb9ULL, + 0xe12e13424bb40e13ULL}}, + // 10^(-13) * 2^235 + {{0x6d909c74fcc733e8ULL, 0x538484c19ef38c94ULL, + 0xb424dc35095cd80fULL}}, + // 10^(-14) * 2^238 + {{0x57a6e390ca38f653ULL, 0x0f9d37014bf60a10ULL, + 0x901d7cf73ab0acd9ULL}}, + // 10^(-15) * 2^241 + {{0xbf716c1add27f085ULL, 0x4c2ebe687989a9b3ULL, + 0xe69594bec44de15bULL}}, + // 10^(-16) * 2^245 + {{0xff8df0157db98d37ULL, 0x09befeb9fad487c2ULL, + 0xb877aa3236a4b449ULL}}, + // 10^(-17) * 2^248 + {{0x32d7f344649470f9ULL, 0x3aff322e62439fcfULL, + 0x9392ee8e921d5d07ULL}}, + // 10^(-18) * 2^251 + {{0x1e2652070753e7f4ULL, 0x2b31e9e3d06c32e5ULL, + 0xec1e4a7db69561a5ULL}}, + // 10^(-19) * 2^255 + {{0x181ea8059f76532aULL, 0x88f4bb1ca6bcf584ULL, + 0xbce5086492111aeaULL}}, + // 10^(-20) * 2^258 + {{0x467eecd14c5ea8eeULL, 0xd3f6fc16ebca5e03ULL, + 0x971da05074da7beeULL}}, + // 10^(-21) * 2^261 + {{0x70cb148213caa7e4ULL, 0x5324c68b12dd6338ULL, + 0xf1c90080baf72cb1ULL}}, + // 10^(-22) * 2^265 + {{0x8d6f439b43088650ULL, 0x75b7053c0f178293ULL, 0xc16d9a0095928a27ULL}} + // 10^(-23) * 2^268 +}; + +// shiftright192M[] contains the right shift count to obtain C2* from the top +// 192 bits of the 192x192-bit product C2 * Kx if 0 <= ind <= 14 where ind is +// the index in the table, or from the top 128 bits if 15 <= ind <= 18 +int shiftright192M[] = { + 16, // 208 - 192 + 19, // 211 - 192 + 23, // 215 - 192 + 26, // 218 - 192 + 29, // 221 - 192 + 33, // 225 - 192 + 36, // 228 - 192 + 39, // 231 - 192 + 43, // 235 - 192 + 46, // 238 - 192 + 49, // 241 - 192 + 53, // 245 - 192 + 56, // 248 - 192 + 59, // 251 - 192 + 63, // 255 - 192 + 2, // 258 - 256 + 5, // 261 - 256 + 9, // 265 - 256 + 12 // 268 - 256 +}; + +// maskhigh192M[] contains the mask to apply to the top 192 bits of the +// 192x192-bit product in order to obtain the high bits of f* +// if 0 <= ind <= 14 where ind is the index in the table, then the high 128 bits +// of the 384-bit mask are 0; if 15 <= ind <= 18 then the high 64 bits are 0 +UINT64 maskhigh192M[] = { + 0x000000000000ffffULL, // 16 = 208 - 192 bits + 0x000000000007ffffULL, // 19 = 211 - 192 bits + 0x00000000007fffffULL, // 23 = 215 - 192 bits + 0x0000000003ffffffULL, // 26 = 218 - 192 bits + 0x000000001fffffffULL, // 29 = 221 - 192 bits + 0x00000001ffffffffULL, // 33 = 225 - 192 bits + 0x0000000fffffffffULL, // 36 = 228 - 192 bits + 0x0000007fffffffffULL, // 39 = 231 - 192 bits + 0x000007ffffffffffULL, // 43 = 235 - 192 bits + 0x00003fffffffffffULL, // 46 = 238 - 192 bits + 0x0001ffffffffffffULL, // 49 = 241 - 192 bits + 0x001fffffffffffffULL, // 53 = 245 - 192 bits + 0x00ffffffffffffffULL, // 56 = 248 - 192 bits + 0x07ffffffffffffffULL, // 59 = 251 - 192 bits + 0x7fffffffffffffffULL, // 63 = 255 - 192 bits + 0x0000000000000003ULL, // 2 = 258 - 256 bits + 0x000000000000001fULL, // 5 = 261 - 256 bits + 0x00000000000001ffULL, // 9 = 265 - 256 bits + 0x0000000000000fffULL // 12 = 268 - 256 bits +}; + +// onehalf192M[] contains 1/2 positioned correctly for +// comparison with the high bits of f* +// if 0 <= ind <= 14 where ind is the index in the table, then the high 128 bits +// of the 384-bit mask are 0; if 15 <= ind <= 18 then the high 648 bits are 0 +UINT64 onehalf192M[] = { + 0x0000000000008000ULL, // 16 = 208 - 192 bits + 0x0000000000040000ULL, // 19 = 211 - 192 bits + 0x0000000000400000ULL, // 23 = 215 - 192 bits + 0x0000000002000000ULL, // 26 = 218 - 192 bits + 0x0000000010000000ULL, // 29 = 221 - 192 bits + 0x0000000100000000ULL, // 33 = 225 - 192 bits + 0x0000000800000000ULL, // 36 = 228 - 192 bits + 0x0000004000000000ULL, // 39 = 231 - 192 bits + 0x0000040000000000ULL, // 43 = 235 - 192 bits + 0x0000200000000000ULL, // 46 = 238 - 192 bits + 0x0001000000000000ULL, // 49 = 241 - 192 bits + 0x0010000000000000ULL, // 53 = 245 - 192 bits + 0x0080000000000000ULL, // 56 = 248 - 192 bits + 0x0400000000000000ULL, // 59 = 251 - 192 bits + 0x4000000000000000ULL, // 63 = 255 - 192 bits + 0x0000000000000002ULL, // 2 = 258 - 256 bits + 0x0000000000000010ULL, // 5 = 261 - 256 bits + 0x0000000000000100ULL, // 9 = 265 - 256 bits + 0x0000000000000800ULL // 12 = 268 - 256 bits +}; + +// ten2mk256M[k - 1] = 10^(-k-23) * 2^exp (k), where 1 <= k <= 11 and +// exp (k) = shiftright128[k - 1] + 128 +UINT256 ten2mk256M[] = { // the 64-bit word order is LL, LH, HL, HH + {{0xf23472530ce6e3edULL, 0xd78c3615cf3a050cULL, + 0xc4926a9672793542ULL, 0x9abe14cd44753b52ULL}}, // 10^(-24) * 2^335 + {{0xe9ed83b814a49fe1ULL, 0x8c1389bc7ec33b47ULL, + 0x3a83ddbd83f52204ULL, 0xf79687aed3eec551ULL}}, // 10^(-25) * 2^339 + {{0x87f1362cdd507fe7ULL, 0x3cdc6e306568fc39ULL, + 0x95364afe032a819dULL, 0xc612062576589ddaULL}}, // 10^(-26) * 2^342 + {{0x9ff42b5717739986ULL, 0xca49f1c05120c9c7ULL, + 0x775ea264cf55347dULL, 0x9e74d1b791e07e48ULL}}, // 10^(-27) * 2^345 + {{0xccb9def1bf1f5c09ULL, 0x76dcb60081ce0fa5ULL, + 0x8bca9d6e188853fcULL, 0xfd87b5f28300ca0dULL}}, // 10^(-28) * 2^349 + {{0xa3c7e58e327f7cd4ULL, 0x5f16f80067d80c84ULL, + 0x096ee45813a04330ULL, 0xcad2f7f5359a3b3eULL}}, // 10^(-29) * 2^352 + {{0xb6398471c1ff9710ULL, 0x18df2ccd1fe00a03ULL, + 0xa1258379a94d028dULL, 0xa2425ff75e14fc31ULL}}, // 10^(-30) * 2^355 + {{0xf82e038e34cc78daULL, 0x4718f0a419800802ULL, + 0x80eacf948770ced7ULL, 0x81ceb32c4b43fcf4ULL}}, // 10^(-31) * 2^358 + {{0x59e338e387ad8e29ULL, 0x0b5b1aa028ccd99eULL, + 0x67de18eda5814af2ULL, 0xcfb11ead453994baULL}}, // 10^(-32) * 2^362 + {{0x47e8fa4f9fbe0b54ULL, 0x6f7c154ced70ae18ULL, + 0xecb1ad8aeacdd58eULL, 0xa6274bbdd0fadd61ULL}}, // 10^(-33) * 2^365 + {{0xd320c83fb2fe6f76ULL, 0xbf967770bdf3be79ULL, + 0xbd5af13bef0b113eULL, 0x84ec3c97da624ab4ULL}} // 10^(-34) * 2^368 +}; + +// ten2mk256truncM[] contains T*, the top Ex >= 256 bits of 10^(-k), +// for 24 <= k <= 34; the top bits which are 0 are not represented +UINT256 ten2mk256truncM[] = { // the 64-bit word order is LL, LH, HL, HH + {{0xf23472530ce6e3ecULL, 0xd78c3615cf3a050cULL, + 0xc4926a9672793542ULL, 0x9abe14cd44753b52ULL}}, // 10^(-24) * 2^335 + {{0xe9ed83b814a49fe0ULL, 0x8c1389bc7ec33b47ULL, + 0x3a83ddbd83f52204ULL, 0xf79687aed3eec551ULL}}, // 10^(-25) * 2^339 + {{0x87f1362cdd507fe6ULL, 0x3cdc6e306568fc39ULL, + 0x95364afe032a819dULL, 0xc612062576589ddaULL}}, // 10^(-26) * 2^342 + {{0x775ea264cf55347cULL, 0x9ff42b5717739986ULL, + 0xca49f1c05120c9c7ULL, 0x9e74d1b791e07e48ULL}}, // 10^(-27) * 2^345 + {{0xccb9def1bf1f5c08ULL, 0x76dcb60081ce0fa5ULL, + 0x8bca9d6e188853fcULL, 0xfd87b5f28300ca0dULL}}, // 10^(-28) * 2^349 + {{0xa3c7e58e327f7cd3ULL, 0x5f16f80067d80c84ULL, + 0x096ee45813a04330ULL, 0xcad2f7f5359a3b3eULL}}, // 10^(-29) * 2^352 + {{0xb6398471c1ff970fULL, 0x18df2ccd1fe00a03ULL, + 0xa1258379a94d028dULL, 0xa2425ff75e14fc31ULL}}, // 10^(-30) * 2^355 + {{0xf82e038e34cc78d9ULL, 0x4718f0a419800802ULL, + 0x80eacf948770ced7ULL, 0x81ceb32c4b43fcf4ULL}}, // 10^(-31) * 2^358 + {{0x59e338e387ad8e28ULL, 0x0b5b1aa028ccd99eULL, + 0x67de18eda5814af2ULL, 0xcfb11ead453994baULL}}, // 10^(-32) * 2^362 + {{0x47e8fa4f9fbe0b53ULL, 0x6f7c154ced70ae18ULL, + 0xecb1ad8aeacdd58eULL, 0xa6274bbdd0fadd61ULL}}, // 10^(-33) * 2^365 + {{0xd320c83fb2fe6f75ULL, 0xbf967770bdf3be79ULL, + 0xbd5af13bef0b113eULL, 0x84ec3c97da624ab4ULL}} // 10^(-34) * 2^368 +}; + +// shiftright256M[] contains the right shift count to obtain C2* from the top +// 192 bits of the 256x256-bit product C2 * Kx +int shiftright256M[] = { + 15, // 335 - 320 + 19, // 339 - 320 + 22, // 342 - 320 + 25, // 345 - 320 + 29, // 349 - 320 + 32, // 352 - 320 // careful of 32-bit machines! + 35, // 355 - 320 + 38, // 358 - 320 + 42, // 362 - 320 + 45, // 365 - 320 + 48 // 368 - 320 +}; + +// maskhigh256M[] contains the mask to apply to the top 192 bits of the +// 256x256-bit product in order to obtain the high bits of f* +UINT64 maskhigh256M[] = { + 0x0000000000007fffULL, // 15 = 335 - 320 bits + 0x000000000007ffffULL, // 19 = 339 - 320 bits + 0x00000000003fffffULL, // 22 = 342 - 320 bits + 0x0000000001ffffffULL, // 25 = 345 - 320 bits + 0x000000001fffffffULL, // 29 = 349 - 320 bits + 0x00000000ffffffffULL, // 32 = 352 - 320 bits + 0x00000007ffffffffULL, // 35 = 355 - 320 bits + 0x0000003fffffffffULL, // 38 = 358 - 320 bits + 0x000003ffffffffffULL, // 42 = 362 - 320 bits + 0x00001fffffffffffULL, // 45 = 365 - 320 bits + 0x0000ffffffffffffULL // 48 = 368 - 320 bits +}; + +// onehalf256M[] contains 1/2 positioned correctly for comparison with the +// high bits of f*; the high 128 bits of the 512-bit mask are 0 +UINT64 onehalf256M[] = { + 0x0000000000004000ULL, // 15 = 335 - 320 bits + 0x0000000000040000ULL, // 19 = 339 - 320 bits + 0x0000000000200000ULL, // 22 = 342 - 320 bits + 0x0000000001000000ULL, // 25 = 345 - 320 bits + 0x0000000010000000ULL, // 29 = 349 - 320 bits + 0x0000000080000000ULL, // 32 = 352 - 320 bits + 0x0000000400000000ULL, // 35 = 355 - 320 bits + 0x0000002000000000ULL, // 38 = 358 - 320 bits + 0x0000020000000000ULL, // 42 = 362 - 320 bits + 0x0000100000000000ULL, // 45 = 365 - 320 bits + 0x0000800000000000ULL // 48 = 368 - 320 bits +}; + + +// char_table2[] is used to convert n to string, where 10 <= n <= 99 +unsigned char char_table2[180] = { + '1', '0', + '1', '1', + '1', '2', + '1', '3', + '1', '4', + '1', '5', + '1', '6', + '1', '7', + '1', '8', + '1', '9', + '2', '0', + '2', '1', + '2', '2', + '2', '3', + '2', '4', + '2', '5', + '2', '6', + '2', '7', + '2', '8', + '2', '9', + '3', '0', + '3', '1', + '3', '2', + '3', '3', + '3', '4', + '3', '5', + '3', '6', + '3', '7', + '3', '8', + '3', '9', + '4', '0', + '4', '1', + '4', '2', + '4', '3', + '4', '4', + '4', '5', + '4', '6', + '4', '7', + '4', '8', + '4', '9', + '5', '0', + '5', '1', + '5', '2', + '5', '3', + '5', '4', + '5', '5', + '5', '6', + '5', '7', + '5', '8', + '5', '9', + '6', '0', + '6', '1', + '6', '2', + '6', '3', + '6', '4', + '6', '5', + '6', '6', + '6', '7', + '6', '8', + '6', '9', + '7', '0', + '7', '1', + '7', '2', + '7', '3', + '7', '4', + '7', '5', + '7', '6', + '7', '7', + '7', '8', + '7', '9', + '8', '0', + '8', '1', + '8', '2', + '8', '3', + '8', '4', + '8', '5', + '8', '6', + '8', '7', + '8', '8', + '8', '9', + '9', '0', + '9', '1', + '9', '2', + '9', '3', + '9', '4', + '9', '5', + '9', '6', + '9', '7', + '9', '8', + '9', '9' +}; + + +// char_table3[] is used to convert n to string, where 000 <= n <= 999 +unsigned char char_table3[3000] = { + '0', '0', '0', + '0', '0', '1', + '0', '0', '2', + '0', '0', '3', + '0', '0', '4', + '0', '0', '5', + '0', '0', '6', + '0', '0', '7', + '0', '0', '8', + '0', '0', '9', + '0', '1', '0', + '0', '1', '1', + '0', '1', '2', + '0', '1', '3', + '0', '1', '4', + '0', '1', '5', + '0', '1', '6', + '0', '1', '7', + '0', '1', '8', + '0', '1', '9', + '0', '2', '0', + '0', '2', '1', + '0', '2', '2', + '0', '2', '3', + '0', '2', '4', + '0', '2', '5', + '0', '2', '6', + '0', '2', '7', + '0', '2', '8', + '0', '2', '9', + '0', '3', '0', + '0', '3', '1', + '0', '3', '2', + '0', '3', '3', + '0', '3', '4', + '0', '3', '5', + '0', '3', '6', + '0', '3', '7', + '0', '3', '8', + '0', '3', '9', + '0', '4', '0', + '0', '4', '1', + '0', '4', '2', + '0', '4', '3', + '0', '4', '4', + '0', '4', '5', + '0', '4', '6', + '0', '4', '7', + '0', '4', '8', + '0', '4', '9', + '0', '5', '0', + '0', '5', '1', + '0', '5', '2', + '0', '5', '3', + '0', '5', '4', + '0', '5', '5', + '0', '5', '6', + '0', '5', '7', + '0', '5', '8', + '0', '5', '9', + '0', '6', '0', + '0', '6', '1', + '0', '6', '2', + '0', '6', '3', + '0', '6', '4', + '0', '6', '5', + '0', '6', '6', + '0', '6', '7', + '0', '6', '8', + '0', '6', '9', + '0', '7', '0', + '0', '7', '1', + '0', '7', '2', + '0', '7', '3', + '0', '7', '4', + '0', '7', '5', + '0', '7', '6', + '0', '7', '7', + '0', '7', '8', + '0', '7', '9', + '0', '8', '0', + '0', '8', '1', + '0', '8', '2', + '0', '8', '3', + '0', '8', '4', + '0', '8', '5', + '0', '8', '6', + '0', '8', '7', + '0', '8', '8', + '0', '8', '9', + '0', '9', '0', + '0', '9', '1', + '0', '9', '2', + '0', '9', '3', + '0', '9', '4', + '0', '9', '5', + '0', '9', '6', + '0', '9', '7', + '0', '9', '8', + '0', '9', '9', + '1', '0', '0', + '1', '0', '1', + '1', '0', '2', + '1', '0', '3', + '1', '0', '4', + '1', '0', '5', + '1', '0', '6', + '1', '0', '7', + '1', '0', '8', + '1', '0', '9', + '1', '1', '0', + '1', '1', '1', + '1', '1', '2', + '1', '1', '3', + '1', '1', '4', + '1', '1', '5', + '1', '1', '6', + '1', '1', '7', + '1', '1', '8', + '1', '1', '9', + '1', '2', '0', + '1', '2', '1', + '1', '2', '2', + '1', '2', '3', + '1', '2', '4', + '1', '2', '5', + '1', '2', '6', + '1', '2', '7', + '1', '2', '8', + '1', '2', '9', + '1', '3', '0', + '1', '3', '1', + '1', '3', '2', + '1', '3', '3', + '1', '3', '4', + '1', '3', '5', + '1', '3', '6', + '1', '3', '7', + '1', '3', '8', + '1', '3', '9', + '1', '4', '0', + '1', '4', '1', + '1', '4', '2', + '1', '4', '3', + '1', '4', '4', + '1', '4', '5', + '1', '4', '6', + '1', '4', '7', + '1', '4', '8', + '1', '4', '9', + '1', '5', '0', + '1', '5', '1', + '1', '5', '2', + '1', '5', '3', + '1', '5', '4', + '1', '5', '5', + '1', '5', '6', + '1', '5', '7', + '1', '5', '8', + '1', '5', '9', + '1', '6', '0', + '1', '6', '1', + '1', '6', '2', + '1', '6', '3', + '1', '6', '4', + '1', '6', '5', + '1', '6', '6', + '1', '6', '7', + '1', '6', '8', + '1', '6', '9', + '1', '7', '0', + '1', '7', '1', + '1', '7', '2', + '1', '7', '3', + '1', '7', '4', + '1', '7', '5', + '1', '7', '6', + '1', '7', '7', + '1', '7', '8', + '1', '7', '9', + '1', '8', '0', + '1', '8', '1', + '1', '8', '2', + '1', '8', '3', + '1', '8', '4', + '1', '8', '5', + '1', '8', '6', + '1', '8', '7', + '1', '8', '8', + '1', '8', '9', + '1', '9', '0', + '1', '9', '1', + '1', '9', '2', + '1', '9', '3', + '1', '9', '4', + '1', '9', '5', + '1', '9', '6', + '1', '9', '7', + '1', '9', '8', + '1', '9', '9', + '2', '0', '0', + '2', '0', '1', + '2', '0', '2', + '2', '0', '3', + '2', '0', '4', + '2', '0', '5', + '2', '0', '6', + '2', '0', '7', + '2', '0', '8', + '2', '0', '9', + '2', '1', '0', + '2', '1', '1', + '2', '1', '2', + '2', '1', '3', + '2', '1', '4', + '2', '1', '5', + '2', '1', '6', + '2', '1', '7', + '2', '1', '8', + '2', '1', '9', + '2', '2', '0', + '2', '2', '1', + '2', '2', '2', + '2', '2', '3', + '2', '2', '4', + '2', '2', '5', + '2', '2', '6', + '2', '2', '7', + '2', '2', '8', + '2', '2', '9', + '2', '3', '0', + '2', '3', '1', + '2', '3', '2', + '2', '3', '3', + '2', '3', '4', + '2', '3', '5', + '2', '3', '6', + '2', '3', '7', + '2', '3', '8', + '2', '3', '9', + '2', '4', '0', + '2', '4', '1', + '2', '4', '2', + '2', '4', '3', + '2', '4', '4', + '2', '4', '5', + '2', '4', '6', + '2', '4', '7', + '2', '4', '8', + '2', '4', '9', + '2', '5', '0', + '2', '5', '1', + '2', '5', '2', + '2', '5', '3', + '2', '5', '4', + '2', '5', '5', + '2', '5', '6', + '2', '5', '7', + '2', '5', '8', + '2', '5', '9', + '2', '6', '0', + '2', '6', '1', + '2', '6', '2', + '2', '6', '3', + '2', '6', '4', + '2', '6', '5', + '2', '6', '6', + '2', '6', '7', + '2', '6', '8', + '2', '6', '9', + '2', '7', '0', + '2', '7', '1', + '2', '7', '2', + '2', '7', '3', + '2', '7', '4', + '2', '7', '5', + '2', '7', '6', + '2', '7', '7', + '2', '7', '8', + '2', '7', '9', + '2', '8', '0', + '2', '8', '1', + '2', '8', '2', + '2', '8', '3', + '2', '8', '4', + '2', '8', '5', + '2', '8', '6', + '2', '8', '7', + '2', '8', '8', + '2', '8', '9', + '2', '9', '0', + '2', '9', '1', + '2', '9', '2', + '2', '9', '3', + '2', '9', '4', + '2', '9', '5', + '2', '9', '6', + '2', '9', '7', + '2', '9', '8', + '2', '9', '9', + '3', '0', '0', + '3', '0', '1', + '3', '0', '2', + '3', '0', '3', + '3', '0', '4', + '3', '0', '5', + '3', '0', '6', + '3', '0', '7', + '3', '0', '8', + '3', '0', '9', + '3', '1', '0', + '3', '1', '1', + '3', '1', '2', + '3', '1', '3', + '3', '1', '4', + '3', '1', '5', + '3', '1', '6', + '3', '1', '7', + '3', '1', '8', + '3', '1', '9', + '3', '2', '0', + '3', '2', '1', + '3', '2', '2', + '3', '2', '3', + '3', '2', '4', + '3', '2', '5', + '3', '2', '6', + '3', '2', '7', + '3', '2', '8', + '3', '2', '9', + '3', '3', '0', + '3', '3', '1', + '3', '3', '2', + '3', '3', '3', + '3', '3', '4', + '3', '3', '5', + '3', '3', '6', + '3', '3', '7', + '3', '3', '8', + '3', '3', '9', + '3', '4', '0', + '3', '4', '1', + '3', '4', '2', + '3', '4', '3', + '3', '4', '4', + '3', '4', '5', + '3', '4', '6', + '3', '4', '7', + '3', '4', '8', + '3', '4', '9', + '3', '5', '0', + '3', '5', '1', + '3', '5', '2', + '3', '5', '3', + '3', '5', '4', + '3', '5', '5', + '3', '5', '6', + '3', '5', '7', + '3', '5', '8', + '3', '5', '9', + '3', '6', '0', + '3', '6', '1', + '3', '6', '2', + '3', '6', '3', + '3', '6', '4', + '3', '6', '5', + '3', '6', '6', + '3', '6', '7', + '3', '6', '8', + '3', '6', '9', + '3', '7', '0', + '3', '7', '1', + '3', '7', '2', + '3', '7', '3', + '3', '7', '4', + '3', '7', '5', + '3', '7', '6', + '3', '7', '7', + '3', '7', '8', + '3', '7', '9', + '3', '8', '0', + '3', '8', '1', + '3', '8', '2', + '3', '8', '3', + '3', '8', '4', + '3', '8', '5', + '3', '8', '6', + '3', '8', '7', + '3', '8', '8', + '3', '8', '9', + '3', '9', '0', + '3', '9', '1', + '3', '9', '2', + '3', '9', '3', + '3', '9', '4', + '3', '9', '5', + '3', '9', '6', + '3', '9', '7', + '3', '9', '8', + '3', '9', '9', + '4', '0', '0', + '4', '0', '1', + '4', '0', '2', + '4', '0', '3', + '4', '0', '4', + '4', '0', '5', + '4', '0', '6', + '4', '0', '7', + '4', '0', '8', + '4', '0', '9', + '4', '1', '0', + '4', '1', '1', + '4', '1', '2', + '4', '1', '3', + '4', '1', '4', + '4', '1', '5', + '4', '1', '6', + '4', '1', '7', + '4', '1', '8', + '4', '1', '9', + '4', '2', '0', + '4', '2', '1', + '4', '2', '2', + '4', '2', '3', + '4', '2', '4', + '4', '2', '5', + '4', '2', '6', + '4', '2', '7', + '4', '2', '8', + '4', '2', '9', + '4', '3', '0', + '4', '3', '1', + '4', '3', '2', + '4', '3', '3', + '4', '3', '4', + '4', '3', '5', + '4', '3', '6', + '4', '3', '7', + '4', '3', '8', + '4', '3', '9', + '4', '4', '0', + '4', '4', '1', + '4', '4', '2', + '4', '4', '3', + '4', '4', '4', + '4', '4', '5', + '4', '4', '6', + '4', '4', '7', + '4', '4', '8', + '4', '4', '9', + '4', '5', '0', + '4', '5', '1', + '4', '5', '2', + '4', '5', '3', + '4', '5', '4', + '4', '5', '5', + '4', '5', '6', + '4', '5', '7', + '4', '5', '8', + '4', '5', '9', + '4', '6', '0', + '4', '6', '1', + '4', '6', '2', + '4', '6', '3', + '4', '6', '4', + '4', '6', '5', + '4', '6', '6', + '4', '6', '7', + '4', '6', '8', + '4', '6', '9', + '4', '7', '0', + '4', '7', '1', + '4', '7', '2', + '4', '7', '3', + '4', '7', '4', + '4', '7', '5', + '4', '7', '6', + '4', '7', '7', + '4', '7', '8', + '4', '7', '9', + '4', '8', '0', + '4', '8', '1', + '4', '8', '2', + '4', '8', '3', + '4', '8', '4', + '4', '8', '5', + '4', '8', '6', + '4', '8', '7', + '4', '8', '8', + '4', '8', '9', + '4', '9', '0', + '4', '9', '1', + '4', '9', '2', + '4', '9', '3', + '4', '9', '4', + '4', '9', '5', + '4', '9', '6', + '4', '9', '7', + '4', '9', '8', + '4', '9', '9', + '5', '0', '0', + '5', '0', '1', + '5', '0', '2', + '5', '0', '3', + '5', '0', '4', + '5', '0', '5', + '5', '0', '6', + '5', '0', '7', + '5', '0', '8', + '5', '0', '9', + '5', '1', '0', + '5', '1', '1', + '5', '1', '2', + '5', '1', '3', + '5', '1', '4', + '5', '1', '5', + '5', '1', '6', + '5', '1', '7', + '5', '1', '8', + '5', '1', '9', + '5', '2', '0', + '5', '2', '1', + '5', '2', '2', + '5', '2', '3', + '5', '2', '4', + '5', '2', '5', + '5', '2', '6', + '5', '2', '7', + '5', '2', '8', + '5', '2', '9', + '5', '3', '0', + '5', '3', '1', + '5', '3', '2', + '5', '3', '3', + '5', '3', '4', + '5', '3', '5', + '5', '3', '6', + '5', '3', '7', + '5', '3', '8', + '5', '3', '9', + '5', '4', '0', + '5', '4', '1', + '5', '4', '2', + '5', '4', '3', + '5', '4', '4', + '5', '4', '5', + '5', '4', '6', + '5', '4', '7', + '5', '4', '8', + '5', '4', '9', + '5', '5', '0', + '5', '5', '1', + '5', '5', '2', + '5', '5', '3', + '5', '5', '4', + '5', '5', '5', + '5', '5', '6', + '5', '5', '7', + '5', '5', '8', + '5', '5', '9', + '5', '6', '0', + '5', '6', '1', + '5', '6', '2', + '5', '6', '3', + '5', '6', '4', + '5', '6', '5', + '5', '6', '6', + '5', '6', '7', + '5', '6', '8', + '5', '6', '9', + '5', '7', '0', + '5', '7', '1', + '5', '7', '2', + '5', '7', '3', + '5', '7', '4', + '5', '7', '5', + '5', '7', '6', + '5', '7', '7', + '5', '7', '8', + '5', '7', '9', + '5', '8', '0', + '5', '8', '1', + '5', '8', '2', + '5', '8', '3', + '5', '8', '4', + '5', '8', '5', + '5', '8', '6', + '5', '8', '7', + '5', '8', '8', + '5', '8', '9', + '5', '9', '0', + '5', '9', '1', + '5', '9', '2', + '5', '9', '3', + '5', '9', '4', + '5', '9', '5', + '5', '9', '6', + '5', '9', '7', + '5', '9', '8', + '5', '9', '9', + '6', '0', '0', + '6', '0', '1', + '6', '0', '2', + '6', '0', '3', + '6', '0', '4', + '6', '0', '5', + '6', '0', '6', + '6', '0', '7', + '6', '0', '8', + '6', '0', '9', + '6', '1', '0', + '6', '1', '1', + '6', '1', '2', + '6', '1', '3', + '6', '1', '4', + '6', '1', '5', + '6', '1', '6', + '6', '1', '7', + '6', '1', '8', + '6', '1', '9', + '6', '2', '0', + '6', '2', '1', + '6', '2', '2', + '6', '2', '3', + '6', '2', '4', + '6', '2', '5', + '6', '2', '6', + '6', '2', '7', + '6', '2', '8', + '6', '2', '9', + '6', '3', '0', + '6', '3', '1', + '6', '3', '2', + '6', '3', '3', + '6', '3', '4', + '6', '3', '5', + '6', '3', '6', + '6', '3', '7', + '6', '3', '8', + '6', '3', '9', + '6', '4', '0', + '6', '4', '1', + '6', '4', '2', + '6', '4', '3', + '6', '4', '4', + '6', '4', '5', + '6', '4', '6', + '6', '4', '7', + '6', '4', '8', + '6', '4', '9', + '6', '5', '0', + '6', '5', '1', + '6', '5', '2', + '6', '5', '3', + '6', '5', '4', + '6', '5', '5', + '6', '5', '6', + '6', '5', '7', + '6', '5', '8', + '6', '5', '9', + '6', '6', '0', + '6', '6', '1', + '6', '6', '2', + '6', '6', '3', + '6', '6', '4', + '6', '6', '5', + '6', '6', '6', + '6', '6', '7', + '6', '6', '8', + '6', '6', '9', + '6', '7', '0', + '6', '7', '1', + '6', '7', '2', + '6', '7', '3', + '6', '7', '4', + '6', '7', '5', + '6', '7', '6', + '6', '7', '7', + '6', '7', '8', + '6', '7', '9', + '6', '8', '0', + '6', '8', '1', + '6', '8', '2', + '6', '8', '3', + '6', '8', '4', + '6', '8', '5', + '6', '8', '6', + '6', '8', '7', + '6', '8', '8', + '6', '8', '9', + '6', '9', '0', + '6', '9', '1', + '6', '9', '2', + '6', '9', '3', + '6', '9', '4', + '6', '9', '5', + '6', '9', '6', + '6', '9', '7', + '6', '9', '8', + '6', '9', '9', + '7', '0', '0', + '7', '0', '1', + '7', '0', '2', + '7', '0', '3', + '7', '0', '4', + '7', '0', '5', + '7', '0', '6', + '7', '0', '7', + '7', '0', '8', + '7', '0', '9', + '7', '1', '0', + '7', '1', '1', + '7', '1', '2', + '7', '1', '3', + '7', '1', '4', + '7', '1', '5', + '7', '1', '6', + '7', '1', '7', + '7', '1', '8', + '7', '1', '9', + '7', '2', '0', + '7', '2', '1', + '7', '2', '2', + '7', '2', '3', + '7', '2', '4', + '7', '2', '5', + '7', '2', '6', + '7', '2', '7', + '7', '2', '8', + '7', '2', '9', + '7', '3', '0', + '7', '3', '1', + '7', '3', '2', + '7', '3', '3', + '7', '3', '4', + '7', '3', '5', + '7', '3', '6', + '7', '3', '7', + '7', '3', '8', + '7', '3', '9', + '7', '4', '0', + '7', '4', '1', + '7', '4', '2', + '7', '4', '3', + '7', '4', '4', + '7', '4', '5', + '7', '4', '6', + '7', '4', '7', + '7', '4', '8', + '7', '4', '9', + '7', '5', '0', + '7', '5', '1', + '7', '5', '2', + '7', '5', '3', + '7', '5', '4', + '7', '5', '5', + '7', '5', '6', + '7', '5', '7', + '7', '5', '8', + '7', '5', '9', + '7', '6', '0', + '7', '6', '1', + '7', '6', '2', + '7', '6', '3', + '7', '6', '4', + '7', '6', '5', + '7', '6', '6', + '7', '6', '7', + '7', '6', '8', + '7', '6', '9', + '7', '7', '0', + '7', '7', '1', + '7', '7', '2', + '7', '7', '3', + '7', '7', '4', + '7', '7', '5', + '7', '7', '6', + '7', '7', '7', + '7', '7', '8', + '7', '7', '9', + '7', '8', '0', + '7', '8', '1', + '7', '8', '2', + '7', '8', '3', + '7', '8', '4', + '7', '8', '5', + '7', '8', '6', + '7', '8', '7', + '7', '8', '8', + '7', '8', '9', + '7', '9', '0', + '7', '9', '1', + '7', '9', '2', + '7', '9', '3', + '7', '9', '4', + '7', '9', '5', + '7', '9', '6', + '7', '9', '7', + '7', '9', '8', + '7', '9', '9', + '8', '0', '0', + '8', '0', '1', + '8', '0', '2', + '8', '0', '3', + '8', '0', '4', + '8', '0', '5', + '8', '0', '6', + '8', '0', '7', + '8', '0', '8', + '8', '0', '9', + '8', '1', '0', + '8', '1', '1', + '8', '1', '2', + '8', '1', '3', + '8', '1', '4', + '8', '1', '5', + '8', '1', '6', + '8', '1', '7', + '8', '1', '8', + '8', '1', '9', + '8', '2', '0', + '8', '2', '1', + '8', '2', '2', + '8', '2', '3', + '8', '2', '4', + '8', '2', '5', + '8', '2', '6', + '8', '2', '7', + '8', '2', '8', + '8', '2', '9', + '8', '3', '0', + '8', '3', '1', + '8', '3', '2', + '8', '3', '3', + '8', '3', '4', + '8', '3', '5', + '8', '3', '6', + '8', '3', '7', + '8', '3', '8', + '8', '3', '9', + '8', '4', '0', + '8', '4', '1', + '8', '4', '2', + '8', '4', '3', + '8', '4', '4', + '8', '4', '5', + '8', '4', '6', + '8', '4', '7', + '8', '4', '8', + '8', '4', '9', + '8', '5', '0', + '8', '5', '1', + '8', '5', '2', + '8', '5', '3', + '8', '5', '4', + '8', '5', '5', + '8', '5', '6', + '8', '5', '7', + '8', '5', '8', + '8', '5', '9', + '8', '6', '0', + '8', '6', '1', + '8', '6', '2', + '8', '6', '3', + '8', '6', '4', + '8', '6', '5', + '8', '6', '6', + '8', '6', '7', + '8', '6', '8', + '8', '6', '9', + '8', '7', '0', + '8', '7', '1', + '8', '7', '2', + '8', '7', '3', + '8', '7', '4', + '8', '7', '5', + '8', '7', '6', + '8', '7', '7', + '8', '7', '8', + '8', '7', '9', + '8', '8', '0', + '8', '8', '1', + '8', '8', '2', + '8', '8', '3', + '8', '8', '4', + '8', '8', '5', + '8', '8', '6', + '8', '8', '7', + '8', '8', '8', + '8', '8', '9', + '8', '9', '0', + '8', '9', '1', + '8', '9', '2', + '8', '9', '3', + '8', '9', '4', + '8', '9', '5', + '8', '9', '6', + '8', '9', '7', + '8', '9', '8', + '8', '9', '9', + '9', '0', '0', + '9', '0', '1', + '9', '0', '2', + '9', '0', '3', + '9', '0', '4', + '9', '0', '5', + '9', '0', '6', + '9', '0', '7', + '9', '0', '8', + '9', '0', '9', + '9', '1', '0', + '9', '1', '1', + '9', '1', '2', + '9', '1', '3', + '9', '1', '4', + '9', '1', '5', + '9', '1', '6', + '9', '1', '7', + '9', '1', '8', + '9', '1', '9', + '9', '2', '0', + '9', '2', '1', + '9', '2', '2', + '9', '2', '3', + '9', '2', '4', + '9', '2', '5', + '9', '2', '6', + '9', '2', '7', + '9', '2', '8', + '9', '2', '9', + '9', '3', '0', + '9', '3', '1', + '9', '3', '2', + '9', '3', '3', + '9', '3', '4', + '9', '3', '5', + '9', '3', '6', + '9', '3', '7', + '9', '3', '8', + '9', '3', '9', + '9', '4', '0', + '9', '4', '1', + '9', '4', '2', + '9', '4', '3', + '9', '4', '4', + '9', '4', '5', + '9', '4', '6', + '9', '4', '7', + '9', '4', '8', + '9', '4', '9', + '9', '5', '0', + '9', '5', '1', + '9', '5', '2', + '9', '5', '3', + '9', '5', '4', + '9', '5', '5', + '9', '5', '6', + '9', '5', '7', + '9', '5', '8', + '9', '5', '9', + '9', '6', '0', + '9', '6', '1', + '9', '6', '2', + '9', '6', '3', + '9', '6', '4', + '9', '6', '5', + '9', '6', '6', + '9', '6', '7', + '9', '6', '8', + '9', '6', '9', + '9', '7', '0', + '9', '7', '1', + '9', '7', '2', + '9', '7', '3', + '9', '7', '4', + '9', '7', '5', + '9', '7', '6', + '9', '7', '7', + '9', '7', '8', + '9', '7', '9', + '9', '8', '0', + '9', '8', '1', + '9', '8', '2', + '9', '8', '3', + '9', '8', '4', + '9', '8', '5', + '9', '8', '6', + '9', '8', '7', + '9', '8', '8', + '9', '8', '9', + '9', '9', '0', + '9', '9', '1', + '9', '9', '2', + '9', '9', '3', + '9', '9', '4', + '9', '9', '5', + '9', '9', '6', + '9', '9', '7', + '9', '9', '8', + '9', '9', '9' +}; + +// ten2m3k64[], shift_ten2m3k64[] used for conversion from BID128 to string +UINT64 ten2m3k64[] = { + 0x4189374bc6a7ef9eull, // 4189374bc6a7ef9e * 2^-72 = (10^-3)RP,63 + 0x10c6f7a0b5ed8d37ull, // 10c6f7a0b5ed8d37 * 2^-80 = (10^-6)RP,61 + 0x44b82fa09b5a52ccull, // 44b82fa09b5a52cc * 2^-92 = (10^-9)RP,63 + 0x119799812dea111aull, // 119799812dea111a * 2^-100 = (10^-12)RP,61 + 0x480ebe7b9d58566dull // 480ebe7b9d58566d * 2^-112 = (10^-15)RP,63 +}; + +unsigned int shift_ten2m3k64[] = { + 8, // 72 - 64 + 16, // 80 - 64 + 28, // 92 - 64 + 36, // 100 - 64 + 48 // 112 - 64 +}; + +UINT128 ten2m3k128[] = { + {{0xb22d0e5604189375ull, 0x4189374bc6a7ef9dull}}, + // 4189374bc6a7ef9d b22d0e5604189375 * 2^-136 = (10^-3)RP,127 + {{0xb4c7f34938583622ull, 0x10c6f7a0b5ed8d36ull}}, + // 10c6f7a0b5ed8d36 b4c7f34938583622 * 2^-144 = (10^-6)RP,125 + {{0x98b405447c4a9819ull, 0x44b82fa09b5a52cbull}}, + // 44b82fa09b5a52cb 98b405447c4a9819 * 2^-156 = (10^-9)RP,127 + {{0x7f27f0f6e885c8bbull, 0x119799812dea1119ull}}, + // 119799812dea1119 7f27f0f6e885c8bb * 2^-164 = (10^-12)RP,125 + {{0x87ce9b80a5fb0509ull, 0x480ebe7b9d58566cull}}, + // 480ebe7b9d58566c 87ce9b80a5fb0509 * 2^-176 = (10^-15)RP,127 + {{0xe75fe645cc4873faull, 0x12725dd1d243aba0ull}}, + // 12725dd1d243aba0 e75fe645cc4873fa * 2^-184 = (10^-18)RP,125 + {{0x69fb7e0b75e52f02ull, 0x4b8ed0283a6d3df7ull}}, + // 4b8ed0283a6d3df7 69fb7e0b75e52f02 * 2^-196 = (10^-21)RP,127 + {{0x58924d52ce4f26a9ull, 0x1357c299a88ea76aull}}, + // 1357c299a88ea76a 58924d52ce4f26a9 * 2^-204 = (10^-24)RP,125 + {{0x3baf513267aa9a3full, 0x4f3a68dbc8f03f24ull}}, + // 4f3a68dbc8f03f24 3baf513267aa9a3f * 2^-216 = (10^-27)RP,127 + {{0x3424b06f3529a052ull, 0x14484bfeebc29f86ull}}, + // 14484bfeebc29f86 3424b06f3529a052 * 2^-224 = (10^-30)RP,125 + {{0xf658d6c57566eac8ull, 0x5313a5dee87d6eb0ull}} + // 5313a5dee87d6eb0 f658d6c57566eac8 * 2^-236 = (10^-33)RP,127 +}; + +unsigned int shift_ten2m3k128[] = { + 8, // 136 - 128 + 16, // 144 - 128 + 28, // 156 - 128 + 36, // 164 - 128 + 48, // 176 - 128 + 56, // 184 - 128 + 4, // 196 - 192 + 12, // 204 - 192 + 24, // 216 - 192 + 32, // 224 - 192 + 44 // 236 - 192 +}; + + +/*************************************************************************** + *************** TABLES FOR GENERAL ROUNDING FUNCTIONS ********************* + ***************************************************************************/ +// Note: not all entries in these tables will be used with IEEE 754R decimal +// floating-point arithmetic +// a) In round128_2_18() numbers with 2 <= q <= 18 will be rounded only +// for 1 <= x <= 3: +// x = 1 or x = 2 when q = 17 +// x = 2 or x = 3 when q = 18 +// b) In round128_19_38() numbers with 19 <= q <= 38 will be rounded only +// for 1 <= x <= 23: +// x = 3 or x = 4 when q = 19 +// x = 4 or x = 5 when q = 20 +// ... +// x = 18 or x = 19 when q = 34 +// x = 1 or x = 2 or x = 19 or x = 20 when q = 35 +// x = 2 or x = 3 or x = 20 or x = 21 when q = 36 +// x = 3 or x = 4 or x = 21 or x = 22 when q = 37 +// x = 4 or x = 5 or x = 22 or x = 23 when q = 38 +// c) ... +// However, for generality and possible uses outside the frame of IEEE 754R +// this implementation includes table values for all x in [1, q - 1] + +// Note: 64-bit tables generated with ten2mx64.ma; output in ten2mx64.out + +// Kx from 10^(-x) ~= Kx * 2^(-Ex); Kx rounded up to 64 bits, 1 <= x <= 17 +UINT64 Kx64[] = { + 0xcccccccccccccccdULL, // 10^-1 ~= cccccccccccccccd * 2^-67 + 0xa3d70a3d70a3d70bULL, // 10^-2 ~= a3d70a3d70a3d70b * 2^-70 + 0x83126e978d4fdf3cULL, // 10^-3 ~= 83126e978d4fdf3c * 2^-73 + 0xd1b71758e219652cULL, // 10^-4 ~= d1b71758e219652c * 2^-77 + 0xa7c5ac471b478424ULL, // 10^-5 ~= a7c5ac471b478424 * 2^-80 + 0x8637bd05af6c69b6ULL, // 10^-6 ~= 8637bd05af6c69b6 * 2^-83 + 0xd6bf94d5e57a42bdULL, // 10^-7 ~= d6bf94d5e57a42bd * 2^-87 + 0xabcc77118461cefdULL, // 10^-8 ~= abcc77118461cefd * 2^-90 + 0x89705f4136b4a598ULL, // 10^-9 ~= 89705f4136b4a598 * 2^-93 + 0xdbe6fecebdedd5bfULL, // 10^-10 ~= dbe6fecebdedd5bf * 2^-97 + 0xafebff0bcb24aaffULL, // 10^-11 ~= afebff0bcb24aaff * 2^-100 + 0x8cbccc096f5088ccULL, // 10^-12 ~= 8cbccc096f5088cc * 2^-103 + 0xe12e13424bb40e14ULL, // 10^-13 ~= e12e13424bb40e14 * 2^-107 + 0xb424dc35095cd810ULL, // 10^-14 ~= b424dc35095cd810 * 2^-110 + 0x901d7cf73ab0acdaULL, // 10^-15 ~= 901d7cf73ab0acda * 2^-113 + 0xe69594bec44de15cULL, // 10^-16 ~= e69594bec44de15c * 2^-117 + 0xb877aa3236a4b44aULL // 10^-17 ~= b877aa3236a4b44a * 2^-120 +}; + +// Ex-64 from 10^(-x) ~= Kx * 2^(-Ex); Kx rounded up to 64 bits, 1 <= x <= 17 +unsigned int Ex64m64[] = { + 3, // 67 - 64, Ex = 67 + 6, // 70 - 64, Ex = 70 + 9, // 73 - 64, Ex = 73 + 13, // 77 - 64, Ex = 77 + 16, // 80 - 64, Ex = 80 + 19, // 83 - 64, Ex = 83 + 23, // 87 - 64, Ex = 87 + 26, // 90 - 64, Ex = 90 + 29, // 93 - 64, Ex = 93 + 33, // 97 - 64, Ex = 97 + 36, // 100 - 64, Ex = 100 + 39, // 103 - 64, Ex = 103 + 43, // 107 - 64, Ex = 107 + 46, // 110 - 64, Ex = 110 + 49, // 113 - 64, Ex = 113 + 53, // 117 - 64, Ex = 117 + 56 // 120 - 64, Ex = 120 +}; + +// Values of 1/2 in the right position to be compared with the fraction from +// C * kx, 1 <= x <= 17; the fraction consists of the low Ex bits in C * kx +// (these values are aligned with the high 64 bits of the fraction) +UINT64 half64[] = { + 0x0000000000000004ULL, // half / 2^64 = 4 + 0x0000000000000020ULL, // half / 2^64 = 20 + 0x0000000000000100ULL, // half / 2^64 = 100 + 0x0000000000001000ULL, // half / 2^64 = 1000 + 0x0000000000008000ULL, // half / 2^64 = 8000 + 0x0000000000040000ULL, // half / 2^64 = 40000 + 0x0000000000400000ULL, // half / 2^64 = 400000 + 0x0000000002000000ULL, // half / 2^64 = 2000000 + 0x0000000010000000ULL, // half / 2^64 = 10000000 + 0x0000000100000000ULL, // half / 2^64 = 100000000 + 0x0000000800000000ULL, // half / 2^64 = 800000000 + 0x0000004000000000ULL, // half / 2^64 = 4000000000 + 0x0000040000000000ULL, // half / 2^64 = 40000000000 + 0x0000200000000000ULL, // half / 2^64 = 200000000000 + 0x0001000000000000ULL, // half / 2^64 = 1000000000000 + 0x0010000000000000ULL, // half / 2^64 = 10000000000000 + 0x0080000000000000ULL // half / 2^64 = 80000000000000 +}; + +// Values of mask in the right position to obtain the high Ex - 64 bits +// of the fraction from C * kx, 1 <= x <= 17; the fraction consists of +// the low Ex bits in C * kx +UINT64 mask64[] = { + 0x0000000000000007ULL, // mask / 2^64 + 0x000000000000003fULL, // mask / 2^64 + 0x00000000000001ffULL, // mask / 2^64 + 0x0000000000001fffULL, // mask / 2^64 + 0x000000000000ffffULL, // mask / 2^64 + 0x000000000007ffffULL, // mask / 2^64 + 0x00000000007fffffULL, // mask / 2^64 + 0x0000000003ffffffULL, // mask / 2^64 + 0x000000001fffffffULL, // mask / 2^64 + 0x00000001ffffffffULL, // mask / 2^64 + 0x0000000fffffffffULL, // mask / 2^64 + 0x0000007fffffffffULL, // mask / 2^64 + 0x000007ffffffffffULL, // mask / 2^64 + 0x00003fffffffffffULL, // mask / 2^64 + 0x0001ffffffffffffULL, // mask / 2^64 + 0x001fffffffffffffULL, // mask / 2^64 + 0x00ffffffffffffffULL // mask / 2^64 +}; + +// Values of 10^(-x) trancated to Ex bits beyond the binary point, and +// in the right position to be compared with the fraction from C * kx, +// 1 <= x <= 17; the fraction consists of the low Ex bits in C * kx +// (these values are aligned with the low 64 bits of the fraction) +UINT64 ten2mxtrunc64[] = { + 0xccccccccccccccccULL, // (ten2mx >> 64) = cccccccccccccccc + 0xa3d70a3d70a3d70aULL, // (ten2mx >> 64) = a3d70a3d70a3d70a + 0x83126e978d4fdf3bULL, // (ten2mx >> 64) = 83126e978d4fdf3b + 0xd1b71758e219652bULL, // (ten2mx >> 64) = d1b71758e219652b + 0xa7c5ac471b478423ULL, // (ten2mx >> 64) = a7c5ac471b478423 + 0x8637bd05af6c69b5ULL, // (ten2mx >> 64) = 8637bd05af6c69b5 + 0xd6bf94d5e57a42bcULL, // (ten2mx >> 64) = d6bf94d5e57a42bc + 0xabcc77118461cefcULL, // (ten2mx >> 64) = abcc77118461cefc + 0x89705f4136b4a597ULL, // (ten2mx >> 64) = 89705f4136b4a597 + 0xdbe6fecebdedd5beULL, // (ten2mx >> 64) = dbe6fecebdedd5be + 0xafebff0bcb24aafeULL, // (ten2mx >> 64) = afebff0bcb24aafe + 0x8cbccc096f5088cbULL, // (ten2mx >> 64) = 8cbccc096f5088cb + 0xe12e13424bb40e13ULL, // (ten2mx >> 64) = e12e13424bb40e13 + 0xb424dc35095cd80fULL, // (ten2mx >> 64) = b424dc35095cd80f + 0x901d7cf73ab0acd9ULL, // (ten2mx >> 64) = 901d7cf73ab0acd9 + 0xe69594bec44de15bULL, // (ten2mx >> 64) = e69594bec44de15b + 0xb877aa3236a4b449ULL // (ten2mx >> 64) = b877aa3236a4b449 +}; + +// Note: 128-bit tables generated with ten2mx128.ma; output in ten2mx128.out +// The order of the 64-bit components is L, H + +// Kx from 10^(-x) ~= Kx * 2^(-Ex); Kx rounded up to 128 bits, 1 <= x <= 37 +UINT128 Kx128[] = { + {{0xcccccccccccccccdULL, 0xccccccccccccccccULL}}, + // 10^-1 ~= cccccccccccccccccccccccccccccccd * 2^-131 + {{0x3d70a3d70a3d70a4ULL, 0xa3d70a3d70a3d70aULL}}, + // 10^-2 ~= a3d70a3d70a3d70a3d70a3d70a3d70a4 * 2^-134 + {{0x645a1cac083126eaULL, 0x83126e978d4fdf3bULL}}, + // 10^-3 ~= 83126e978d4fdf3b645a1cac083126ea * 2^-137 + {{0xd3c36113404ea4a9ULL, 0xd1b71758e219652bULL}}, + // 10^-4 ~= d1b71758e219652bd3c36113404ea4a9 * 2^-141 + {{0x0fcf80dc33721d54ULL, 0xa7c5ac471b478423ULL}}, + // 10^-5 ~= a7c5ac471b4784230fcf80dc33721d54 * 2^-144 + {{0xa63f9a49c2c1b110ULL, 0x8637bd05af6c69b5ULL}}, + // 10^-6 ~= 8637bd05af6c69b5a63f9a49c2c1b110 * 2^-147 + {{0x3d32907604691b4dULL, 0xd6bf94d5e57a42bcULL}}, + // 10^-7 ~= d6bf94d5e57a42bc3d32907604691b4d * 2^-151 + {{0xfdc20d2b36ba7c3eULL, 0xabcc77118461cefcULL}}, + // 10^-8 ~= abcc77118461cefcfdc20d2b36ba7c3e * 2^-154 + {{0x31680a88f8953031ULL, 0x89705f4136b4a597ULL}}, + // 10^-9 ~= 89705f4136b4a59731680a88f8953031 * 2^-157 + {{0xb573440e5a884d1cULL, 0xdbe6fecebdedd5beULL}}, + // 10^-10 ~= dbe6fecebdedd5beb573440e5a884d1c * 2^-161 + {{0xf78f69a51539d749ULL, 0xafebff0bcb24aafeULL}}, + // 10^-11 ~= afebff0bcb24aafef78f69a51539d749 * 2^-164 + {{0xf93f87b7442e45d4ULL, 0x8cbccc096f5088cbULL}}, + // 10^-12 ~= 8cbccc096f5088cbf93f87b7442e45d4 * 2^-167 + {{0x2865a5f206b06fbaULL, 0xe12e13424bb40e13ULL}}, + // 10^-13 ~= e12e13424bb40e132865a5f206b06fba * 2^-171 + {{0x538484c19ef38c95ULL, 0xb424dc35095cd80fULL}}, + // 10^-14 ~= b424dc35095cd80f538484c19ef38c95 * 2^-174 + {{0x0f9d37014bf60a11ULL, 0x901d7cf73ab0acd9ULL}}, + // 10^-15 ~= 901d7cf73ab0acd90f9d37014bf60a11 * 2^-177 + {{0x4c2ebe687989a9b4ULL, 0xe69594bec44de15bULL}}, + // 10^-16 ~= e69594bec44de15b4c2ebe687989a9b4 * 2^-181 + {{0x09befeb9fad487c3ULL, 0xb877aa3236a4b449ULL}}, + // 10^-17 ~= b877aa3236a4b44909befeb9fad487c3 * 2^-184 + {{0x3aff322e62439fd0ULL, 0x9392ee8e921d5d07ULL}}, + // 10^-18 ~= 9392ee8e921d5d073aff322e62439fd0 * 2^-187 + {{0x2b31e9e3d06c32e6ULL, 0xec1e4a7db69561a5ULL}}, + // 10^-19 ~= ec1e4a7db69561a52b31e9e3d06c32e6 * 2^-191 + {{0x88f4bb1ca6bcf585ULL, 0xbce5086492111aeaULL}}, + // 10^-20 ~= bce5086492111aea88f4bb1ca6bcf585 * 2^-194 + {{0xd3f6fc16ebca5e04ULL, 0x971da05074da7beeULL}}, + // 10^-21 ~= 971da05074da7beed3f6fc16ebca5e04 * 2^-197 + {{0x5324c68b12dd6339ULL, 0xf1c90080baf72cb1ULL}}, + // 10^-22 ~= f1c90080baf72cb15324c68b12dd6339 * 2^-201 + {{0x75b7053c0f178294ULL, 0xc16d9a0095928a27ULL}}, + // 10^-23 ~= c16d9a0095928a2775b7053c0f178294 * 2^-204 + {{0xc4926a9672793543ULL, 0x9abe14cd44753b52ULL}}, + // 10^-24 ~= 9abe14cd44753b52c4926a9672793543 * 2^-207 + {{0x3a83ddbd83f52205ULL, 0xf79687aed3eec551ULL}}, + // 10^-25 ~= f79687aed3eec5513a83ddbd83f52205 * 2^-211 + {{0x95364afe032a819eULL, 0xc612062576589ddaULL}}, + // 10^-26 ~= c612062576589dda95364afe032a819e * 2^-214 + {{0x775ea264cf55347eULL, 0x9e74d1b791e07e48ULL}}, + // 10^-27 ~= 9e74d1b791e07e48775ea264cf55347e * 2^-217 + {{0x8bca9d6e188853fdULL, 0xfd87b5f28300ca0dULL}}, + // 10^-28 ~= fd87b5f28300ca0d8bca9d6e188853fd * 2^-221 + {{0x096ee45813a04331ULL, 0xcad2f7f5359a3b3eULL}}, + // 10^-29 ~= cad2f7f5359a3b3e096ee45813a04331 * 2^-224 + {{0xa1258379a94d028eULL, 0xa2425ff75e14fc31ULL}}, + // 10^-30 ~= a2425ff75e14fc31a1258379a94d028e * 2^-227 + {{0x80eacf948770ced8ULL, 0x81ceb32c4b43fcf4ULL}}, + // 10^-31 ~= 81ceb32c4b43fcf480eacf948770ced8 * 2^-230 + {{0x67de18eda5814af3ULL, 0xcfb11ead453994baULL}}, + // 10^-32 ~= cfb11ead453994ba67de18eda5814af3 * 2^-234 + {{0xecb1ad8aeacdd58fULL, 0xa6274bbdd0fadd61ULL}}, + // 10^-33 ~= a6274bbdd0fadd61ecb1ad8aeacdd58f * 2^-237 + {{0xbd5af13bef0b113fULL, 0x84ec3c97da624ab4ULL}}, + // 10^-34 ~= 84ec3c97da624ab4bd5af13bef0b113f * 2^-240 + {{0x955e4ec64b44e865ULL, 0xd4ad2dbfc3d07787ULL}}, + // 10^-35 ~= d4ad2dbfc3d07787955e4ec64b44e865 * 2^-244 + {{0xdde50bd1d5d0b9eaULL, 0xaa242499697392d2ULL}}, + // 10^-36 ~= aa242499697392d2dde50bd1d5d0b9ea * 2^-247 + {{0x7e50d64177da2e55ULL, 0x881cea14545c7575ULL}} + // 10^-37 ~= 881cea14545c75757e50d64177da2e55 * 2^-250 +}; + +// Ex-128 from 10^(-x) ~= Kx*2^(-Ex); Kx rounded up to 128 bits, 1 <= x <= 37 +unsigned int Ex128m128[] = { + 3, // 131 - 128, Ex = 131 + 6, // 134 - 128, Ex = 134 + 9, // 137 - 128, Ex = 137 + 13, // 141 - 128, Ex = 141 + 16, // 144 - 128, Ex = 144 + 19, // 147 - 128, Ex = 147 + 23, // 151 - 128, Ex = 151 + 26, // 154 - 128, Ex = 154 + 29, // 157 - 128, Ex = 157 + 33, // 161 - 128, Ex = 161 + 36, // 164 - 128, Ex = 164 + 39, // 167 - 128, Ex = 167 + 43, // 171 - 128, Ex = 171 + 46, // 174 - 128, Ex = 174 + 49, // 177 - 128, Ex = 177 + 53, // 181 - 128, Ex = 181 + 56, // 184 - 128, Ex = 184 + 59, // 187 - 128, Ex = 187 + 63, // 191 - 128, Ex = 191 + 2, // 194 - 192, Ex = 194 + 5, // 197 - 192, Ex = 197 + 9, // 201 - 192, Ex = 201 + 12, // 204 - 192, Ex = 204 + 15, // 207 - 192, Ex = 207 + 19, // 211 - 192, Ex = 211 + 22, // 214 - 192, Ex = 214 + 25, // 217 - 192, Ex = 217 + 29, // 221 - 192, Ex = 221 + 32, // 224 - 192, Ex = 224 + 35, // 227 - 192, Ex = 227 + 38, // 230 - 192, Ex = 230 + 42, // 234 - 192, Ex = 234 + 45, // 237 - 192, Ex = 237 + 48, // 240 - 192, Ex = 240 + 52, // 244 - 192, Ex = 244 + 55, // 247 - 192, Ex = 247 + 58 // 250 - 192, Ex = 250 +}; + +// Values of 1/2 in the right position to be compared with the fraction from +// C * kx, 1 <= x <= 37; the fraction consists of the low Ex bits in C * kx +// (these values are aligned with the high 128 bits of the fraction) +UINT64 half128[] = { + 0x0000000000000004ULL, // half / 2^128 = 4 + 0x0000000000000020ULL, // half / 2^128 = 20 + 0x0000000000000100ULL, // half / 2^128 = 100 + 0x0000000000001000ULL, // half / 2^128 = 1000 + 0x0000000000008000ULL, // half / 2^128 = 8000 + 0x0000000000040000ULL, // half / 2^128 = 40000 + 0x0000000000400000ULL, // half / 2^128 = 400000 + 0x0000000002000000ULL, // half / 2^128 = 2000000 + 0x0000000010000000ULL, // half / 2^128 = 10000000 + 0x0000000100000000ULL, // half / 2^128 = 100000000 + 0x0000000800000000ULL, // half / 2^128 = 800000000 + 0x0000004000000000ULL, // half / 2^128 = 4000000000 + 0x0000040000000000ULL, // half / 2^128 = 40000000000 + 0x0000200000000000ULL, // half / 2^128 = 200000000000 + 0x0001000000000000ULL, // half / 2^128 = 1000000000000 + 0x0010000000000000ULL, // half / 2^128 = 10000000000000 + 0x0080000000000000ULL, // half / 2^128 = 80000000000000 + 0x0400000000000000ULL, // half / 2^128 = 400000000000000 + 0x4000000000000000ULL, // half / 2^128 = 4000000000000000 + 0x0000000000000002ULL, // half / 2^192 = 2 + 0x0000000000000010ULL, // half / 2^192 = 10 + 0x0000000000000100ULL, // half / 2^192 = 100 + 0x0000000000000800ULL, // half / 2^192 = 800 + 0x0000000000004000ULL, // half / 2^192 = 4000 + 0x0000000000040000ULL, // half / 2^192 = 40000 + 0x0000000000200000ULL, // half / 2^192 = 200000 + 0x0000000001000000ULL, // half / 2^192 = 1000000 + 0x0000000010000000ULL, // half / 2^192 = 10000000 + 0x0000000080000000ULL, // half / 2^192 = 80000000 + 0x0000000400000000ULL, // half / 2^192 = 400000000 + 0x0000002000000000ULL, // half / 2^192 = 2000000000 + 0x0000020000000000ULL, // half / 2^192 = 20000000000 + 0x0000100000000000ULL, // half / 2^192 = 100000000000 + 0x0000800000000000ULL, // half / 2^192 = 800000000000 + 0x0008000000000000ULL, // half / 2^192 = 8000000000000 + 0x0040000000000000ULL, // half / 2^192 = 40000000000000 + 0x0200000000000000ULL // half / 2^192 = 200000000000000 +}; + +// Values of mask in the right position to obtain the high Ex - 128 or Ex - 192 +// bits of the fraction from C * kx, 1 <= x <= 37; the fraction consists of +// the low Ex bits in C * kx +UINT64 mask128[] = { + 0x0000000000000007ULL, // mask / 2^128 + 0x000000000000003fULL, // mask / 2^128 + 0x00000000000001ffULL, // mask / 2^128 + 0x0000000000001fffULL, // mask / 2^128 + 0x000000000000ffffULL, // mask / 2^128 + 0x000000000007ffffULL, // mask / 2^128 + 0x00000000007fffffULL, // mask / 2^128 + 0x0000000003ffffffULL, // mask / 2^128 + 0x000000001fffffffULL, // mask / 2^128 + 0x00000001ffffffffULL, // mask / 2^128 + 0x0000000fffffffffULL, // mask / 2^128 + 0x0000007fffffffffULL, // mask / 2^128 + 0x000007ffffffffffULL, // mask / 2^128 + 0x00003fffffffffffULL, // mask / 2^128 + 0x0001ffffffffffffULL, // mask / 2^128 + 0x001fffffffffffffULL, // mask / 2^128 + 0x00ffffffffffffffULL, // mask / 2^128 + 0x07ffffffffffffffULL, // mask / 2^128 + 0x7fffffffffffffffULL, // mask / 2^128 + 0x0000000000000003ULL, // mask / 2^192 + 0x000000000000001fULL, // mask / 2^192 + 0x00000000000001ffULL, // mask / 2^192 + 0x0000000000000fffULL, // mask / 2^192 + 0x0000000000007fffULL, // mask / 2^192 + 0x000000000007ffffULL, // mask / 2^192 + 0x00000000003fffffULL, // mask / 2^192 + 0x0000000001ffffffULL, // mask / 2^192 + 0x000000001fffffffULL, // mask / 2^192 + 0x00000000ffffffffULL, // mask / 2^192 + 0x00000007ffffffffULL, // mask / 2^192 + 0x0000003fffffffffULL, // mask / 2^192 + 0x000003ffffffffffULL, // mask / 2^192 + 0x00001fffffffffffULL, // mask / 2^192 + 0x0000ffffffffffffULL, // mask / 2^192 + 0x000fffffffffffffULL, // mask / 2^192 + 0x007fffffffffffffULL, // mask / 2^192 + 0x03ffffffffffffffULL // mask / 2^192 +}; + +// Values of 10^(-x) trancated to Ex bits beyond the binary point, and +// in the right position to be compared with the fraction from C * kx, +// 1 <= x <= 37; the fraction consists of the low Ex bits in C * kx +// (these values are aligned with the low 128 bits of the fraction) +UINT128 ten2mxtrunc128[] = { + {{0xccccccccccccccccULL, 0xccccccccccccccccULL}}, + // (ten2mx >> 128) = cccccccccccccccccccccccccccccccc + {{0x3d70a3d70a3d70a3ULL, 0xa3d70a3d70a3d70aULL}}, + // (ten2mx >> 128) = a3d70a3d70a3d70a3d70a3d70a3d70a3 + {{0x645a1cac083126e9ULL, 0x83126e978d4fdf3bULL}}, + // (ten2mx >> 128) = 83126e978d4fdf3b645a1cac083126e9 + {{0xd3c36113404ea4a8ULL, 0xd1b71758e219652bULL}}, + // (ten2mx >> 128) = d1b71758e219652bd3c36113404ea4a8 + {{0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}}, + // (ten2mx >> 128) = a7c5ac471b4784230fcf80dc33721d53 + {{0xa63f9a49c2c1b10fULL, 0x8637bd05af6c69b5ULL}}, + // (ten2mx >> 128) = 8637bd05af6c69b5a63f9a49c2c1b10f + {{0x3d32907604691b4cULL, 0xd6bf94d5e57a42bcULL}}, + // (ten2mx >> 128) = d6bf94d5e57a42bc3d32907604691b4c + {{0xfdc20d2b36ba7c3dULL, 0xabcc77118461cefcULL}}, + // (ten2mx >> 128) = abcc77118461cefcfdc20d2b36ba7c3d + {{0x31680a88f8953030ULL, 0x89705f4136b4a597ULL}}, + // (ten2mx >> 128) = 89705f4136b4a59731680a88f8953030 + {{0xb573440e5a884d1bULL, 0xdbe6fecebdedd5beULL}}, + // (ten2mx >> 128) = dbe6fecebdedd5beb573440e5a884d1b + {{0xf78f69a51539d748ULL, 0xafebff0bcb24aafeULL}}, + // (ten2mx >> 128) = afebff0bcb24aafef78f69a51539d748 + {{0xf93f87b7442e45d3ULL, 0x8cbccc096f5088cbULL}}, + // (ten2mx >> 128) = 8cbccc096f5088cbf93f87b7442e45d3 + {{0x2865a5f206b06fb9ULL, 0xe12e13424bb40e13ULL}}, + // (ten2mx >> 128) = e12e13424bb40e132865a5f206b06fb9 + {{0x538484c19ef38c94ULL, 0xb424dc35095cd80fULL}}, + // (ten2mx >> 128) = b424dc35095cd80f538484c19ef38c94 + {{0x0f9d37014bf60a10ULL, 0x901d7cf73ab0acd9ULL}}, + // (ten2mx >> 128) = 901d7cf73ab0acd90f9d37014bf60a10 + {{0x4c2ebe687989a9b3ULL, 0xe69594bec44de15bULL}}, + // (ten2mx >> 128) = e69594bec44de15b4c2ebe687989a9b3 + {{0x09befeb9fad487c2ULL, 0xb877aa3236a4b449ULL}}, + // (ten2mx >> 128) = b877aa3236a4b44909befeb9fad487c2 + {{0x3aff322e62439fcfULL, 0x9392ee8e921d5d07ULL}}, + // (ten2mx >> 128) = 9392ee8e921d5d073aff322e62439fcf + {{0x2b31e9e3d06c32e5ULL, 0xec1e4a7db69561a5ULL}}, + // (ten2mx >> 128) = ec1e4a7db69561a52b31e9e3d06c32e5 + {{0x88f4bb1ca6bcf584ULL, 0xbce5086492111aeaULL}}, + // (ten2mx >> 128) = bce5086492111aea88f4bb1ca6bcf584 + {{0xd3f6fc16ebca5e03ULL, 0x971da05074da7beeULL}}, + // (ten2mx >> 128) = 971da05074da7beed3f6fc16ebca5e03 + {{0x5324c68b12dd6338ULL, 0xf1c90080baf72cb1ULL}}, + // (ten2mx >> 128) = f1c90080baf72cb15324c68b12dd6338 + {{0x75b7053c0f178293ULL, 0xc16d9a0095928a27ULL}}, + // (ten2mx >> 128) = c16d9a0095928a2775b7053c0f178293 + {{0xc4926a9672793542ULL, 0x9abe14cd44753b52ULL}}, + // (ten2mx >> 128) = 9abe14cd44753b52c4926a9672793542 + {{0x3a83ddbd83f52204ULL, 0xf79687aed3eec551ULL}}, + // (ten2mx >> 128) = f79687aed3eec5513a83ddbd83f52204 + {{0x95364afe032a819dULL, 0xc612062576589ddaULL}}, + // (ten2mx >> 128) = c612062576589dda95364afe032a819d + {{0x775ea264cf55347dULL, 0x9e74d1b791e07e48ULL}}, + // (ten2mx >> 128) = 9e74d1b791e07e48775ea264cf55347d + {{0x8bca9d6e188853fcULL, 0xfd87b5f28300ca0dULL}}, + // (ten2mx >> 128) = fd87b5f28300ca0d8bca9d6e188853fc + {{0x096ee45813a04330ULL, 0xcad2f7f5359a3b3eULL}}, + // (ten2mx >> 128) = cad2f7f5359a3b3e096ee45813a04330 + {{0xa1258379a94d028dULL, 0xa2425ff75e14fc31ULL}}, + // (ten2mx >> 128) = a2425ff75e14fc31a1258379a94d028d + {{0x80eacf948770ced7ULL, 0x81ceb32c4b43fcf4ULL}}, + // (ten2mx >> 128) = 81ceb32c4b43fcf480eacf948770ced7 + {{0x67de18eda5814af2ULL, 0xcfb11ead453994baULL}}, + // (ten2mx >> 128) = cfb11ead453994ba67de18eda5814af2 + {{0xecb1ad8aeacdd58eULL, 0xa6274bbdd0fadd61ULL}}, + // (ten2mx >> 128) = a6274bbdd0fadd61ecb1ad8aeacdd58e + {{0xbd5af13bef0b113eULL, 0x84ec3c97da624ab4ULL}}, + // (ten2mx >> 128) = 84ec3c97da624ab4bd5af13bef0b113e + {{0x955e4ec64b44e864ULL, 0xd4ad2dbfc3d07787ULL}}, + // (ten2mx >> 128) = d4ad2dbfc3d07787955e4ec64b44e864 + {{0xdde50bd1d5d0b9e9ULL, 0xaa242499697392d2ULL}}, + // (ten2mx >> 128) = aa242499697392d2dde50bd1d5d0b9e9 + {{0x7e50d64177da2e54ULL, 0x881cea14545c7575ULL}} + // (ten2mx >> 128) = 881cea14545c75757e50d64177da2e54 +}; + +UINT192 Kx192[] = { + {{0xcccccccccccccccdULL, 0xccccccccccccccccULL, + 0xccccccccccccccccULL}}, + // 10^-1 ~= cccccccccccccccccccccccccccccccccccccccccccccccd * 2^-195 + {{0xd70a3d70a3d70a3eULL, 0x3d70a3d70a3d70a3ULL, + 0xa3d70a3d70a3d70aULL}}, + // 10^-2 ~= a3d70a3d70a3d70a3d70a3d70a3d70a3d70a3d70a3d70a3e * 2^-198 + {{0x78d4fdf3b645a1cbULL, 0x645a1cac083126e9ULL, + 0x83126e978d4fdf3bULL}}, + // 10^-3 ~= 83126e978d4fdf3b645a1cac083126e978d4fdf3b645a1cb * 2^-201 + {{0xc154c985f06f6945ULL, 0xd3c36113404ea4a8ULL, + 0xd1b71758e219652bULL}}, + // 10^-4 ~= d1b71758e219652bd3c36113404ea4a8c154c985f06f6945 * 2^-205 + {{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, + 0xa7c5ac471b478423ULL}}, + // 10^-5 ~= a7c5ac471b4784230fcf80dc33721d53cddd6e04c0592104 * 2^-208 + {{0xd7e45803cd141a6aULL, 0xa63f9a49c2c1b10fULL, + 0x8637bd05af6c69b5ULL}}, + // 10^-6 ~= 8637bd05af6c69b5a63f9a49c2c1b10fd7e45803cd141a6a * 2^-211 + {{0x8ca08cd2e1b9c3dcULL, 0x3d32907604691b4cULL, + 0xd6bf94d5e57a42bcULL}}, + // 10^-7 ~= d6bf94d5e57a42bc3d32907604691b4c8ca08cd2e1b9c3dc * 2^-215 + {{0x3d4d3d758161697dULL, 0xfdc20d2b36ba7c3dULL, + 0xabcc77118461cefcULL}}, + // 10^-8 ~= abcc77118461cefcfdc20d2b36ba7c3d3d4d3d758161697d * 2^-218 + {{0xfdd7645e011abacaULL, 0x31680a88f8953030ULL, + 0x89705f4136b4a597ULL}}, + // 10^-9 ~= 89705f4136b4a59731680a88f8953030fdd7645e011abaca * 2^-221 + {{0x2fbf06fcce912addULL, 0xb573440e5a884d1bULL, + 0xdbe6fecebdedd5beULL}}, + // 10^-10 ~= dbe6fecebdedd5beb573440e5a884d1b2fbf06fcce912add * 2^-225 + {{0xf2ff38ca3eda88b1ULL, 0xf78f69a51539d748ULL, + 0xafebff0bcb24aafeULL}}, + // 10^-11 ~= afebff0bcb24aafef78f69a51539d748f2ff38ca3eda88b1 * 2^-228 + {{0xf598fa3b657ba08eULL, 0xf93f87b7442e45d3ULL, + 0x8cbccc096f5088cbULL}}, + // 10^-12 ~= 8cbccc096f5088cbf93f87b7442e45d3f598fa3b657ba08e * 2^-231 + {{0x88f4c3923bf900e3ULL, 0x2865a5f206b06fb9ULL, + 0xe12e13424bb40e13ULL}}, + // 10^-13 ~= e12e13424bb40e132865a5f206b06fb988f4c3923bf900e3 * 2^-235 + {{0x6d909c74fcc733e9ULL, 0x538484c19ef38c94ULL, + 0xb424dc35095cd80fULL}}, + // 10^-14 ~= b424dc35095cd80f538484c19ef38c946d909c74fcc733e9 * 2^-238 + {{0x57a6e390ca38f654ULL, 0x0f9d37014bf60a10ULL, + 0x901d7cf73ab0acd9ULL}}, + // 10^-15 ~= 901d7cf73ab0acd90f9d37014bf60a1057a6e390ca38f654 * 2^-241 + {{0xbf716c1add27f086ULL, 0x4c2ebe687989a9b3ULL, + 0xe69594bec44de15bULL}}, + // 10^-16 ~= e69594bec44de15b4c2ebe687989a9b3bf716c1add27f086 * 2^-245 + {{0xff8df0157db98d38ULL, 0x09befeb9fad487c2ULL, + 0xb877aa3236a4b449ULL}}, + // 10^-17 ~= b877aa3236a4b44909befeb9fad487c2ff8df0157db98d38 * 2^-248 + {{0x32d7f344649470faULL, 0x3aff322e62439fcfULL, + 0x9392ee8e921d5d07ULL}}, + // 10^-18 ~= 9392ee8e921d5d073aff322e62439fcf32d7f344649470fa * 2^-251 + {{0x1e2652070753e7f5ULL, 0x2b31e9e3d06c32e5ULL, + 0xec1e4a7db69561a5ULL}}, + // 10^-19 ~= ec1e4a7db69561a52b31e9e3d06c32e51e2652070753e7f5 * 2^-255 + {{0x181ea8059f76532bULL, 0x88f4bb1ca6bcf584ULL, + 0xbce5086492111aeaULL}}, + // 10^-20 ~= bce5086492111aea88f4bb1ca6bcf584181ea8059f76532b * 2^-258 + {{0x467eecd14c5ea8efULL, 0xd3f6fc16ebca5e03ULL, + 0x971da05074da7beeULL}}, + // 10^-21 ~= 971da05074da7beed3f6fc16ebca5e03467eecd14c5ea8ef * 2^-261 + {{0x70cb148213caa7e5ULL, 0x5324c68b12dd6338ULL, + 0xf1c90080baf72cb1ULL}}, + // 10^-22 ~= f1c90080baf72cb15324c68b12dd633870cb148213caa7e5 * 2^-265 + {{0x8d6f439b43088651ULL, 0x75b7053c0f178293ULL, + 0xc16d9a0095928a27ULL}}, + // 10^-23 ~= c16d9a0095928a2775b7053c0f1782938d6f439b43088651 * 2^-268 + {{0xd78c3615cf3a050dULL, 0xc4926a9672793542ULL, + 0x9abe14cd44753b52ULL}}, + // 10^-24 ~= 9abe14cd44753b52c4926a9672793542d78c3615cf3a050d * 2^-271 + {{0x8c1389bc7ec33b48ULL, 0x3a83ddbd83f52204ULL, + 0xf79687aed3eec551ULL}}, + // 10^-25 ~= f79687aed3eec5513a83ddbd83f522048c1389bc7ec33b48 * 2^-275 + {{0x3cdc6e306568fc3aULL, 0x95364afe032a819dULL, + 0xc612062576589ddaULL}}, + // 10^-26 ~= c612062576589dda95364afe032a819d3cdc6e306568fc3a * 2^-278 + {{0xca49f1c05120c9c8ULL, 0x775ea264cf55347dULL, + 0x9e74d1b791e07e48ULL}}, + // 10^-27 ~= 9e74d1b791e07e48775ea264cf55347dca49f1c05120c9c8 * 2^-281 + {{0x76dcb60081ce0fa6ULL, 0x8bca9d6e188853fcULL, + 0xfd87b5f28300ca0dULL}}, + // 10^-28 ~= fd87b5f28300ca0d8bca9d6e188853fc76dcb60081ce0fa6 * 2^-285 + {{0x5f16f80067d80c85ULL, 0x096ee45813a04330ULL, + 0xcad2f7f5359a3b3eULL}}, + // 10^-29 ~= cad2f7f5359a3b3e096ee45813a043305f16f80067d80c85 * 2^-288 + {{0x18df2ccd1fe00a04ULL, 0xa1258379a94d028dULL, + 0xa2425ff75e14fc31ULL}}, + // 10^-30 ~= a2425ff75e14fc31a1258379a94d028d18df2ccd1fe00a04 * 2^-291 + {{0x4718f0a419800803ULL, 0x80eacf948770ced7ULL, + 0x81ceb32c4b43fcf4ULL}}, + // 10^-31 ~= 81ceb32c4b43fcf480eacf948770ced74718f0a419800803 * 2^-294 + {{0x0b5b1aa028ccd99fULL, 0x67de18eda5814af2ULL, + 0xcfb11ead453994baULL}}, + // 10^-32 ~= cfb11ead453994ba67de18eda5814af20b5b1aa028ccd99f * 2^-298 + {{0x6f7c154ced70ae19ULL, 0xecb1ad8aeacdd58eULL, + 0xa6274bbdd0fadd61ULL}}, + // 10^-33 ~= a6274bbdd0fadd61ecb1ad8aeacdd58e6f7c154ced70ae19 * 2^-301 + {{0xbf967770bdf3be7aULL, 0xbd5af13bef0b113eULL, + 0x84ec3c97da624ab4ULL}}, + // 10^-34 ~= 84ec3c97da624ab4bd5af13bef0b113ebf967770bdf3be7a * 2^-304 + {{0x65bd8be79652ca5dULL, 0x955e4ec64b44e864ULL, + 0xd4ad2dbfc3d07787ULL}}, + // 10^-35 ~= d4ad2dbfc3d07787955e4ec64b44e86465bd8be79652ca5d * 2^-308 + {{0xeafe098611dbd517ULL, 0xdde50bd1d5d0b9e9ULL, + 0xaa242499697392d2ULL}}, + // 10^-36 ~= aa242499697392d2dde50bd1d5d0b9e9eafe098611dbd517 * 2^-311 + {{0xbbfe6e04db164413ULL, 0x7e50d64177da2e54ULL, + 0x881cea14545c7575ULL}}, + // 10^-37 ~= 881cea14545c75757e50d64177da2e54bbfe6e04db164413 * 2^-314 + {{0x2cca49a15e8a0684ULL, 0x96e7bd358c904a21ULL, + 0xd9c7dced53c72255ULL}}, + // 10^-38 ~= d9c7dced53c7225596e7bd358c904a212cca49a15e8a0684 * 2^-318 + {{0x8a3b6e1ab2080537ULL, 0xabec975e0a0d081aULL, + 0xae397d8aa96c1b77ULL}}, + // 10^-39 ~= ae397d8aa96c1b77abec975e0a0d081a8a3b6e1ab2080537 * 2^-321 + {{0x3b62be7bc1a0042cULL, 0x2323ac4b3b3da015ULL, + 0x8b61313bbabce2c6ULL}}, + // 10^-40 ~= 8b61313bbabce2c62323ac4b3b3da0153b62be7bc1a0042c * 2^-324 + {{0x5f0463f935ccd379ULL, 0x6b6c46dec52f6688ULL, + 0xdf01e85f912e37a3ULL}}, + // 10^-41 ~= df01e85f912e37a36b6c46dec52f66885f0463f935ccd379 * 2^-328 + {{0x7f36b660f7d70f94ULL, 0x55f038b237591ed3ULL, + 0xb267ed1940f1c61cULL}}, + // 10^-42 ~= b267ed1940f1c61c55f038b237591ed37f36b660f7d70f94 * 2^-331 + {{0xcc2bc51a5fdf3faaULL, 0x77f3608e92adb242ULL, + 0x8eb98a7a9a5b04e3ULL}}, + // 10^-43 ~= 8eb98a7a9a5b04e377f3608e92adb242cc2bc51a5fdf3faa * 2^-334 + {{0xe046082a32fecc42ULL, 0x8cb89a7db77c506aULL, + 0xe45c10c42a2b3b05ULL}}, + // 10^-44 ~= e45c10c42a2b3b058cb89a7db77c506ae046082a32fecc42 * 2^-338 + {{0x4d04d354f598a368ULL, 0x3d607b97c5fd0d22ULL, + 0xb6b00d69bb55c8d1ULL}}, + // 10^-45 ~= b6b00d69bb55c8d13d607b97c5fd0d224d04d354f598a368 * 2^-341 + {{0x3d9d75dd9146e920ULL, 0xcab3961304ca70e8ULL, + 0x9226712162ab070dULL}}, + // 10^-46 ~= 9226712162ab070dcab3961304ca70e83d9d75dd9146e920 * 2^-344 + {{0xc8fbefc8e8717500ULL, 0xaab8f01e6e10b4a6ULL, + 0xe9d71b689dde71afULL}}, + // 10^-47 ~= e9d71b689dde71afaab8f01e6e10b4a6c8fbefc8e8717500 * 2^-348 + {{0x3a63263a538df734ULL, 0x5560c018580d5d52ULL, + 0xbb127c53b17ec159ULL}}, + // 10^-48 ~= bb127c53b17ec1595560c018580d5d523a63263a538df734 * 2^-351 + {{0x2eb5b82ea93e5f5dULL, 0xdde7001379a44aa8ULL, + 0x95a8637627989aadULL}}, + // 10^-49 ~= 95a8637627989aaddde7001379a44aa82eb5b82ea93e5f5d * 2^-354 + {{0x4abc59e441fd6561ULL, 0x963e66858f6d4440ULL, + 0xef73d256a5c0f77cULL}}, + // 10^-50 ~= ef73d256a5c0f77c963e66858f6d44404abc59e441fd6561 * 2^-358 + {{0x6efd14b69b311de7ULL, 0xde98520472bdd033ULL, + 0xbf8fdb78849a5f96ULL}}, + // 10^-51 ~= bf8fdb78849a5f96de98520472bdd0336efd14b69b311de7 * 2^-361 + {{0x259743c548f417ecULL, 0xe546a8038efe4029ULL, + 0x993fe2c6d07b7fabULL}}, + // 10^-52 ~= 993fe2c6d07b7fabe546a8038efe4029259743c548f417ec * 2^-364 + {{0x3c25393ba7ecf313ULL, 0xd53dd99f4b3066a8ULL, + 0xf53304714d9265dfULL}}, + // 10^-53 ~= f53304714d9265dfd53dd99f4b3066a83c25393ba7ecf313 * 2^-368 + {{0x96842dc95323f5a9ULL, 0xaa97e14c3c26b886ULL, + 0xc428d05aa4751e4cULL}}, + // 10^-54 ~= c428d05aa4751e4caa97e14c3c26b88696842dc95323f5a9 * 2^-371 + {{0xab9cf16ddc1cc487ULL, 0x55464dd69685606bULL, + 0x9ced737bb6c4183dULL}}, + // 10^-55 ~= 9ced737bb6c4183d55464dd69685606bab9cf16ddc1cc487 * 2^-374 + {{0xac2e4f162cfad40bULL, 0xeed6e2f0f0d56712ULL, 0xfb158592be068d2eULL}} + // 10^-56 ~= fb158592be068d2eeed6e2f0f0d56712ac2e4f162cfad40b * 2^-378 +}; + +unsigned int Ex192m192[] = { + 3, // 195 - 192, Ex = 195 + 6, // 198 - 192, Ex = 198 + 9, // 201 - 192, Ex = 201 + 13, // 205 - 192, Ex = 205 + 16, // 208 - 192, Ex = 208 + 19, // 211 - 192, Ex = 211 + 23, // 215 - 192, Ex = 215 + 26, // 218 - 192, Ex = 218 + 29, // 221 - 192, Ex = 221 + 33, // 225 - 192, Ex = 225 + 36, // 228 - 192, Ex = 228 + 39, // 231 - 192, Ex = 231 + 43, // 235 - 192, Ex = 235 + 46, // 238 - 192, Ex = 238 + 49, // 241 - 192, Ex = 241 + 53, // 245 - 192, Ex = 245 + 56, // 248 - 192, Ex = 248 + 59, // 251 - 192, Ex = 251 + 63, // 255 - 192, Ex = 255 + 2, // 258 - 256, Ex = 258 + 5, // 261 - 256, Ex = 261 + 9, // 265 - 256, Ex = 265 + 12, // 268 - 256, Ex = 268 + 15, // 271 - 256, Ex = 271 + 19, // 275 - 256, Ex = 275 + 22, // 278 - 256, Ex = 278 + 25, // 281 - 256, Ex = 281 + 29, // 285 - 256, Ex = 285 + 32, // 288 - 256, Ex = 288 + 35, // 291 - 256, Ex = 291 + 38, // 294 - 256, Ex = 294 + 42, // 298 - 256, Ex = 298 + 45, // 301 - 256, Ex = 301 + 48, // 304 - 256, Ex = 304 + 52, // 308 - 256, Ex = 308 + 55, // 311 - 256, Ex = 311 + 58, // 314 - 256, Ex = 314 + 62, // 318 - 256, Ex = 318 + 1, // 321 - 320, Ex = 321 + 4, // 324 - 320, Ex = 324 + 8, // 328 - 320, Ex = 328 + 11, // 331 - 320, Ex = 331 + 14, // 334 - 320, Ex = 334 + 18, // 338 - 320, Ex = 338 + 21, // 341 - 320, Ex = 341 + 24, // 344 - 320, Ex = 344 + 28, // 348 - 320, Ex = 348 + 31, // 351 - 320, Ex = 351 + 34, // 354 - 320, Ex = 354 + 38, // 358 - 320, Ex = 358 + 41, // 361 - 320, Ex = 361 + 44, // 364 - 320, Ex = 364 + 48, // 368 - 320, Ex = 368 + 51, // 371 - 320, Ex = 371 + 54, // 374 - 320, Ex = 374 + 58 // 378 - 320, Ex = 378 +}; + +UINT64 half192[] = { + 0x0000000000000004ULL, // half / 2^192 = 4 + 0x0000000000000020ULL, // half / 2^192 = 20 + 0x0000000000000100ULL, // half / 2^192 = 100 + 0x0000000000001000ULL, // half / 2^192 = 1000 + 0x0000000000008000ULL, // half / 2^192 = 8000 + 0x0000000000040000ULL, // half / 2^192 = 40000 + 0x0000000000400000ULL, // half / 2^192 = 400000 + 0x0000000002000000ULL, // half / 2^192 = 2000000 + 0x0000000010000000ULL, // half / 2^192 = 10000000 + 0x0000000100000000ULL, // half / 2^192 = 100000000 + 0x0000000800000000ULL, // half / 2^192 = 800000000 + 0x0000004000000000ULL, // half / 2^192 = 4000000000 + 0x0000040000000000ULL, // half / 2^192 = 40000000000 + 0x0000200000000000ULL, // half / 2^192 = 200000000000 + 0x0001000000000000ULL, // half / 2^192 = 1000000000000 + 0x0010000000000000ULL, // half / 2^192 = 10000000000000 + 0x0080000000000000ULL, // half / 2^192 = 80000000000000 + 0x0400000000000000ULL, // half / 2^192 = 400000000000000 + 0x4000000000000000ULL, // half / 2^192 = 4000000000000000 + 0x0000000000000002ULL, // half / 2^256 = 2 + 0x0000000000000010ULL, // half / 2^256 = 10 + 0x0000000000000100ULL, // half / 2^256 = 100 + 0x0000000000000800ULL, // half / 2^256 = 800 + 0x0000000000004000ULL, // half / 2^256 = 4000 + 0x0000000000040000ULL, // half / 2^256 = 40000 + 0x0000000000200000ULL, // half / 2^256 = 200000 + 0x0000000001000000ULL, // half / 2^256 = 1000000 + 0x0000000010000000ULL, // half / 2^256 = 10000000 + 0x0000000080000000ULL, // half / 2^256 = 80000000 + 0x0000000400000000ULL, // half / 2^256 = 400000000 + 0x0000002000000000ULL, // half / 2^256 = 2000000000 + 0x0000020000000000ULL, // half / 2^256 = 20000000000 + 0x0000100000000000ULL, // half / 2^256 = 100000000000 + 0x0000800000000000ULL, // half / 2^256 = 800000000000 + 0x0008000000000000ULL, // half / 2^256 = 8000000000000 + 0x0040000000000000ULL, // half / 2^256 = 40000000000000 + 0x0200000000000000ULL, // half / 2^256 = 200000000000000 + 0x2000000000000000ULL, // half / 2^256 = 2000000000000000 + 0x0000000000000001ULL, // half / 2^320 = 1 + 0x0000000000000008ULL, // half / 2^320 = 8 + 0x0000000000000080ULL, // half / 2^320 = 80 + 0x0000000000000400ULL, // half / 2^320 = 400 + 0x0000000000002000ULL, // half / 2^320 = 2000 + 0x0000000000020000ULL, // half / 2^320 = 20000 + 0x0000000000100000ULL, // half / 2^320 = 100000 + 0x0000000000800000ULL, // half / 2^320 = 800000 + 0x0000000008000000ULL, // half / 2^320 = 8000000 + 0x0000000040000000ULL, // half / 2^320 = 40000000 + 0x0000000200000000ULL, // half / 2^320 = 200000000 + 0x0000002000000000ULL, // half / 2^320 = 2000000000 + 0x0000010000000000ULL, // half / 2^320 = 10000000000 + 0x0000080000000000ULL, // half / 2^320 = 80000000000 + 0x0000800000000000ULL, // half / 2^320 = 800000000000 + 0x0004000000000000ULL, // half / 2^320 = 4000000000000 + 0x0020000000000000ULL, // half / 2^320 = 20000000000000 + 0x0200000000000000ULL // half / 2^320 = 200000000000000 +}; + +UINT64 mask192[] = { + 0x0000000000000007ULL, // mask / 2^192 + 0x000000000000003fULL, // mask / 2^192 + 0x00000000000001ffULL, // mask / 2^192 + 0x0000000000001fffULL, // mask / 2^192 + 0x000000000000ffffULL, // mask / 2^192 + 0x000000000007ffffULL, // mask / 2^192 + 0x00000000007fffffULL, // mask / 2^192 + 0x0000000003ffffffULL, // mask / 2^192 + 0x000000001fffffffULL, // mask / 2^192 + 0x00000001ffffffffULL, // mask / 2^192 + 0x0000000fffffffffULL, // mask / 2^192 + 0x0000007fffffffffULL, // mask / 2^192 + 0x000007ffffffffffULL, // mask / 2^192 + 0x00003fffffffffffULL, // mask / 2^192 + 0x0001ffffffffffffULL, // mask / 2^192 + 0x001fffffffffffffULL, // mask / 2^192 + 0x00ffffffffffffffULL, // mask / 2^192 + 0x07ffffffffffffffULL, // mask / 2^192 + 0x7fffffffffffffffULL, // mask / 2^192 + 0x0000000000000003ULL, // mask / 2^256 + 0x000000000000001fULL, // mask / 2^256 + 0x00000000000001ffULL, // mask / 2^256 + 0x0000000000000fffULL, // mask / 2^256 + 0x0000000000007fffULL, // mask / 2^256 + 0x000000000007ffffULL, // mask / 2^256 + 0x00000000003fffffULL, // mask / 2^256 + 0x0000000001ffffffULL, // mask / 2^256 + 0x000000001fffffffULL, // mask / 2^256 + 0x00000000ffffffffULL, // mask / 2^256 + 0x00000007ffffffffULL, // mask / 2^256 + 0x0000003fffffffffULL, // mask / 2^256 + 0x000003ffffffffffULL, // mask / 2^256 + 0x00001fffffffffffULL, // mask / 2^256 + 0x0000ffffffffffffULL, // mask / 2^256 + 0x000fffffffffffffULL, // mask / 2^256 + 0x007fffffffffffffULL, // mask / 2^256 + 0x03ffffffffffffffULL, // mask / 2^256 + 0x3fffffffffffffffULL, // mask / 2^256 + 0x0000000000000001ULL, // mask / 2^320 + 0x000000000000000fULL, // mask / 2^320 + 0x00000000000000ffULL, // mask / 2^320 + 0x00000000000007ffULL, // mask / 2^320 + 0x0000000000003fffULL, // mask / 2^320 + 0x000000000003ffffULL, // mask / 2^320 + 0x00000000001fffffULL, // mask / 2^320 + 0x0000000000ffffffULL, // mask / 2^320 + 0x000000000fffffffULL, // mask / 2^320 + 0x000000007fffffffULL, // mask / 2^320 + 0x00000003ffffffffULL, // mask / 2^320 + 0x0000003fffffffffULL, // mask / 2^320 + 0x000001ffffffffffULL, // mask / 2^320 + 0x00000fffffffffffULL, // mask / 2^320 + 0x0000ffffffffffffULL, // mask / 2^320 + 0x0007ffffffffffffULL, // mask / 2^320 + 0x003fffffffffffffULL, // mask / 2^320 + 0x03ffffffffffffffULL // mask / 2^320 +}; + +UINT192 ten2mxtrunc192[] = { + {{0xccccccccccccccccULL, 0xccccccccccccccccULL, + 0xccccccccccccccccULL}}, + // (ten2mx >> 192) = cccccccccccccccccccccccccccccccccccccccccccccccc + {{0xd70a3d70a3d70a3dULL, 0x3d70a3d70a3d70a3ULL, + 0xa3d70a3d70a3d70aULL}}, + // (ten2mx >> 192) = a3d70a3d70a3d70a3d70a3d70a3d70a3d70a3d70a3d70a3d + {{0x78d4fdf3b645a1caULL, 0x645a1cac083126e9ULL, + 0x83126e978d4fdf3bULL}}, + // (ten2mx >> 192) = 83126e978d4fdf3b645a1cac083126e978d4fdf3b645a1ca + {{0xc154c985f06f6944ULL, 0xd3c36113404ea4a8ULL, + 0xd1b71758e219652bULL}}, + // (ten2mx >> 192) = d1b71758e219652bd3c36113404ea4a8c154c985f06f6944 + {{0xcddd6e04c0592103ULL, 0x0fcf80dc33721d53ULL, + 0xa7c5ac471b478423ULL}}, + // (ten2mx >> 192) = a7c5ac471b4784230fcf80dc33721d53cddd6e04c0592103 + {{0xd7e45803cd141a69ULL, 0xa63f9a49c2c1b10fULL, + 0x8637bd05af6c69b5ULL}}, + // (ten2mx >> 192) = 8637bd05af6c69b5a63f9a49c2c1b10fd7e45803cd141a69 + {{0x8ca08cd2e1b9c3dbULL, 0x3d32907604691b4cULL, + 0xd6bf94d5e57a42bcULL}}, + // (ten2mx >> 192) = d6bf94d5e57a42bc3d32907604691b4c8ca08cd2e1b9c3db + {{0x3d4d3d758161697cULL, 0xfdc20d2b36ba7c3dULL, + 0xabcc77118461cefcULL}}, + // (ten2mx >> 192) = abcc77118461cefcfdc20d2b36ba7c3d3d4d3d758161697c + {{0xfdd7645e011abac9ULL, 0x31680a88f8953030ULL, + 0x89705f4136b4a597ULL}}, + // (ten2mx >> 192) = 89705f4136b4a59731680a88f8953030fdd7645e011abac9 + {{0x2fbf06fcce912adcULL, 0xb573440e5a884d1bULL, + 0xdbe6fecebdedd5beULL}}, + // (ten2mx >> 192) = dbe6fecebdedd5beb573440e5a884d1b2fbf06fcce912adc + {{0xf2ff38ca3eda88b0ULL, 0xf78f69a51539d748ULL, + 0xafebff0bcb24aafeULL}}, + // (ten2mx >> 192) = afebff0bcb24aafef78f69a51539d748f2ff38ca3eda88b0 + {{0xf598fa3b657ba08dULL, 0xf93f87b7442e45d3ULL, + 0x8cbccc096f5088cbULL}}, + // (ten2mx >> 192) = 8cbccc096f5088cbf93f87b7442e45d3f598fa3b657ba08d + {{0x88f4c3923bf900e2ULL, 0x2865a5f206b06fb9ULL, + 0xe12e13424bb40e13ULL}}, + // (ten2mx >> 192) = e12e13424bb40e132865a5f206b06fb988f4c3923bf900e2 + {{0x6d909c74fcc733e8ULL, 0x538484c19ef38c94ULL, + 0xb424dc35095cd80fULL}}, + // (ten2mx >> 192) = b424dc35095cd80f538484c19ef38c946d909c74fcc733e8 + {{0x57a6e390ca38f653ULL, 0x0f9d37014bf60a10ULL, + 0x901d7cf73ab0acd9ULL}}, + // (ten2mx >> 192) = 901d7cf73ab0acd90f9d37014bf60a1057a6e390ca38f653 + {{0xbf716c1add27f085ULL, 0x4c2ebe687989a9b3ULL, + 0xe69594bec44de15bULL}}, + // (ten2mx >> 192) = e69594bec44de15b4c2ebe687989a9b3bf716c1add27f085 + {{0xff8df0157db98d37ULL, 0x09befeb9fad487c2ULL, + 0xb877aa3236a4b449ULL}}, + // (ten2mx >> 192) = b877aa3236a4b44909befeb9fad487c2ff8df0157db98d37 + {{0x32d7f344649470f9ULL, 0x3aff322e62439fcfULL, + 0x9392ee8e921d5d07ULL}}, + // (ten2mx >> 192) = 9392ee8e921d5d073aff322e62439fcf32d7f344649470f9 + {{0x1e2652070753e7f4ULL, 0x2b31e9e3d06c32e5ULL, + 0xec1e4a7db69561a5ULL}}, + // (ten2mx >> 192) = ec1e4a7db69561a52b31e9e3d06c32e51e2652070753e7f4 + {{0x181ea8059f76532aULL, 0x88f4bb1ca6bcf584ULL, + 0xbce5086492111aeaULL}}, + // (ten2mx >> 192) = bce5086492111aea88f4bb1ca6bcf584181ea8059f76532a + {{0x467eecd14c5ea8eeULL, 0xd3f6fc16ebca5e03ULL, + 0x971da05074da7beeULL}}, + // (ten2mx >> 192) = 971da05074da7beed3f6fc16ebca5e03467eecd14c5ea8ee + {{0x70cb148213caa7e4ULL, 0x5324c68b12dd6338ULL, + 0xf1c90080baf72cb1ULL}}, + // (ten2mx >> 192) = f1c90080baf72cb15324c68b12dd633870cb148213caa7e4 + {{0x8d6f439b43088650ULL, 0x75b7053c0f178293ULL, + 0xc16d9a0095928a27ULL}}, + // (ten2mx >> 192) = c16d9a0095928a2775b7053c0f1782938d6f439b43088650 + {{0xd78c3615cf3a050cULL, 0xc4926a9672793542ULL, + 0x9abe14cd44753b52ULL}}, + // (ten2mx >> 192) = 9abe14cd44753b52c4926a9672793542d78c3615cf3a050c + {{0x8c1389bc7ec33b47ULL, 0x3a83ddbd83f52204ULL, + 0xf79687aed3eec551ULL}}, + // (ten2mx >> 192) = f79687aed3eec5513a83ddbd83f522048c1389bc7ec33b47 + {{0x3cdc6e306568fc39ULL, 0x95364afe032a819dULL, + 0xc612062576589ddaULL}}, + // (ten2mx >> 192) = c612062576589dda95364afe032a819d3cdc6e306568fc39 + {{0xca49f1c05120c9c7ULL, 0x775ea264cf55347dULL, + 0x9e74d1b791e07e48ULL}}, + // (ten2mx >> 192) = 9e74d1b791e07e48775ea264cf55347dca49f1c05120c9c7 + {{0x76dcb60081ce0fa5ULL, 0x8bca9d6e188853fcULL, + 0xfd87b5f28300ca0dULL}}, + // (ten2mx >> 192) = fd87b5f28300ca0d8bca9d6e188853fc76dcb60081ce0fa5 + {{0x5f16f80067d80c84ULL, 0x096ee45813a04330ULL, + 0xcad2f7f5359a3b3eULL}}, + // (ten2mx >> 192) = cad2f7f5359a3b3e096ee45813a043305f16f80067d80c84 + {{0x18df2ccd1fe00a03ULL, 0xa1258379a94d028dULL, + 0xa2425ff75e14fc31ULL}}, + // (ten2mx >> 192) = a2425ff75e14fc31a1258379a94d028d18df2ccd1fe00a03 + {{0x4718f0a419800802ULL, 0x80eacf948770ced7ULL, + 0x81ceb32c4b43fcf4ULL}}, + // (ten2mx >> 192) = 81ceb32c4b43fcf480eacf948770ced74718f0a419800802 + {{0x0b5b1aa028ccd99eULL, 0x67de18eda5814af2ULL, + 0xcfb11ead453994baULL}}, + // (ten2mx >> 192) = cfb11ead453994ba67de18eda5814af20b5b1aa028ccd99e + {{0x6f7c154ced70ae18ULL, 0xecb1ad8aeacdd58eULL, + 0xa6274bbdd0fadd61ULL}}, + // (ten2mx >> 192) = a6274bbdd0fadd61ecb1ad8aeacdd58e6f7c154ced70ae18 + {{0xbf967770bdf3be79ULL, 0xbd5af13bef0b113eULL, + 0x84ec3c97da624ab4ULL}}, + // (ten2mx >> 192) = 84ec3c97da624ab4bd5af13bef0b113ebf967770bdf3be79 + {{0x65bd8be79652ca5cULL, 0x955e4ec64b44e864ULL, + 0xd4ad2dbfc3d07787ULL}}, + // (ten2mx >> 192) = d4ad2dbfc3d07787955e4ec64b44e86465bd8be79652ca5c + {{0xeafe098611dbd516ULL, 0xdde50bd1d5d0b9e9ULL, + 0xaa242499697392d2ULL}}, + // (ten2mx >> 192) = aa242499697392d2dde50bd1d5d0b9e9eafe098611dbd516 + {{0xbbfe6e04db164412ULL, 0x7e50d64177da2e54ULL, + 0x881cea14545c7575ULL}}, + // (ten2mx >> 192) = 881cea14545c75757e50d64177da2e54bbfe6e04db164412 + {{0x2cca49a15e8a0683ULL, 0x96e7bd358c904a21ULL, + 0xd9c7dced53c72255ULL}}, + // (ten2mx >> 192) = d9c7dced53c7225596e7bd358c904a212cca49a15e8a0683 + {{0x8a3b6e1ab2080536ULL, 0xabec975e0a0d081aULL, + 0xae397d8aa96c1b77ULL}}, + // (ten2mx >> 192) = ae397d8aa96c1b77abec975e0a0d081a8a3b6e1ab2080536 + {{0x3b62be7bc1a0042bULL, 0x2323ac4b3b3da015ULL, + 0x8b61313bbabce2c6ULL}}, + // (ten2mx >> 192) = 8b61313bbabce2c62323ac4b3b3da0153b62be7bc1a0042b + {{0x5f0463f935ccd378ULL, 0x6b6c46dec52f6688ULL, + 0xdf01e85f912e37a3ULL}}, + // (ten2mx >> 192) = df01e85f912e37a36b6c46dec52f66885f0463f935ccd378 + {{0x7f36b660f7d70f93ULL, 0x55f038b237591ed3ULL, + 0xb267ed1940f1c61cULL}}, + // (ten2mx >> 192) = b267ed1940f1c61c55f038b237591ed37f36b660f7d70f93 + {{0xcc2bc51a5fdf3fa9ULL, 0x77f3608e92adb242ULL, + 0x8eb98a7a9a5b04e3ULL}}, + // (ten2mx >> 192) = 8eb98a7a9a5b04e377f3608e92adb242cc2bc51a5fdf3fa9 + {{0xe046082a32fecc41ULL, 0x8cb89a7db77c506aULL, + 0xe45c10c42a2b3b05ULL}}, + // (ten2mx >> 192) = e45c10c42a2b3b058cb89a7db77c506ae046082a32fecc41 + {{0x4d04d354f598a367ULL, 0x3d607b97c5fd0d22ULL, + 0xb6b00d69bb55c8d1ULL}}, + // (ten2mx >> 192) = b6b00d69bb55c8d13d607b97c5fd0d224d04d354f598a367 + {{0x3d9d75dd9146e91fULL, 0xcab3961304ca70e8ULL, + 0x9226712162ab070dULL}}, + // (ten2mx >> 192) = 9226712162ab070dcab3961304ca70e83d9d75dd9146e91f + {{0xc8fbefc8e87174ffULL, 0xaab8f01e6e10b4a6ULL, + 0xe9d71b689dde71afULL}}, + // (ten2mx >> 192) = e9d71b689dde71afaab8f01e6e10b4a6c8fbefc8e87174ff + {{0x3a63263a538df733ULL, 0x5560c018580d5d52ULL, + 0xbb127c53b17ec159ULL}}, + // (ten2mx >> 192) = bb127c53b17ec1595560c018580d5d523a63263a538df733 + {{0x2eb5b82ea93e5f5cULL, 0xdde7001379a44aa8ULL, + 0x95a8637627989aadULL}}, + // (ten2mx >> 192) = 95a8637627989aaddde7001379a44aa82eb5b82ea93e5f5c + {{0x4abc59e441fd6560ULL, 0x963e66858f6d4440ULL, + 0xef73d256a5c0f77cULL}}, + // (ten2mx >> 192) = ef73d256a5c0f77c963e66858f6d44404abc59e441fd6560 + {{0x6efd14b69b311de6ULL, 0xde98520472bdd033ULL, + 0xbf8fdb78849a5f96ULL}}, + // (ten2mx >> 192) = bf8fdb78849a5f96de98520472bdd0336efd14b69b311de6 + {{0x259743c548f417ebULL, 0xe546a8038efe4029ULL, + 0x993fe2c6d07b7fabULL}}, + // (ten2mx >> 192) = 993fe2c6d07b7fabe546a8038efe4029259743c548f417eb + {{0x3c25393ba7ecf312ULL, 0xd53dd99f4b3066a8ULL, + 0xf53304714d9265dfULL}}, + // (ten2mx >> 192) = f53304714d9265dfd53dd99f4b3066a83c25393ba7ecf312 + {{0x96842dc95323f5a8ULL, 0xaa97e14c3c26b886ULL, + 0xc428d05aa4751e4cULL}}, + // (ten2mx >> 192) = c428d05aa4751e4caa97e14c3c26b88696842dc95323f5a8 + {{0xab9cf16ddc1cc486ULL, 0x55464dd69685606bULL, + 0x9ced737bb6c4183dULL}}, + // (ten2mx >> 192) = 9ced737bb6c4183d55464dd69685606bab9cf16ddc1cc486 + {{0xac2e4f162cfad40aULL, 0xeed6e2f0f0d56712ULL, 0xfb158592be068d2eULL}} + // (ten2mx >> 192) = fb158592be068d2eeed6e2f0f0d56712ac2e4f162cfad40a +}; + +UINT256 Kx256[] = { + {{0xcccccccccccccccdULL, 0xccccccccccccccccULL, + 0xccccccccccccccccULL, 0xccccccccccccccccULL}}, + // 10^-1 ~= cccccccccccccccc cccccccccccccccc + // cccccccccccccccccccccccccccccccd * 2^-259 + {{0x70a3d70a3d70a3d8ULL, 0xd70a3d70a3d70a3dULL, + 0x3d70a3d70a3d70a3ULL, 0xa3d70a3d70a3d70aULL}}, + // 10^-2 ~= a3d70a3d70a3d70a 3d70a3d70a3d70a3 + // d70a3d70a3d70a3d70a3d70a3d70a3d8 * 2^-262 + {{0xc083126e978d4fe0ULL, 0x78d4fdf3b645a1caULL, + 0x645a1cac083126e9ULL, 0x83126e978d4fdf3bULL}}, + // 10^-3 ~= 83126e978d4fdf3b 645a1cac083126e9 + // 78d4fdf3b645a1cac083126e978d4fe0 * 2^-265 + {{0x67381d7dbf487fccULL, 0xc154c985f06f6944ULL, + 0xd3c36113404ea4a8ULL, 0xd1b71758e219652bULL}}, + // 10^-4 ~= d1b71758e219652b d3c36113404ea4a8 + // c154c985f06f694467381d7dbf487fcc * 2^-269 + {{0x85c67dfe32a0663dULL, 0xcddd6e04c0592103ULL, + 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}}, + // 10^-5 ~= a7c5ac471b478423 fcf80dc33721d53 + // cddd6e04c059210385c67dfe32a0663d * 2^-272 + {{0x37d1fe64f54d1e97ULL, 0xd7e45803cd141a69ULL, + 0xa63f9a49c2c1b10fULL, 0x8637bd05af6c69b5ULL}}, + // 10^-6 ~= 8637bd05af6c69b5 a63f9a49c2c1b10f + // d7e45803cd141a6937d1fe64f54d1e97 * 2^-275 + {{0x8c8330a1887b6425ULL, 0x8ca08cd2e1b9c3dbULL, + 0x3d32907604691b4cULL, 0xd6bf94d5e57a42bcULL}}, + // 10^-7 ~= d6bf94d5e57a42bc 3d32907604691b4c + // 8ca08cd2e1b9c3db8c8330a1887b6425 * 2^-279 + {{0x7068f3b46d2f8351ULL, 0x3d4d3d758161697cULL, + 0xfdc20d2b36ba7c3dULL, 0xabcc77118461cefcULL}}, + // 10^-8 ~= abcc77118461cefc fdc20d2b36ba7c3d + // 3d4d3d758161697c7068f3b46d2f8351 * 2^-282 + {{0xf387295d242602a7ULL, 0xfdd7645e011abac9ULL, + 0x31680a88f8953030ULL, 0x89705f4136b4a597ULL}}, + // 10^-9 ~= 89705f4136b4a597 31680a88f8953030 + // fdd7645e011abac9f387295d242602a7 * 2^-285 + {{0xb8d8422ea03cd10bULL, 0x2fbf06fcce912adcULL, + 0xb573440e5a884d1bULL, 0xdbe6fecebdedd5beULL}}, + // 10^-10 ~= dbe6fecebdedd5be b573440e5a884d1b + // 2fbf06fcce912adcb8d8422ea03cd10b * 2^-289 + {{0x93e034f219ca40d6ULL, 0xf2ff38ca3eda88b0ULL, + 0xf78f69a51539d748ULL, 0xafebff0bcb24aafeULL}}, + // 10^-11 ~= afebff0bcb24aafe f78f69a51539d748 + // f2ff38ca3eda88b093e034f219ca40d6 * 2^-292 + {{0x4319c3f4e16e9a45ULL, 0xf598fa3b657ba08dULL, + 0xf93f87b7442e45d3ULL, 0x8cbccc096f5088cbULL}}, + // 10^-12 ~= 8cbccc096f5088cb f93f87b7442e45d3 + // f598fa3b657ba08d4319c3f4e16e9a45 * 2^-295 + {{0x04f606549be42a07ULL, 0x88f4c3923bf900e2ULL, + 0x2865a5f206b06fb9ULL, 0xe12e13424bb40e13ULL}}, + // 10^-13 ~= e12e13424bb40e13 2865a5f206b06fb9 + // 88f4c3923bf900e204f606549be42a07 * 2^-299 + {{0x03f805107cb68806ULL, 0x6d909c74fcc733e8ULL, + 0x538484c19ef38c94ULL, 0xb424dc35095cd80fULL}}, + // 10^-14 ~= b424dc35095cd80f 538484c19ef38c94 + // 6d909c74fcc733e803f805107cb68806 * 2^-302 + {{0x3660040d3092066bULL, 0x57a6e390ca38f653ULL, + 0x0f9d37014bf60a10ULL, 0x901d7cf73ab0acd9ULL}}, + // 10^-15 ~= 901d7cf73ab0acd9 f9d37014bf60a10 + // 57a6e390ca38f6533660040d3092066b * 2^-305 + {{0x23ccd3484db670abULL, 0xbf716c1add27f085ULL, + 0x4c2ebe687989a9b3ULL, 0xe69594bec44de15bULL}}, + // 10^-16 ~= e69594bec44de15b 4c2ebe687989a9b3 + // bf716c1add27f08523ccd3484db670ab * 2^-309 + {{0x4fd70f6d0af85a23ULL, 0xff8df0157db98d37ULL, + 0x09befeb9fad487c2ULL, 0xb877aa3236a4b449ULL}}, + // 10^-17 ~= b877aa3236a4b449 9befeb9fad487c2 + // ff8df0157db98d374fd70f6d0af85a23 * 2^-312 + {{0x0cac0c573bf9e1b6ULL, 0x32d7f344649470f9ULL, + 0x3aff322e62439fcfULL, 0x9392ee8e921d5d07ULL}}, + // 10^-18 ~= 9392ee8e921d5d07 3aff322e62439fcf + // 32d7f344649470f90cac0c573bf9e1b6 * 2^-315 + {{0xe11346f1f98fcf89ULL, 0x1e2652070753e7f4ULL, + 0x2b31e9e3d06c32e5ULL, 0xec1e4a7db69561a5ULL}}, + // 10^-19 ~= ec1e4a7db69561a5 2b31e9e3d06c32e5 + // 1e2652070753e7f4e11346f1f98fcf89 * 2^-319 + {{0x4da9058e613fd93aULL, 0x181ea8059f76532aULL, + 0x88f4bb1ca6bcf584ULL, 0xbce5086492111aeaULL}}, + // 10^-20 ~= bce5086492111aea 88f4bb1ca6bcf584 + // 181ea8059f76532a4da9058e613fd93a * 2^-322 + {{0xa48737a51a997a95ULL, 0x467eecd14c5ea8eeULL, + 0xd3f6fc16ebca5e03ULL, 0x971da05074da7beeULL}}, + // 10^-21 ~= 971da05074da7bee d3f6fc16ebca5e03 + // 467eecd14c5ea8eea48737a51a997a95 * 2^-325 + {{0x3a71f2a1c428c421ULL, 0x70cb148213caa7e4ULL, + 0x5324c68b12dd6338ULL, 0xf1c90080baf72cb1ULL}}, + // 10^-22 ~= f1c90080baf72cb1 5324c68b12dd6338 + // 70cb148213caa7e43a71f2a1c428c421 * 2^-329 + {{0x2ec18ee7d0209ce8ULL, 0x8d6f439b43088650ULL, + 0x75b7053c0f178293ULL, 0xc16d9a0095928a27ULL}}, + // 10^-23 ~= c16d9a0095928a27 75b7053c0f178293 + // 8d6f439b430886502ec18ee7d0209ce8 * 2^-332 + {{0xf23472530ce6e3edULL, 0xd78c3615cf3a050cULL, + 0xc4926a9672793542ULL, 0x9abe14cd44753b52ULL}}, + // 10^-24 ~= 9abe14cd44753b52 c4926a9672793542 + // d78c3615cf3a050cf23472530ce6e3ed * 2^-335 + {{0xe9ed83b814a49fe1ULL, 0x8c1389bc7ec33b47ULL, + 0x3a83ddbd83f52204ULL, 0xf79687aed3eec551ULL}}, + // 10^-25 ~= f79687aed3eec551 3a83ddbd83f52204 + // 8c1389bc7ec33b47e9ed83b814a49fe1 * 2^-339 + {{0x87f1362cdd507fe7ULL, 0x3cdc6e306568fc39ULL, + 0x95364afe032a819dULL, 0xc612062576589ddaULL}}, + // 10^-26 ~= c612062576589dda 95364afe032a819d + // 3cdc6e306568fc3987f1362cdd507fe7 * 2^-342 + {{0x9ff42b5717739986ULL, 0xca49f1c05120c9c7ULL, + 0x775ea264cf55347dULL, 0x9e74d1b791e07e48ULL}}, + // 10^-27 ~= 9e74d1b791e07e48 775ea264cf55347d + // ca49f1c05120c9c79ff42b5717739986 * 2^-345 + {{0xccb9def1bf1f5c09ULL, 0x76dcb60081ce0fa5ULL, + 0x8bca9d6e188853fcULL, 0xfd87b5f28300ca0dULL}}, + // 10^-28 ~= fd87b5f28300ca0d 8bca9d6e188853fc + // 76dcb60081ce0fa5ccb9def1bf1f5c09 * 2^-349 + {{0xa3c7e58e327f7cd4ULL, 0x5f16f80067d80c84ULL, + 0x096ee45813a04330ULL, 0xcad2f7f5359a3b3eULL}}, + // 10^-29 ~= cad2f7f5359a3b3e 96ee45813a04330 + // 5f16f80067d80c84a3c7e58e327f7cd4 * 2^-352 + {{0xb6398471c1ff9710ULL, 0x18df2ccd1fe00a03ULL, + 0xa1258379a94d028dULL, 0xa2425ff75e14fc31ULL}}, + // 10^-30 ~= a2425ff75e14fc31 a1258379a94d028d + // 18df2ccd1fe00a03b6398471c1ff9710 * 2^-355 + {{0xf82e038e34cc78daULL, 0x4718f0a419800802ULL, + 0x80eacf948770ced7ULL, 0x81ceb32c4b43fcf4ULL}}, + // 10^-31 ~= 81ceb32c4b43fcf4 80eacf948770ced7 + // 4718f0a419800802f82e038e34cc78da * 2^-358 + {{0x59e338e387ad8e29ULL, 0x0b5b1aa028ccd99eULL, + 0x67de18eda5814af2ULL, 0xcfb11ead453994baULL}}, + // 10^-32 ~= cfb11ead453994ba 67de18eda5814af2 + // b5b1aa028ccd99e59e338e387ad8e29 * 2^-362 + {{0x47e8fa4f9fbe0b54ULL, 0x6f7c154ced70ae18ULL, + 0xecb1ad8aeacdd58eULL, 0xa6274bbdd0fadd61ULL}}, + // 10^-33 ~= a6274bbdd0fadd61 ecb1ad8aeacdd58e + // 6f7c154ced70ae1847e8fa4f9fbe0b54 * 2^-365 + {{0xd320c83fb2fe6f76ULL, 0xbf967770bdf3be79ULL, + 0xbd5af13bef0b113eULL, 0x84ec3c97da624ab4ULL}}, + // 10^-34 ~= 84ec3c97da624ab4 bd5af13bef0b113e + // bf967770bdf3be79d320c83fb2fe6f76 * 2^-368 + {{0x85014065eb30b257ULL, 0x65bd8be79652ca5cULL, + 0x955e4ec64b44e864ULL, 0xd4ad2dbfc3d07787ULL}}, + // 10^-35 ~= d4ad2dbfc3d07787 955e4ec64b44e864 + // 65bd8be79652ca5c85014065eb30b257 * 2^-372 + {{0xd0cdcd1e55c08eacULL, 0xeafe098611dbd516ULL, + 0xdde50bd1d5d0b9e9ULL, 0xaa242499697392d2ULL}}, + // 10^-36 ~= aa242499697392d2 dde50bd1d5d0b9e9 + // eafe098611dbd516d0cdcd1e55c08eac * 2^-375 + {{0x40a4a418449a0bbdULL, 0xbbfe6e04db164412ULL, + 0x7e50d64177da2e54ULL, 0x881cea14545c7575ULL}}, + // 10^-37 ~= 881cea14545c7575 7e50d64177da2e54 + // bbfe6e04db16441240a4a418449a0bbd * 2^-378 + {{0x9aa1068d3a9012c8ULL, 0x2cca49a15e8a0683ULL, + 0x96e7bd358c904a21ULL, 0xd9c7dced53c72255ULL}}, + // 10^-38 ~= d9c7dced53c72255 96e7bd358c904a21 + // 2cca49a15e8a06839aa1068d3a9012c8 * 2^-382 + {{0x154d9ed7620cdbd3ULL, 0x8a3b6e1ab2080536ULL, + 0xabec975e0a0d081aULL, 0xae397d8aa96c1b77ULL}}, + // 10^-39 ~= ae397d8aa96c1b77 abec975e0a0d081a + // 8a3b6e1ab2080536154d9ed7620cdbd3 * 2^-385 + {{0x443e18ac4e70afdcULL, 0x3b62be7bc1a0042bULL, + 0x2323ac4b3b3da015ULL, 0x8b61313bbabce2c6ULL}}, + // 10^-40 ~= 8b61313bbabce2c6 2323ac4b3b3da015 + // 3b62be7bc1a0042b443e18ac4e70afdc * 2^-388 + {{0x6d30277a171ab2f9ULL, 0x5f0463f935ccd378ULL, + 0x6b6c46dec52f6688ULL, 0xdf01e85f912e37a3ULL}}, + // 10^-41 ~= df01e85f912e37a3 6b6c46dec52f6688 + // 5f0463f935ccd3786d30277a171ab2f9 * 2^-392 + {{0x8a8cec61ac155bfbULL, 0x7f36b660f7d70f93ULL, + 0x55f038b237591ed3ULL, 0xb267ed1940f1c61cULL}}, + // 10^-42 ~= b267ed1940f1c61c 55f038b237591ed3 + // 7f36b660f7d70f938a8cec61ac155bfb * 2^-395 + {{0x3ba3f04e23444996ULL, 0xcc2bc51a5fdf3fa9ULL, + 0x77f3608e92adb242ULL, 0x8eb98a7a9a5b04e3ULL}}, + // 10^-43 ~= 8eb98a7a9a5b04e3 77f3608e92adb242 + // cc2bc51a5fdf3fa93ba3f04e23444996 * 2^-398 + {{0xf9064d49d206dc22ULL, 0xe046082a32fecc41ULL, + 0x8cb89a7db77c506aULL, 0xe45c10c42a2b3b05ULL}}, + // 10^-44 ~= e45c10c42a2b3b05 8cb89a7db77c506a + // e046082a32fecc41f9064d49d206dc22 * 2^-402 + {{0xfa6b7107db38b01bULL, 0x4d04d354f598a367ULL, + 0x3d607b97c5fd0d22ULL, 0xb6b00d69bb55c8d1ULL}}, + // 10^-45 ~= b6b00d69bb55c8d1 3d607b97c5fd0d22 + // 4d04d354f598a367fa6b7107db38b01b * 2^-405 + {{0xfb8927397c2d59b0ULL, 0x3d9d75dd9146e91fULL, + 0xcab3961304ca70e8ULL, 0x9226712162ab070dULL}}, + // 10^-46 ~= 9226712162ab070d cab3961304ca70e8 + // 3d9d75dd9146e91ffb8927397c2d59b0 * 2^-408 + {{0xf8db71f5937bc2b2ULL, 0xc8fbefc8e87174ffULL, + 0xaab8f01e6e10b4a6ULL, 0xe9d71b689dde71afULL}}, + // 10^-47 ~= e9d71b689dde71af aab8f01e6e10b4a6 + // c8fbefc8e87174fff8db71f5937bc2b2 * 2^-412 + {{0x2d7c5b2adc630228ULL, 0x3a63263a538df733ULL, + 0x5560c018580d5d52ULL, 0xbb127c53b17ec159ULL}}, + // 10^-48 ~= bb127c53b17ec159 5560c018580d5d52 + // 3a63263a538df7332d7c5b2adc630228 * 2^-415 + {{0x24637c2249e8ce87ULL, 0x2eb5b82ea93e5f5cULL, + 0xdde7001379a44aa8ULL, 0x95a8637627989aadULL}}, + // 10^-49 ~= 95a8637627989aad dde7001379a44aa8 + // 2eb5b82ea93e5f5c24637c2249e8ce87 * 2^-418 + {{0x3a38c69d430e173eULL, 0x4abc59e441fd6560ULL, + 0x963e66858f6d4440ULL, 0xef73d256a5c0f77cULL}}, + // 10^-50 ~= ef73d256a5c0f77c 963e66858f6d4440 + // 4abc59e441fd65603a38c69d430e173e * 2^-422 + {{0x94fa387dcf3e78feULL, 0x6efd14b69b311de6ULL, + 0xde98520472bdd033ULL, 0xbf8fdb78849a5f96ULL}}, + // 10^-51 ~= bf8fdb78849a5f96 de98520472bdd033 + // 6efd14b69b311de694fa387dcf3e78fe * 2^-425 + {{0xaa61c6cb0c31fa65ULL, 0x259743c548f417ebULL, + 0xe546a8038efe4029ULL, 0x993fe2c6d07b7fabULL}}, + // 10^-52 ~= 993fe2c6d07b7fab e546a8038efe4029 + // 259743c548f417ebaa61c6cb0c31fa65 * 2^-428 + {{0xaa360ade79e990a2ULL, 0x3c25393ba7ecf312ULL, + 0xd53dd99f4b3066a8ULL, 0xf53304714d9265dfULL}}, + // 10^-53 ~= f53304714d9265df d53dd99f4b3066a8 + // 3c25393ba7ecf312aa360ade79e990a2 * 2^-432 + {{0x882b3be52e5473b5ULL, 0x96842dc95323f5a8ULL, + 0xaa97e14c3c26b886ULL, 0xc428d05aa4751e4cULL}}, + // 10^-54 ~= c428d05aa4751e4c aa97e14c3c26b886 + // 96842dc95323f5a8882b3be52e5473b5 * 2^-435 + {{0xd355c98425105c91ULL, 0xab9cf16ddc1cc486ULL, + 0x55464dd69685606bULL, 0x9ced737bb6c4183dULL}}, + // 10^-55 ~= 9ced737bb6c4183d 55464dd69685606b + // ab9cf16ddc1cc486d355c98425105c91 * 2^-438 + {{0xebbc75a03b4d60e7ULL, 0xac2e4f162cfad40aULL, + 0xeed6e2f0f0d56712ULL, 0xfb158592be068d2eULL}}, + // 10^-56 ~= fb158592be068d2e eed6e2f0f0d56712 + // ac2e4f162cfad40aebbc75a03b4d60e7 * 2^-442 + {{0x8963914cfc3de71fULL, 0x568b727823fbdcd5ULL, + 0xf245825a5a445275ULL, 0xc8de047564d20a8bULL}}, + // 10^-57 ~= c8de047564d20a8b f245825a5a445275 + // 568b727823fbdcd58963914cfc3de71f * 2^-445 + {{0xd44fa770c9cb1f4cULL, 0x453c5b934ffcb0aaULL, + 0x5b6aceaeae9d0ec4ULL, 0xa0b19d2ab70e6ed6ULL}}, + // 10^-58 ~= a0b19d2ab70e6ed6 5b6aceaeae9d0ec4 + // 453c5b934ffcb0aad44fa770c9cb1f4c * 2^-448 + {{0xdd0c85f3d4a27f70ULL, 0x37637c75d996f3bbULL, + 0xe2bbd88bbee40bd0ULL, 0x808e17555f3ebf11ULL}}, + // 10^-59 ~= 808e17555f3ebf11 e2bbd88bbee40bd0 + // 37637c75d996f3bbdd0c85f3d4a27f70 * 2^-451 + {{0x61ada31fba9d98b3ULL, 0x256bfa5628f185f9ULL, + 0x3792f412cb06794dULL, 0xcdb02555653131b6ULL}}, + // 10^-60 ~= cdb02555653131b6 3792f412cb06794d + // 256bfa5628f185f961ada31fba9d98b3 * 2^-455 + {{0xe7be1c196217ad5cULL, 0x51232eab53f46b2dULL, + 0x5fa8c3423c052dd7ULL, 0xa48ceaaab75a8e2bULL}}, + // 10^-61 ~= a48ceaaab75a8e2b 5fa8c3423c052dd7 + // 51232eab53f46b2de7be1c196217ad5c * 2^-458 + {{0x52fe7ce11b46244aULL, 0x40e8f222a99055beULL, + 0x1953cf68300424acULL, 0x83a3eeeef9153e89ULL}}, + // 10^-62 ~= 83a3eeeef9153e89 1953cf68300424ac + // 40e8f222a99055be52fe7ce11b46244a * 2^-461 + {{0x51972e34f8703a10ULL, 0x34a7e9d10f4d55fdULL, + 0x8eec7f0d19a03aadULL, 0xd29fe4b18e88640eULL}}, + // 10^-63 ~= d29fe4b18e88640e 8eec7f0d19a03aad + // 34a7e9d10f4d55fd51972e34f8703a10 * 2^-465 + {{0x0e128b5d938cfb40ULL, 0x2a1fee40d90aab31ULL, + 0x3f2398d747b36224ULL, 0xa87fea27a539e9a5ULL}}, + // 10^-64 ~= a87fea27a539e9a5 3f2398d747b36224 + // 2a1fee40d90aab310e128b5d938cfb40 * 2^-468 + {{0x3e753c4adc70c900ULL, 0xbb4cbe9a473bbc27ULL, + 0x98e947129fc2b4e9ULL, 0x86ccbb52ea94baeaULL}}, + // 10^-65 ~= 86ccbb52ea94baea 98e947129fc2b4e9 + // bb4cbe9a473bbc273e753c4adc70c900 * 2^-471 + {{0x30bb93aafa4e0e66ULL, 0x9214642a0b92c6a5ULL, + 0x5b0ed81dcc6abb0fULL, 0xd7adf884aa879177ULL}}, + // 10^-66 ~= d7adf884aa879177 5b0ed81dcc6abb0f + // 9214642a0b92c6a530bb93aafa4e0e66 * 2^-475 + {{0xc0960fbbfb71a51fULL, 0xa8105021a2dbd21dULL, + 0xe272467e3d222f3fULL, 0xac8b2d36eed2dac5ULL}}, + // 10^-67 ~= ac8b2d36eed2dac5 e272467e3d222f3f + // a8105021a2dbd21dc0960fbbfb71a51f * 2^-478 + {{0x66de72fcc927b74cULL, 0xb9a6a6814f1641b1ULL, + 0x1b8e9ecb641b58ffULL, 0x8a08f0f8bf0f156bULL}}, + // 10^-68 ~= 8a08f0f8bf0f156b 1b8e9ecb641b58ff + // b9a6a6814f1641b166de72fcc927b74c * 2^-481 + {{0xd7ca5194750c5879ULL, 0xf5d770cee4f0691bULL, + 0xf8e431456cf88e65ULL, 0xdcdb1b2798182244ULL}}, + // 10^-69 ~= dcdb1b2798182244 f8e431456cf88e65 + // f5d770cee4f0691bd7ca5194750c5879 * 2^-485 + {{0xdfd50e105da379faULL, 0x9179270bea59edafULL, + 0x2d835a9df0c6d851ULL, 0xb0af48ec79ace837ULL}}, + // 10^-70 ~= b0af48ec79ace837 2d835a9df0c6d851 + // 9179270bea59edafdfd50e105da379fa * 2^-488 + {{0x19773e737e1c6195ULL, 0x0dfa85a321e18af3ULL, + 0x579c487e5a38ad0eULL, 0x8d590723948a535fULL}}, + // 10^-71 ~= 8d590723948a535f 579c487e5a38ad0e + // dfa85a321e18af319773e737e1c6195 * 2^-491 + {{0xf58b971f302d68efULL, 0x165da29e9c9c1184ULL, + 0x25c6da63c38de1b0ULL, 0xe2280b6c20dd5232ULL}}, + // 10^-72 ~= e2280b6c20dd5232 25c6da63c38de1b0 + // 165da29e9c9c1184f58b971f302d68ef * 2^-495 + {{0xc46fac18f3578725ULL, 0x4517b54bb07cdad0ULL, + 0x1e38aeb6360b1af3ULL, 0xb4ecd5f01a4aa828ULL}}, + // 10^-73 ~= b4ecd5f01a4aa828 1e38aeb6360b1af3 + // 4517b54bb07cdad0c46fac18f3578725 * 2^-498 + {{0x36bfbce0c2ac6c1eULL, 0x9dac910959fd7bdaULL, + 0xb1c6f22b5e6f48c2ULL, 0x90bd77f3483bb9b9ULL}}, + // 10^-74 ~= 90bd77f3483bb9b9 b1c6f22b5e6f48c2 + // 9dac910959fd7bda36bfbce0c2ac6c1e * 2^-501 + {{0x2465fb01377a4696ULL, 0x2f7a81a88ffbf95dULL, + 0xb60b1d1230b20e04ULL, 0xe7958cb87392c2c2ULL}} + // 10^-75 ~= e7958cb87392c2c2 b60b1d1230b20e04 + // 2f7a81a88ffbf95d2465fb01377a4696 * 2^-505 +}; + +unsigned int Ex256m256[] = { + 3, // 259 - 256, Ex = 259 + 6, // 262 - 256, Ex = 262 + 9, // 265 - 256, Ex = 265 + 13, // 269 - 256, Ex = 269 + 16, // 272 - 256, Ex = 272 + 19, // 275 - 256, Ex = 275 + 23, // 279 - 256, Ex = 279 + 26, // 282 - 256, Ex = 282 + 29, // 285 - 256, Ex = 285 + 33, // 289 - 256, Ex = 289 + 36, // 292 - 256, Ex = 292 + 39, // 295 - 256, Ex = 295 + 43, // 299 - 256, Ex = 299 + 46, // 302 - 256, Ex = 302 + 49, // 305 - 256, Ex = 305 + 53, // 309 - 256, Ex = 309 + 56, // 312 - 256, Ex = 312 + 59, // 315 - 256, Ex = 315 + 63, // 319 - 256, Ex = 319 + 2, // 322 - 320, Ex = 322 + 5, // 325 - 320, Ex = 325 + 9, // 329 - 320, Ex = 329 + 12, // 332 - 320, Ex = 332 + 15, // 335 - 320, Ex = 335 + 19, // 339 - 320, Ex = 339 + 22, // 342 - 320, Ex = 342 + 25, // 345 - 320, Ex = 345 + 29, // 349 - 320, Ex = 349 + 32, // 352 - 320, Ex = 352 + 35, // 355 - 320, Ex = 355 + 38, // 358 - 320, Ex = 358 + 42, // 362 - 320, Ex = 362 + 45, // 365 - 320, Ex = 365 + 48, // 368 - 320, Ex = 368 + 52, // 372 - 320, Ex = 372 + 55, // 375 - 320, Ex = 375 + 58, // 378 - 320, Ex = 378 + 62, // 382 - 320, Ex = 382 + 1, // 385 - 384, Ex = 385 + 4, // 388 - 384, Ex = 388 + 8, // 392 - 384, Ex = 392 + 11, // 395 - 384, Ex = 395 + 14, // 398 - 384, Ex = 398 + 18, // 402 - 384, Ex = 402 + 21, // 405 - 384, Ex = 405 + 24, // 408 - 384, Ex = 408 + 28, // 412 - 384, Ex = 412 + 31, // 415 - 384, Ex = 415 + 34, // 418 - 384, Ex = 418 + 38, // 422 - 384, Ex = 422 + 41, // 425 - 384, Ex = 425 + 44, // 428 - 384, Ex = 428 + 48, // 432 - 384, Ex = 432 + 51, // 435 - 384, Ex = 435 + 54, // 438 - 384, Ex = 438 + 58, // 442 - 384, Ex = 442 + 61, // 445 - 384, Ex = 445 + 0, // 448 - 448, Ex = 448 + 3, // 451 - 448, Ex = 451 + 7, // 455 - 448, Ex = 455 + 10, // 458 - 448, Ex = 458 + 13, // 461 - 448, Ex = 461 + 17, // 465 - 448, Ex = 465 + 20, // 468 - 448, Ex = 468 + 23, // 471 - 448, Ex = 471 + 27, // 475 - 448, Ex = 475 + 30, // 478 - 448, Ex = 478 + 33, // 481 - 448, Ex = 481 + 37, // 485 - 448, Ex = 485 + 40, // 488 - 448, Ex = 488 + 43, // 491 - 448, Ex = 491 + 47, // 495 - 448, Ex = 495 + 50, // 498 - 448, Ex = 498 + 53, // 501 - 448, Ex = 501 + 57 // 505 - 448, Ex = 505 +}; + +UINT64 half256[] = { + 0x0000000000000004ULL, // half / 2^256 = 4 + 0x0000000000000020ULL, // half / 2^256 = 20 + 0x0000000000000100ULL, // half / 2^256 = 100 + 0x0000000000001000ULL, // half / 2^256 = 1000 + 0x0000000000008000ULL, // half / 2^256 = 8000 + 0x0000000000040000ULL, // half / 2^256 = 40000 + 0x0000000000400000ULL, // half / 2^256 = 400000 + 0x0000000002000000ULL, // half / 2^256 = 2000000 + 0x0000000010000000ULL, // half / 2^256 = 10000000 + 0x0000000100000000ULL, // half / 2^256 = 100000000 + 0x0000000800000000ULL, // half / 2^256 = 800000000 + 0x0000004000000000ULL, // half / 2^256 = 4000000000 + 0x0000040000000000ULL, // half / 2^256 = 40000000000 + 0x0000200000000000ULL, // half / 2^256 = 200000000000 + 0x0001000000000000ULL, // half / 2^256 = 1000000000000 + 0x0010000000000000ULL, // half / 2^256 = 10000000000000 + 0x0080000000000000ULL, // half / 2^256 = 80000000000000 + 0x0400000000000000ULL, // half / 2^256 = 400000000000000 + 0x4000000000000000ULL, // half / 2^256 = 4000000000000000 + 0x0000000000000002ULL, // half / 2^320 = 2 + 0x0000000000000010ULL, // half / 2^320 = 10 + 0x0000000000000100ULL, // half / 2^320 = 100 + 0x0000000000000800ULL, // half / 2^320 = 800 + 0x0000000000004000ULL, // half / 2^320 = 4000 + 0x0000000000040000ULL, // half / 2^320 = 40000 + 0x0000000000200000ULL, // half / 2^320 = 200000 + 0x0000000001000000ULL, // half / 2^320 = 1000000 + 0x0000000010000000ULL, // half / 2^320 = 10000000 + 0x0000000080000000ULL, // half / 2^320 = 80000000 + 0x0000000400000000ULL, // half / 2^320 = 400000000 + 0x0000002000000000ULL, // half / 2^320 = 2000000000 + 0x0000020000000000ULL, // half / 2^320 = 20000000000 + 0x0000100000000000ULL, // half / 2^320 = 100000000000 + 0x0000800000000000ULL, // half / 2^320 = 800000000000 + 0x0008000000000000ULL, // half / 2^320 = 8000000000000 + 0x0040000000000000ULL, // half / 2^320 = 40000000000000 + 0x0200000000000000ULL, // half / 2^320 = 200000000000000 + 0x2000000000000000ULL, // half / 2^320 = 2000000000000000 + 0x0000000000000001ULL, // half / 2^384 = 1 + 0x0000000000000008ULL, // half / 2^384 = 8 + 0x0000000000000080ULL, // half / 2^384 = 80 + 0x0000000000000400ULL, // half / 2^384 = 400 + 0x0000000000002000ULL, // half / 2^384 = 2000 + 0x0000000000020000ULL, // half / 2^384 = 20000 + 0x0000000000100000ULL, // half / 2^384 = 100000 + 0x0000000000800000ULL, // half / 2^384 = 800000 + 0x0000000008000000ULL, // half / 2^384 = 8000000 + 0x0000000040000000ULL, // half / 2^384 = 40000000 + 0x0000000200000000ULL, // half / 2^384 = 200000000 + 0x0000002000000000ULL, // half / 2^384 = 2000000000 + 0x0000010000000000ULL, // half / 2^384 = 10000000000 + 0x0000080000000000ULL, // half / 2^384 = 80000000000 + 0x0000800000000000ULL, // half / 2^384 = 800000000000 + 0x0004000000000000ULL, // half / 2^384 = 4000000000000 + 0x0020000000000000ULL, // half / 2^384 = 20000000000000 + 0x0200000000000000ULL, // half / 2^384 = 200000000000000 + 0x1000000000000000ULL, // half / 2^384 = 1000000000000000 + 0x8000000000000000ULL, // half / 2^384 = 8000000000000000 + 0x0000000000000004ULL, // half / 2^448 = 4 + 0x0000000000000040ULL, // half / 2^448 = 40 + 0x0000000000000200ULL, // half / 2^448 = 200 + 0x0000000000001000ULL, // half / 2^448 = 1000 + 0x0000000000010000ULL, // half / 2^448 = 10000 + 0x0000000000080000ULL, // half / 2^448 = 80000 + 0x0000000000400000ULL, // half / 2^448 = 400000 + 0x0000000004000000ULL, // half / 2^448 = 4000000 + 0x0000000020000000ULL, // half / 2^448 = 20000000 + 0x0000000100000000ULL, // half / 2^448 = 100000000 + 0x0000001000000000ULL, // half / 2^448 = 1000000000 + 0x0000008000000000ULL, // half / 2^448 = 8000000000 + 0x0000040000000000ULL, // half / 2^448 = 40000000000 + 0x0000400000000000ULL, // half / 2^448 = 400000000000 + 0x0002000000000000ULL, // half / 2^448 = 2000000000000 + 0x0010000000000000ULL, // half / 2^448 = 10000000000000 + 0x0100000000000000ULL // half / 2^448 = 100000000000000 +}; + +UINT64 mask256[] = { + 0x0000000000000007ULL, // mask / 2^256 + 0x000000000000003fULL, // mask / 2^256 + 0x00000000000001ffULL, // mask / 2^256 + 0x0000000000001fffULL, // mask / 2^256 + 0x000000000000ffffULL, // mask / 2^256 + 0x000000000007ffffULL, // mask / 2^256 + 0x00000000007fffffULL, // mask / 2^256 + 0x0000000003ffffffULL, // mask / 2^256 + 0x000000001fffffffULL, // mask / 2^256 + 0x00000001ffffffffULL, // mask / 2^256 + 0x0000000fffffffffULL, // mask / 2^256 + 0x0000007fffffffffULL, // mask / 2^256 + 0x000007ffffffffffULL, // mask / 2^256 + 0x00003fffffffffffULL, // mask / 2^256 + 0x0001ffffffffffffULL, // mask / 2^256 + 0x001fffffffffffffULL, // mask / 2^256 + 0x00ffffffffffffffULL, // mask / 2^256 + 0x07ffffffffffffffULL, // mask / 2^256 + 0x7fffffffffffffffULL, // mask / 2^256 + 0x0000000000000003ULL, // mask / 2^320 + 0x000000000000001fULL, // mask / 2^320 + 0x00000000000001ffULL, // mask / 2^320 + 0x0000000000000fffULL, // mask / 2^320 + 0x0000000000007fffULL, // mask / 2^320 + 0x000000000007ffffULL, // mask / 2^320 + 0x00000000003fffffULL, // mask / 2^320 + 0x0000000001ffffffULL, // mask / 2^320 + 0x000000001fffffffULL, // mask / 2^320 + 0x00000000ffffffffULL, // mask / 2^320 + 0x00000007ffffffffULL, // mask / 2^320 + 0x0000003fffffffffULL, // mask / 2^320 + 0x000003ffffffffffULL, // mask / 2^320 + 0x00001fffffffffffULL, // mask / 2^320 + 0x0000ffffffffffffULL, // mask / 2^320 + 0x000fffffffffffffULL, // mask / 2^320 + 0x007fffffffffffffULL, // mask / 2^320 + 0x03ffffffffffffffULL, // mask / 2^320 + 0x3fffffffffffffffULL, // mask / 2^320 + 0x0000000000000001ULL, // mask / 2^384 + 0x000000000000000fULL, // mask / 2^384 + 0x00000000000000ffULL, // mask / 2^384 + 0x00000000000007ffULL, // mask / 2^384 + 0x0000000000003fffULL, // mask / 2^384 + 0x000000000003ffffULL, // mask / 2^384 + 0x00000000001fffffULL, // mask / 2^384 + 0x0000000000ffffffULL, // mask / 2^384 + 0x000000000fffffffULL, // mask / 2^384 + 0x000000007fffffffULL, // mask / 2^384 + 0x00000003ffffffffULL, // mask / 2^384 + 0x0000003fffffffffULL, // mask / 2^384 + 0x000001ffffffffffULL, // mask / 2^384 + 0x00000fffffffffffULL, // mask / 2^384 + 0x0000ffffffffffffULL, // mask / 2^384 + 0x0007ffffffffffffULL, // mask / 2^384 + 0x003fffffffffffffULL, // mask / 2^384 + 0x03ffffffffffffffULL, // mask / 2^384 + 0x1fffffffffffffffULL, // mask / 2^384 + 0xffffffffffffffffULL, // mask / 2^384 + 0x0000000000000007ULL, // mask / 2^448 + 0x000000000000007fULL, // mask / 2^448 + 0x00000000000003ffULL, // mask / 2^448 + 0x0000000000001fffULL, // mask / 2^448 + 0x000000000001ffffULL, // mask / 2^448 + 0x00000000000fffffULL, // mask / 2^448 + 0x00000000007fffffULL, // mask / 2^448 + 0x0000000007ffffffULL, // mask / 2^448 + 0x000000003fffffffULL, // mask / 2^448 + 0x00000001ffffffffULL, // mask / 2^448 + 0x0000001fffffffffULL, // mask / 2^448 + 0x000000ffffffffffULL, // mask / 2^448 + 0x000007ffffffffffULL, // mask / 2^448 + 0x00007fffffffffffULL, // mask / 2^448 + 0x0003ffffffffffffULL, // mask / 2^448 + 0x001fffffffffffffULL, // mask / 2^448 + 0x01ffffffffffffffULL // mask / 2^448 +}; + +UINT256 ten2mxtrunc256[] = { + {{0xccccccccccccccccULL, 0xccccccccccccccccULL, + 0xccccccccccccccccULL, 0xccccccccccccccccULL}}, + // (ten2mx >> 256) = cccccccccccccccc cccccccccccccccc + // cccccccccccccccccccccccccccccccc + {{0x70a3d70a3d70a3d7ULL, 0xd70a3d70a3d70a3dULL, + 0x3d70a3d70a3d70a3ULL, 0xa3d70a3d70a3d70aULL}}, + // (ten2mx >> 256) = a3d70a3d70a3d70a 3d70a3d70a3d70a3 + // d70a3d70a3d70a3d70a3d70a3d70a3d7 + {{0xc083126e978d4fdfULL, 0x78d4fdf3b645a1caULL, + 0x645a1cac083126e9ULL, 0x83126e978d4fdf3bULL}}, + // (ten2mx >> 256) = 83126e978d4fdf3b 645a1cac083126e9 + // 78d4fdf3b645a1cac083126e978d4fdf + {{0x67381d7dbf487fcbULL, 0xc154c985f06f6944ULL, + 0xd3c36113404ea4a8ULL, 0xd1b71758e219652bULL}}, + // (ten2mx >> 256) = d1b71758e219652b d3c36113404ea4a8 + // c154c985f06f694467381d7dbf487fcb + {{0x85c67dfe32a0663cULL, 0xcddd6e04c0592103ULL, + 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}}, + // (ten2mx >> 256) = a7c5ac471b478423 fcf80dc33721d53 + // cddd6e04c059210385c67dfe32a0663c + {{0x37d1fe64f54d1e96ULL, 0xd7e45803cd141a69ULL, + 0xa63f9a49c2c1b10fULL, 0x8637bd05af6c69b5ULL}}, + // (ten2mx >> 256) = 8637bd05af6c69b5 a63f9a49c2c1b10f + // d7e45803cd141a6937d1fe64f54d1e96 + {{0x8c8330a1887b6424ULL, 0x8ca08cd2e1b9c3dbULL, + 0x3d32907604691b4cULL, 0xd6bf94d5e57a42bcULL}}, + // (ten2mx >> 256) = d6bf94d5e57a42bc 3d32907604691b4c + // 8ca08cd2e1b9c3db8c8330a1887b6424 + {{0x7068f3b46d2f8350ULL, 0x3d4d3d758161697cULL, + 0xfdc20d2b36ba7c3dULL, 0xabcc77118461cefcULL}}, + // (ten2mx >> 256) = abcc77118461cefc fdc20d2b36ba7c3d + // 3d4d3d758161697c7068f3b46d2f8350 + {{0xf387295d242602a6ULL, 0xfdd7645e011abac9ULL, + 0x31680a88f8953030ULL, 0x89705f4136b4a597ULL}}, + // (ten2mx >> 256) = 89705f4136b4a597 31680a88f8953030 + // fdd7645e011abac9f387295d242602a6 + {{0xb8d8422ea03cd10aULL, 0x2fbf06fcce912adcULL, + 0xb573440e5a884d1bULL, 0xdbe6fecebdedd5beULL}}, + // (ten2mx >> 256) = dbe6fecebdedd5be b573440e5a884d1b + // 2fbf06fcce912adcb8d8422ea03cd10a + {{0x93e034f219ca40d5ULL, 0xf2ff38ca3eda88b0ULL, + 0xf78f69a51539d748ULL, 0xafebff0bcb24aafeULL}}, + // (ten2mx >> 256) = afebff0bcb24aafe f78f69a51539d748 + // f2ff38ca3eda88b093e034f219ca40d5 + {{0x4319c3f4e16e9a44ULL, 0xf598fa3b657ba08dULL, + 0xf93f87b7442e45d3ULL, 0x8cbccc096f5088cbULL}}, + // (ten2mx >> 256) = 8cbccc096f5088cb f93f87b7442e45d3 + // f598fa3b657ba08d4319c3f4e16e9a44 + {{0x04f606549be42a06ULL, 0x88f4c3923bf900e2ULL, + 0x2865a5f206b06fb9ULL, 0xe12e13424bb40e13ULL}}, + // (ten2mx >> 256) = e12e13424bb40e13 2865a5f206b06fb9 + // 88f4c3923bf900e204f606549be42a06 + {{0x03f805107cb68805ULL, 0x6d909c74fcc733e8ULL, + 0x538484c19ef38c94ULL, 0xb424dc35095cd80fULL}}, + // (ten2mx >> 256) = b424dc35095cd80f 538484c19ef38c94 + // 6d909c74fcc733e803f805107cb68805 + {{0x3660040d3092066aULL, 0x57a6e390ca38f653ULL, + 0x0f9d37014bf60a10ULL, 0x901d7cf73ab0acd9ULL}}, + // (ten2mx >> 256) = 901d7cf73ab0acd9 f9d37014bf60a10 + // 57a6e390ca38f6533660040d3092066a + {{0x23ccd3484db670aaULL, 0xbf716c1add27f085ULL, + 0x4c2ebe687989a9b3ULL, 0xe69594bec44de15bULL}}, + // (ten2mx >> 256) = e69594bec44de15b 4c2ebe687989a9b3 + // bf716c1add27f08523ccd3484db670aa + {{0x4fd70f6d0af85a22ULL, 0xff8df0157db98d37ULL, + 0x09befeb9fad487c2ULL, 0xb877aa3236a4b449ULL}}, + // (ten2mx >> 256) = b877aa3236a4b449 9befeb9fad487c2 + // ff8df0157db98d374fd70f6d0af85a22 + {{0x0cac0c573bf9e1b5ULL, 0x32d7f344649470f9ULL, + 0x3aff322e62439fcfULL, 0x9392ee8e921d5d07ULL}}, + // (ten2mx >> 256) = 9392ee8e921d5d07 3aff322e62439fcf + // 32d7f344649470f90cac0c573bf9e1b5 + {{0xe11346f1f98fcf88ULL, 0x1e2652070753e7f4ULL, + 0x2b31e9e3d06c32e5ULL, 0xec1e4a7db69561a5ULL}}, + // (ten2mx >> 256) = ec1e4a7db69561a5 2b31e9e3d06c32e5 + // 1e2652070753e7f4e11346f1f98fcf88 + {{0x4da9058e613fd939ULL, 0x181ea8059f76532aULL, + 0x88f4bb1ca6bcf584ULL, 0xbce5086492111aeaULL}}, + // (ten2mx >> 256) = bce5086492111aea 88f4bb1ca6bcf584 + // 181ea8059f76532a4da9058e613fd939 + {{0xa48737a51a997a94ULL, 0x467eecd14c5ea8eeULL, + 0xd3f6fc16ebca5e03ULL, 0x971da05074da7beeULL}}, + // (ten2mx >> 256) = 971da05074da7bee d3f6fc16ebca5e03 + // 467eecd14c5ea8eea48737a51a997a94 + {{0x3a71f2a1c428c420ULL, 0x70cb148213caa7e4ULL, + 0x5324c68b12dd6338ULL, 0xf1c90080baf72cb1ULL}}, + // (ten2mx >> 256) = f1c90080baf72cb1 5324c68b12dd6338 + // 70cb148213caa7e43a71f2a1c428c420 + {{0x2ec18ee7d0209ce7ULL, 0x8d6f439b43088650ULL, + 0x75b7053c0f178293ULL, 0xc16d9a0095928a27ULL}}, + // (ten2mx >> 256) = c16d9a0095928a27 75b7053c0f178293 + // 8d6f439b430886502ec18ee7d0209ce7 + {{0xf23472530ce6e3ecULL, 0xd78c3615cf3a050cULL, + 0xc4926a9672793542ULL, 0x9abe14cd44753b52ULL}}, + // (ten2mx >> 256) = 9abe14cd44753b52 c4926a9672793542 + // d78c3615cf3a050cf23472530ce6e3ec + {{0xe9ed83b814a49fe0ULL, 0x8c1389bc7ec33b47ULL, + 0x3a83ddbd83f52204ULL, 0xf79687aed3eec551ULL}}, + // (ten2mx >> 256) = f79687aed3eec551 3a83ddbd83f52204 + // 8c1389bc7ec33b47e9ed83b814a49fe0 + {{0x87f1362cdd507fe6ULL, 0x3cdc6e306568fc39ULL, + 0x95364afe032a819dULL, 0xc612062576589ddaULL}}, + // (ten2mx >> 256) = c612062576589dda 95364afe032a819d + // 3cdc6e306568fc3987f1362cdd507fe6 + {{0x9ff42b5717739985ULL, 0xca49f1c05120c9c7ULL, + 0x775ea264cf55347dULL, 0x9e74d1b791e07e48ULL}}, + // (ten2mx >> 256) = 9e74d1b791e07e48 775ea264cf55347d + // ca49f1c05120c9c79ff42b5717739985 + {{0xccb9def1bf1f5c08ULL, 0x76dcb60081ce0fa5ULL, + 0x8bca9d6e188853fcULL, 0xfd87b5f28300ca0dULL}}, + // (ten2mx >> 256) = fd87b5f28300ca0d 8bca9d6e188853fc + // 76dcb60081ce0fa5ccb9def1bf1f5c08 + {{0xa3c7e58e327f7cd3ULL, 0x5f16f80067d80c84ULL, + 0x096ee45813a04330ULL, 0xcad2f7f5359a3b3eULL}}, + // (ten2mx >> 256) = cad2f7f5359a3b3e 96ee45813a04330 + // 5f16f80067d80c84a3c7e58e327f7cd3 + {{0xb6398471c1ff970fULL, 0x18df2ccd1fe00a03ULL, + 0xa1258379a94d028dULL, 0xa2425ff75e14fc31ULL}}, + // (ten2mx >> 256) = a2425ff75e14fc31 a1258379a94d028d + // 18df2ccd1fe00a03b6398471c1ff970f + {{0xf82e038e34cc78d9ULL, 0x4718f0a419800802ULL, + 0x80eacf948770ced7ULL, 0x81ceb32c4b43fcf4ULL}}, + // (ten2mx >> 256) = 81ceb32c4b43fcf4 80eacf948770ced7 + // 4718f0a419800802f82e038e34cc78d9 + {{0x59e338e387ad8e28ULL, 0x0b5b1aa028ccd99eULL, + 0x67de18eda5814af2ULL, 0xcfb11ead453994baULL}}, + // (ten2mx >> 256) = cfb11ead453994ba 67de18eda5814af2 + // b5b1aa028ccd99e59e338e387ad8e28 + {{0x47e8fa4f9fbe0b53ULL, 0x6f7c154ced70ae18ULL, + 0xecb1ad8aeacdd58eULL, 0xa6274bbdd0fadd61ULL}}, + // (ten2mx >> 256) = a6274bbdd0fadd61 ecb1ad8aeacdd58e + // 6f7c154ced70ae1847e8fa4f9fbe0b53 + {{0xd320c83fb2fe6f75ULL, 0xbf967770bdf3be79ULL, + 0xbd5af13bef0b113eULL, 0x84ec3c97da624ab4ULL}}, + // (ten2mx >> 256) = 84ec3c97da624ab4 bd5af13bef0b113e + // bf967770bdf3be79d320c83fb2fe6f75 + {{0x85014065eb30b256ULL, 0x65bd8be79652ca5cULL, + 0x955e4ec64b44e864ULL, 0xd4ad2dbfc3d07787ULL}}, + // (ten2mx >> 256) = d4ad2dbfc3d07787 955e4ec64b44e864 + // 65bd8be79652ca5c85014065eb30b256 + {{0xd0cdcd1e55c08eabULL, 0xeafe098611dbd516ULL, + 0xdde50bd1d5d0b9e9ULL, 0xaa242499697392d2ULL}}, + // (ten2mx >> 256) = aa242499697392d2 dde50bd1d5d0b9e9 + // eafe098611dbd516d0cdcd1e55c08eab + {{0x40a4a418449a0bbcULL, 0xbbfe6e04db164412ULL, + 0x7e50d64177da2e54ULL, 0x881cea14545c7575ULL}}, + // (ten2mx >> 256) = 881cea14545c7575 7e50d64177da2e54 + // bbfe6e04db16441240a4a418449a0bbc + {{0x9aa1068d3a9012c7ULL, 0x2cca49a15e8a0683ULL, + 0x96e7bd358c904a21ULL, 0xd9c7dced53c72255ULL}}, + // (ten2mx >> 256) = d9c7dced53c72255 96e7bd358c904a21 + // 2cca49a15e8a06839aa1068d3a9012c7 + {{0x154d9ed7620cdbd2ULL, 0x8a3b6e1ab2080536ULL, + 0xabec975e0a0d081aULL, 0xae397d8aa96c1b77ULL}}, + // (ten2mx >> 256) = ae397d8aa96c1b77 abec975e0a0d081a + // 8a3b6e1ab2080536154d9ed7620cdbd2 + {{0x443e18ac4e70afdbULL, 0x3b62be7bc1a0042bULL, + 0x2323ac4b3b3da015ULL, 0x8b61313bbabce2c6ULL}}, + // (ten2mx >> 256) = 8b61313bbabce2c6 2323ac4b3b3da015 + // 3b62be7bc1a0042b443e18ac4e70afdb + {{0x6d30277a171ab2f8ULL, 0x5f0463f935ccd378ULL, + 0x6b6c46dec52f6688ULL, 0xdf01e85f912e37a3ULL}}, + // (ten2mx >> 256) = df01e85f912e37a3 6b6c46dec52f6688 + // 5f0463f935ccd3786d30277a171ab2f8 + {{0x8a8cec61ac155bfaULL, 0x7f36b660f7d70f93ULL, + 0x55f038b237591ed3ULL, 0xb267ed1940f1c61cULL}}, + // (ten2mx >> 256) = b267ed1940f1c61c 55f038b237591ed3 + // 7f36b660f7d70f938a8cec61ac155bfa + {{0x3ba3f04e23444995ULL, 0xcc2bc51a5fdf3fa9ULL, + 0x77f3608e92adb242ULL, 0x8eb98a7a9a5b04e3ULL}}, + // (ten2mx >> 256) = 8eb98a7a9a5b04e3 77f3608e92adb242 + // cc2bc51a5fdf3fa93ba3f04e23444995 + {{0xf9064d49d206dc21ULL, 0xe046082a32fecc41ULL, + 0x8cb89a7db77c506aULL, 0xe45c10c42a2b3b05ULL}}, + // (ten2mx >> 256) = e45c10c42a2b3b05 8cb89a7db77c506a + // e046082a32fecc41f9064d49d206dc21 + {{0xfa6b7107db38b01aULL, 0x4d04d354f598a367ULL, + 0x3d607b97c5fd0d22ULL, 0xb6b00d69bb55c8d1ULL}}, + // (ten2mx >> 256) = b6b00d69bb55c8d1 3d607b97c5fd0d22 + // 4d04d354f598a367fa6b7107db38b01a + {{0xfb8927397c2d59afULL, 0x3d9d75dd9146e91fULL, + 0xcab3961304ca70e8ULL, 0x9226712162ab070dULL}}, + // (ten2mx >> 256) = 9226712162ab070d cab3961304ca70e8 + // 3d9d75dd9146e91ffb8927397c2d59af + {{0xf8db71f5937bc2b1ULL, 0xc8fbefc8e87174ffULL, + 0xaab8f01e6e10b4a6ULL, 0xe9d71b689dde71afULL}}, + // (ten2mx >> 256) = e9d71b689dde71af aab8f01e6e10b4a6 + // c8fbefc8e87174fff8db71f5937bc2b1 + {{0x2d7c5b2adc630227ULL, 0x3a63263a538df733ULL, + 0x5560c018580d5d52ULL, 0xbb127c53b17ec159ULL}}, + // (ten2mx >> 256) = bb127c53b17ec159 5560c018580d5d52 + // 3a63263a538df7332d7c5b2adc630227 + {{0x24637c2249e8ce86ULL, 0x2eb5b82ea93e5f5cULL, + 0xdde7001379a44aa8ULL, 0x95a8637627989aadULL}}, + // (ten2mx >> 256) = 95a8637627989aad dde7001379a44aa8 + // 2eb5b82ea93e5f5c24637c2249e8ce86 + {{0x3a38c69d430e173dULL, 0x4abc59e441fd6560ULL, + 0x963e66858f6d4440ULL, 0xef73d256a5c0f77cULL}}, + // (ten2mx >> 256) = ef73d256a5c0f77c 963e66858f6d4440 + // 4abc59e441fd65603a38c69d430e173d + {{0x94fa387dcf3e78fdULL, 0x6efd14b69b311de6ULL, + 0xde98520472bdd033ULL, 0xbf8fdb78849a5f96ULL}}, + // (ten2mx >> 256) = bf8fdb78849a5f96 de98520472bdd033 + // 6efd14b69b311de694fa387dcf3e78fd + {{0xaa61c6cb0c31fa64ULL, 0x259743c548f417ebULL, + 0xe546a8038efe4029ULL, 0x993fe2c6d07b7fabULL}}, + // (ten2mx >> 256) = 993fe2c6d07b7fab e546a8038efe4029 + // 259743c548f417ebaa61c6cb0c31fa64 + {{0xaa360ade79e990a1ULL, 0x3c25393ba7ecf312ULL, + 0xd53dd99f4b3066a8ULL, 0xf53304714d9265dfULL}}, + // (ten2mx >> 256) = f53304714d9265df d53dd99f4b3066a8 + // 3c25393ba7ecf312aa360ade79e990a1 + {{0x882b3be52e5473b4ULL, 0x96842dc95323f5a8ULL, + 0xaa97e14c3c26b886ULL, 0xc428d05aa4751e4cULL}}, + // (ten2mx >> 256) = c428d05aa4751e4c aa97e14c3c26b886 + // 96842dc95323f5a8882b3be52e5473b4 + {{0xd355c98425105c90ULL, 0xab9cf16ddc1cc486ULL, + 0x55464dd69685606bULL, 0x9ced737bb6c4183dULL}}, + // (ten2mx >> 256) = 9ced737bb6c4183d 55464dd69685606b + // ab9cf16ddc1cc486d355c98425105c90 + {{0xebbc75a03b4d60e6ULL, 0xac2e4f162cfad40aULL, + 0xeed6e2f0f0d56712ULL, 0xfb158592be068d2eULL}}, + // (ten2mx >> 256) = fb158592be068d2e eed6e2f0f0d56712 + // ac2e4f162cfad40aebbc75a03b4d60e6 + {{0x8963914cfc3de71eULL, 0x568b727823fbdcd5ULL, + 0xf245825a5a445275ULL, 0xc8de047564d20a8bULL}}, + // (ten2mx >> 256) = c8de047564d20a8b f245825a5a445275 + // 568b727823fbdcd58963914cfc3de71e + {{0xd44fa770c9cb1f4bULL, 0x453c5b934ffcb0aaULL, + 0x5b6aceaeae9d0ec4ULL, 0xa0b19d2ab70e6ed6ULL}}, + // (ten2mx >> 256) = a0b19d2ab70e6ed6 5b6aceaeae9d0ec4 + // 453c5b934ffcb0aad44fa770c9cb1f4b + {{0xdd0c85f3d4a27f6fULL, 0x37637c75d996f3bbULL, + 0xe2bbd88bbee40bd0ULL, 0x808e17555f3ebf11ULL}}, + // (ten2mx >> 256) = 808e17555f3ebf11 e2bbd88bbee40bd0 + // 37637c75d996f3bbdd0c85f3d4a27f6f + {{0x61ada31fba9d98b2ULL, 0x256bfa5628f185f9ULL, + 0x3792f412cb06794dULL, 0xcdb02555653131b6ULL}}, + // (ten2mx >> 256) = cdb02555653131b6 3792f412cb06794d + // 256bfa5628f185f961ada31fba9d98b2 + {{0xe7be1c196217ad5bULL, 0x51232eab53f46b2dULL, + 0x5fa8c3423c052dd7ULL, 0xa48ceaaab75a8e2bULL}}, + // (ten2mx >> 256) = a48ceaaab75a8e2b 5fa8c3423c052dd7 + // 51232eab53f46b2de7be1c196217ad5b + {{0x52fe7ce11b462449ULL, 0x40e8f222a99055beULL, + 0x1953cf68300424acULL, 0x83a3eeeef9153e89ULL}}, + // (ten2mx >> 256) = 83a3eeeef9153e89 1953cf68300424ac + // 40e8f222a99055be52fe7ce11b462449 + {{0x51972e34f8703a0fULL, 0x34a7e9d10f4d55fdULL, + 0x8eec7f0d19a03aadULL, 0xd29fe4b18e88640eULL}}, + // (ten2mx >> 256) = d29fe4b18e88640e 8eec7f0d19a03aad + // 34a7e9d10f4d55fd51972e34f8703a0f + {{0x0e128b5d938cfb3fULL, 0x2a1fee40d90aab31ULL, + 0x3f2398d747b36224ULL, 0xa87fea27a539e9a5ULL}}, + // (ten2mx >> 256) = a87fea27a539e9a5 3f2398d747b36224 + // 2a1fee40d90aab310e128b5d938cfb3f + {{0x3e753c4adc70c8ffULL, 0xbb4cbe9a473bbc27ULL, + 0x98e947129fc2b4e9ULL, 0x86ccbb52ea94baeaULL}}, + // (ten2mx >> 256) = 86ccbb52ea94baea 98e947129fc2b4e9 + // bb4cbe9a473bbc273e753c4adc70c8ff + {{0x30bb93aafa4e0e65ULL, 0x9214642a0b92c6a5ULL, + 0x5b0ed81dcc6abb0fULL, 0xd7adf884aa879177ULL}}, + // (ten2mx >> 256) = d7adf884aa879177 5b0ed81dcc6abb0f + // 9214642a0b92c6a530bb93aafa4e0e65 + {{0xc0960fbbfb71a51eULL, 0xa8105021a2dbd21dULL, + 0xe272467e3d222f3fULL, 0xac8b2d36eed2dac5ULL}}, + // (ten2mx >> 256) = ac8b2d36eed2dac5 e272467e3d222f3f + // a8105021a2dbd21dc0960fbbfb71a51e + {{0x66de72fcc927b74bULL, 0xb9a6a6814f1641b1ULL, + 0x1b8e9ecb641b58ffULL, 0x8a08f0f8bf0f156bULL}}, + // (ten2mx >> 256) = 8a08f0f8bf0f156b 1b8e9ecb641b58ff + // b9a6a6814f1641b166de72fcc927b74b + {{0xd7ca5194750c5878ULL, 0xf5d770cee4f0691bULL, + 0xf8e431456cf88e65ULL, 0xdcdb1b2798182244ULL}}, + // (ten2mx >> 256) = dcdb1b2798182244 f8e431456cf88e65 + // f5d770cee4f0691bd7ca5194750c5878 + {{0xdfd50e105da379f9ULL, 0x9179270bea59edafULL, + 0x2d835a9df0c6d851ULL, 0xb0af48ec79ace837ULL}}, + // (ten2mx >> 256) = b0af48ec79ace837 2d835a9df0c6d851 + // 9179270bea59edafdfd50e105da379f9 + {{0x19773e737e1c6194ULL, 0x0dfa85a321e18af3ULL, + 0x579c487e5a38ad0eULL, 0x8d590723948a535fULL}}, + // (ten2mx >> 256) = 8d590723948a535f 579c487e5a38ad0e + // dfa85a321e18af319773e737e1c6194 + {{0xf58b971f302d68eeULL, 0x165da29e9c9c1184ULL, + 0x25c6da63c38de1b0ULL, 0xe2280b6c20dd5232ULL}}, + // (ten2mx >> 256) = e2280b6c20dd5232 25c6da63c38de1b0 + // 165da29e9c9c1184f58b971f302d68ee + {{0xc46fac18f3578724ULL, 0x4517b54bb07cdad0ULL, + 0x1e38aeb6360b1af3ULL, 0xb4ecd5f01a4aa828ULL}}, + // (ten2mx >> 256) = b4ecd5f01a4aa828 1e38aeb6360b1af3 + // 4517b54bb07cdad0c46fac18f3578724 + {{0x36bfbce0c2ac6c1dULL, 0x9dac910959fd7bdaULL, + 0xb1c6f22b5e6f48c2ULL, 0x90bd77f3483bb9b9ULL}}, + // (ten2mx >> 256) = 90bd77f3483bb9b9 b1c6f22b5e6f48c2 + // 9dac910959fd7bda36bfbce0c2ac6c1d + {{0x2465fb01377a4695ULL, 0x2f7a81a88ffbf95dULL, + 0xb60b1d1230b20e04ULL, 0xe7958cb87392c2c2ULL}} + // (ten2mx >> 256) = e7958cb87392c2c2 b60b1d1230b20e04 + // 2f7a81a88ffbf95d2465fb01377a4695 +}; diff --git a/gcc-4.4.3/libgcc/config/libbid/bid128_2_str.h b/gcc-4.4.3/libgcc/config/libbid/bid128_2_str.h new file mode 100644 index 000000000..7f7287ec6 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/bid128_2_str.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +extern UINT64 Twoto60_m_10to18; +extern UINT64 Twoto60; +extern UINT64 Inv_Tento9; +extern UINT32 Twoto30_m_10to9; +extern UINT32 Tento9; +extern UINT32 Tento6; +extern UINT32 Tento3; + +extern char midi_tbl[1000][3]; +extern UINT64 mod10_18_tbl[9][128]; diff --git a/gcc-4.4.3/libgcc/config/libbid/bid128_2_str_macros.h b/gcc-4.4.3/libgcc/config/libbid/bid128_2_str_macros.h new file mode 100644 index 000000000..965501d10 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/bid128_2_str_macros.h @@ -0,0 +1,149 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#define __L0_Normalize_10to18( X_hi, X_lo ) \ +{ \ +UINT64 L0_tmp; \ +L0_tmp = (X_lo) + Twoto60_m_10to18; \ +if (L0_tmp & Twoto60) \ + {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<4)>>4);} \ +} + + +#define __L0_Normalize_10to9( X_hi, X_lo ) \ +{ \ +UINT32 L0_tmp; \ +L0_tmp = (X_lo) + Twoto30_m_10to9; \ +if (L0_tmp & 0x40000000) \ + {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<2)>>2);} \ +} + + +#define __L0_Split_MiDi_2( X, ptr ) \ +{ \ +UINT32 L0_head, L0_tail, L0_tmp; \ + L0_head = (X) >> 10; \ + L0_tail = ((X)&(0x03FF))+(L0_head<<5)-(L0_head<<3); \ + L0_tmp = (L0_tail)>>10; L0_head += L0_tmp; \ + L0_tail = (L0_tail&(0x03FF))+(L0_tmp<<5)-(L0_tmp<<3); \ + if (L0_tail > 999){L0_tail -= 1000; L0_head += 1;} \ + *((ptr)++) = L0_head; *((ptr)++) = L0_tail; \ +} + + +#define __L0_Split_MiDi_3( X, ptr ) \ +{ \ +UINT32 L0_X, L0_head, L0_mid, L0_tail, L0_tmp; \ + L0_X = (UINT32)((X)); \ + L0_head = ((L0_X>>17)*34359)>>18; \ + L0_X -= L0_head*1000000; \ + if (L0_X >= 1000000){L0_X -= 1000000;L0_head+=1;} \ + L0_mid = L0_X >> 10; \ + L0_tail = (L0_X & (0x03FF))+(L0_mid<<5)-(L0_mid<<3); \ + L0_tmp = (L0_tail)>>10; L0_mid += L0_tmp; \ + L0_tail = (L0_tail&(0x3FF))+(L0_tmp<<5)-(L0_tmp<<3); \ + if (L0_tail>999){L0_tail-=1000;L0_mid+=1;} \ + *((ptr)++)=L0_head;*((ptr)++)=L0_mid; \ + *((ptr)++)=L0_tail; \ +} + +#define __L1_Split_MiDi_6( X, ptr ) \ +{ \ +UINT32 L1_X_hi, L1_X_lo; \ +UINT64 L1_Xhi_64, L1_Xlo_64; \ +L1_Xhi_64 = ( ((X)>>28)*Inv_Tento9 ) >> 33; \ +L1_Xlo_64 = (X) - L1_Xhi_64*(UINT64)Tento9; \ +if (L1_Xlo_64 >= (UINT64)Tento9) \ + {L1_Xlo_64-=(UINT64)Tento9;L1_Xhi_64+=1;} \ +L1_X_hi=(UINT32)L1_Xhi_64; L1_X_lo=(UINT32)L1_Xlo_64; \ +__L0_Split_MiDi_3(L1_X_hi,(ptr)); \ +__L0_Split_MiDi_3(L1_X_lo,(ptr)); \ +} + +#define __L1_Split_MiDi_6_Lead( X, ptr ) \ +{ \ +UINT32 L1_X_hi, L1_X_lo; \ +UINT64 L1_Xhi_64, L1_Xlo_64; \ +if ((X)>=(UINT64)Tento9){ \ + L1_Xhi_64 = ( ((X)>>28)*Inv_Tento9 ) >> 33; \ + L1_Xlo_64 = (X) - L1_Xhi_64*(UINT64)Tento9; \ + if (L1_Xlo_64 >= (UINT64)Tento9) \ + {L1_Xlo_64-=(UINT64)Tento9;L1_Xhi_64+=1;} \ + L1_X_hi=(UINT32)L1_Xhi_64; \ + L1_X_lo=(UINT32)L1_Xlo_64; \ + if (L1_X_hi>=Tento6){ \ + __L0_Split_MiDi_3(L1_X_hi,(ptr)); \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ + else if (L1_X_hi>=Tento3){ \ + __L0_Split_MiDi_2(L1_X_hi,(ptr)); \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ + else { \ + *((ptr)++) = L1_X_hi; \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ +} \ +else { \ + L1_X_lo = (UINT32)(X); \ + if (L1_X_lo>=Tento6){ \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ + else if (L1_X_lo>=Tento3){ \ + __L0_Split_MiDi_2(L1_X_lo,(ptr)); \ + } \ + else { \ + *((ptr)++) = L1_X_lo; \ + } \ +} \ +} + + +#define __L0_MiDi2Str( X, c_ptr ) \ +{ \ +char *L0_src; \ + L0_src = midi_tbl[(X)]; \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src); \ +} + +#define __L0_MiDi2Str_Lead( X, c_ptr ) \ +{ \ +char *L0_src; \ + L0_src = midi_tbl[(X)]; \ + if ((X)>=100){ \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src); \ + } \ + else if ((X)>=10){ \ + L0_src++; \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src); \ + } \ + else { \ + L0_src++;L0_src++; \ + *((c_ptr)++) = *(L0_src); \ +} \ +} diff --git a/gcc-4.4.3/libgcc/config/libbid/bid128_2_str_tables.c b/gcc-4.4.3/libgcc/config/libbid/bid128_2_str_tables.c new file mode 100644 index 000000000..f1517ed56 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/bid128_2_str_tables.c @@ -0,0 +1,642 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_internal.h" + +UINT64 Twoto60_m_10to18 = 152921504606846976LL; +UINT64 Twoto60 = 0x1000000000000000LL; +UINT64 Inv_Tento9 = 2305843009LL; /* floor(2^61/10^9) */ +UINT32 Twoto30_m_10to9 = 73741824; +UINT32 Tento9 = 1000000000; +UINT32 Tento6 = 1000000; +UINT32 Tento3 = 1000; + +const char midi_tbl[1000][3] = { + "000", "001", "002", "003", "004", "005", "006", "007", "008", "009", + "010", "011", "012", "013", "014", "015", "016", "017", "018", "019", + "020", "021", "022", "023", "024", "025", "026", "027", "028", "029", + "030", "031", "032", "033", "034", "035", "036", "037", "038", "039", + "040", "041", "042", "043", "044", "045", "046", "047", "048", "049", + "050", "051", "052", "053", "054", "055", "056", "057", "058", "059", + "060", "061", "062", "063", "064", "065", "066", "067", "068", "069", + "070", "071", "072", "073", "074", "075", "076", "077", "078", "079", + "080", "081", "082", "083", "084", "085", "086", "087", "088", "089", + "090", "091", "092", "093", "094", "095", "096", "097", "098", "099", + "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", + "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", + "120", "121", "122", "123", "124", "125", "126", "127", "128", "129", + "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", + "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", + "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", + "160", "161", "162", "163", "164", "165", "166", "167", "168", "169", + "170", "171", "172", "173", "174", "175", "176", "177", "178", "179", + "180", "181", "182", "183", "184", "185", "186", "187", "188", "189", + "190", "191", "192", "193", "194", "195", "196", "197", "198", "199", + "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", + "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", + "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", + "230", "231", "232", "233", "234", "235", "236", "237", "238", "239", + "240", "241", "242", "243", "244", "245", "246", "247", "248", "249", + "250", "251", "252", "253", "254", "255", "256", "257", "258", "259", + "260", "261", "262", "263", "264", "265", "266", "267", "268", "269", + "270", "271", "272", "273", "274", "275", "276", "277", "278", "279", + "280", "281", "282", "283", "284", "285", "286", "287", "288", "289", + "290", "291", "292", "293", "294", "295", "296", "297", "298", "299", + "300", "301", "302", "303", "304", "305", "306", "307", "308", "309", + "310", "311", "312", "313", "314", "315", "316", "317", "318", "319", + "320", "321", "322", "323", "324", "325", "326", "327", "328", "329", + "330", "331", "332", "333", "334", "335", "336", "337", "338", "339", + "340", "341", "342", "343", "344", "345", "346", "347", "348", "349", + "350", "351", "352", "353", "354", "355", "356", "357", "358", "359", + "360", "361", "362", "363", "364", "365", "366", "367", "368", "369", + "370", "371", "372", "373", "374", "375", "376", "377", "378", "379", + "380", "381", "382", "383", "384", "385", "386", "387", "388", "389", + "390", "391", "392", "393", "394", "395", "396", "397", "398", "399", + "400", "401", "402", "403", "404", "405", "406", "407", "408", "409", + "410", "411", "412", "413", "414", "415", "416", "417", "418", "419", + "420", "421", "422", "423", "424", "425", "426", "427", "428", "429", + "430", "431", "432", "433", "434", "435", "436", "437", "438", "439", + "440", "441", "442", "443", "444", "445", "446", "447", "448", "449", + "450", "451", "452", "453", "454", "455", "456", "457", "458", "459", + "460", "461", "462", "463", "464", "465", "466", "467", "468", "469", + "470", "471", "472", "473", "474", "475", "476", "477", "478", "479", + "480", "481", "482", "483", "484", "485", "486", "487", "488", "489", + "490", "491", "492", "493", "494", "495", "496", "497", "498", "499", + "500", "501", "502", "503", "504", "505", "506", "507", "508", "509", + "510", "511", "512", "513", "514", "515", "516", "517", "518", "519", + "520", "521", "522", "523", "524", "525", "526", "527", "528", "529", + "530", "531", "532", "533", "534", "535", "536", "537", "538", "539", + "540", "541", "542", "543", "544", "545", "546", "547", "548", "549", + "550", "551", "552", "553", "554", "555", "556", "557", "558", "559", + "560", "561", "562", "563", "564", "565", "566", "567", "568", "569", + "570", "571", "572", "573", "574", "575", "576", "577", "578", "579", + "580", "581", "582", "583", "584", "585", "586", "587", "588", "589", + "590", "591", "592", "593", "594", "595", "596", "597", "598", "599", + "600", "601", "602", "603", "604", "605", "606", "607", "608", "609", + "610", "611", "612", "613", "614", "615", "616", "617", "618", "619", + "620", "621", "622", "623", "624", "625", "626", "627", "628", "629", + "630", "631", "632", "633", "634", "635", "636", "637", "638", "639", + "640", "641", "642", "643", "644", "645", "646", "647", "648", "649", + "650", "651", "652", "653", "654", "655", "656", "657", "658", "659", + "660", "661", "662", "663", "664", "665", "666", "667", "668", "669", + "670", "671", "672", "673", "674", "675", "676", "677", "678", "679", + "680", "681", "682", "683", "684", "685", "686", "687", "688", "689", + "690", "691", "692", "693", "694", "695", "696", "697", "698", "699", + "700", "701", "702", "703", "704", "705", "706", "707", "708", "709", + "710", "711", "712", "713", "714", "715", "716", "717", "718", "719", + "720", "721", "722", "723", "724", "725", "726", "727", "728", "729", + "730", "731", "732", "733", "734", "735", "736", "737", "738", "739", + "740", "741", "742", "743", "744", "745", "746", "747", "748", "749", + "750", "751", "752", "753", "754", "755", "756", "757", "758", "759", + "760", "761", "762", "763", "764", "765", "766", "767", "768", "769", + "770", "771", "772", "773", "774", "775", "776", "777", "778", "779", + "780", "781", "782", "783", "784", "785", "786", "787", "788", "789", + "790", "791", "792", "793", "794", "795", "796", "797", "798", "799", + "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", + "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", + "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", + "830", "831", "832", "833", "834", "835", "836", "837", "838", "839", + "840", "841", "842", "843", "844", "845", "846", "847", "848", "849", + "850", "851", "852", "853", "854", "855", "856", "857", "858", "859", + "860", "861", "862", "863", "864", "865", "866", "867", "868", "869", + "870", "871", "872", "873", "874", "875", "876", "877", "878", "879", + "880", "881", "882", "883", "884", "885", "886", "887", "888", "889", + "890", "891", "892", "893", "894", "895", "896", "897", "898", "899", + "900", "901", "902", "903", "904", "905", "906", "907", "908", "909", + "910", "911", "912", "913", "914", "915", "916", "917", "918", "919", + "920", "921", "922", "923", "924", "925", "926", "927", "928", "929", + "930", "931", "932", "933", "934", "935", "936", "937", "938", "939", + "940", "941", "942", "943", "944", "945", "946", "947", "948", "949", + "950", "951", "952", "953", "954", "955", "956", "957", "958", "959", + "960", "961", "962", "963", "964", "965", "966", "967", "968", "969", + "970", "971", "972", "973", "974", "975", "976", "977", "978", "979", + "980", "981", "982", "983", "984", "985", "986", "987", "988", "989", + "990", "991", "992", "993", "994", "995", "996", "997", "998", "999" +}; + +const UINT64 mod10_18_tbl[9][128] = { + // 2^59 = 576460752303423488, A and B breakdown, where data = A*10^18 + B + + { + 0LL, 0LL, 0LL, 576460752303423488LL, + // 0*2^59, 1*2^59 + 1LL, 152921504606846976LL, 1LL, 729382256910270464LL, + // 2*2^59, 3*2^59 + 2LL, 305843009213693952LL, 2LL, 882303761517117440LL, + // 4*2^59, 5*2^59 + 3LL, 458764513820540928LL, 4LL, 35225266123964416LL, + // 6*2^59, 7*2^59 + 4LL, 611686018427387904LL, 5LL, 188146770730811392LL, + // 8*2^59, 9*2^59 + 5LL, 764607523034234880LL, 6LL, 341068275337658368LL, + // 10*2^59, 11*2^59 + 6LL, 917529027641081856LL, 7LL, 493989779944505344LL, + // 12*2^59, 13*2^59 + 8LL, 70450532247928832LL, 8LL, 646911284551352320LL, + // 14*2^59, 15*2^59 + 9LL, 223372036854775808LL, 9LL, 799832789158199296LL, + // 16*2^59, 17*2^59 + 10LL, 376293541461622784LL, 10LL, 952754293765046272LL, + // 18*2^59, 19*2^59 + 11LL, 529215046068469760LL, 12LL, 105675798371893248LL, + // 20*2^59, 21*2^59 + 12LL, 682136550675316736LL, 13LL, 258597302978740224LL, + // 22*2^59, 23*2^59 + 13LL, 835058055282163712LL, 14LL, 411518807585587200LL, + // 24*2^59, 25*2^59 + 14LL, 987979559889010688LL, 15LL, 564440312192434176LL, + // 26*2^59, 27*2^59 + 16LL, 140901064495857664LL, 16LL, 717361816799281152LL, + // 28*2^59, 29*2^59 + 17LL, 293822569102704640LL, 17LL, 870283321406128128LL, + // 30*2^59, 31*2^59 + 18LL, 446744073709551616LL, 19LL, 23204826012975104LL, + // 32*2^59, 33*2^59 + 19LL, 599665578316398592LL, 20LL, 176126330619822080LL, + // 34*2^59, 35*2^59 + 20LL, 752587082923245568LL, 21LL, 329047835226669056LL, + // 36*2^59, 37*2^59 + 21LL, 905508587530092544LL, 22LL, 481969339833516032LL, + // 38*2^59, 39*2^59 + 23LL, 58430092136939520LL, 23LL, 634890844440363008LL, + // 40*2^59, 41*2^59 + 24LL, 211351596743786496LL, 24LL, 787812349047209984LL, + // 42*2^59, 43*2^59 + 25LL, 364273101350633472LL, 25LL, 940733853654056960LL, + // 44*2^59, 45*2^59 + 26LL, 517194605957480448LL, 27LL, 93655358260903936LL, + // 46*2^59, 47*2^59 + 27LL, 670116110564327424LL, 28LL, 246576862867750912LL, + // 48*2^59, 49*2^59 + 28LL, 823037615171174400LL, 29LL, 399498367474597888LL, + // 50*2^59, 51*2^59 + 29LL, 975959119778021376LL, 30LL, 552419872081444864LL, + // 52*2^59, 53*2^59 + 31LL, 128880624384868352LL, 31LL, 705341376688291840LL, + // 54*2^59, 55*2^59 + 32LL, 281802128991715328LL, 32LL, 858262881295138816LL, + // 56*2^59, 57*2^59 + 33LL, 434723633598562304LL, 34LL, 11184385901985792LL, + // 58*2^59, 59*2^59 + 34LL, 587645138205409280LL, 35LL, 164105890508832768LL, + // 60*2^59, 61*2^59 + 35LL, 740566642812256256LL, 36LL, 317027395115679744LL, + // 62*2^59, 63*2^59 + }, + + { + // 2^65 = 36*10^18 + 893488147419103232 + 0LL, 0LL, 36LL, 893488147419103232LL, + // 0*2^65, 1*2^65 + 73LL, 786976294838206464LL, 110LL, 680464442257309696LL, + // 2*2^65, 3*2^65 + 147LL, 573952589676412928LL, 184LL, 467440737095516160LL, + // 4*2^65, 5*2^65 + 221LL, 360928884514619392LL, 258LL, 254417031933722624LL, + // 6*2^65, 7*2^65 + 295LL, 147905179352825856LL, 332LL, 41393326771929088LL, + // 8*2^65, 9*2^65 + 368LL, 934881474191032320LL, 405LL, 828369621610135552LL, + // 0*2^65, 1*2^65 + 442LL, 721857769029238784LL, 479LL, 615345916448342016LL, + // 2*2^65, 3*2^65 + 516LL, 508834063867445248LL, 553LL, 402322211286548480LL, + // 4*2^65, 5*2^65 + 590LL, 295810358705651712LL, 627LL, 189298506124754944LL, + // 6*2^65, 7*2^65 + 664LL, 82786653543858176LL, 700LL, 976274800962961408LL, + // 8*2^65, 9*2^65 + 737LL, 869762948382064640LL, 774LL, 763251095801167872LL, + // 0*2^65, 1*2^65 + 811LL, 656739243220271104LL, 848LL, 550227390639374336LL, + // 2*2^65, 3*2^65 + 885LL, 443715538058477568LL, 922LL, 337203685477580800LL, + // 4*2^65, 5*2^65 + 959LL, 230691832896684032LL, 996LL, 124179980315787264LL, + // 6*2^65, 7*2^65 + 1033LL, 17668127734890496LL, 1069LL, 911156275153993728LL, + // 8*2^65, 9*2^65 + 1106LL, 804644422573096960LL, 1143LL, 698132569992200192LL, + // 0*2^65, 1*2^65 + 1180LL, 591620717411303424LL, 1217LL, 485108864830406656LL, + // 2*2^65, 3*2^65 + 1254LL, 378597012249509888LL, 1291LL, 272085159668613120LL, + // 4*2^65, 5*2^65 + 1328LL, 165573307087716352LL, 1365LL, 59061454506819584LL, + // 6*2^65, 7*2^65 + 1401LL, 952549601925922816LL, 1438LL, 846037749345026048LL, + // 8*2^65, 9*2^65 + 1475LL, 739525896764129280LL, 1512LL, 633014044183232512LL, + // 0*2^65, 1*2^65 + 1549LL, 526502191602335744LL, 1586LL, 419990339021438976LL, + // 2*2^65, 3*2^65 + 1623LL, 313478486440542208LL, 1660LL, 206966633859645440LL, + // 4*2^65, 5*2^65 + 1697LL, 100454781278748672LL, 1733LL, 993942928697851904LL, + // 6*2^65, 7*2^65 + 1770LL, 887431076116955136LL, 1807LL, 780919223536058368LL, + // 8*2^65, 9*2^65 + 1844LL, 674407370955161600LL, 1881LL, 567895518374264832LL, + // 0*2^65, 1*2^65 + 1918LL, 461383665793368064LL, 1955LL, 354871813212471296LL, + // 2*2^65, 3*2^65 + 1992LL, 248359960631574528LL, 2029LL, 141848108050677760LL, + // 4*2^65, 5*2^65 + 2066LL, 35336255469780992LL, 2102LL, 928824402888884224LL, + // 6*2^65, 7*2^65 + 2139LL, 822312550307987456LL, 2176LL, 715800697727090688LL, + // 8*2^65, 9*2^65 + 2213LL, 609288845146193920LL, 2250LL, 502776992565297152LL, + // 0*2^65, 1*2^65 + 2287LL, 396265139984400384LL, 2324LL, 289753287403503616LL, + // 2*2^65, 3*2^65 + }, + + { + 0LL, 0LL, 2361LL, 183241434822606848LL, + 4722LL, 366482869645213696LL, 7083LL, 549724304467820544LL, + 9444LL, 732965739290427392LL, 11805LL, 916207174113034240LL, + 14167LL, 99448608935641088LL, 16528LL, 282690043758247936LL, + 18889LL, 465931478580854784LL, 21250LL, 649172913403461632LL, + 23611LL, 832414348226068480LL, 25973LL, 15655783048675328LL, + 28334LL, 198897217871282176LL, 30695LL, 382138652693889024LL, + 33056LL, 565380087516495872LL, 35417LL, 748621522339102720LL, + 37778LL, 931862957161709568LL, 40140LL, 115104391984316416LL, + 42501LL, 298345826806923264LL, 44862LL, 481587261629530112LL, + 47223LL, 664828696452136960LL, 49584LL, 848070131274743808LL, + 51946LL, 31311566097350656LL, 54307LL, 214553000919957504LL, + 56668LL, 397794435742564352LL, 59029LL, 581035870565171200LL, + 61390LL, 764277305387778048LL, 63751LL, 947518740210384896LL, + 66113LL, 130760175032991744LL, 68474LL, 314001609855598592LL, + 70835LL, 497243044678205440LL, 73196LL, 680484479500812288LL, + 75557LL, 863725914323419136LL, 77919LL, 46967349146025984LL, + 80280LL, 230208783968632832LL, 82641LL, 413450218791239680LL, + 85002LL, 596691653613846528LL, 87363LL, 779933088436453376LL, + 89724LL, 963174523259060224LL, 92086LL, 146415958081667072LL, + 94447LL, 329657392904273920LL, 96808LL, 512898827726880768LL, + 99169LL, 696140262549487616LL, 101530LL, 879381697372094464LL, + 103892LL, 62623132194701312LL, 106253LL, 245864567017308160LL, + 108614LL, 429106001839915008LL, 110975LL, 612347436662521856LL, + 113336LL, 795588871485128704LL, 115697LL, 978830306307735552LL, + 118059LL, 162071741130342400LL, 120420LL, 345313175952949248LL, + 122781LL, 528554610775556096LL, 125142LL, 711796045598162944LL, + 127503LL, 895037480420769792LL, 129865LL, 78278915243376640LL, + 132226LL, 261520350065983488LL, 134587LL, 444761784888590336LL, + 136948LL, 628003219711197184LL, 139309LL, 811244654533804032LL, + 141670LL, 994486089356410880LL, 144032LL, 177727524179017728LL, + 146393LL, 360968959001624576LL, 148754LL, 544210393824231424LL, + }, + + { + 0LL, 0LL, 151115LL, 727451828646838272LL, + 302231LL, 454903657293676544LL, 453347LL, 182355485940514816LL, + 604462LL, 909807314587353088LL, 755578LL, 637259143234191360LL, + 906694LL, 364710971881029632LL, 1057810LL, 92162800527867904LL, + 1208925LL, 819614629174706176LL, 1360041LL, 547066457821544448LL, + 1511157LL, 274518286468382720LL, 1662273LL, 1970115115220992LL, + 1813388LL, 729421943762059264LL, 1964504LL, 456873772408897536LL, + 2115620LL, 184325601055735808LL, 2266735LL, 911777429702574080LL, + 2417851LL, 639229258349412352LL, 2568967LL, 366681086996250624LL, + 2720083LL, 94132915643088896LL, 2871198LL, 821584744289927168LL, + 3022314LL, 549036572936765440LL, 3173430LL, 276488401583603712LL, + 3324546LL, 3940230230441984LL, 3475661LL, 731392058877280256LL, + 3626777LL, 458843887524118528LL, 3777893LL, 186295716170956800LL, + 3929008LL, 913747544817795072LL, 4080124LL, 641199373464633344LL, + 4231240LL, 368651202111471616LL, 4382356LL, 96103030758309888LL, + 4533471LL, 823554859405148160LL, 4684587LL, 551006688051986432LL, + 4835703LL, 278458516698824704LL, 4986819LL, 5910345345662976LL, + 5137934LL, 733362173992501248LL, 5289050LL, 460814002639339520LL, + 5440166LL, 188265831286177792LL, 5591281LL, 915717659933016064LL, + 5742397LL, 643169488579854336LL, 5893513LL, 370621317226692608LL, + 6044629LL, 98073145873530880LL, 6195744LL, 825524974520369152LL, + 6346860LL, 552976803167207424LL, 6497976LL, 280428631814045696LL, + 6649092LL, 7880460460883968LL, 6800207LL, 735332289107722240LL, + 6951323LL, 462784117754560512LL, 7102439LL, 190235946401398784LL, + 7253554LL, 917687775048237056LL, 7404670LL, 645139603695075328LL, + 7555786LL, 372591432341913600LL, 7706902LL, 100043260988751872LL, + 7858017LL, 827495089635590144LL, 8009133LL, 554946918282428416LL, + 8160249LL, 282398746929266688LL, 8311365LL, 9850575576104960LL, + 8462480LL, 737302404222943232LL, 8613596LL, 464754232869781504LL, + 8764712LL, 192206061516619776LL, 8915827LL, 919657890163458048LL, + 9066943LL, 647109718810296320LL, 9218059LL, 374561547457134592LL, + 9369175LL, 102013376103972864LL, 9520290LL, 829465204750811136LL, + }, + + { + 0LL, 0LL, 9671406LL, 556917033397649408LL, + 19342813LL, 113834066795298816LL, 29014219LL, 670751100192948224LL, + 38685626LL, 227668133590597632LL, 48357032LL, 784585166988247040LL, + 58028439LL, 341502200385896448LL, 67699845LL, 898419233783545856LL, + 77371252LL, 455336267181195264LL, 87042659LL, 12253300578844672LL, + 96714065LL, 569170333976494080LL, 106385472LL, 126087367374143488LL, + 116056878LL, 683004400771792896LL, 125728285LL, 239921434169442304LL, + 135399691LL, 796838467567091712LL, 145071098LL, 353755500964741120LL, + 154742504LL, 910672534362390528LL, 164413911LL, 467589567760039936LL, + 174085318LL, 24506601157689344LL, 183756724LL, 581423634555338752LL, + 193428131LL, 138340667952988160LL, 203099537LL, 695257701350637568LL, + 212770944LL, 252174734748286976LL, 222442350LL, 809091768145936384LL, + 232113757LL, 366008801543585792LL, 241785163LL, 922925834941235200LL, + 251456570LL, 479842868338884608LL, 261127977LL, 36759901736534016LL, + 270799383LL, 593676935134183424LL, 280470790LL, 150593968531832832LL, + 290142196LL, 707511001929482240LL, 299813603LL, 264428035327131648LL, + 309485009LL, 821345068724781056LL, 319156416LL, 378262102122430464LL, + 328827822LL, 935179135520079872LL, 338499229LL, 492096168917729280LL, + 348170636LL, 49013202315378688LL, 357842042LL, 605930235713028096LL, + 367513449LL, 162847269110677504LL, 377184855LL, 719764302508326912LL, + 386856262LL, 276681335905976320LL, 396527668LL, 833598369303625728LL, + 406199075LL, 390515402701275136LL, 415870481LL, 947432436098924544LL, + 425541888LL, 504349469496573952LL, 435213295LL, 61266502894223360LL, + 444884701LL, 618183536291872768LL, 454556108LL, 175100569689522176LL, + 464227514LL, 732017603087171584LL, 473898921LL, 288934636484820992LL, + 483570327LL, 845851669882470400LL, 493241734LL, 402768703280119808LL, + 502913140LL, 959685736677769216LL, 512584547LL, 516602770075418624LL, + 522255954LL, 73519803473068032LL, 531927360LL, 630436836870717440LL, + 541598767LL, 187353870268366848LL, 551270173LL, 744270903666016256LL, + 560941580LL, 301187937063665664LL, 570612986LL, 858104970461315072LL, + 580284393LL, 415022003858964480LL, 589955799LL, 971939037256613888LL, + 599627206LL, 528856070654263296LL, 609298613LL, 85773104051912704LL, + }, + + { + 0LL, 0LL, 618970019LL, 642690137449562112LL, + 1237940039LL, 285380274899124224LL, 1856910058LL, + 928070412348686336LL, + 2475880078LL, 570760549798248448LL, 3094850098LL, + 213450687247810560LL, + 3713820117LL, 856140824697372672LL, 4332790137LL, + 498830962146934784LL, + 4951760157LL, 141521099596496896LL, 5570730176LL, + 784211237046059008LL, + 6189700196LL, 426901374495621120LL, 6808670216LL, + 69591511945183232LL, + 7427640235LL, 712281649394745344LL, 8046610255LL, + 354971786844307456LL, + 8665580274LL, 997661924293869568LL, 9284550294LL, + 640352061743431680LL, + 9903520314LL, 283042199192993792LL, 10522490333LL, + 925732336642555904LL, + 11141460353LL, 568422474092118016LL, 11760430373LL, + 211112611541680128LL, + 12379400392LL, 853802748991242240LL, 12998370412LL, + 496492886440804352LL, + 13617340432LL, 139183023890366464LL, 14236310451LL, + 781873161339928576LL, + 14855280471LL, 424563298789490688LL, 15474250491LL, + 67253436239052800LL, + 16093220510LL, 709943573688614912LL, 16712190530LL, + 352633711138177024LL, + 17331160549LL, 995323848587739136LL, 17950130569LL, + 638013986037301248LL, + 18569100589LL, 280704123486863360LL, 19188070608LL, + 923394260936425472LL, + 19807040628LL, 566084398385987584LL, 20426010648LL, + 208774535835549696LL, + 21044980667LL, 851464673285111808LL, 21663950687LL, + 494154810734673920LL, + 22282920707LL, 136844948184236032LL, 22901890726LL, + 779535085633798144LL, + 23520860746LL, 422225223083360256LL, 24139830766LL, + 64915360532922368LL, + 24758800785LL, 707605497982484480LL, 25377770805LL, + 350295635432046592LL, + 25996740824LL, 992985772881608704LL, 26615710844LL, + 635675910331170816LL, + 27234680864LL, 278366047780732928LL, 27853650883LL, + 921056185230295040LL, + 28472620903LL, 563746322679857152LL, 29091590923LL, + 206436460129419264LL, + 29710560942LL, 849126597578981376LL, 30329530962LL, + 491816735028543488LL, + 30948500982LL, 134506872478105600LL, 31567471001LL, + 777197009927667712LL, + 32186441021LL, 419887147377229824LL, 32805411041LL, + 62577284826791936LL, + 33424381060LL, 705267422276354048LL, 34043351080LL, + 347957559725916160LL, + 34662321099LL, 990647697175478272LL, 35281291119LL, + 633337834625040384LL, + 35900261139LL, 276027972074602496LL, 36519231158LL, + 918718109524164608LL, + 37138201178LL, 561408246973726720LL, 37757171198LL, + 204098384423288832LL, + 38376141217LL, 846788521872850944LL, 38995111237LL, + 489478659322413056LL, + }, + + { + 0LL, 0LL, 39614081257LL, 132168796771975168LL, + 79228162514LL, 264337593543950336LL, 118842243771LL, + 396506390315925504LL, + 158456325028LL, 528675187087900672LL, 198070406285LL, + 660843983859875840LL, + 237684487542LL, 793012780631851008LL, 277298568799LL, + 925181577403826176LL, + 316912650057LL, 57350374175801344LL, 356526731314LL, + 189519170947776512LL, + 396140812571LL, 321687967719751680LL, 435754893828LL, + 453856764491726848LL, + 475368975085LL, 586025561263702016LL, 514983056342LL, + 718194358035677184LL, + 554597137599LL, 850363154807652352LL, 594211218856LL, + 982531951579627520LL, + 633825300114LL, 114700748351602688LL, 673439381371LL, + 246869545123577856LL, + 713053462628LL, 379038341895553024LL, 752667543885LL, + 511207138667528192LL, + 792281625142LL, 643375935439503360LL, 831895706399LL, + 775544732211478528LL, + 871509787656LL, 907713528983453696LL, 911123868914LL, + 39882325755428864LL, + 950737950171LL, 172051122527404032LL, 990352031428LL, + 304219919299379200LL, + 1029966112685LL, 436388716071354368LL, 1069580193942LL, + 568557512843329536LL, + 1109194275199LL, 700726309615304704LL, 1148808356456LL, + 832895106387279872LL, + 1188422437713LL, 965063903159255040LL, 1228036518971LL, + 97232699931230208LL, + 1267650600228LL, 229401496703205376LL, 1307264681485LL, + 361570293475180544LL, + 1346878762742LL, 493739090247155712LL, 1386492843999LL, + 625907887019130880LL, + 1426106925256LL, 758076683791106048LL, 1465721006513LL, + 890245480563081216LL, + 1505335087771LL, 22414277335056384LL, 1544949169028LL, + 154583074107031552LL, + 1584563250285LL, 286751870879006720LL, 1624177331542LL, + 418920667650981888LL, + 1663791412799LL, 551089464422957056LL, 1703405494056LL, + 683258261194932224LL, + 1743019575313LL, 815427057966907392LL, 1782633656570LL, + 947595854738882560LL, + 1822247737828LL, 79764651510857728LL, 1861861819085LL, + 211933448282832896LL, + 1901475900342LL, 344102245054808064LL, 1941089981599LL, + 476271041826783232LL, + 1980704062856LL, 608439838598758400LL, 2020318144113LL, + 740608635370733568LL, + 2059932225370LL, 872777432142708736LL, 2099546306628LL, + 4946228914683904LL, + 2139160387885LL, 137115025686659072LL, 2178774469142LL, + 269283822458634240LL, + 2218388550399LL, 401452619230609408LL, 2258002631656LL, + 533621416002584576LL, + 2297616712913LL, 665790212774559744LL, 2337230794170LL, + 797959009546534912LL, + 2376844875427LL, 930127806318510080LL, 2416458956685LL, + 62296603090485248LL, + 2456073037942LL, 194465399862460416LL, 2495687119199LL, + 326634196634435584LL, + }, + + { + 0LL, 0LL, 2535301200456LL, 458802993406410752LL, + 5070602400912LL, 917605986812821504LL, 7605903601369LL, + 376408980219232256LL, + 10141204801825LL, 835211973625643008LL, 12676506002282LL, + 294014967032053760LL, + 15211807202738LL, 752817960438464512LL, 17747108403195LL, + 211620953844875264LL, + 20282409603651LL, 670423947251286016LL, 22817710804108LL, + 129226940657696768LL, + 25353012004564LL, 588029934064107520LL, 27888313205021LL, + 46832927470518272LL, + 30423614405477LL, 505635920876929024LL, 32958915605933LL, + 964438914283339776LL, + 35494216806390LL, 423241907689750528LL, 38029518006846LL, + 882044901096161280LL, + 40564819207303LL, 340847894502572032LL, 43100120407759LL, + 799650887908982784LL, + 45635421608216LL, 258453881315393536LL, 48170722808672LL, + 717256874721804288LL, + 50706024009129LL, 176059868128215040LL, 53241325209585LL, + 634862861534625792LL, + 55776626410042LL, 93665854941036544LL, 58311927610498LL, + 552468848347447296LL, + 60847228810955LL, 11271841753858048LL, 63382530011411LL, + 470074835160268800LL, + 65917831211867LL, 928877828566679552LL, 68453132412324LL, + 387680821973090304LL, + 70988433612780LL, 846483815379501056LL, 73523734813237LL, + 305286808785911808LL, + 76059036013693LL, 764089802192322560LL, 78594337214150LL, + 222892795598733312LL, + 81129638414606LL, 681695789005144064LL, 83664939615063LL, + 140498782411554816LL, + 86200240815519LL, 599301775817965568LL, 88735542015976LL, + 58104769224376320LL, + 91270843216432LL, 516907762630787072LL, 93806144416888LL, + 975710756037197824LL, + 96341445617345LL, 434513749443608576LL, 98876746817801LL, + 893316742850019328LL, + 101412048018258LL, 352119736256430080LL, 103947349218714LL, + 810922729662840832LL, + 106482650419171LL, 269725723069251584LL, 109017951619627LL, + 728528716475662336LL, + 111553252820084LL, 187331709882073088LL, 114088554020540LL, + 646134703288483840LL, + 116623855220997LL, 104937696694894592LL, 119159156421453LL, + 563740690101305344LL, + 121694457621910LL, 22543683507716096LL, 124229758822366LL, + 481346676914126848LL, + 126765060022822LL, 940149670320537600LL, 129300361223279LL, + 398952663726948352LL, + 131835662423735LL, 857755657133359104LL, 134370963624192LL, + 316558650539769856LL, + 136906264824648LL, 775361643946180608LL, 139441566025105LL, + 234164637352591360LL, + 141976867225561LL, 692967630759002112LL, 144512168426018LL, + 151770624165412864LL, + 147047469626474LL, 610573617571823616LL, 149582770826931LL, + 69376610978234368LL, + 152118072027387LL, 528179604384645120LL, 154653373227843LL, + 986982597791055872LL, + 157188674428300LL, 445785591197466624LL, 159723975628756LL, + 904588584603877376LL, + }, + + { + 0LL, 0LL, 162259276829213LL, 363391578010288128LL, + 324518553658426LL, 726783156020576256LL, 486777830487640LL, + 90174734030864384LL, + 649037107316853LL, 453566312041152512LL, 811296384146066LL, + 816957890051440640LL, + 973555660975280LL, 180349468061728768LL, 1135814937804493LL, + 543741046072016896LL, + 1298074214633706LL, 907132624082305024LL, 1460333491462920LL, + 270524202092593152LL, + 1622592768292133LL, 633915780102881280LL, 1784852045121346LL, + 997307358113169408LL, + 1947111321950560LL, 360698936123457536LL, 2109370598779773LL, + 724090514133745664LL, + 2271629875608987LL, 87482092144033792LL, 2433889152438200LL, + 450873670154321920LL, + 2596148429267413LL, 814265248164610048LL, 2758407706096627LL, + 177656826174898176LL, + 2920666982925840LL, 541048404185186304LL, 3082926259755053LL, + 904439982195474432LL, + 3245185536584267LL, 267831560205762560LL, 3407444813413480LL, + 631223138216050688LL, + 3569704090242693LL, 994614716226338816LL, 3731963367071907LL, + 358006294236626944LL, + 3894222643901120LL, 721397872246915072LL, 4056481920730334LL, + 84789450257203200LL, + 4218741197559547LL, 448181028267491328LL, 4381000474388760LL, + 811572606277779456LL, + 4543259751217974LL, 174964184288067584LL, 4705519028047187LL, + 538355762298355712LL, + 4867778304876400LL, 901747340308643840LL, 5030037581705614LL, + 265138918318931968LL, + 5192296858534827LL, 628530496329220096LL, 5354556135364040LL, + 991922074339508224LL, + 5516815412193254LL, 355313652349796352LL, 5679074689022467LL, + 718705230360084480LL, + 5841333965851681LL, 82096808370372608LL, 6003593242680894LL, + 445488386380660736LL, + 6165852519510107LL, 808879964390948864LL, 6328111796339321LL, + 172271542401236992LL, + 6490371073168534LL, 535663120411525120LL, 6652630349997747LL, + 899054698421813248LL, + 6814889626826961LL, 262446276432101376LL, 6977148903656174LL, + 625837854442389504LL, + 7139408180485387LL, 989229432452677632LL, 7301667457314601LL, + 352621010462965760LL, + 7463926734143814LL, 716012588473253888LL, 7626186010973028LL, + 79404166483542016LL, + 7788445287802241LL, 442795744493830144LL, 7950704564631454LL, + 806187322504118272LL, + 8112963841460668LL, 169578900514406400LL, 8275223118289881LL, + 532970478524694528LL, + 8437482395119094LL, 896362056534982656LL, 8599741671948308LL, + 259753634545270784LL, + 8762000948777521LL, 623145212555558912LL, 8924260225606734LL, + 986536790565847040LL, + 9086519502435948LL, 349928368576135168LL, 9248778779265161LL, + 713319946586423296LL, + 9411038056094375LL, 76711524596711424LL, 9573297332923588LL, + 440103102606999552LL, + 9735556609752801LL, 803494680617287680LL, 9897815886582015LL, + 166886258627575808LL, + 10060075163411228LL, 530277836637863936LL, 10222334440240441LL, + 893669414648152064LL} +}; diff --git a/gcc-4.4.3/libgcc/config/libbid/bid128_add.c b/gcc-4.4.3/libgcc/config/libbid/bid128_add.c new file mode 100644 index 000000000..dacc7a1f6 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/bid128_add.c @@ -0,0 +1,2941 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_internal.h" + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid64dq_add (UINT64 * pres, UINT64 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 x = *px; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT64 +bid64dq_add (UINT64 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT64 res = 0xbaddbaddbaddbaddull; + UINT128 x1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&x1, &x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid64qq_add (&res, &x1, py + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + x1 = bid64_to_bid128 (x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid64qq_add (x1, y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid64qd_add (UINT64 * pres, UINT128 * px, UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT64 +bid64qd_add (UINT128 x, UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT64 res = 0xbaddbaddbaddbaddull; + UINT128 y1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&y1, &y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid64qq_add (&res, px, &y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + y1 = bid64_to_bid128 (y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid64qq_add (x, y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid64qq_add (UINT64 * pres, UINT128 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT128 x = *px, y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT64 +bid64qq_add (UINT128 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + + UINT128 one = { {0x0000000000000001ull, 0x3040000000000000ull} + }; + UINT64 res = 0xbaddbaddbaddbaddull; + + BID_SWAP128 (one); +#if DECIMAL_CALL_BY_REFERENCE + bid64qqq_fma (&res, &one, &x, &y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + res = bid64qqq_fma (one, x, y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128dd_add (UINT128 * pres, UINT64 * px, UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 x = *px, y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128dd_add (UINT64 x, UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} + }; + UINT128 x1, y1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&x1, &x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid64_to_bid128 (&y1, &y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid128_add (&res, &x1, &y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + x1 = bid64_to_bid128 (x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + y1 = bid64_to_bid128 (y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid128_add (x1, y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128dq_add (UINT128 * pres, UINT64 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 x = *px; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128dq_add (UINT64 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} + }; + UINT128 x1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&x1, &x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid128_add (&res, &x1, py + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + x1 = bid64_to_bid128 (x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid128_add (x1, y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128qd_add (UINT128 * pres, UINT128 * px, UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128qd_add (UINT128 x, UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} + }; + UINT128 y1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&y1, &y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid128_add (&res, px, &y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + y1 = bid64_to_bid128 (y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid128_add (x, y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +// bid128_add stands for bid128qq_add + + +/***************************************************************************** + * BID64/BID128 sub + ****************************************************************************/ + +#if DECIMAL_CALL_BY_REFERENCE +void +bid64dq_sub (UINT64 * pres, UINT64 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 x = *px; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT64 +bid64dq_sub (UINT64 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT64 res = 0xbaddbaddbaddbaddull; + UINT128 x1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&x1, &x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid64qq_sub (&res, &x1, py + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + x1 = bid64_to_bid128 (x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid64qq_sub (x1, y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid64qd_sub (UINT64 * pres, UINT128 * px, UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT64 +bid64qd_sub (UINT128 x, UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT64 res = 0xbaddbaddbaddbaddull; + UINT128 y1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&y1, &y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid64qq_sub (&res, px, &y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + y1 = bid64_to_bid128 (y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid64qq_sub (x, y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid64qq_sub (UINT64 * pres, UINT128 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT128 x = *px, y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT64 +bid64qq_sub (UINT128 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + + UINT128 one = { {0x0000000000000001ull, 0x3040000000000000ull} + }; + UINT64 res = 0xbaddbaddbaddbaddull; + UINT64 y_sign; + + BID_SWAP128 (one); + if ((y.w[HIGH_128W] & MASK_NAN) != MASK_NAN) { // y is not NAN + // change its sign + y_sign = y.w[HIGH_128W] & MASK_SIGN; // 0 for positive, MASK_SIGN for negative + if (y_sign) + y.w[HIGH_128W] = y.w[HIGH_128W] & 0x7fffffffffffffffull; + else + y.w[HIGH_128W] = y.w[HIGH_128W] | 0x8000000000000000ull; + } +#if DECIMAL_CALL_BY_REFERENCE + bid64qqq_fma (&res, &one, &x, &y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + res = bid64qqq_fma (one, x, y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128dd_sub (UINT128 * pres, UINT64 * px, UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 x = *px, y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128dd_sub (UINT64 x, UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} + }; + UINT128 x1, y1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&x1, &x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid64_to_bid128 (&y1, &y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid128_sub (&res, &x1, &y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + x1 = bid64_to_bid128 (x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + y1 = bid64_to_bid128 (y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid128_sub (x1, y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128dq_sub (UINT128 * pres, UINT64 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 x = *px; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128dq_sub (UINT64 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} + }; + UINT128 x1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&x1, &x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid128_sub (&res, &x1, py + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + x1 = bid64_to_bid128 (x _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid128_sub (x1, y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128qd_sub (UINT128 * pres, UINT128 * px, UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT64 y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128qd_sub (UINT128 x, UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} + }; + UINT128 y1; + +#if DECIMAL_CALL_BY_REFERENCE + bid64_to_bid128 (&y1, &y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + bid128_sub (&res, px, &y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + y1 = bid64_to_bid128 (y _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG); + res = bid128_sub (x, y1 + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128_add (UINT128 * pres, UINT128 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT128 x = *px, y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128_add (UINT128 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} + }; + UINT64 x_sign, y_sign, tmp_sign; + UINT64 x_exp, y_exp, tmp_exp; // e1 = x_exp, e2 = y_exp + UINT64 C1_hi, C2_hi, tmp_signif_hi; + UINT64 C1_lo, C2_lo, tmp_signif_lo; + // Note: C1.w[1], C1.w[0] represent C1_hi, C1_lo (all UINT64) + // Note: C2.w[1], C2.w[0] represent C2_hi, C2_lo (all UINT64) + UINT64 tmp64, tmp64A, tmp64B; + BID_UI64DOUBLE tmp1, tmp2; + int x_nr_bits, y_nr_bits; + int q1, q2, delta, scale, x1, ind, shift, tmp_inexact = 0; + UINT64 halfulp64; + UINT128 halfulp128; + UINT128 C1, C2; + UINT128 ten2m1; + UINT128 highf2star; // top 128 bits in f2*; low 128 bits in R256[1], R256[0] + UINT256 P256, Q256, R256; + int is_inexact = 0, is_midpoint_lt_even = 0, is_midpoint_gt_even = 0; + int is_inexact_lt_midpoint = 0, is_inexact_gt_midpoint = 0; + int second_pass = 0; + + BID_SWAP128 (x); + BID_SWAP128 (y); + x_sign = x.w[1] & MASK_SIGN; // 0 for positive, MASK_SIGN for negative + y_sign = y.w[1] & MASK_SIGN; // 0 for positive, MASK_SIGN for negative + + // check for NaN or Infinity + if (((x.w[1] & MASK_SPECIAL) == MASK_SPECIAL) + || ((y.w[1] & MASK_SPECIAL) == MASK_SPECIAL)) { + // x is special or y is special + if ((x.w[1] & MASK_NAN) == MASK_NAN) { // x is NAN + // check first for non-canonical NaN payload + if (((x.w[1] & 0x00003fffffffffffull) > 0x0000314dc6448d93ull) || + (((x.w[1] & 0x00003fffffffffffull) == 0x0000314dc6448d93ull) + && (x.w[0] > 0x38c15b09ffffffffull))) { + x.w[1] = x.w[1] & 0xffffc00000000000ull; + x.w[0] = 0x0ull; + } + if ((x.w[1] & MASK_SNAN) == MASK_SNAN) { // x is SNAN + // set invalid flag + *pfpsf |= INVALID_EXCEPTION; + // return quiet (x) + res.w[1] = x.w[1] & 0xfc003fffffffffffull; + // clear out also G[6]-G[16] + res.w[0] = x.w[0]; + } else { // x is QNaN + // return x + res.w[1] = x.w[1] & 0xfc003fffffffffffull; + // clear out G[6]-G[16] + res.w[0] = x.w[0]; + // if y = SNaN signal invalid exception + if ((y.w[1] & MASK_SNAN) == MASK_SNAN) { + // set invalid flag + *pfpsf |= INVALID_EXCEPTION; + } + } + BID_SWAP128 (res); + BID_RETURN (res); + } else if ((y.w[1] & MASK_NAN) == MASK_NAN) { // y is NAN + // check first for non-canonical NaN payload + if (((y.w[1] & 0x00003fffffffffffull) > 0x0000314dc6448d93ull) || + (((y.w[1] & 0x00003fffffffffffull) == 0x0000314dc6448d93ull) + && (y.w[0] > 0x38c15b09ffffffffull))) { + y.w[1] = y.w[1] & 0xffffc00000000000ull; + y.w[0] = 0x0ull; + } + if ((y.w[1] & MASK_SNAN) == MASK_SNAN) { // y is SNAN + // set invalid flag + *pfpsf |= INVALID_EXCEPTION; + // return quiet (y) + res.w[1] = y.w[1] & 0xfc003fffffffffffull; + // clear out also G[6]-G[16] + res.w[0] = y.w[0]; + } else { // y is QNaN + // return y + res.w[1] = y.w[1] & 0xfc003fffffffffffull; + // clear out G[6]-G[16] + res.w[0] = y.w[0]; + } + BID_SWAP128 (res); + BID_RETURN (res); + } else { // neither x not y is NaN; at least one is infinity + if ((x.w[1] & MASK_ANY_INF) == MASK_INF) { // x is infinity + if ((y.w[1] & MASK_ANY_INF) == MASK_INF) { // y is infinity + // if same sign, return either of them + if ((x.w[1] & MASK_SIGN) == (y.w[1] & MASK_SIGN)) { + res.w[1] = x_sign | MASK_INF; + res.w[0] = 0x0ull; + } else { // x and y are infinities of opposite signs + // set invalid flag + *pfpsf |= INVALID_EXCEPTION; + // return QNaN Indefinite + res.w[1] = 0x7c00000000000000ull; + res.w[0] = 0x0000000000000000ull; + } + } else { // y is 0 or finite + // return x + res.w[1] = x_sign | MASK_INF; + res.w[0] = 0x0ull; + } + } else { // x is not NaN or infinity, so y must be infinity + res.w[1] = y_sign | MASK_INF; + res.w[0] = 0x0ull; + } + BID_SWAP128 (res); + BID_RETURN (res); + } + } + // unpack the arguments + + // unpack x + C1_hi = x.w[1] & MASK_COEFF; + C1_lo = x.w[0]; + // test for non-canonical values: + // - values whose encoding begins with x00, x01, or x10 and whose + // coefficient is larger than 10^34 -1, or + // - values whose encoding begins with x1100, x1101, x1110 (if NaNs + // and infinitis were eliminated already this test is reduced to + // checking for x10x) + + // x is not infinity; check for non-canonical values - treated as zero + if ((x.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull) { + // G0_G1=11; non-canonical + x_exp = (x.w[1] << 2) & MASK_EXP; // biased and shifted left 49 bits + C1_hi = 0; // significand high + C1_lo = 0; // significand low + } else { // G0_G1 != 11 + x_exp = x.w[1] & MASK_EXP; // biased and shifted left 49 bits + if (C1_hi > 0x0001ed09bead87c0ull || + (C1_hi == 0x0001ed09bead87c0ull + && C1_lo > 0x378d8e63ffffffffull)) { + // x is non-canonical if coefficient is larger than 10^34 -1 + C1_hi = 0; + C1_lo = 0; + } else { // canonical + ; + } + } + + // unpack y + C2_hi = y.w[1] & MASK_COEFF; + C2_lo = y.w[0]; + // y is not infinity; check for non-canonical values - treated as zero + if ((y.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull) { + // G0_G1=11; non-canonical + y_exp = (y.w[1] << 2) & MASK_EXP; // biased and shifted left 49 bits + C2_hi = 0; // significand high + C2_lo = 0; // significand low + } else { // G0_G1 != 11 + y_exp = y.w[1] & MASK_EXP; // biased and shifted left 49 bits + if (C2_hi > 0x0001ed09bead87c0ull || + (C2_hi == 0x0001ed09bead87c0ull + && C2_lo > 0x378d8e63ffffffffull)) { + // y is non-canonical if coefficient is larger than 10^34 -1 + C2_hi = 0; + C2_lo = 0; + } else { // canonical + ; + } + } + + if ((C1_hi == 0x0ull) && (C1_lo == 0x0ull)) { + // x is 0 and y is not special + // if y is 0 return 0 with the smaller exponent + if ((C2_hi == 0x0ull) && (C2_lo == 0x0ull)) { + if (x_exp < y_exp) + res.w[1] = x_exp; + else + res.w[1] = y_exp; + if (x_sign && y_sign) + res.w[1] = res.w[1] | x_sign; // both negative + else if (rnd_mode == ROUNDING_DOWN && x_sign != y_sign) + res.w[1] = res.w[1] | 0x8000000000000000ull; // -0 + // else; // res = +0 + res.w[0] = 0; + } else { + // for 0 + y return y, with the preferred exponent + if (y_exp <= x_exp) { + res.w[1] = y.w[1]; + res.w[0] = y.w[0]; + } else { // if y_exp > x_exp + // return (C2 * 10^scale) * 10^(y_exp - scale) + // where scale = min (P34-q2, y_exp-x_exp) + // determine q2 = nr. of decimal digits in y + // determine first the nr. of bits in y (y_nr_bits) + + if (C2_hi == 0) { // y_bits is the nr. of bits in C2_lo + if (C2_lo >= 0x0020000000000000ull) { // y >= 2^53 + // split the 64-bit value in two 32-bit halves to avoid + // rounding errors + if (C2_lo >= 0x0000000100000000ull) { // y >= 2^32 + tmp2.d = (double) (C2_lo >> 32); // exact conversion + y_nr_bits = + 32 + + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } else { // y < 2^32 + tmp2.d = (double) (C2_lo); // exact conversion + y_nr_bits = + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // if y < 2^53 + tmp2.d = (double) C2_lo; // exact conversion + y_nr_bits = + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // C2_hi != 0 => nr. bits = 64 + nr_bits (C2_hi) + tmp2.d = (double) C2_hi; // exact conversion + y_nr_bits = + 64 + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + q2 = nr_digits[y_nr_bits].digits; + if (q2 == 0) { + q2 = nr_digits[y_nr_bits].digits1; + if (C2_hi > nr_digits[y_nr_bits].threshold_hi || + (C2_hi == nr_digits[y_nr_bits].threshold_hi && + C2_lo >= nr_digits[y_nr_bits].threshold_lo)) + q2++; + } + // return (C2 * 10^scale) * 10^(y_exp - scale) + // where scale = min (P34-q2, y_exp-x_exp) + scale = P34 - q2; + ind = (y_exp - x_exp) >> 49; + if (ind < scale) + scale = ind; + if (scale == 0) { + res.w[1] = y.w[1]; + res.w[0] = y.w[0]; + } else if (q2 <= 19) { // y fits in 64 bits + if (scale <= 19) { // 10^scale fits in 64 bits + // 64 x 64 C2_lo * ten2k64[scale] + __mul_64x64_to_128MACH (res, C2_lo, ten2k64[scale]); + } else { // 10^scale fits in 128 bits + // 64 x 128 C2_lo * ten2k128[scale - 20] + __mul_128x64_to_128 (res, C2_lo, ten2k128[scale - 20]); + } + } else { // y fits in 128 bits, but 10^scale must fit in 64 bits + // 64 x 128 ten2k64[scale] * C2 + C2.w[1] = C2_hi; + C2.w[0] = C2_lo; + __mul_128x64_to_128 (res, ten2k64[scale], C2); + } + // subtract scale from the exponent + y_exp = y_exp - ((UINT64) scale << 49); + res.w[1] = res.w[1] | y_sign | y_exp; + } + } + BID_SWAP128 (res); + BID_RETURN (res); + } else if ((C2_hi == 0x0ull) && (C2_lo == 0x0ull)) { + // y is 0 and x is not special, and not zero + // for x + 0 return x, with the preferred exponent + if (x_exp <= y_exp) { + res.w[1] = x.w[1]; + res.w[0] = x.w[0]; + } else { // if x_exp > y_exp + // return (C1 * 10^scale) * 10^(x_exp - scale) + // where scale = min (P34-q1, x_exp-y_exp) + // determine q1 = nr. of decimal digits in x + // determine first the nr. of bits in x + if (C1_hi == 0) { // x_bits is the nr. of bits in C1_lo + if (C1_lo >= 0x0020000000000000ull) { // x >= 2^53 + // split the 64-bit value in two 32-bit halves to avoid + // rounding errors + if (C1_lo >= 0x0000000100000000ull) { // x >= 2^32 + tmp1.d = (double) (C1_lo >> 32); // exact conversion + x_nr_bits = + 32 + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - + 0x3ff); + } else { // x < 2^32 + tmp1.d = (double) (C1_lo); // exact conversion + x_nr_bits = + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // if x < 2^53 + tmp1.d = (double) C1_lo; // exact conversion + x_nr_bits = + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // C1_hi != 0 => nr. bits = 64 + nr_bits (C1_hi) + tmp1.d = (double) C1_hi; // exact conversion + x_nr_bits = + 64 + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + q1 = nr_digits[x_nr_bits].digits; + if (q1 == 0) { + q1 = nr_digits[x_nr_bits].digits1; + if (C1_hi > nr_digits[x_nr_bits].threshold_hi || + (C1_hi == nr_digits[x_nr_bits].threshold_hi && + C1_lo >= nr_digits[x_nr_bits].threshold_lo)) + q1++; + } + // return (C1 * 10^scale) * 10^(x_exp - scale) + // where scale = min (P34-q1, x_exp-y_exp) + scale = P34 - q1; + ind = (x_exp - y_exp) >> 49; + if (ind < scale) + scale = ind; + if (scale == 0) { + res.w[1] = x.w[1]; + res.w[0] = x.w[0]; + } else if (q1 <= 19) { // x fits in 64 bits + if (scale <= 19) { // 10^scale fits in 64 bits + // 64 x 64 C1_lo * ten2k64[scale] + __mul_64x64_to_128MACH (res, C1_lo, ten2k64[scale]); + } else { // 10^scale fits in 128 bits + // 64 x 128 C1_lo * ten2k128[scale - 20] + __mul_128x64_to_128 (res, C1_lo, ten2k128[scale - 20]); + } + } else { // x fits in 128 bits, but 10^scale must fit in 64 bits + // 64 x 128 ten2k64[scale] * C1 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + __mul_128x64_to_128 (res, ten2k64[scale], C1); + } + // subtract scale from the exponent + x_exp = x_exp - ((UINT64) scale << 49); + res.w[1] = res.w[1] | x_sign | x_exp; + } + BID_SWAP128 (res); + BID_RETURN (res); + } else { // x and y are not canonical, not special, and are not zero + // note that the result may still be zero, and then it has to have the + // preferred exponent + if (x_exp < y_exp) { // if exp_x < exp_y then swap x and y + tmp_sign = x_sign; + tmp_exp = x_exp; + tmp_signif_hi = C1_hi; + tmp_signif_lo = C1_lo; + x_sign = y_sign; + x_exp = y_exp; + C1_hi = C2_hi; + C1_lo = C2_lo; + y_sign = tmp_sign; + y_exp = tmp_exp; + C2_hi = tmp_signif_hi; + C2_lo = tmp_signif_lo; + } + // q1 = nr. of decimal digits in x + // determine first the nr. of bits in x + if (C1_hi == 0) { // x_bits is the nr. of bits in C1_lo + if (C1_lo >= 0x0020000000000000ull) { // x >= 2^53 + //split the 64-bit value in two 32-bit halves to avoid rounding errors + if (C1_lo >= 0x0000000100000000ull) { // x >= 2^32 + tmp1.d = (double) (C1_lo >> 32); // exact conversion + x_nr_bits = + 32 + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff); + } else { // x < 2^32 + tmp1.d = (double) (C1_lo); // exact conversion + x_nr_bits = + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // if x < 2^53 + tmp1.d = (double) C1_lo; // exact conversion + x_nr_bits = + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // C1_hi != 0 => nr. bits = 64 + nr_bits (C1_hi) + tmp1.d = (double) C1_hi; // exact conversion + x_nr_bits = + 64 + ((((unsigned int) (tmp1.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + + q1 = nr_digits[x_nr_bits].digits; + if (q1 == 0) { + q1 = nr_digits[x_nr_bits].digits1; + if (C1_hi > nr_digits[x_nr_bits].threshold_hi || + (C1_hi == nr_digits[x_nr_bits].threshold_hi && + C1_lo >= nr_digits[x_nr_bits].threshold_lo)) + q1++; + } + // q2 = nr. of decimal digits in y + // determine first the nr. of bits in y (y_nr_bits) + if (C2_hi == 0) { // y_bits is the nr. of bits in C2_lo + if (C2_lo >= 0x0020000000000000ull) { // y >= 2^53 + //split the 64-bit value in two 32-bit halves to avoid rounding errors + if (C2_lo >= 0x0000000100000000ull) { // y >= 2^32 + tmp2.d = (double) (C2_lo >> 32); // exact conversion + y_nr_bits = + 32 + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } else { // y < 2^32 + tmp2.d = (double) (C2_lo); // exact conversion + y_nr_bits = + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // if y < 2^53 + tmp2.d = (double) C2_lo; // exact conversion + y_nr_bits = + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + } else { // C2_hi != 0 => nr. bits = 64 + nr_bits (C2_hi) + tmp2.d = (double) C2_hi; // exact conversion + y_nr_bits = + 64 + ((((unsigned int) (tmp2.ui64 >> 52)) & 0x7ff) - 0x3ff); + } + + q2 = nr_digits[y_nr_bits].digits; + if (q2 == 0) { + q2 = nr_digits[y_nr_bits].digits1; + if (C2_hi > nr_digits[y_nr_bits].threshold_hi || + (C2_hi == nr_digits[y_nr_bits].threshold_hi && + C2_lo >= nr_digits[y_nr_bits].threshold_lo)) + q2++; + } + + delta = q1 + (int) (x_exp >> 49) - q2 - (int) (y_exp >> 49); + + if (delta >= P34) { + // round the result directly because 0 < C2 < ulp (C1 * 10^(x_exp-e2)) + // n = C1 * 10^e1 or n = C1 +/- 10^(q1-P34)) * 10^e1 + // the result is inexact; the preferred exponent is the least possible + + if (delta >= P34 + 1) { + // for RN the result is the operand with the larger magnitude, + // possibly scaled up by 10^(P34-q1) + // an overflow cannot occur in this case (rounding to nearest) + if (q1 < P34) { // scale C1 up by 10^(P34-q1) + // Note: because delta >= P34+1 it is certain that + // x_exp - ((UINT64)scale << 49) will stay above e_min + scale = P34 - q1; + if (q1 <= 19) { // C1 fits in 64 bits + // 1 <= q1 <= 19 => 15 <= scale <= 33 + if (scale <= 19) { // 10^scale fits in 64 bits + __mul_64x64_to_128MACH (C1, ten2k64[scale], C1_lo); + } else { // if 20 <= scale <= 33 + // C1 * 10^scale = (C1 * 10^(scale-19)) * 10^19 where + // (C1 * 10^(scale-19)) fits in 64 bits + C1_lo = C1_lo * ten2k64[scale - 19]; + __mul_64x64_to_128MACH (C1, ten2k64[19], C1_lo); + } + } else { //if 20 <= q1 <= 33=P34-1 then C1 fits only in 128 bits + // => 1 <= P34 - q1 <= 14 so 10^(P34-q1) fits in 64 bits + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + // C1 = ten2k64[P34 - q1] * C1 + __mul_128x64_to_128 (C1, ten2k64[P34 - q1], C1); + } + x_exp = x_exp - ((UINT64) scale << 49); + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + } + // some special cases arise: if delta = P34 + 1 and C1 = 10^(P34-1) + // (after scaling) and x_sign != y_sign and C2 > 5*10^(q2-1) => + // subtract 1 ulp + // Note: do this only for rounding to nearest; for other rounding + // modes the correction will be applied next + if ((rnd_mode == ROUNDING_TO_NEAREST + || rnd_mode == ROUNDING_TIES_AWAY) && delta == (P34 + 1) + && C1_hi == 0x0000314dc6448d93ull + && C1_lo == 0x38c15b0a00000000ull && x_sign != y_sign + && ((q2 <= 19 && C2_lo > midpoint64[q2 - 1]) || (q2 >= 20 + && (C2_hi > + midpoint128 + [q2 - + 20]. + w[1] + || + (C2_hi + == + midpoint128 + [q2 - + 20]. + w[1] + && + C2_lo + > + midpoint128 + [q2 - + 20]. + w + [0]))))) + { + // C1 = 10^34 - 1 and decrement x_exp by 1 (no underflow possible) + C1_hi = 0x0001ed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; + } + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((rnd_mode == ROUNDING_DOWN && x_sign && y_sign) || + (rnd_mode == ROUNDING_UP && !x_sign && !y_sign)) { + // add 1 ulp and then check for overflow + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + if (x_exp == EXP_MAX_P1) { // overflow + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + x_exp = 0; // x_sign is preserved + // set overflow flag (the inexact flag was set too) + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } else if ((rnd_mode == ROUNDING_DOWN && !x_sign && y_sign) || + (rnd_mode == ROUNDING_UP && x_sign && !y_sign) || + (rnd_mode == ROUNDING_TO_ZERO + && x_sign != y_sign)) { + // subtract 1 ulp from C1 + // Note: because delta >= P34 + 1 the result cannot be zero + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi = C1_hi - 1; + // if the coefficient is 10^33 - 1 then make it 10^34 - 1 and + // decrease the exponent by 1 (because delta >= P34 + 1 the + // exponent will not become less than e_min) + // 10^33 - 1 = 0x0000314dc6448d9338c15b09ffffffff + // 10^34 - 1 = 0x0001ed09bead87c0378d8e63ffffffff + if (C1_hi == 0x0000314dc6448d93ull + && C1_lo == 0x38c15b09ffffffffull) { + // make C1 = 10^34 - 1 + C1_hi = 0x0001ed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; + } + } else { + ; // the result is already correct + } + } + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // assemble the result + res.w[1] = x_sign | x_exp | C1_hi; + res.w[0] = C1_lo; + } else { // delta = P34 + // in most cases, the smaller operand may be < or = or > 1/2 ulp of the + // larger operand + // however, the case C1 = 10^(q1-1) and x_sign != y_sign is special due + // to accuracy loss after subtraction, and will be treated separately + if (x_sign == y_sign || (q1 <= 20 + && (C1_hi != 0 + || C1_lo != ten2k64[q1 - 1])) + || (q1 >= 21 && (C1_hi != ten2k128[q1 - 21].w[1] + || C1_lo != ten2k128[q1 - 21].w[0]))) { + // if x_sign == y_sign or C1 != 10^(q1-1) + // compare C2 with 1/2 ulp = 5 * 10^(q2-1), the latter read from table + // Note: cases q1<=19 and q1>=20 can be coalesced at some latency cost + if (q2 <= 19) { // C2 and 5*10^(q2-1) both fit in 64 bits + halfulp64 = midpoint64[q2 - 1]; // 5 * 10^(q2-1) + if (C2_lo < halfulp64) { // n2 < 1/2 ulp (n1) + // for RN the result is the operand with the larger magnitude, + // possibly scaled up by 10^(P34-q1) + // an overflow cannot occur in this case (rounding to nearest) + if (q1 < P34) { // scale C1 up by 10^(P34-q1) + // Note: because delta = P34 it is certain that + // x_exp - ((UINT64)scale << 49) will stay above e_min + scale = P34 - q1; + if (q1 <= 19) { // C1 fits in 64 bits + // 1 <= q1 <= 19 => 15 <= scale <= 33 + if (scale <= 19) { // 10^scale fits in 64 bits + __mul_64x64_to_128MACH (C1, ten2k64[scale], C1_lo); + } else { // if 20 <= scale <= 33 + // C1 * 10^scale = (C1 * 10^(scale-19)) * 10^19 where + // (C1 * 10^(scale-19)) fits in 64 bits + C1_lo = C1_lo * ten2k64[scale - 19]; + __mul_64x64_to_128MACH (C1, ten2k64[19], C1_lo); + } + } else { //if 20 <= q1 <= 33=P34-1 then C1 fits only in 128 bits + // => 1 <= P34 - q1 <= 14 so 10^(P34-q1) fits in 64 bits + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + // C1 = ten2k64[P34 - q1] * C1 + __mul_128x64_to_128 (C1, ten2k64[P34 - q1], C1); + } + x_exp = x_exp - ((UINT64) scale << 49); + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + } + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((rnd_mode == ROUNDING_DOWN && x_sign && y_sign) || + (rnd_mode == ROUNDING_UP && !x_sign && !y_sign)) { + // add 1 ulp and then check for overflow + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + if (x_exp == EXP_MAX_P1) { // overflow + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + x_exp = 0; // x_sign is preserved + // set overflow flag (the inexact flag was set too) + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } else + if ((rnd_mode == ROUNDING_DOWN && !x_sign && y_sign) + || (rnd_mode == ROUNDING_UP && x_sign && !y_sign) + || (rnd_mode == ROUNDING_TO_ZERO + && x_sign != y_sign)) { + // subtract 1 ulp from C1 + // Note: because delta >= P34 + 1 the result cannot be zero + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi = C1_hi - 1; + // if the coefficient is 10^33-1 then make it 10^34-1 and + // decrease the exponent by 1 (because delta >= P34 + 1 the + // exponent will not become less than e_min) + // 10^33 - 1 = 0x0000314dc6448d9338c15b09ffffffff + // 10^34 - 1 = 0x0001ed09bead87c0378d8e63ffffffff + if (C1_hi == 0x0000314dc6448d93ull + && C1_lo == 0x38c15b09ffffffffull) { + // make C1 = 10^34 - 1 + C1_hi = 0x0001ed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; + } + } else { + ; // the result is already correct + } + } + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // assemble the result + res.w[1] = x_sign | x_exp | C1_hi; + res.w[0] = C1_lo; + } else if ((C2_lo == halfulp64) + && (q1 < P34 || ((C1_lo & 0x1) == 0))) { + // n2 = 1/2 ulp (n1) and C1 is even + // the result is the operand with the larger magnitude, + // possibly scaled up by 10^(P34-q1) + // an overflow cannot occur in this case (rounding to nearest) + if (q1 < P34) { // scale C1 up by 10^(P34-q1) + // Note: because delta = P34 it is certain that + // x_exp - ((UINT64)scale << 49) will stay above e_min + scale = P34 - q1; + if (q1 <= 19) { // C1 fits in 64 bits + // 1 <= q1 <= 19 => 15 <= scale <= 33 + if (scale <= 19) { // 10^scale fits in 64 bits + __mul_64x64_to_128MACH (C1, ten2k64[scale], C1_lo); + } else { // if 20 <= scale <= 33 + // C1 * 10^scale = (C1 * 10^(scale-19)) * 10^19 where + // (C1 * 10^(scale-19)) fits in 64 bits + C1_lo = C1_lo * ten2k64[scale - 19]; + __mul_64x64_to_128MACH (C1, ten2k64[19], C1_lo); + } + } else { //if 20 <= q1 <= 33=P34-1 then C1 fits only in 128 bits + // => 1 <= P34 - q1 <= 14 so 10^(P34-q1) fits in 64 bits + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + // C1 = ten2k64[P34 - q1] * C1 + __mul_128x64_to_128 (C1, ten2k64[P34 - q1], C1); + } + x_exp = x_exp - ((UINT64) scale << 49); + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + } + if ((rnd_mode == ROUNDING_TO_NEAREST && x_sign == y_sign + && (C1_lo & 0x01)) || (rnd_mode == ROUNDING_TIES_AWAY + && x_sign == y_sign) + || (rnd_mode == ROUNDING_UP && !x_sign && !y_sign) + || (rnd_mode == ROUNDING_DOWN && x_sign && y_sign)) { + // add 1 ulp and then check for overflow + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + if (x_exp == EXP_MAX_P1) { // overflow + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + x_exp = 0; // x_sign is preserved + // set overflow flag (the inexact flag was set too) + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } else + if ((rnd_mode == ROUNDING_TO_NEAREST && x_sign != y_sign + && (C1_lo & 0x01)) || (rnd_mode == ROUNDING_DOWN + && !x_sign && y_sign) + || (rnd_mode == ROUNDING_UP && x_sign && !y_sign) + || (rnd_mode == ROUNDING_TO_ZERO + && x_sign != y_sign)) { + // subtract 1 ulp from C1 + // Note: because delta >= P34 + 1 the result cannot be zero + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi = C1_hi - 1; + // if the coefficient is 10^33 - 1 then make it 10^34 - 1 + // and decrease the exponent by 1 (because delta >= P34 + 1 + // the exponent will not become less than e_min) + // 10^33 - 1 = 0x0000314dc6448d9338c15b09ffffffff + // 10^34 - 1 = 0x0001ed09bead87c0378d8e63ffffffff + if (C1_hi == 0x0000314dc6448d93ull + && C1_lo == 0x38c15b09ffffffffull) { + // make C1 = 10^34 - 1 + C1_hi = 0x0001ed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; + } + } else { + ; // the result is already correct + } + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // assemble the result + res.w[1] = x_sign | x_exp | C1_hi; + res.w[0] = C1_lo; + } else { // if C2_lo > halfulp64 || + // (C2_lo == halfulp64 && q1 == P34 && ((C1_lo & 0x1) == 1)), i.e. + // 1/2 ulp(n1) < n2 < 1 ulp(n1) or n2 = 1/2 ulp(n1) and C1 odd + // res = x+1 ulp if n1*n2 > 0 and res = x-1 ulp if n1*n2 < 0 + if (q1 < P34) { // then 1 ulp = 10^(e1+q1-P34) < 10^e1 + // Note: if (q1 == P34) then 1 ulp = 10^(e1+q1-P34) = 10^e1 + // because q1 < P34 we must first replace C1 by + // C1 * 10^(P34-q1), and must decrease the exponent by + // (P34-q1) (it will still be at least e_min) + scale = P34 - q1; + if (q1 <= 19) { // C1 fits in 64 bits + // 1 <= q1 <= 19 => 15 <= scale <= 33 + if (scale <= 19) { // 10^scale fits in 64 bits + __mul_64x64_to_128MACH (C1, ten2k64[scale], C1_lo); + } else { // if 20 <= scale <= 33 + // C1 * 10^scale = (C1 * 10^(scale-19)) * 10^19 where + // (C1 * 10^(scale-19)) fits in 64 bits + C1_lo = C1_lo * ten2k64[scale - 19]; + __mul_64x64_to_128MACH (C1, ten2k64[19], C1_lo); + } + } else { //if 20 <= q1 <= 33=P34-1 then C1 fits only in 128 bits + // => 1 <= P34 - q1 <= 14 so 10^(P34-q1) fits in 64 bits + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + // C1 = ten2k64[P34 - q1] * C1 + __mul_128x64_to_128 (C1, ten2k64[P34 - q1], C1); + } + x_exp = x_exp - ((UINT64) scale << 49); + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + // check for rounding overflow + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + } + } + if ((rnd_mode == ROUNDING_TO_NEAREST && x_sign != y_sign) + || (rnd_mode == ROUNDING_TIES_AWAY && x_sign != y_sign + && C2_lo != halfulp64) + || (rnd_mode == ROUNDING_DOWN && !x_sign && y_sign) + || (rnd_mode == ROUNDING_UP && x_sign && !y_sign) + || (rnd_mode == ROUNDING_TO_ZERO + && x_sign != y_sign)) { + // the result is x - 1 + // for RN n1 * n2 < 0; underflow not possible + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi--; + // check if we crossed into the lower decade + if (C1_hi == 0x0000314dc6448d93ull && C1_lo == 0x38c15b09ffffffffull) { // 10^33 - 1 + C1_hi = 0x0001ed09bead87c0ull; // 10^34 - 1 + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; // no underflow, because n1 >> n2 + } + } else + if ((rnd_mode == ROUNDING_TO_NEAREST + && x_sign == y_sign) + || (rnd_mode == ROUNDING_TIES_AWAY + && x_sign == y_sign) + || (rnd_mode == ROUNDING_DOWN && x_sign && y_sign) + || (rnd_mode == ROUNDING_UP && !x_sign + && !y_sign)) { + // the result is x + 1 + // for RN x_sign = y_sign, i.e. n1*n2 > 0 + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + if (x_exp == EXP_MAX_P1) { // overflow + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + x_exp = 0; // x_sign is preserved + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } else { + ; // the result is x + } + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // assemble the result + res.w[1] = x_sign | x_exp | C1_hi; + res.w[0] = C1_lo; + } + } else { // if q2 >= 20 then 5*10^(q2-1) and C2 (the latter in + // most cases) fit only in more than 64 bits + halfulp128 = midpoint128[q2 - 20]; // 5 * 10^(q2-1) + if ((C2_hi < halfulp128.w[1]) + || (C2_hi == halfulp128.w[1] + && C2_lo < halfulp128.w[0])) { + // n2 < 1/2 ulp (n1) + // the result is the operand with the larger magnitude, + // possibly scaled up by 10^(P34-q1) + // an overflow cannot occur in this case (rounding to nearest) + if (q1 < P34) { // scale C1 up by 10^(P34-q1) + // Note: because delta = P34 it is certain that + // x_exp - ((UINT64)scale << 49) will stay above e_min + scale = P34 - q1; + if (q1 <= 19) { // C1 fits in 64 bits + // 1 <= q1 <= 19 => 15 <= scale <= 33 + if (scale <= 19) { // 10^scale fits in 64 bits + __mul_64x64_to_128MACH (C1, ten2k64[scale], C1_lo); + } else { // if 20 <= scale <= 33 + // C1 * 10^scale = (C1 * 10^(scale-19)) * 10^19 where + // (C1 * 10^(scale-19)) fits in 64 bits + C1_lo = C1_lo * ten2k64[scale - 19]; + __mul_64x64_to_128MACH (C1, ten2k64[19], C1_lo); + } + } else { //if 20 <= q1 <= 33=P34-1 then C1 fits only in 128 bits + // => 1 <= P34 - q1 <= 14 so 10^(P34-q1) fits in 64 bits + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + // C1 = ten2k64[P34 - q1] * C1 + __mul_128x64_to_128 (C1, ten2k64[P34 - q1], C1); + } + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + x_exp = x_exp - ((UINT64) scale << 49); + } + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((rnd_mode == ROUNDING_DOWN && x_sign && y_sign) || + (rnd_mode == ROUNDING_UP && !x_sign && !y_sign)) { + // add 1 ulp and then check for overflow + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + if (x_exp == EXP_MAX_P1) { // overflow + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + x_exp = 0; // x_sign is preserved + // set overflow flag (the inexact flag was set too) + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } else + if ((rnd_mode == ROUNDING_DOWN && !x_sign && y_sign) + || (rnd_mode == ROUNDING_UP && x_sign && !y_sign) + || (rnd_mode == ROUNDING_TO_ZERO + && x_sign != y_sign)) { + // subtract 1 ulp from C1 + // Note: because delta >= P34 + 1 the result cannot be zero + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi = C1_hi - 1; + // if the coefficient is 10^33-1 then make it 10^34-1 and + // decrease the exponent by 1 (because delta >= P34 + 1 the + // exponent will not become less than e_min) + // 10^33 - 1 = 0x0000314dc6448d9338c15b09ffffffff + // 10^34 - 1 = 0x0001ed09bead87c0378d8e63ffffffff + if (C1_hi == 0x0000314dc6448d93ull + && C1_lo == 0x38c15b09ffffffffull) { + // make C1 = 10^34 - 1 + C1_hi = 0x0001ed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; + } + } else { + ; // the result is already correct + } + } + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // assemble the result + res.w[1] = x_sign | x_exp | C1_hi; + res.w[0] = C1_lo; + } else if ((C2_hi == halfulp128.w[1] + && C2_lo == halfulp128.w[0]) + && (q1 < P34 || ((C1_lo & 0x1) == 0))) { + // midpoint & lsb in C1 is 0 + // n2 = 1/2 ulp (n1) and C1 is even + // the result is the operand with the larger magnitude, + // possibly scaled up by 10^(P34-q1) + // an overflow cannot occur in this case (rounding to nearest) + if (q1 < P34) { // scale C1 up by 10^(P34-q1) + // Note: because delta = P34 it is certain that + // x_exp - ((UINT64)scale << 49) will stay above e_min + scale = P34 - q1; + if (q1 <= 19) { // C1 fits in 64 bits + // 1 <= q1 <= 19 => 15 <= scale <= 33 + if (scale <= 19) { // 10^scale fits in 64 bits + __mul_64x64_to_128MACH (C1, ten2k64[scale], C1_lo); + } else { // if 20 <= scale <= 33 + // C1 * 10^scale = (C1 * 10^(scale-19)) * 10^19 where + // (C1 * 10^(scale-19)) fits in 64 bits + C1_lo = C1_lo * ten2k64[scale - 19]; + __mul_64x64_to_128MACH (C1, ten2k64[19], C1_lo); + } + } else { //if 20 <= q1 <= 33=P34-1 then C1 fits only in 128 bits + // => 1 <= P34 - q1 <= 14 so 10^(P34-q1) fits in 64 bits + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + // C1 = ten2k64[P34 - q1] * C1 + __mul_128x64_to_128 (C1, ten2k64[P34 - q1], C1); + } + x_exp = x_exp - ((UINT64) scale << 49); + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + } + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((rnd_mode == ROUNDING_TIES_AWAY && x_sign == y_sign) + || (rnd_mode == ROUNDING_UP && !y_sign)) { + // add 1 ulp and then check for overflow + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + if (x_exp == EXP_MAX_P1) { // overflow + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + x_exp = 0; // x_sign is preserved + // set overflow flag (the inexact flag was set too) + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } else if ((rnd_mode == ROUNDING_DOWN && y_sign) + || (rnd_mode == ROUNDING_TO_ZERO + && x_sign != y_sign)) { + // subtract 1 ulp from C1 + // Note: because delta >= P34 + 1 the result cannot be zero + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi = C1_hi - 1; + // if the coefficient is 10^33 - 1 then make it 10^34 - 1 + // and decrease the exponent by 1 (because delta >= P34 + 1 + // the exponent will not become less than e_min) + // 10^33 - 1 = 0x0000314dc6448d9338c15b09ffffffff + // 10^34 - 1 = 0x0001ed09bead87c0378d8e63ffffffff + if (C1_hi == 0x0000314dc6448d93ull + && C1_lo == 0x38c15b09ffffffffull) { + // make C1 = 10^34 - 1 + C1_hi = 0x0001ed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; + } + } else { + ; // the result is already correct + } + } + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // assemble the result + res.w[1] = x_sign | x_exp | C1_hi; + res.w[0] = C1_lo; + } else { // if C2 > halfulp128 || + // (C2 == halfulp128 && q1 == P34 && ((C1 & 0x1) == 1)), i.e. + // 1/2 ulp(n1) < n2 < 1 ulp(n1) or n2 = 1/2 ulp(n1) and C1 odd + // res = x+1 ulp if n1*n2 > 0 and res = x-1 ulp if n1*n2 < 0 + if (q1 < P34) { // then 1 ulp = 10^(e1+q1-P34) < 10^e1 + // Note: if (q1 == P34) then 1 ulp = 10^(e1+q1-P34) = 10^e1 + // because q1 < P34 we must first replace C1 by C1*10^(P34-q1), + // and must decrease the exponent by (P34-q1) (it will still be + // at least e_min) + scale = P34 - q1; + if (q1 <= 19) { // C1 fits in 64 bits + // 1 <= q1 <= 19 => 15 <= scale <= 33 + if (scale <= 19) { // 10^scale fits in 64 bits + __mul_64x64_to_128MACH (C1, ten2k64[scale], C1_lo); + } else { // if 20 <= scale <= 33 + // C1 * 10^scale = (C1 * 10^(scale-19)) * 10^19 where + // (C1 * 10^(scale-19)) fits in 64 bits + C1_lo = C1_lo * ten2k64[scale - 19]; + __mul_64x64_to_128MACH (C1, ten2k64[19], C1_lo); + } + } else { //if 20 <= q1 <= 33=P34-1 then C1 fits only in 128 bits + // => 1 <= P34 - q1 <= 14 so 10^(P34-q1) fits in 64 bits + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + // C1 = ten2k64[P34 - q1] * C1 + __mul_128x64_to_128 (C1, ten2k64[P34 - q1], C1); + } + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + x_exp = x_exp - ((UINT64) scale << 49); + } + if ((rnd_mode == ROUNDING_TO_NEAREST && x_sign != y_sign) + || (rnd_mode == ROUNDING_TIES_AWAY && x_sign != y_sign + && (C2_hi != halfulp128.w[1] + || C2_lo != halfulp128.w[0])) + || (rnd_mode == ROUNDING_DOWN && !x_sign && y_sign) + || (rnd_mode == ROUNDING_UP && x_sign && !y_sign) + || (rnd_mode == ROUNDING_TO_ZERO + && x_sign != y_sign)) { + // the result is x - 1 + // for RN n1 * n2 < 0; underflow not possible + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi--; + // check if we crossed into the lower decade + if (C1_hi == 0x0000314dc6448d93ull && C1_lo == 0x38c15b09ffffffffull) { // 10^33 - 1 + C1_hi = 0x0001ed09bead87c0ull; // 10^34 - 1 + C1_lo = 0x378d8e63ffffffffull; + x_exp = x_exp - EXP_P1; // no underflow, because n1 >> n2 + } + } else + if ((rnd_mode == ROUNDING_TO_NEAREST + && x_sign == y_sign) + || (rnd_mode == ROUNDING_TIES_AWAY + && x_sign == y_sign) + || (rnd_mode == ROUNDING_DOWN && x_sign && y_sign) + || (rnd_mode == ROUNDING_UP && !x_sign + && !y_sign)) { + // the result is x + 1 + // for RN x_sign = y_sign, i.e. n1*n2 > 0 + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + x_exp = x_exp + EXP_P1; + if (x_exp == EXP_MAX_P1) { // overflow + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + x_exp = 0; // x_sign is preserved + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } else { + ; // the result is x + } + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // assemble the result + res.w[1] = x_sign | x_exp | C1_hi; + res.w[0] = C1_lo; + } + } // end q1 >= 20 + // end case where C1 != 10^(q1-1) + } else { // C1 = 10^(q1-1) and x_sign != y_sign + // instead of C' = (C1 * 10^(e1-e2) + C2)rnd,P34 + // calculate C' = C1 * 10^(e1-e2-x1) + (C2 * 10^(-x1))rnd,P34 + // where x1 = q2 - 1, 0 <= x1 <= P34 - 1 + // Because C1 = 10^(q1-1) and x_sign != y_sign, C' will have P34 + // digits and n = C' * 10^(e2+x1) + // If the result has P34+1 digits, redo the steps above with x1+1 + // If the result has P34-1 digits or less, redo the steps above with + // x1-1 but only if initially x1 >= 1 + // NOTE: these two steps can be improved, e.g we could guess if + // P34+1 or P34-1 digits will be obtained by adding/subtracting + // just the top 64 bits of the two operands + // The result cannot be zero, and it cannot overflow + x1 = q2 - 1; // 0 <= x1 <= P34-1 + // Calculate C1 * 10^(e1-e2-x1) where 1 <= e1-e2-x1 <= P34 + // scale = (int)(e1 >> 49) - (int)(e2 >> 49) - x1; 0 <= scale <= P34-1 + scale = P34 - q1 + 1; // scale=e1-e2-x1 = P34+1-q1; 1<=scale<=P34 + // either C1 or 10^(e1-e2-x1) may not fit is 64 bits, + // but their product fits with certainty in 128 bits + if (scale >= 20) { //10^(e1-e2-x1) doesn't fit in 64 bits, but C1 does + __mul_128x64_to_128 (C1, C1_lo, ten2k128[scale - 20]); + } else { // if (scale >= 1 + // if 1 <= scale <= 19 then 10^(e1-e2-x1) fits in 64 bits + if (q1 <= 19) { // C1 fits in 64 bits + __mul_64x64_to_128MACH (C1, C1_lo, ten2k64[scale]); + } else { // q1 >= 20 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + __mul_128x64_to_128 (C1, ten2k64[scale], C1); + } + } + tmp64 = C1.w[0]; // C1.w[1], C1.w[0] contains C1 * 10^(e1-e2-x1) + + // now round C2 to q2-x1 = 1 decimal digit + // C2' = C2 + 1/2 * 10^x1 = C2 + 5 * 10^(x1-1) + ind = x1 - 1; // -1 <= ind <= P34 - 2 + if (ind >= 0) { // if (x1 >= 1) + C2.w[0] = C2_lo; + C2.w[1] = C2_hi; + if (ind <= 18) { + C2.w[0] = C2.w[0] + midpoint64[ind]; + if (C2.w[0] < C2_lo) + C2.w[1]++; + } else { // 19 <= ind <= 32 + C2.w[0] = C2.w[0] + midpoint128[ind - 19].w[0]; + C2.w[1] = C2.w[1] + midpoint128[ind - 19].w[1]; + if (C2.w[0] < C2_lo) + C2.w[1]++; + } + // the approximation of 10^(-x1) was rounded up to 118 bits + __mul_128x128_to_256 (R256, C2, ten2mk128[ind]); // R256 = C2*, f2* + // calculate C2* and f2* + // C2* is actually floor(C2*) in this case + // C2* and f2* need shifting and masking, as shown by + // shiftright128[] and maskhigh128[] + // the top Ex bits of 10^(-x1) are T* = ten2mk128trunc[ind], e.g. + // if x1=1, T*=ten2mk128trunc[0]=0x19999999999999999999999999999999 + // if (0 < f2* < 10^(-x1)) then + // if floor(C1+C2*) is even then C2* = floor(C2*) - logical right + // shift; C2* has p decimal digits, correct by Prop. 1) + // else if floor(C1+C2*) is odd C2* = floor(C2*)-1 (logical right + // shift; C2* has p decimal digits, correct by Pr. 1) + // else + // C2* = floor(C2*) (logical right shift; C has p decimal digits, + // correct by Property 1) + // n = C2* * 10^(e2+x1) + + if (ind <= 2) { + highf2star.w[1] = 0x0; + highf2star.w[0] = 0x0; // low f2* ok + } else if (ind <= 21) { + highf2star.w[1] = 0x0; + highf2star.w[0] = R256.w[2] & maskhigh128[ind]; // low f2* ok + } else { + highf2star.w[1] = R256.w[3] & maskhigh128[ind]; + highf2star.w[0] = R256.w[2]; // low f2* is ok + } + // shift right C2* by Ex-128 = shiftright128[ind] + if (ind >= 3) { + shift = shiftright128[ind]; + if (shift < 64) { // 3 <= shift <= 63 + R256.w[2] = + (R256.w[2] >> shift) | (R256.w[3] << (64 - shift)); + R256.w[3] = (R256.w[3] >> shift); + } else { // 66 <= shift <= 102 + R256.w[2] = (R256.w[3] >> (shift - 64)); + R256.w[3] = 0x0ULL; + } + } + // redundant + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + is_midpoint_lt_even = 0; + is_midpoint_gt_even = 0; + // determine inexactness of the rounding of C2* + // (cannot be followed by a second rounding) + // if (0 < f2* - 1/2 < 10^(-x1)) then + // the result is exact + // else (if f2* - 1/2 > T* then) + // the result of is inexact + if (ind <= 2) { + if (R256.w[1] > 0x8000000000000000ull || + (R256.w[1] == 0x8000000000000000ull + && R256.w[0] > 0x0ull)) { + // f2* > 1/2 and the result may be exact + tmp64A = R256.w[1] - 0x8000000000000000ull; // f* - 1/2 + if ((tmp64A > ten2mk128trunc[ind].w[1] + || (tmp64A == ten2mk128trunc[ind].w[1] + && R256.w[0] >= ten2mk128trunc[ind].w[0]))) { + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // this rounding is applied to C2 only! + // x_sign != y_sign + is_inexact_gt_midpoint = 1; + } // else the result is exact + // rounding down, unless a midpoint in [ODD, EVEN] + } else { // the result is inexact; f2* <= 1/2 + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // this rounding is applied to C2 only! + // x_sign != y_sign + is_inexact_lt_midpoint = 1; + } + } else if (ind <= 21) { // if 3 <= ind <= 21 + if (highf2star.w[1] > 0x0 || (highf2star.w[1] == 0x0 + && highf2star.w[0] > + onehalf128[ind]) + || (highf2star.w[1] == 0x0 + && highf2star.w[0] == onehalf128[ind] + && (R256.w[1] || R256.w[0]))) { + // f2* > 1/2 and the result may be exact + // Calculate f2* - 1/2 + tmp64A = highf2star.w[0] - onehalf128[ind]; + tmp64B = highf2star.w[1]; + if (tmp64A > highf2star.w[0]) + tmp64B--; + if (tmp64B || tmp64A + || R256.w[1] > ten2mk128trunc[ind].w[1] + || (R256.w[1] == ten2mk128trunc[ind].w[1] + && R256.w[0] > ten2mk128trunc[ind].w[0])) { + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // this rounding is applied to C2 only! + // x_sign != y_sign + is_inexact_gt_midpoint = 1; + } // else the result is exact + } else { // the result is inexact; f2* <= 1/2 + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // this rounding is applied to C2 only! + // x_sign != y_sign + is_inexact_lt_midpoint = 1; + } + } else { // if 22 <= ind <= 33 + if (highf2star.w[1] > onehalf128[ind] + || (highf2star.w[1] == onehalf128[ind] + && (highf2star.w[0] || R256.w[1] + || R256.w[0]))) { + // f2* > 1/2 and the result may be exact + // Calculate f2* - 1/2 + // tmp64A = highf2star.w[0]; + tmp64B = highf2star.w[1] - onehalf128[ind]; + if (tmp64B || highf2star.w[0] + || R256.w[1] > ten2mk128trunc[ind].w[1] + || (R256.w[1] == ten2mk128trunc[ind].w[1] + && R256.w[0] > ten2mk128trunc[ind].w[0])) { + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // this rounding is applied to C2 only! + // x_sign != y_sign + is_inexact_gt_midpoint = 1; + } // else the result is exact + } else { // the result is inexact; f2* <= 1/2 + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // this rounding is applied to C2 only! + // x_sign != y_sign + is_inexact_lt_midpoint = 1; + } + } + // check for midpoints after determining inexactness + if ((R256.w[1] || R256.w[0]) && (highf2star.w[1] == 0) + && (highf2star.w[0] == 0) + && (R256.w[1] < ten2mk128trunc[ind].w[1] + || (R256.w[1] == ten2mk128trunc[ind].w[1] + && R256.w[0] <= ten2mk128trunc[ind].w[0]))) { + // the result is a midpoint + if ((tmp64 + R256.w[2]) & 0x01) { // MP in [EVEN, ODD] + // if floor(C2*) is odd C = floor(C2*) - 1; the result may be 0 + R256.w[2]--; + if (R256.w[2] == 0xffffffffffffffffull) + R256.w[3]--; + // this rounding is applied to C2 only! + // x_sign != y_sign + is_midpoint_lt_even = 1; + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + } else { + // else MP in [ODD, EVEN] + // this rounding is applied to C2 only! + // x_sign != y_sign + is_midpoint_gt_even = 1; + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + } + } + } else { // if (ind == -1) only when x1 = 0 + R256.w[2] = C2_lo; + R256.w[3] = C2_hi; + is_midpoint_lt_even = 0; + is_midpoint_gt_even = 0; + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + } + // and now subtract C1 * 10^(e1-e2-x1) - (C2 * 10^(-x1))rnd,P34 + // because x_sign != y_sign this last operation is exact + C1.w[0] = C1.w[0] - R256.w[2]; + C1.w[1] = C1.w[1] - R256.w[3]; + if (C1.w[0] > tmp64) + C1.w[1]--; // borrow + if (C1.w[1] >= 0x8000000000000000ull) { // negative coefficient! + C1.w[0] = ~C1.w[0]; + C1.w[0]++; + C1.w[1] = ~C1.w[1]; + if (C1.w[0] == 0x0) + C1.w[1]++; + tmp_sign = y_sign; // the result will have the sign of y + } else { + tmp_sign = x_sign; + } + // the difference has exactly P34 digits + x_sign = tmp_sign; + if (x1 >= 1) + y_exp = y_exp + ((UINT64) x1 << 49); + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + // general correction from RN to RA, RM, RP, RZ; result uses y_exp + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((!x_sign + && ((rnd_mode == ROUNDING_UP && is_inexact_lt_midpoint) + || + ((rnd_mode == ROUNDING_TIES_AWAY + || rnd_mode == ROUNDING_UP) + && is_midpoint_gt_even))) || (x_sign + && + ((rnd_mode == + ROUNDING_DOWN + && + is_inexact_lt_midpoint) + || + ((rnd_mode == + ROUNDING_TIES_AWAY + || rnd_mode == + ROUNDING_DOWN) + && + is_midpoint_gt_even)))) + { + // C1 = C1 + 1 + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + y_exp = y_exp + EXP_P1; + } + } else if ((is_midpoint_lt_even || is_inexact_gt_midpoint) + && + ((x_sign + && (rnd_mode == ROUNDING_UP + || rnd_mode == ROUNDING_TO_ZERO)) + || (!x_sign + && (rnd_mode == ROUNDING_DOWN + || rnd_mode == ROUNDING_TO_ZERO)))) { + // C1 = C1 - 1 + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi--; + // check if we crossed into the lower decade + if (C1_hi == 0x0000314dc6448d93ull && C1_lo == 0x38c15b09ffffffffull) { // 10^33 - 1 + C1_hi = 0x0001ed09bead87c0ull; // 10^34 - 1 + C1_lo = 0x378d8e63ffffffffull; + y_exp = y_exp - EXP_P1; + // no underflow, because delta + q2 >= P34 + 1 + } + } else { + ; // exact, the result is already correct + } + } + // assemble the result + res.w[1] = x_sign | y_exp | C1_hi; + res.w[0] = C1_lo; + } + } // end delta = P34 + } else { // if (|delta| <= P34 - 1) + if (delta >= 0) { // if (0 <= delta <= P34 - 1) + if (delta <= P34 - 1 - q2) { + // calculate C' directly; the result is exact + // in this case 1<=q1<=P34-1, 1<=q2<=P34-1 and 0 <= e1-e2 <= P34-2 + // The coefficient of the result is C1 * 10^(e1-e2) + C2 and the + // exponent is e2; either C1 or 10^(e1-e2) may not fit is 64 bits, + // but their product fits with certainty in 128 bits (actually in 113) + scale = delta - q1 + q2; // scale = (int)(e1 >> 49) - (int)(e2 >> 49) + + if (scale >= 20) { // 10^(e1-e2) does not fit in 64 bits, but C1 does + __mul_128x64_to_128 (C1, C1_lo, ten2k128[scale - 20]); + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + } else if (scale >= 1) { + // if 1 <= scale <= 19 then 10^(e1-e2) fits in 64 bits + if (q1 <= 19) { // C1 fits in 64 bits + __mul_64x64_to_128MACH (C1, C1_lo, ten2k64[scale]); + } else { // q1 >= 20 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + __mul_128x64_to_128 (C1, ten2k64[scale], C1); + } + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + } else { // if (scale == 0) C1 is unchanged + C1.w[0] = C1_lo; // C1.w[1] = C1_hi; + } + // now add C2 + if (x_sign == y_sign) { + // the result cannot overflow + C1_lo = C1_lo + C2_lo; + C1_hi = C1_hi + C2_hi; + if (C1_lo < C1.w[0]) + C1_hi++; + } else { // if x_sign != y_sign + C1_lo = C1_lo - C2_lo; + C1_hi = C1_hi - C2_hi; + if (C1_lo > C1.w[0]) + C1_hi--; + // the result can be zero, but it cannot overflow + if (C1_lo == 0 && C1_hi == 0) { + // assemble the result + if (x_exp < y_exp) + res.w[1] = x_exp; + else + res.w[1] = y_exp; + res.w[0] = 0; + if (rnd_mode == ROUNDING_DOWN) { + res.w[1] |= 0x8000000000000000ull; + } + BID_SWAP128 (res); + BID_RETURN (res); + } + if (C1_hi >= 0x8000000000000000ull) { // negative coefficient! + C1_lo = ~C1_lo; + C1_lo++; + C1_hi = ~C1_hi; + if (C1_lo == 0x0) + C1_hi++; + x_sign = y_sign; // the result will have the sign of y + } + } + // assemble the result + res.w[1] = x_sign | y_exp | C1_hi; + res.w[0] = C1_lo; + } else if (delta == P34 - q2) { + // calculate C' directly; the result may be inexact if it requires + // P34+1 decimal digits; in this case the 'cutoff' point for addition + // is at the position of the lsb of C2, so 0 <= e1-e2 <= P34-1 + // The coefficient of the result is C1 * 10^(e1-e2) + C2 and the + // exponent is e2; either C1 or 10^(e1-e2) may not fit is 64 bits, + // but their product fits with certainty in 128 bits (actually in 113) + scale = delta - q1 + q2; // scale = (int)(e1 >> 49) - (int)(e2 >> 49) + if (scale >= 20) { // 10^(e1-e2) does not fit in 64 bits, but C1 does + __mul_128x64_to_128 (C1, C1_lo, ten2k128[scale - 20]); + } else if (scale >= 1) { + // if 1 <= scale <= 19 then 10^(e1-e2) fits in 64 bits + if (q1 <= 19) { // C1 fits in 64 bits + __mul_64x64_to_128MACH (C1, C1_lo, ten2k64[scale]); + } else { // q1 >= 20 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + __mul_128x64_to_128 (C1, ten2k64[scale], C1); + } + } else { // if (scale == 0) C1 is unchanged + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; // only the low part is necessary + } + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + // now add C2 + if (x_sign == y_sign) { + // the result can overflow! + C1_lo = C1_lo + C2_lo; + C1_hi = C1_hi + C2_hi; + if (C1_lo < C1.w[0]) + C1_hi++; + // test for overflow, possible only when C1 >= 10^34 + if (C1_hi > 0x0001ed09bead87c0ull || (C1_hi == 0x0001ed09bead87c0ull && C1_lo >= 0x378d8e6400000000ull)) { // C1 >= 10^34 + // in this case q = P34 + 1 and x = q - P34 = 1, so multiply + // C'' = C'+ 5 = C1 + 5 by k1 ~ 10^(-1) calculated for P34 + 1 + // decimal digits + // Calculate C'' = C' + 1/2 * 10^x + if (C1_lo >= 0xfffffffffffffffbull) { // low half add has carry + C1_lo = C1_lo + 5; + C1_hi = C1_hi + 1; + } else { + C1_lo = C1_lo + 5; + } + // the approximation of 10^(-1) was rounded up to 118 bits + // 10^(-1) =~ 33333333333333333333333333333400 * 2^-129 + // 10^(-1) =~ 19999999999999999999999999999a00 * 2^-128 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; // C'' + ten2m1.w[1] = 0x1999999999999999ull; + ten2m1.w[0] = 0x9999999999999a00ull; + __mul_128x128_to_256 (P256, C1, ten2m1); // P256 = C*, f* + // C* is actually floor(C*) in this case + // the top Ex = 128 bits of 10^(-1) are + // T* = 0x00199999999999999999999999999999 + // if (0 < f* < 10^(-x)) then + // if floor(C*) is even then C = floor(C*) - logical right + // shift; C has p decimal digits, correct by Prop. 1) + // else if floor(C*) is odd C = floor(C*) - 1 (logical right + // shift; C has p decimal digits, correct by Pr. 1) + // else + // C = floor(C*) (logical right shift; C has p decimal digits, + // correct by Property 1) + // n = C * 10^(e2+x) + if ((P256.w[1] || P256.w[0]) + && (P256.w[1] < 0x1999999999999999ull + || (P256.w[1] == 0x1999999999999999ull + && P256.w[0] <= 0x9999999999999999ull))) { + // the result is a midpoint + if (P256.w[2] & 0x01) { + is_midpoint_gt_even = 1; + // if floor(C*) is odd C = floor(C*) - 1; the result is not 0 + P256.w[2]--; + if (P256.w[2] == 0xffffffffffffffffull) + P256.w[3]--; + } else { + is_midpoint_lt_even = 1; + } + } + // n = Cstar * 10^(e2+1) + y_exp = y_exp + EXP_P1; + // C* != 10^P because C* has P34 digits + // check for overflow + if (y_exp == EXP_MAX_P1 + && (rnd_mode == ROUNDING_TO_NEAREST + || rnd_mode == ROUNDING_TIES_AWAY)) { + // overflow for RN + res.w[1] = x_sign | 0x7800000000000000ull; // +/-inf + res.w[0] = 0x0ull; + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + BID_SWAP128 (res); + BID_RETURN (res); + } + // if (0 < f* - 1/2 < 10^(-x)) then + // the result of the addition is exact + // else + // the result of the addition is inexact + if (P256.w[1] > 0x8000000000000000ull || (P256.w[1] == 0x8000000000000000ull && P256.w[0] > 0x0ull)) { // the result may be exact + tmp64 = P256.w[1] - 0x8000000000000000ull; // f* - 1/2 + if ((tmp64 > 0x1999999999999999ull + || (tmp64 == 0x1999999999999999ull + && P256.w[0] >= 0x9999999999999999ull))) { + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + is_inexact = 1; + } // else the result is exact + } else { // the result is inexact + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + is_inexact = 1; + } + C1_hi = P256.w[3]; + C1_lo = P256.w[2]; + if (!is_midpoint_gt_even && !is_midpoint_lt_even) { + is_inexact_lt_midpoint = is_inexact + && (P256.w[1] & 0x8000000000000000ull); + is_inexact_gt_midpoint = is_inexact + && !(P256.w[1] & 0x8000000000000000ull); + } + // general correction from RN to RA, RM, RP, RZ; + // result uses y_exp + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((!x_sign + && + ((rnd_mode == ROUNDING_UP + && is_inexact_lt_midpoint) + || + ((rnd_mode == ROUNDING_TIES_AWAY + || rnd_mode == ROUNDING_UP) + && is_midpoint_gt_even))) || (x_sign + && + ((rnd_mode == + ROUNDING_DOWN + && + is_inexact_lt_midpoint) + || + ((rnd_mode == + ROUNDING_TIES_AWAY + || rnd_mode == + ROUNDING_DOWN) + && + is_midpoint_gt_even)))) + { + // C1 = C1 + 1 + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + y_exp = y_exp + EXP_P1; + } + } else + if ((is_midpoint_lt_even || is_inexact_gt_midpoint) + && + ((x_sign + && (rnd_mode == ROUNDING_UP + || rnd_mode == ROUNDING_TO_ZERO)) + || (!x_sign + && (rnd_mode == ROUNDING_DOWN + || rnd_mode == ROUNDING_TO_ZERO)))) { + // C1 = C1 - 1 + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi--; + // check if we crossed into the lower decade + if (C1_hi == 0x0000314dc6448d93ull && C1_lo == 0x38c15b09ffffffffull) { // 10^33 - 1 + C1_hi = 0x0001ed09bead87c0ull; // 10^34 - 1 + C1_lo = 0x378d8e63ffffffffull; + y_exp = y_exp - EXP_P1; + // no underflow, because delta + q2 >= P34 + 1 + } + } else { + ; // exact, the result is already correct + } + // in all cases check for overflow (RN and RA solved already) + if (y_exp == EXP_MAX_P1) { // overflow + if ((rnd_mode == ROUNDING_DOWN && x_sign) || // RM and res < 0 + (rnd_mode == ROUNDING_UP && !x_sign)) { // RP and res > 0 + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + } else { // RM and res > 0, RP and res < 0, or RZ + C1_hi = 0x5fffed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + } + y_exp = 0; // x_sign is preserved + // set the inexact flag (in case the exact addition was exact) + *pfpsf |= INEXACT_EXCEPTION; + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } // else if (C1 < 10^34) then C1 is the coeff.; the result is exact + } else { // if x_sign != y_sign the result is exact + C1_lo = C1_lo - C2_lo; + C1_hi = C1_hi - C2_hi; + if (C1_lo > C1.w[0]) + C1_hi--; + // the result can be zero, but it cannot overflow + if (C1_lo == 0 && C1_hi == 0) { + // assemble the result + if (x_exp < y_exp) + res.w[1] = x_exp; + else + res.w[1] = y_exp; + res.w[0] = 0; + if (rnd_mode == ROUNDING_DOWN) { + res.w[1] |= 0x8000000000000000ull; + } + BID_SWAP128 (res); + BID_RETURN (res); + } + if (C1_hi >= 0x8000000000000000ull) { // negative coefficient! + C1_lo = ~C1_lo; + C1_lo++; + C1_hi = ~C1_hi; + if (C1_lo == 0x0) + C1_hi++; + x_sign = y_sign; // the result will have the sign of y + } + } + // assemble the result + res.w[1] = x_sign | y_exp | C1_hi; + res.w[0] = C1_lo; + } else { // if (delta >= P34 + 1 - q2) + // instead of C' = (C1 * 10^(e1-e2) + C2)rnd,P34 + // calculate C' = C1 * 10^(e1-e2-x1) + (C2 * 10^(-x1))rnd,P34 + // where x1 = q1 + e1 - e2 - P34, 1 <= x1 <= P34 - 1 + // In most cases C' will have P34 digits, and n = C' * 10^(e2+x1) + // If the result has P34+1 digits, redo the steps above with x1+1 + // If the result has P34-1 digits or less, redo the steps above with + // x1-1 but only if initially x1 >= 1 + // NOTE: these two steps can be improved, e.g we could guess if + // P34+1 or P34-1 digits will be obtained by adding/subtracting just + // the top 64 bits of the two operands + // The result cannot be zero, but it can overflow + x1 = delta + q2 - P34; // 1 <= x1 <= P34-1 + roundC2: + // Calculate C1 * 10^(e1-e2-x1) where 0 <= e1-e2-x1 <= P34 - 1 + // scale = (int)(e1 >> 49) - (int)(e2 >> 49) - x1; 0 <= scale <= P34-1 + scale = delta - q1 + q2 - x1; // scale = e1 - e2 - x1 = P34 - q1 + // either C1 or 10^(e1-e2-x1) may not fit is 64 bits, + // but their product fits with certainty in 128 bits (actually in 113) + if (scale >= 20) { //10^(e1-e2-x1) doesn't fit in 64 bits, but C1 does + __mul_128x64_to_128 (C1, C1_lo, ten2k128[scale - 20]); + } else if (scale >= 1) { + // if 1 <= scale <= 19 then 10^(e1-e2-x1) fits in 64 bits + if (q1 <= 19) { // C1 fits in 64 bits + __mul_64x64_to_128MACH (C1, C1_lo, ten2k64[scale]); + } else { // q1 >= 20 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + __mul_128x64_to_128 (C1, ten2k64[scale], C1); + } + } else { // if (scale == 0) C1 is unchanged + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + } + tmp64 = C1.w[0]; // C1.w[1], C1.w[0] contains C1 * 10^(e1-e2-x1) + + // now round C2 to q2-x1 decimal digits, where 1<=x1<=q2-1<=P34-1 + // (but if we got here a second time after x1 = x1 - 1, then + // x1 >= 0; note that for x1 = 0 C2 is unchanged) + // C2' = C2 + 1/2 * 10^x1 = C2 + 5 * 10^(x1-1) + ind = x1 - 1; // 0 <= ind <= q2-2<=P34-2=32; but note that if x1 = 0 + // during a second pass, then ind = -1 + if (ind >= 0) { // if (x1 >= 1) + C2.w[0] = C2_lo; + C2.w[1] = C2_hi; + if (ind <= 18) { + C2.w[0] = C2.w[0] + midpoint64[ind]; + if (C2.w[0] < C2_lo) + C2.w[1]++; + } else { // 19 <= ind <= 32 + C2.w[0] = C2.w[0] + midpoint128[ind - 19].w[0]; + C2.w[1] = C2.w[1] + midpoint128[ind - 19].w[1]; + if (C2.w[0] < C2_lo) + C2.w[1]++; + } + // the approximation of 10^(-x1) was rounded up to 118 bits + __mul_128x128_to_256 (R256, C2, ten2mk128[ind]); // R256 = C2*, f2* + // calculate C2* and f2* + // C2* is actually floor(C2*) in this case + // C2* and f2* need shifting and masking, as shown by + // shiftright128[] and maskhigh128[] + // the top Ex bits of 10^(-x1) are T* = ten2mk128trunc[ind], e.g. + // if x1=1, T*=ten2mk128trunc[0]=0x19999999999999999999999999999999 + // if (0 < f2* < 10^(-x1)) then + // if floor(C1+C2*) is even then C2* = floor(C2*) - logical right + // shift; C2* has p decimal digits, correct by Prop. 1) + // else if floor(C1+C2*) is odd C2* = floor(C2*)-1 (logical right + // shift; C2* has p decimal digits, correct by Pr. 1) + // else + // C2* = floor(C2*) (logical right shift; C has p decimal digits, + // correct by Property 1) + // n = C2* * 10^(e2+x1) + + if (ind <= 2) { + highf2star.w[1] = 0x0; + highf2star.w[0] = 0x0; // low f2* ok + } else if (ind <= 21) { + highf2star.w[1] = 0x0; + highf2star.w[0] = R256.w[2] & maskhigh128[ind]; // low f2* ok + } else { + highf2star.w[1] = R256.w[3] & maskhigh128[ind]; + highf2star.w[0] = R256.w[2]; // low f2* is ok + } + // shift right C2* by Ex-128 = shiftright128[ind] + if (ind >= 3) { + shift = shiftright128[ind]; + if (shift < 64) { // 3 <= shift <= 63 + R256.w[2] = + (R256.w[2] >> shift) | (R256.w[3] << (64 - shift)); + R256.w[3] = (R256.w[3] >> shift); + } else { // 66 <= shift <= 102 + R256.w[2] = (R256.w[3] >> (shift - 64)); + R256.w[3] = 0x0ULL; + } + } + if (second_pass) { + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + is_midpoint_lt_even = 0; + is_midpoint_gt_even = 0; + } + // determine inexactness of the rounding of C2* (this may be + // followed by a second rounding only if we get P34+1 + // decimal digits) + // if (0 < f2* - 1/2 < 10^(-x1)) then + // the result is exact + // else (if f2* - 1/2 > T* then) + // the result of is inexact + if (ind <= 2) { + if (R256.w[1] > 0x8000000000000000ull || + (R256.w[1] == 0x8000000000000000ull + && R256.w[0] > 0x0ull)) { + // f2* > 1/2 and the result may be exact + tmp64A = R256.w[1] - 0x8000000000000000ull; // f* - 1/2 + if ((tmp64A > ten2mk128trunc[ind].w[1] + || (tmp64A == ten2mk128trunc[ind].w[1] + && R256.w[0] >= ten2mk128trunc[ind].w[0]))) { + // set the inexact flag + // *pfpsf |= INEXACT_EXCEPTION; + tmp_inexact = 1; // may be set again during a second pass + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_inexact_lt_midpoint = 1; + else // if (x_sign != y_sign) + is_inexact_gt_midpoint = 1; + } // else the result is exact + // rounding down, unless a midpoint in [ODD, EVEN] + } else { // the result is inexact; f2* <= 1/2 + // set the inexact flag + // *pfpsf |= INEXACT_EXCEPTION; + tmp_inexact = 1; // just in case we will round a second time + // rounding up, unless a midpoint in [EVEN, ODD] + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_inexact_gt_midpoint = 1; + else // if (x_sign != y_sign) + is_inexact_lt_midpoint = 1; + } + } else if (ind <= 21) { // if 3 <= ind <= 21 + if (highf2star.w[1] > 0x0 || (highf2star.w[1] == 0x0 + && highf2star.w[0] > + onehalf128[ind]) + || (highf2star.w[1] == 0x0 + && highf2star.w[0] == onehalf128[ind] + && (R256.w[1] || R256.w[0]))) { + // f2* > 1/2 and the result may be exact + // Calculate f2* - 1/2 + tmp64A = highf2star.w[0] - onehalf128[ind]; + tmp64B = highf2star.w[1]; + if (tmp64A > highf2star.w[0]) + tmp64B--; + if (tmp64B || tmp64A + || R256.w[1] > ten2mk128trunc[ind].w[1] + || (R256.w[1] == ten2mk128trunc[ind].w[1] + && R256.w[0] > ten2mk128trunc[ind].w[0])) { + // set the inexact flag + // *pfpsf |= INEXACT_EXCEPTION; + tmp_inexact = 1; // may be set again during a second pass + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_inexact_lt_midpoint = 1; + else // if (x_sign != y_sign) + is_inexact_gt_midpoint = 1; + } // else the result is exact + } else { // the result is inexact; f2* <= 1/2 + // set the inexact flag + // *pfpsf |= INEXACT_EXCEPTION; + tmp_inexact = 1; // may be set again during a second pass + // rounding up, unless a midpoint in [EVEN, ODD] + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_inexact_gt_midpoint = 1; + else // if (x_sign != y_sign) + is_inexact_lt_midpoint = 1; + } + } else { // if 22 <= ind <= 33 + if (highf2star.w[1] > onehalf128[ind] + || (highf2star.w[1] == onehalf128[ind] + && (highf2star.w[0] || R256.w[1] + || R256.w[0]))) { + // f2* > 1/2 and the result may be exact + // Calculate f2* - 1/2 + // tmp64A = highf2star.w[0]; + tmp64B = highf2star.w[1] - onehalf128[ind]; + if (tmp64B || highf2star.w[0] + || R256.w[1] > ten2mk128trunc[ind].w[1] + || (R256.w[1] == ten2mk128trunc[ind].w[1] + && R256.w[0] > ten2mk128trunc[ind].w[0])) { + // set the inexact flag + // *pfpsf |= INEXACT_EXCEPTION; + tmp_inexact = 1; // may be set again during a second pass + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_inexact_lt_midpoint = 1; + else // if (x_sign != y_sign) + is_inexact_gt_midpoint = 1; + } // else the result is exact + } else { // the result is inexact; f2* <= 1/2 + // set the inexact flag + // *pfpsf |= INEXACT_EXCEPTION; + tmp_inexact = 1; // may be set again during a second pass + // rounding up, unless a midpoint in [EVEN, ODD] + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_inexact_gt_midpoint = 1; + else // if (x_sign != y_sign) + is_inexact_lt_midpoint = 1; + } + } + // check for midpoints + if ((R256.w[1] || R256.w[0]) && (highf2star.w[1] == 0) + && (highf2star.w[0] == 0) + && (R256.w[1] < ten2mk128trunc[ind].w[1] + || (R256.w[1] == ten2mk128trunc[ind].w[1] + && R256.w[0] <= ten2mk128trunc[ind].w[0]))) { + // the result is a midpoint + if ((tmp64 + R256.w[2]) & 0x01) { // MP in [EVEN, ODD] + // if floor(C2*) is odd C = floor(C2*) - 1; the result may be 0 + R256.w[2]--; + if (R256.w[2] == 0xffffffffffffffffull) + R256.w[3]--; + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_midpoint_gt_even = 1; + else // if (x_sign != y_sign) + is_midpoint_lt_even = 1; + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + } else { + // else MP in [ODD, EVEN] + // this rounding is applied to C2 only! + if (x_sign == y_sign) + is_midpoint_lt_even = 1; + else // if (x_sign != y_sign) + is_midpoint_gt_even = 1; + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + } + } + // end if (ind >= 0) + } else { // if (ind == -1); only during a 2nd pass, and when x1 = 0 + R256.w[2] = C2_lo; + R256.w[3] = C2_hi; + tmp_inexact = 0; + // to correct a possible setting to 1 from 1st pass + if (second_pass) { + is_midpoint_lt_even = 0; + is_midpoint_gt_even = 0; + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + } + } + // and now add/subtract C1 * 10^(e1-e2-x1) +/- (C2 * 10^(-x1))rnd,P34 + if (x_sign == y_sign) { // addition; could overflow + // no second pass is possible this way (only for x_sign != y_sign) + C1.w[0] = C1.w[0] + R256.w[2]; + C1.w[1] = C1.w[1] + R256.w[3]; + if (C1.w[0] < tmp64) + C1.w[1]++; // carry + // if the sum has P34+1 digits, i.e. C1>=10^34 redo the calculation + // with x1=x1+1 + if (C1.w[1] > 0x0001ed09bead87c0ull || (C1.w[1] == 0x0001ed09bead87c0ull && C1.w[0] >= 0x378d8e6400000000ull)) { // C1 >= 10^34 + // chop off one more digit from the sum, but make sure there is + // no double-rounding error (see table - double rounding logic) + // now round C1 from P34+1 to P34 decimal digits + // C1' = C1 + 1/2 * 10 = C1 + 5 + if (C1.w[0] >= 0xfffffffffffffffbull) { // low half add has carry + C1.w[0] = C1.w[0] + 5; + C1.w[1] = C1.w[1] + 1; + } else { + C1.w[0] = C1.w[0] + 5; + } + // the approximation of 10^(-1) was rounded up to 118 bits + __mul_128x128_to_256 (Q256, C1, ten2mk128[0]); // Q256 = C1*, f1* + // C1* is actually floor(C1*) in this case + // the top 128 bits of 10^(-1) are + // T* = ten2mk128trunc[0]=0x19999999999999999999999999999999 + // if (0 < f1* < 10^(-1)) then + // if floor(C1*) is even then C1* = floor(C1*) - logical right + // shift; C1* has p decimal digits, correct by Prop. 1) + // else if floor(C1*) is odd C1* = floor(C1*) - 1 (logical right + // shift; C1* has p decimal digits, correct by Pr. 1) + // else + // C1* = floor(C1*) (logical right shift; C has p decimal digits + // correct by Property 1) + // n = C1* * 10^(e2+x1+1) + if ((Q256.w[1] || Q256.w[0]) + && (Q256.w[1] < ten2mk128trunc[0].w[1] + || (Q256.w[1] == ten2mk128trunc[0].w[1] + && Q256.w[0] <= ten2mk128trunc[0].w[0]))) { + // the result is a midpoint + if (is_inexact_lt_midpoint) { // for the 1st rounding + is_inexact_gt_midpoint = 1; + is_inexact_lt_midpoint = 0; + is_midpoint_gt_even = 0; + is_midpoint_lt_even = 0; + } else if (is_inexact_gt_midpoint) { // for the 1st rounding + Q256.w[2]--; + if (Q256.w[2] == 0xffffffffffffffffull) + Q256.w[3]--; + is_inexact_gt_midpoint = 0; + is_inexact_lt_midpoint = 1; + is_midpoint_gt_even = 0; + is_midpoint_lt_even = 0; + } else if (is_midpoint_gt_even) { // for the 1st rounding + // Note: cannot have is_midpoint_lt_even + is_inexact_gt_midpoint = 0; + is_inexact_lt_midpoint = 1; + is_midpoint_gt_even = 0; + is_midpoint_lt_even = 0; + } else { // the first rounding must have been exact + if (Q256.w[2] & 0x01) { // MP in [EVEN, ODD] + // the truncated result is correct + Q256.w[2]--; + if (Q256.w[2] == 0xffffffffffffffffull) + Q256.w[3]--; + is_inexact_gt_midpoint = 0; + is_inexact_lt_midpoint = 0; + is_midpoint_gt_even = 1; + is_midpoint_lt_even = 0; + } else { // MP in [ODD, EVEN] + is_inexact_gt_midpoint = 0; + is_inexact_lt_midpoint = 0; + is_midpoint_gt_even = 0; + is_midpoint_lt_even = 1; + } + } + tmp_inexact = 1; // in all cases + } else { // the result is not a midpoint + // determine inexactness of the rounding of C1 (the sum C1+C2*) + // if (0 < f1* - 1/2 < 10^(-1)) then + // the result is exact + // else (if f1* - 1/2 > T* then) + // the result of is inexact + // ind = 0 + if (Q256.w[1] > 0x8000000000000000ull + || (Q256.w[1] == 0x8000000000000000ull + && Q256.w[0] > 0x0ull)) { + // f1* > 1/2 and the result may be exact + Q256.w[1] = Q256.w[1] - 0x8000000000000000ull; // f1* - 1/2 + if ((Q256.w[1] > ten2mk128trunc[0].w[1] + || (Q256.w[1] == ten2mk128trunc[0].w[1] + && Q256.w[0] > ten2mk128trunc[0].w[0]))) { + is_inexact_gt_midpoint = 0; + is_inexact_lt_midpoint = 1; + is_midpoint_gt_even = 0; + is_midpoint_lt_even = 0; + // set the inexact flag + tmp_inexact = 1; + // *pfpsf |= INEXACT_EXCEPTION; + } else { // else the result is exact for the 2nd rounding + if (tmp_inexact) { // if the previous rounding was inexact + if (is_midpoint_lt_even) { + is_inexact_gt_midpoint = 1; + is_midpoint_lt_even = 0; + } else if (is_midpoint_gt_even) { + is_inexact_lt_midpoint = 1; + is_midpoint_gt_even = 0; + } else { + ; // no change + } + } + } + // rounding down, unless a midpoint in [ODD, EVEN] + } else { // the result is inexact; f1* <= 1/2 + is_inexact_gt_midpoint = 1; + is_inexact_lt_midpoint = 0; + is_midpoint_gt_even = 0; + is_midpoint_lt_even = 0; + // set the inexact flag + tmp_inexact = 1; + // *pfpsf |= INEXACT_EXCEPTION; + } + } // end 'the result is not a midpoint' + // n = C1 * 10^(e2+x1) + C1.w[1] = Q256.w[3]; + C1.w[0] = Q256.w[2]; + y_exp = y_exp + ((UINT64) (x1 + 1) << 49); + } else { // C1 < 10^34 + // C1.w[1] and C1.w[0] already set + // n = C1 * 10^(e2+x1) + y_exp = y_exp + ((UINT64) x1 << 49); + } + // check for overflow + if (y_exp == EXP_MAX_P1 + && (rnd_mode == ROUNDING_TO_NEAREST + || rnd_mode == ROUNDING_TIES_AWAY)) { + res.w[1] = 0x7800000000000000ull | x_sign; // +/-inf + res.w[0] = 0x0ull; + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + BID_SWAP128 (res); + BID_RETURN (res); + } // else no overflow + } else { // if x_sign != y_sign the result of this subtract. is exact + C1.w[0] = C1.w[0] - R256.w[2]; + C1.w[1] = C1.w[1] - R256.w[3]; + if (C1.w[0] > tmp64) + C1.w[1]--; // borrow + if (C1.w[1] >= 0x8000000000000000ull) { // negative coefficient! + C1.w[0] = ~C1.w[0]; + C1.w[0]++; + C1.w[1] = ~C1.w[1]; + if (C1.w[0] == 0x0) + C1.w[1]++; + tmp_sign = y_sign; + // the result will have the sign of y if last rnd + } else { + tmp_sign = x_sign; + } + // if the difference has P34-1 digits or less, i.e. C1 < 10^33 then + // redo the calculation with x1=x1-1; + // redo the calculation also if C1 = 10^33 and + // (is_inexact_gt_midpoint or is_midpoint_lt_even); + // (the last part should have really been + // (is_inexact_lt_midpoint or is_midpoint_gt_even) from + // the rounding of C2, but the position flags have been reversed) + // 10^33 = 0x0000314dc6448d93 0x38c15b0a00000000 + if ((C1.w[1] < 0x0000314dc6448d93ull || (C1.w[1] == 0x0000314dc6448d93ull && C1.w[0] < 0x38c15b0a00000000ull)) || (C1.w[1] == 0x0000314dc6448d93ull && C1.w[0] == 0x38c15b0a00000000ull && (is_inexact_gt_midpoint || is_midpoint_lt_even))) { // C1=10^33 + x1 = x1 - 1; // x1 >= 0 + if (x1 >= 0) { + // clear position flags and tmp_inexact + is_midpoint_lt_even = 0; + is_midpoint_gt_even = 0; + is_inexact_lt_midpoint = 0; + is_inexact_gt_midpoint = 0; + tmp_inexact = 0; + second_pass = 1; + goto roundC2; // else result has less than P34 digits + } + } + // if the coefficient of the result is 10^34 it means that this + // must be the second pass, and we are done + if (C1.w[1] == 0x0001ed09bead87c0ull && C1.w[0] == 0x378d8e6400000000ull) { // if C1 = 10^34 + C1.w[1] = 0x0000314dc6448d93ull; // C1 = 10^33 + C1.w[0] = 0x38c15b0a00000000ull; + y_exp = y_exp + ((UINT64) 1 << 49); + } + x_sign = tmp_sign; + if (x1 >= 1) + y_exp = y_exp + ((UINT64) x1 << 49); + // x1 = -1 is possible at the end of a second pass when the + // first pass started with x1 = 1 + } + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + // general correction from RN to RA, RM, RP, RZ; result uses y_exp + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((!x_sign + && ((rnd_mode == ROUNDING_UP && is_inexact_lt_midpoint) + || + ((rnd_mode == ROUNDING_TIES_AWAY + || rnd_mode == ROUNDING_UP) + && is_midpoint_gt_even))) || (x_sign + && + ((rnd_mode == + ROUNDING_DOWN + && + is_inexact_lt_midpoint) + || + ((rnd_mode == + ROUNDING_TIES_AWAY + || rnd_mode == + ROUNDING_DOWN) + && + is_midpoint_gt_even)))) + { + // C1 = C1 + 1 + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + y_exp = y_exp + EXP_P1; + } + } else if ((is_midpoint_lt_even || is_inexact_gt_midpoint) + && + ((x_sign + && (rnd_mode == ROUNDING_UP + || rnd_mode == ROUNDING_TO_ZERO)) + || (!x_sign + && (rnd_mode == ROUNDING_DOWN + || rnd_mode == ROUNDING_TO_ZERO)))) { + // C1 = C1 - 1 + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi--; + // check if we crossed into the lower decade + if (C1_hi == 0x0000314dc6448d93ull && C1_lo == 0x38c15b09ffffffffull) { // 10^33 - 1 + C1_hi = 0x0001ed09bead87c0ull; // 10^34 - 1 + C1_lo = 0x378d8e63ffffffffull; + y_exp = y_exp - EXP_P1; + // no underflow, because delta + q2 >= P34 + 1 + } + } else { + ; // exact, the result is already correct + } + // in all cases check for overflow (RN and RA solved already) + if (y_exp == EXP_MAX_P1) { // overflow + if ((rnd_mode == ROUNDING_DOWN && x_sign) || // RM and res < 0 + (rnd_mode == ROUNDING_UP && !x_sign)) { // RP and res > 0 + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + } else { // RM and res > 0, RP and res < 0, or RZ + C1_hi = 0x5fffed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + } + y_exp = 0; // x_sign is preserved + // set the inexact flag (in case the exact addition was exact) + *pfpsf |= INEXACT_EXCEPTION; + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + // assemble the result + res.w[1] = x_sign | y_exp | C1_hi; + res.w[0] = C1_lo; + if (tmp_inexact) + *pfpsf |= INEXACT_EXCEPTION; + } + } else { // if (-P34 + 1 <= delta <= -1) <=> 1 <= -delta <= P34 - 1 + // NOTE: the following, up to "} else { // if x_sign != y_sign + // the result is exact" is identical to "else if (delta == P34 - q2) {" + // from above; also, the code is not symmetric: a+b and b+a may take + // different paths (need to unify eventually!) + // calculate C' = C2 + C1 * 10^(e1-e2) directly; the result may be + // inexact if it requires P34 + 1 decimal digits; in either case the + // 'cutoff' point for addition is at the position of the lsb of C2 + // The coefficient of the result is C1 * 10^(e1-e2) + C2 and the + // exponent is e2; either C1 or 10^(e1-e2) may not fit is 64 bits, + // but their product fits with certainty in 128 bits (actually in 113) + // Note that 0 <= e1 - e2 <= P34 - 2 + // -P34 + 1 <= delta <= -1 <=> -P34 + 1 <= delta <= -1 <=> + // -P34 + 1 <= q1 + e1 - q2 - e2 <= -1 <=> + // q2 - q1 - P34 + 1 <= e1 - e2 <= q2 - q1 - 1 <=> + // 1 - P34 - P34 + 1 <= e1-e2 <= P34 - 1 - 1 => 0 <= e1-e2 <= P34 - 2 + scale = delta - q1 + q2; // scale = (int)(e1 >> 49) - (int)(e2 >> 49) + if (scale >= 20) { // 10^(e1-e2) does not fit in 64 bits, but C1 does + __mul_128x64_to_128 (C1, C1_lo, ten2k128[scale - 20]); + } else if (scale >= 1) { + // if 1 <= scale <= 19 then 10^(e1-e2) fits in 64 bits + if (q1 <= 19) { // C1 fits in 64 bits + __mul_64x64_to_128MACH (C1, C1_lo, ten2k64[scale]); + } else { // q1 >= 20 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; + __mul_128x64_to_128 (C1, ten2k64[scale], C1); + } + } else { // if (scale == 0) C1 is unchanged + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; // only the low part is necessary + } + C1_hi = C1.w[1]; + C1_lo = C1.w[0]; + // now add C2 + if (x_sign == y_sign) { + // the result can overflow! + C1_lo = C1_lo + C2_lo; + C1_hi = C1_hi + C2_hi; + if (C1_lo < C1.w[0]) + C1_hi++; + // test for overflow, possible only when C1 >= 10^34 + if (C1_hi > 0x0001ed09bead87c0ull || (C1_hi == 0x0001ed09bead87c0ull && C1_lo >= 0x378d8e6400000000ull)) { // C1 >= 10^34 + // in this case q = P34 + 1 and x = q - P34 = 1, so multiply + // C'' = C'+ 5 = C1 + 5 by k1 ~ 10^(-1) calculated for P34 + 1 + // decimal digits + // Calculate C'' = C' + 1/2 * 10^x + if (C1_lo >= 0xfffffffffffffffbull) { // low half add has carry + C1_lo = C1_lo + 5; + C1_hi = C1_hi + 1; + } else { + C1_lo = C1_lo + 5; + } + // the approximation of 10^(-1) was rounded up to 118 bits + // 10^(-1) =~ 33333333333333333333333333333400 * 2^-129 + // 10^(-1) =~ 19999999999999999999999999999a00 * 2^-128 + C1.w[1] = C1_hi; + C1.w[0] = C1_lo; // C'' + ten2m1.w[1] = 0x1999999999999999ull; + ten2m1.w[0] = 0x9999999999999a00ull; + __mul_128x128_to_256 (P256, C1, ten2m1); // P256 = C*, f* + // C* is actually floor(C*) in this case + // the top Ex = 128 bits of 10^(-1) are + // T* = 0x00199999999999999999999999999999 + // if (0 < f* < 10^(-x)) then + // if floor(C*) is even then C = floor(C*) - logical right + // shift; C has p decimal digits, correct by Prop. 1) + // else if floor(C*) is odd C = floor(C*) - 1 (logical right + // shift; C has p decimal digits, correct by Pr. 1) + // else + // C = floor(C*) (logical right shift; C has p decimal digits, + // correct by Property 1) + // n = C * 10^(e2+x) + if ((P256.w[1] || P256.w[0]) + && (P256.w[1] < 0x1999999999999999ull + || (P256.w[1] == 0x1999999999999999ull + && P256.w[0] <= 0x9999999999999999ull))) { + // the result is a midpoint + if (P256.w[2] & 0x01) { + is_midpoint_gt_even = 1; + // if floor(C*) is odd C = floor(C*) - 1; the result is not 0 + P256.w[2]--; + if (P256.w[2] == 0xffffffffffffffffull) + P256.w[3]--; + } else { + is_midpoint_lt_even = 1; + } + } + // n = Cstar * 10^(e2+1) + y_exp = y_exp + EXP_P1; + // C* != 10^P34 because C* has P34 digits + // check for overflow + if (y_exp == EXP_MAX_P1 + && (rnd_mode == ROUNDING_TO_NEAREST + || rnd_mode == ROUNDING_TIES_AWAY)) { + // overflow for RN + res.w[1] = x_sign | 0x7800000000000000ull; // +/-inf + res.w[0] = 0x0ull; + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + BID_SWAP128 (res); + BID_RETURN (res); + } + // if (0 < f* - 1/2 < 10^(-x)) then + // the result of the addition is exact + // else + // the result of the addition is inexact + if (P256.w[1] > 0x8000000000000000ull || (P256.w[1] == 0x8000000000000000ull && P256.w[0] > 0x0ull)) { // the result may be exact + tmp64 = P256.w[1] - 0x8000000000000000ull; // f* - 1/2 + if ((tmp64 > 0x1999999999999999ull + || (tmp64 == 0x1999999999999999ull + && P256.w[0] >= 0x9999999999999999ull))) { + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + is_inexact = 1; + } // else the result is exact + } else { // the result is inexact + // set the inexact flag + *pfpsf |= INEXACT_EXCEPTION; + is_inexact = 1; + } + C1_hi = P256.w[3]; + C1_lo = P256.w[2]; + if (!is_midpoint_gt_even && !is_midpoint_lt_even) { + is_inexact_lt_midpoint = is_inexact + && (P256.w[1] & 0x8000000000000000ull); + is_inexact_gt_midpoint = is_inexact + && !(P256.w[1] & 0x8000000000000000ull); + } + // general correction from RN to RA, RM, RP, RZ; result uses y_exp + if (rnd_mode != ROUNDING_TO_NEAREST) { + if ((!x_sign + && ((rnd_mode == ROUNDING_UP + && is_inexact_lt_midpoint) + || ((rnd_mode == ROUNDING_TIES_AWAY + || rnd_mode == ROUNDING_UP) + && is_midpoint_gt_even))) || (x_sign + && + ((rnd_mode == + ROUNDING_DOWN + && + is_inexact_lt_midpoint) + || + ((rnd_mode == + ROUNDING_TIES_AWAY + || rnd_mode + == + ROUNDING_DOWN) + && + is_midpoint_gt_even)))) + { + // C1 = C1 + 1 + C1_lo = C1_lo + 1; + if (C1_lo == 0) { // rounding overflow in the low 64 bits + C1_hi = C1_hi + 1; + } + if (C1_hi == 0x0001ed09bead87c0ull + && C1_lo == 0x378d8e6400000000ull) { + // C1 = 10^34 => rounding overflow + C1_hi = 0x0000314dc6448d93ull; + C1_lo = 0x38c15b0a00000000ull; // 10^33 + y_exp = y_exp + EXP_P1; + } + } else + if ((is_midpoint_lt_even || is_inexact_gt_midpoint) && + ((x_sign && (rnd_mode == ROUNDING_UP || + rnd_mode == ROUNDING_TO_ZERO)) || + (!x_sign && (rnd_mode == ROUNDING_DOWN || + rnd_mode == ROUNDING_TO_ZERO)))) { + // C1 = C1 - 1 + C1_lo = C1_lo - 1; + if (C1_lo == 0xffffffffffffffffull) + C1_hi--; + // check if we crossed into the lower decade + if (C1_hi == 0x0000314dc6448d93ull && C1_lo == 0x38c15b09ffffffffull) { // 10^33 - 1 + C1_hi = 0x0001ed09bead87c0ull; // 10^34 - 1 + C1_lo = 0x378d8e63ffffffffull; + y_exp = y_exp - EXP_P1; + // no underflow, because delta + q2 >= P34 + 1 + } + } else { + ; // exact, the result is already correct + } + // in all cases check for overflow (RN and RA solved already) + if (y_exp == EXP_MAX_P1) { // overflow + if ((rnd_mode == ROUNDING_DOWN && x_sign) || // RM and res < 0 + (rnd_mode == ROUNDING_UP && !x_sign)) { // RP and res > 0 + C1_hi = 0x7800000000000000ull; // +inf + C1_lo = 0x0ull; + } else { // RM and res > 0, RP and res < 0, or RZ + C1_hi = 0x5fffed09bead87c0ull; + C1_lo = 0x378d8e63ffffffffull; + } + y_exp = 0; // x_sign is preserved + // set the inexact flag (in case the exact addition was exact) + *pfpsf |= INEXACT_EXCEPTION; + // set the overflow flag + *pfpsf |= OVERFLOW_EXCEPTION; + } + } + } // else if (C1 < 10^34) then C1 is the coeff.; the result is exact + // assemble the result + res.w[1] = x_sign | y_exp | C1_hi; + res.w[0] = C1_lo; + } else { // if x_sign != y_sign the result is exact + C1_lo = C2_lo - C1_lo; + C1_hi = C2_hi - C1_hi; + if (C1_lo > C2_lo) + C1_hi--; + if (C1_hi >= 0x8000000000000000ull) { // negative coefficient! + C1_lo = ~C1_lo; + C1_lo++; + C1_hi = ~C1_hi; + if (C1_lo == 0x0) + C1_hi++; + x_sign = y_sign; // the result will have the sign of y + } + // the result can be zero, but it cannot overflow + if (C1_lo == 0 && C1_hi == 0) { + // assemble the result + if (x_exp < y_exp) + res.w[1] = x_exp; + else + res.w[1] = y_exp; + res.w[0] = 0; + if (rnd_mode == ROUNDING_DOWN) { + res.w[1] |= 0x8000000000000000ull; + } + BID_SWAP128 (res); + BID_RETURN (res); + } + // assemble the result + res.w[1] = y_sign | y_exp | C1_hi; + res.w[0] = C1_lo; + } + } + } + BID_SWAP128 (res); + BID_RETURN (res) + } +} + + + +// bid128_sub stands for bid128qq_sub + +/***************************************************************************** + * BID128 sub + ****************************************************************************/ + +#if DECIMAL_CALL_BY_REFERENCE +void +bid128_sub (UINT128 * pres, UINT128 * px, UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + UINT128 x = *px, y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + unsigned int rnd_mode = *prnd_mode; +#endif +#else +UINT128 +bid128_sub (UINT128 x, UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { +#endif + + UINT128 res; + UINT64 y_sign; + + if ((y.w[HIGH_128W] & MASK_NAN) != MASK_NAN) { // y is not NAN + // change its sign + y_sign = y.w[HIGH_128W] & MASK_SIGN; // 0 for positive, MASK_SIGN for negative + if (y_sign) + y.w[HIGH_128W] = y.w[HIGH_128W] & 0x7fffffffffffffffull; + else + y.w[HIGH_128W] = y.w[HIGH_128W] | 0x8000000000000000ull; + } +#if DECIMAL_CALL_BY_REFERENCE + bid128_add (&res, &x, &y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#else + res = bid128_add (x, y + _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +#endif + BID_RETURN (res); +} diff --git a/gcc-4.4.3/libgcc/config/libbid/bid128_compare.c b/gcc-4.4.3/libgcc/config/libbid/bid128_compare.c new file mode 100644 index 000000000..18ed94284 --- /dev/null +++ b/gcc-4.4.3/libgcc/config/libbid/bid128_compare.c @@ -0,0 +1,4346 @@ +/* Copyright (C) 2007, 2009 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 +<http://www.gnu.org/licenses/>. */ + +#include "bid_internal.h" + +BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (int, bid128_quiet_equal, x, y) + + int res; + int exp_x, exp_y, exp_t; + UINT128 sig_x, sig_y, sig_t; + UINT192 sig_n_prime192; + UINT256 sig_n_prime256; + char x_is_zero = 0, y_is_zero = 0, non_canon_x, non_canon_y; + + // NaN (CASE1) + // if either number is NAN, the comparison is unordered, + // rather than equal : return 0 +if (((x.w[1] & MASK_NAN) == MASK_NAN) + || ((y.w[1] & MASK_NAN) == MASK_NAN)) { +if ((x.w[1] & MASK_SNAN) == MASK_SNAN + || (y.w[1] & MASK_SNAN) == MASK_SNAN) { + *pfpsf |= INVALID_EXCEPTION; +} +{ + res = 0; + BID_RETURN (res); +} +} + // SIMPLE (CASE2) + // if all the bits are the same, these numbers are equivalent. +if (x.w[0] == y.w[0] && x.w[1] == y.w[1]) { + res = 1; + BID_RETURN (res); +} + // INFINITY (CASE3) +if ((x.w[1] & MASK_INF) == MASK_INF) { + if ((y.w[1] & MASK_INF) == MASK_INF) { + res = (((x.w[1] ^ y.w[1]) & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); + } else { + res = 0; + BID_RETURN (res); + } +} +if ((y.w[1] & MASK_INF) == MASK_INF) { + res = 0; + BID_RETURN (res); +} + // CONVERT X +sig_x.w[1] = x.w[1] & 0x0001ffffffffffffull; +sig_x.w[0] = x.w[0]; +exp_x = (x.w[1] >> 49) & 0x000000000003fffull; + + // CHECK IF X IS CANONICAL + // 9999999999999999999999999999999999(decimal) = + // 1ed09_bead87c0_378d8e63_ffffffff(hexadecimal) + // [0, 10^34) is the 754r supported canonical range. + // If the value exceeds that, it is interpreted as 0. +if ((sig_x.w[1] > 0x0001ed09bead87c0ull) + || ((sig_x.w[1] == 0x0001ed09bead87c0ull) + && (sig_x.w[0] > 0x378d8e63ffffffffull)) + || ((x.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull)) + non_canon_x = 1; +else + non_canon_x = 0; + + // CONVERT Y +exp_y = (y.w[1] >> 49) & 0x0000000000003fffull; +sig_y.w[1] = y.w[1] & 0x0001ffffffffffffull; +sig_y.w[0] = y.w[0]; + + // CHECK IF Y IS CANONICAL + // 9999999999999999999999999999999999(decimal) = + // 1ed09_bead87c0_378d8e63_ffffffff(hexadecimal) + // [0, 10^34) is the 754r supported canonical range. + // If the value exceeds that, it is interpreted as 0. +if ((sig_y.w[1] > 0x0001ed09bead87c0ull) + || ((sig_y.w[1] == 0x0001ed09bead87c0ull) + && (sig_y.w[0] > 0x378d8e63ffffffffull)) + || ((y.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull)) + non_canon_y = 1; +else + non_canon_y = 0; + + // some properties: + // (+ZERO == -ZERO) => therefore ignore the sign + // (ZERO x 10^A == ZERO x 10^B) for any valid A, B => therefore + // ignore the exponent field + // (Any non-canonical # is considered 0) +if (non_canon_x || ((sig_x.w[1] == 0) && (sig_x.w[0] == 0))) { + x_is_zero = 1; +} +if (non_canon_y || ((sig_y.w[1] == 0) && (sig_y.w[0] == 0))) { + y_is_zero = 1; +} + +if (x_is_zero && y_is_zero) { + res = 1; + BID_RETURN (res); +} else if ((x_is_zero && !y_is_zero) || (!x_is_zero && y_is_zero)) { + res = 0; + BID_RETURN (res); +} + // OPPOSITE SIGN (CASE5) + // now, if the sign bits differ => not equal : return 0 +if ((x.w[1] ^ y.w[1]) & MASK_SIGN) { + res = 0; + BID_RETURN (res); +} + // REDUNDANT REPRESENTATIONS (CASE6) +if (exp_x > exp_y) { // to simplify the loop below, + SWAP (exp_x, exp_y, exp_t); // put the larger exp in y, + SWAP (sig_x.w[1], sig_y.w[1], sig_t.w[1]); // and the smaller exp in x + SWAP (sig_x.w[0], sig_y.w[0], sig_t.w[0]); // and the smaller exp in x +} + + +if (exp_y - exp_x > 33) { + res = 0; + BID_RETURN (res); +} // difference cannot be greater than 10^33 + +if (exp_y - exp_x > 19) { + // recalculate y's significand upwards + __mul_128x128_to_256 (sig_n_prime256, sig_y, + ten2k128[exp_y - exp_x - 20]); + { + res = ((sig_n_prime256.w[3] == 0) && (sig_n_prime256.w[2] == 0) + && (sig_n_prime256.w[1] == sig_x.w[1]) + && (sig_n_prime256.w[0] == sig_x.w[0])); + BID_RETURN (res); + } + +} + //else{ + // recalculate y's significand upwards +__mul_64x128_to_192 (sig_n_prime192, ten2k64[exp_y - exp_x], sig_y); +{ + res = ((sig_n_prime192.w[2] == 0) + && (sig_n_prime192.w[1] == sig_x.w[1]) + && (sig_n_prime192.w[0] == sig_x.w[0])); + BID_RETURN (res); +} +} + +BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (int, bid128_quiet_greater, x, + y) + + int res; + int exp_x, exp_y; + int diff; + UINT128 sig_x, sig_y; + UINT192 sig_n_prime192; + UINT256 sig_n_prime256; + char x_is_zero = 0, y_is_zero = 0, non_canon_x, non_canon_y; + + // NaN (CASE1) + // if either number is NAN, the comparison is unordered, rather than + // equal : return 0 +if (((x.w[1] & MASK_NAN) == MASK_NAN) + || ((y.w[1] & MASK_NAN) == MASK_NAN)) { +if ((x.w[1] & MASK_SNAN) == MASK_SNAN + || (y.w[1] & MASK_SNAN) == MASK_SNAN) { + *pfpsf |= INVALID_EXCEPTION; +} +{ + res = 0; + BID_RETURN (res); +} +} + // SIMPLE (CASE2) + // if all the bits are the same, these numbers are equal (not Greater). +if (x.w[0] == y.w[0] && x.w[1] == y.w[1]) { + res = 0; + BID_RETURN (res); +} + // INFINITY (CASE3) +if ((x.w[1] & MASK_INF) == MASK_INF) { + // if x is neg infinity, there is no way it is greater than y, return 0 + if (((x.w[1] & MASK_SIGN) == MASK_SIGN)) { + res = 0; + BID_RETURN (res); + } + // x is pos infinity, it is greater, unless y is positive infinity => + // return y!=pos_infinity + else { + res = (((y.w[1] & MASK_INF) != MASK_INF) + || ((y.w[1] & MASK_SIGN) == MASK_SIGN)); + BID_RETURN (res); + } +} else if ((y.w[1] & MASK_INF) == MASK_INF) { + // x is finite, so if y is positive infinity, then x is less, return 0 + // if y is negative infinity, then x is greater, return 1 + { + res = ((y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); + } +} + // CONVERT X +sig_x.w[1] = x.w[1] & 0x0001ffffffffffffull; +sig_x.w[0] = x.w[0]; +exp_x = (x.w[1] >> 49) & 0x000000000003fffull; + + // CHECK IF X IS CANONICAL + // 9999999999999999999999999999999999(decimal) = + // 1ed09_bead87c0_378d8e63_ffffffff(hexadecimal) + // [0, 10^34) is the 754r supported canonical range. + // If the value exceeds that, it is interpreted as 0. +if ((sig_x.w[1] > 0x0001ed09bead87c0ull) + || ((sig_x.w[1] == 0x0001ed09bead87c0ull) + && (sig_x.w[0] > 0x378d8e63ffffffffull)) + || ((x.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull)) + non_canon_x = 1; +else + non_canon_x = 0; + + // CONVERT Y +exp_y = (y.w[1] >> 49) & 0x0000000000003fffull; +sig_y.w[1] = y.w[1] & 0x0001ffffffffffffull; +sig_y.w[0] = y.w[0]; + + // CHECK IF Y IS CANONICAL + // 9999999999999999999999999999999999(decimal) = + // 1ed09_bead87c0_378d8e63_ffffffff(hexadecimal) + // [0, 10^34) is the 754r supported canonical range. + // If the value exceeds that, it is interpreted as 0. +if ((sig_y.w[1] > 0x0001ed09bead87c0ull) + || ((sig_y.w[1] == 0x0001ed09bead87c0ull) + && (sig_y.w[0] > 0x378d8e63ffffffffull)) + || ((y.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull)) + non_canon_y = 1; +else + non_canon_y = 0; + + // ZERO (CASE4) + // some properties: + // (+ZERO == -ZERO) => therefore ignore the sign + // (ZERO x 10^A == ZERO x 10^B) for any valid A, B => therefore + // ignore the exponent field + // (Any non-canonical # is considered 0) +if (non_canon_x || ((sig_x.w[1] == 0) && (sig_x.w[0] == 0))) { + x_is_zero = 1; +} +if (non_canon_y || ((sig_y.w[1] == 0) && (sig_y.w[0] == 0))) { + y_is_zero = 1; +} + // if both numbers are zero, neither is greater => return NOTGREATERTHAN +if (x_is_zero && y_is_zero) { + res = 0; + BID_RETURN (res); +} + // is x is zero, it is greater if Y is negative +else if (x_is_zero) { + res = ((y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} + // is y is zero, X is greater if it is positive +else if (y_is_zero) { + res = ((x.w[1] & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); +} + // OPPOSITE SIGN (CASE5) + // now, if the sign bits differ, x is greater if y is negative +if (((x.w[1] ^ y.w[1]) & MASK_SIGN) == MASK_SIGN) { + res = ((y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} + // REDUNDANT REPRESENTATIONS (CASE6) + // if exponents are the same, then we have a simple comparison + // of the significands +if (exp_y == exp_x) { + res = (((sig_x.w[1] > sig_y.w[1]) + || (sig_x.w[1] == sig_y.w[1] + && sig_x.w[0] >= sig_y.w[0])) ^ ((x.w[1] & MASK_SIGN) == + MASK_SIGN)); + BID_RETURN (res); +} + // if both components are either bigger or smaller, + // it is clear what needs to be done +if ((sig_x.w[1] > sig_y.w[1] + || (sig_x.w[1] == sig_y.w[1] && sig_x.w[0] > sig_y.w[0])) + && exp_x >= exp_y) { + { + res = ((x.w[1] & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); + } +} +if ((sig_x.w[1] < sig_y.w[1] + || (sig_x.w[1] == sig_y.w[1] && sig_x.w[0] < sig_y.w[0])) + && exp_x <= exp_y) { + { + res = ((x.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); + } +} + +diff = exp_x - exp_y; + + // if |exp_x - exp_y| < 33, it comes down to the compensated significand +if (diff > 0) { // to simplify the loop below, + + // if exp_x is 33 greater than exp_y, no need for compensation + if (diff > 33) { + res = ((x.w[1] & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); + } // difference cannot be greater than 10^33 + + if (diff > 19) { //128 by 128 bit multiply -> 256 bits + __mul_128x128_to_256 (sig_n_prime256, sig_x, ten2k128[diff - 20]); + + // if postitive, return whichever significand is larger + // (converse if negative) + if (sig_n_prime256.w[3] == 0 && (sig_n_prime256.w[2] == 0) + && sig_n_prime256.w[1] == sig_y.w[1] + && (sig_n_prime256.w[0] == sig_y.w[0])) { + res = 0; + BID_RETURN (res); + } // if equal, return 0 + { + res = ((((sig_n_prime256.w[3] > 0) || sig_n_prime256.w[2] > 0) + || (sig_n_prime256.w[1] > sig_y.w[1]) + || (sig_n_prime256.w[1] == sig_y.w[1] + && sig_n_prime256.w[0] > + sig_y.w[0])) ^ ((y.w[1] & MASK_SIGN) == MASK_SIGN)); + BID_RETURN (res); + } + } + //else { //128 by 64 bit multiply -> 192 bits + __mul_64x128_to_192 (sig_n_prime192, ten2k64[diff], sig_x); + + // if postitive, return whichever significand is larger + // (converse if negative) + if ((sig_n_prime192.w[2] == 0) && sig_n_prime192.w[1] == sig_y.w[1] + && (sig_n_prime192.w[0] == sig_y.w[0])) { + res = 0; + BID_RETURN (res); + } // if equal, return 0 + { + res = (((sig_n_prime192.w[2] > 0) || + (sig_n_prime192.w[1] > sig_y.w[1]) || + (sig_n_prime192.w[1] == sig_y.w[1] && + sig_n_prime192.w[0] > sig_y.w[0])) ^ + ((y.w[1] & MASK_SIGN) == MASK_SIGN)); + BID_RETURN (res); + } +} + +diff = exp_y - exp_x; + + // if exp_x is 33 less than exp_y, no need for compensation +if (diff > 33) { + res = ((x.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} + +if (diff > 19) { //128 by 128 bit multiply -> 256 bits + // adjust the y significand upwards + __mul_128x128_to_256 (sig_n_prime256, sig_y, ten2k128[diff - 20]); + + // if postitive, return whichever significand is larger + // (converse if negative) + if (sig_n_prime256.w[3] == 0 && (sig_n_prime256.w[2] == 0) + && sig_n_prime256.w[1] == sig_x.w[1] + && (sig_n_prime256.w[0] == sig_x.w[0])) { + res = 0; + BID_RETURN (res); + } // if equal, return 0 + { + res = ((sig_n_prime256.w[3] != 0 || sig_n_prime256.w[2] != 0 || + (sig_n_prime256.w[1] > sig_x.w[1] || + (sig_n_prime256.w[1] == sig_x.w[1] && + sig_n_prime256.w[0] > sig_x.w[0]))) ^ + ((x.w[1] & MASK_SIGN) != MASK_SIGN)); + BID_RETURN (res); + } +} + //else { //128 by 64 bit multiply -> 192 bits + // adjust the y significand upwards +__mul_64x128_to_192 (sig_n_prime192, ten2k64[diff], sig_y); + + // if postitive, return whichever significand is larger + // (converse if negative) +if ((sig_n_prime192.w[2] == 0) && sig_n_prime192.w[1] == sig_x.w[1] + && (sig_n_prime192.w[0] == sig_x.w[0])) { + res = 0; + BID_RETURN (res); +} // if equal, return 0 +{ + res = (sig_n_prime192.w[2] != 0 + || (sig_n_prime192.w[1] > sig_x.w[1] + || (sig_n_prime192.w[1] == sig_x.w[1] + && sig_n_prime192.w[0] > + sig_x.w[0]))) ^ ((y.w[1] & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); +} +} + +BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (int, + bid128_quiet_greater_equal, x, + y) + + int res; + int exp_x, exp_y; + int diff; + UINT128 sig_x, sig_y; + UINT192 sig_n_prime192; + UINT256 sig_n_prime256; + char x_is_zero = 0, y_is_zero = 0, non_canon_x, non_canon_y; + + // NaN (CASE1) + // if either number is NAN, the comparison is unordered, + // rather than equal : return 1 +if (((x.w[1] & MASK_NAN) == MASK_NAN) + || ((y.w[1] & MASK_NAN) == MASK_NAN)) { +if ((x.w[1] & MASK_SNAN) == MASK_SNAN + || (y.w[1] & MASK_SNAN) == MASK_SNAN) { + *pfpsf |= INVALID_EXCEPTION; +} +{ + res = 0; + BID_RETURN (res); +} +} + // SIMPLE (CASE2) + // if all the bits are the same, these numbers are equal (not Greater). +if (x.w[0] == y.w[0] && x.w[1] == y.w[1]) { + res = 1; + BID_RETURN (res); +} + // INFINITY (CASE3) +if ((x.w[1] & MASK_INF) == MASK_INF) { + // if x==neg_inf, { res = (y == neg_inf)?1:0; BID_RETURN (res) } + if ((x.w[1] & MASK_SIGN) == MASK_SIGN) + // x is -inf, so it is less than y unless y is -inf + { + res = (((y.w[1] & MASK_INF) == MASK_INF) + && (y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); + } else + // x is pos_inf, no way for it to be less than y + { + res = 1; + BID_RETURN (res); + } +} else if ((y.w[1] & MASK_INF) == MASK_INF) { + // x is finite, so if y is positive infinity, then x is less, return 0 + // if y is negative infinity, then x is greater, return 1 + { + res = ((y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); + } +} + // CONVERT X +sig_x.w[1] = x.w[1] & 0x0001ffffffffffffull; +sig_x.w[0] = x.w[0]; +exp_x = (x.w[1] >> 49) & 0x000000000003fffull; + + // CHECK IF X IS CANONICAL + // 9999999999999999999999999999999999(decimal) = + // 1ed09_bead87c0_378d8e63_ffffffff(hexadecimal) + // [0, 10^34) is the 754r supported canonical range. + // If the value exceeds that, it is interpreted as 0. +if ((sig_x.w[1] > 0x0001ed09bead87c0ull) + || ((sig_x.w[1] == 0x0001ed09bead87c0ull) + && (sig_x.w[0] > 0x378d8e63ffffffffull)) + || ((x.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull)) + non_canon_x = 1; +else + non_canon_x = 0; + + // CONVERT Y +exp_y = (y.w[1] >> 49) & 0x0000000000003fffull; +sig_y.w[1] = y.w[1] & 0x0001ffffffffffffull; +sig_y.w[0] = y.w[0]; + + // CHECK IF Y IS CANONICAL + // 9999999999999999999999999999999999(decimal) = + // 1ed09_bead87c0_378d8e63_ffffffff(hexadecimal) + // [0, 10^34) is the 754r supported canonical range. + // If the value exceeds that, it is interpreted as 0. +if ((sig_y.w[1] > 0x0001ed09bead87c0ull) + || ((sig_y.w[1] == 0x0001ed09bead87c0ull) + && (sig_y.w[0] > 0x378d8e63ffffffffull)) + || ((y.w[1] & 0x6000000000000000ull) == 0x6000000000000000ull)) + non_canon_y = 1; +else + non_canon_y = 0; + + // ZERO (CASE4) + // some properties: + // (+ZERO == -ZERO) => therefore ignore the sign + // (ZERO x 10^A == ZERO x 10^B) for any valid A, B => therefore + // ignore the exponent field + // (Any non-canonical # is considered 0) +if (non_canon_x || ((sig_x.w[1] == 0) && (sig_x.w[0] == 0))) { + x_is_zero = 1; +} +if (non_canon_y || ((sig_y.w[1] == 0) && (sig_y.w[0] == 0))) { + y_is_zero = 1; +} + // if both numbers are zero, neither is greater => return NOTGREATERTHAN +if (x_is_zero && y_is_zero) { + res = 1; + BID_RETURN (res); +} + // is x is zero, it is greater if Y is negative +else if (x_is_zero) { + res = ((y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} + // is y is zero, X is greater if it is positive +else if (y_is_zero) { + res = ((x.w[1] & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); +} + // OPPOSITE SIGN (CASE5) + // now, if the sign bits differ, x is greater if y is negative +if (((x.w[1] ^ y.w[1]) & MASK_SIGN) == MASK_SIGN) { + res = ((y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} + // REDUNDANT REPRESENTATIONS (CASE6) + // if exponents are the same, then we have a simple comparison of the + // significands +if (exp_y == exp_x) { + res = (((sig_x.w[1] > sig_y.w[1]) + || (sig_x.w[1] == sig_y.w[1] + && sig_x.w[0] >= sig_y.w[0])) ^ ((x.w[1] & MASK_SIGN) == + MASK_SIGN)); + BID_RETURN (res); +} + // if both components are either bigger or smaller, + // it is clear what needs to be done +if (sig_x.w[1] >= sig_y.w[1] && sig_x.w[0] >= sig_y.w[0] + && exp_x > exp_y) { + res = ((x.w[1] & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); +} +if (sig_x.w[1] <= sig_y.w[1] && sig_x.w[0] <= sig_y.w[0] + && exp_x < exp_y) { + res = ((x.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} + +diff = exp_x - exp_y; + + // if |exp_x - exp_y| < 33, it comes down to the compensated significand +if (diff > 0) { // to simplify the loop below, + + // if exp_x is 33 greater than exp_y, no need for compensation + if (diff > 33) { + res = ((x.w[1] & MASK_SIGN) != MASK_SIGN); + BID_RETURN (res); + } // difference cannot be greater than 10^33 + + if (diff > 19) { //128 by 128 bit multiply -> 256 bits + __mul_128x128_to_256 (sig_n_prime256, sig_x, ten2k128[diff - 20]); + + + // if postitive, return whichever significand is larger + // (converse if negative) + if (sig_n_prime256.w[3] == 0 && (sig_n_prime256.w[2] == 0) + && sig_n_prime256.w[1] == sig_y.w[1] + && (sig_n_prime256.w[0] == sig_y.w[0])) { + res = 1; + BID_RETURN (res); + } // if equal, return 1 + { + res = ((((sig_n_prime256.w[3] > 0) || sig_n_prime256.w[2] > 0) + || (sig_n_prime256.w[1] > sig_y.w[1]) + || (sig_n_prime256.w[1] == sig_y.w[1] + && sig_n_prime256.w[0] > + sig_y.w[0])) ^ ((y.w[1] & MASK_SIGN) == MASK_SIGN)); + BID_RETURN (res); + } + } + //else { //128 by 64 bit multiply -> 192 bits + __mul_64x128_to192 (sig_n_prime192, ten2k64[diff], sig_x); + + // if postitive, return whichever significand is larger + // (converse if negative) + if ((sig_n_prime192.w[2] == 0) && sig_n_prime192.w[1] == sig_y.w[1] + && (sig_n_prime192.w[0] == sig_y.w[0])) { + res = 1; + BID_RETURN (res); + } // if equal, return 1 + { + res = (((sig_n_prime192.w[2] > 0) + || (sig_n_prime192.w[1] > sig_y.w[1]) + || (sig_n_prime192.w[1] == sig_y.w[1] + && sig_n_prime192.w[0] > + sig_y.w[0])) ^ ((y.w[1] & MASK_SIGN) == MASK_SIGN)); + BID_RETURN (res); + } +} + +diff = exp_y - exp_x; + + // if exp_x is 33 less than exp_y, no need for compensation +if (diff > 33) { + res = ((x.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} + +if (diff > 19) { //128 by 128 bit multiply -> 256 bits + // adjust the y significand upwards + __mul_128x128_to_256 (sig_n_prime256, sig_y, ten2k128[diff - 20]); + + + // if postitive, return whichever significand is larger + // (converse if negative) + if (sig_n_prime256.w[3] == 0 && (sig_n_prime256.w[2] == 0) + && sig_n_prime256.w[1] == sig_x.w[1] + && (sig_n_prime256.w[0] == sig_x.w[0])) { + res = 1; + BID_RETURN (res); + } // if equal, return 1 + { + res = ((sig_n_prime256.w[3] == 0 && sig_n_prime256.w[2] == 0 + && (sig_n_prime256.w[1] < sig_x.w[1] + || (sig_n_prime256.w[1] == sig_x.w[1] + && sig_n_prime256.w[0] < + sig_x.w[0]))) ^ ((x.w[1] & MASK_SIGN) == + MASK_SIGN)); + BID_RETURN (res); + } +} + //else { //128 by 64 bit multiply -> 192 bits + // adjust the y significand upwards +__mul_64x128_to192 (sig_n_prime192, ten2k64[diff], sig_y); + + // if postitive, return whichever significand is larger + // (converse if negative) +if ((sig_n_prime192.w[2] == 0) && sig_n_prime192.w[1] == sig_x.w[1] + && (sig_n_prime192.w[0] == sig_x.w[0])) { + res = 1; + BID_RETURN (res); +} // if equal, return 1 +{ + res = (sig_n_prime192.w[2] == 0 + && (sig_n_prime192.w[1] < sig_x.w[1] + || (sig_n_prime192.w[1] == sig_x.w[1] + && sig_n_prime192.w[0] < + sig_x.w[0]))) ^ ((y.w[1] & MASK_SIGN) == MASK_SIGN); + BID_RETURN (res); +} +} + +BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (int, + bid128_quiet_greater_unordered, + x, y) + + int res; + int exp_x, exp_y; + int diff; + UINT128 sig_x, sig_y; + UINT192 sig_n_prime192; + UINT256 sig_n_prime256; + char x_is_zero = 0, y_is_zero = 0, non_canon_x, non_canon_y; + + // NaN (CASE1) + // if either number is NAN, the comparison is unordered, + // rather than + // equal : return 1 +if (((x.w[1] & MASK_NAN) == MASK_NAN) + || ((y.w[1] & MASK_NAN) == MASK_NAN)) { +if ((x.w[1] & MASK_SNAN) == MASK_SNAN + || (y.w[1] & MASK_SNAN) == MASK_SNAN) { + *pfpsf |= INVALID_EXCEPTION; +} +{ + res = 1; |