gcc/libgcc/config
Jakub Jelinek 2ce182e258 libgcc _BitInt support [PR102989]
This patch adds the library helpers for multiplication, division + modulo
and casts from and to floating point (both binary and decimal).
As described in the intro, the first step is try to reduce further the
passed in precision by skipping over most significant limbs with just zeros
or sign bit copies.  For multiplication and division I've implemented
a simple algorithm, using something smarter like Karatsuba or Toom N-Way
might be faster for very large _BitInts (which we don't support right now
anyway), but could mean more code in libgcc, which maybe isn't what people
are willing to accept.
For the to/from floating point conversions the patch uses soft-fp, because
it already has tons of handy macros which can be used for that.  In theory
it could be implemented using {,unsigned} long long or {,unsigned} __int128
to/from floating point conversions with some frexp before/after, but at that
point we already need to force it into integer registers and analyze it
anyway.  Plus, for 32-bit arches there is no __int128 that could be used
for XF/TF mode stuff.
I know that soft-fp is owned by glibc and I think the op-common.h change
should be propagated there, but the bitint stuff is really GCC specific
and IMHO doesn't belong into the glibc copy.

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

	PR c/102989
libgcc/
	* config/aarch64/t-softfp (softfp_extras): Use += rather than :=.
	* config/i386/64/t-softfp (softfp_extras): Likewise.
	* config/i386/libgcc-glibc.ver (GCC_14.0.0): Export _BitInt support
	routines.
	* config/i386/t-softfp (softfp_extras): Add fixxfbitint and
	bf, hf and xf mode floatbitint.
	(CFLAGS-floatbitintbf.c, CFLAGS-floatbitinthf.c): Add -msse2.
	* config/riscv/t-softfp32 (softfp_extras): Use += rather than :=.
	* config/rs6000/t-e500v1-fp (softfp_extras): Likewise.
	* config/rs6000/t-e500v2-fp (softfp_extras): Likewise.
	* config/t-softfp (softfp_floatbitint_funcs): New.
	(softfp_bid_list): New.
	(softfp_func_list): Add sf and df mode from and to _BitInt libcalls.
	(softfp_bid_file_list): New.
	(LIB2ADD_ST): Add $(softfp_bid_file_list).
	* config/t-softfp-sfdftf (softfp_extras): Add fixtfbitint and
	floatbitinttf.
	* config/t-softfp-tf (softfp_extras): Likewise.
	* libgcc2.c (bitint_reduce_prec): New inline function.
	(BITINT_INC, BITINT_END): Define.
	(bitint_mul_1, bitint_addmul_1): New helper functions.
	(__mulbitint3): New function.
	(bitint_negate, bitint_submul_1): New helper functions.
	(__divmodbitint4): New function.
	* libgcc2.h (LIBGCC2_UNITS_PER_WORD): When building _BitInt support
	libcalls, redefine depending on __LIBGCC_BITINT_LIMB_WIDTH__.
	(__mulbitint3, __divmodbitint4): Declare.
	* libgcc-std.ver.in (GCC_14.0.0): Export _BitInt support routines.
	* Makefile.in (lib2funcs): Add _mulbitint3.
	(LIB2_DIVMOD_FUNCS): Add _divmodbitint4.
	* soft-fp/bitint.h: New file.
	* soft-fp/fixdfbitint.c: New file.
	* soft-fp/fixsfbitint.c: New file.
	* soft-fp/fixtfbitint.c: New file.
	* soft-fp/fixxfbitint.c: New file.
	* soft-fp/floatbitintbf.c: New file.
	* soft-fp/floatbitintdf.c: New file.
	* soft-fp/floatbitinthf.c: New file.
	* soft-fp/floatbitintsf.c: New file.
	* soft-fp/floatbitinttf.c: New file.
	* soft-fp/floatbitintxf.c: New file.
	* soft-fp/op-common.h (_FP_FROM_INT): Add support for rsize up to
	4 * _FP_W_TYPE_SIZE rather than just 2 * _FP_W_TYPE_SIZE.
	* soft-fp/bitintpow10.c: New file.
	* soft-fp/fixsdbitint.c: New file.
	* soft-fp/fixddbitint.c: New file.
	* soft-fp/fixtdbitint.c: New file.
	* soft-fp/floatbitintsd.c: New file.
	* soft-fp/floatbitintdd.c: New file.
	* soft-fp/floatbitinttd.c: New file.
2023-09-06 17:33:05 +02:00
..
aarch64 libgcc _BitInt support [PR102989] 2023-09-06 17:33:05 +02:00
alpha Update copyright years. 2023-01-16 11:52:17 +01:00
arc Update copyright years. 2023-01-16 11:52:17 +01:00
arm arm: Fix warning in libgcc/config/arm/pr-support.c 2023-02-03 16:40:42 +01:00
avr Update copyright years. 2023-01-16 11:52:17 +01:00
bfin Update copyright years. 2023-01-16 11:52:17 +01:00
bpf
c6x Update copyright years. 2023-01-16 11:52:17 +01:00
cris libgcc CRIS: Define TARGET_HAS_NO_HW_DIVIDE 2023-04-27 02:00:33 +02:00
csky Update copyright years. 2023-01-16 11:52:17 +01:00
epiphany Update copyright years. 2023-01-16 11:52:17 +01:00
fr30 Update copyright years. 2023-01-16 11:52:17 +01:00
frv Update copyright years. 2023-01-16 11:52:17 +01:00
ft32 Update copyright years. 2023-01-16 11:52:17 +01:00
gcn amdgcn: implement vector div and mod libfuncs 2023-06-19 12:35:35 +01:00
h8300 Update copyright years. 2023-01-16 11:52:17 +01:00
i386 libgcc _BitInt support [PR102989] 2023-09-06 17:33:05 +02:00
ia64 Update copyright years. 2023-01-16 11:52:17 +01:00
iq2000 Update copyright years. 2023-01-16 11:52:17 +01:00
libbid Update copyright years. 2023-01-16 11:52:17 +01:00
lm32 Update copyright years. 2023-01-16 11:52:17 +01:00
loongarch Update copyright years. 2023-01-16 11:52:17 +01:00
m32c Update copyright years. 2023-01-16 11:52:17 +01:00
m32r Update copyright years. 2023-01-16 11:52:17 +01:00
m68k Update copyright years. 2023-01-16 11:52:17 +01:00
mcore Update copyright years. 2023-01-16 11:52:17 +01:00
microblaze Update copyright years. 2023-01-16 11:52:17 +01:00
mips MIPS: Add speculation_barrier support 2023-06-05 11:22:00 +08:00
mmix Update copyright years. 2023-01-16 11:52:17 +01:00
moxie Update copyright years. 2023-01-16 11:52:17 +01:00
msp430 Update copyright years. 2023-01-16 11:52:17 +01:00
nds32 Update copyright years. 2023-01-16 11:52:17 +01:00
nios2 Update copyright years. 2023-01-16 11:52:17 +01:00
nvptx Update copyright years. 2023-01-16 11:52:17 +01:00
or1k or1k: Do not clear existing FPU exceptions before updating 2023-03-19 15:41:22 +09:00
pa Add assember CFI directives to millicode division and remainder routines. 2023-04-05 14:44:54 +00:00
pdp11
pru libgcc pru: Define TARGET_HAS_NO_HW_DIVIDE 2023-05-01 11:08:51 +03:00
riscv libgcc _BitInt support [PR102989] 2023-09-06 17:33:05 +02:00
rl78 Update copyright years. 2023-01-16 11:52:17 +01:00
rs6000 libgcc _BitInt support [PR102989] 2023-09-06 17:33:05 +02:00
rx Update copyright years. 2023-01-16 11:52:17 +01:00
s390 libgcc: Use initarray section type for .init_stack 2023-06-04 22:39:32 -05:00
score Update copyright years. 2023-01-16 11:52:17 +01:00
sh Update copyright years. 2023-01-16 11:52:17 +01:00
sol2 Update copyright years. 2023-01-16 11:52:17 +01:00
sparc Update copyright years. 2023-01-16 11:52:17 +01:00
stormy16 Update copyright years. 2023-01-16 11:52:17 +01:00
v850 PR target/109402: v850 (not v850e) variant of __muldi3() moves sp in reversed direction [PR109402] 2023-04-08 08:26:00 -06:00
vax Update copyright years. 2023-01-16 11:52:17 +01:00
visium Update copyright years. 2023-01-16 11:52:17 +01:00
vms Update copyright years. 2023-01-16 11:52:17 +01:00
xtensa xtensa: add .note.GNU-stack section on linux 2023-03-13 13:42:18 -07:00
darwin-64.c Update copyright years. 2023-01-16 11:52:17 +01:00
darwin-crt-tm.c Update copyright years. 2023-01-16 11:52:17 +01:00
darwin-crt3.c Update copyright years. 2023-01-16 11:52:17 +01:00
darwin-unwind.ver libgcc, Darwin: Build a libgcc_s.1 for backwards compatibility. 2021-12-08 19:53:28 +00:00
darwin10-unwind-find-enc-func.c Darwin, libgcc : Adjust min version supported for the OS. 2023-05-19 09:06:01 +01:00
gthr-lynx.h Update copyright years. 2023-01-16 11:52:17 +01:00
gthr-rtems.h Update copyright years. 2023-01-16 11:52:17 +01:00
gthr-vxworks-cond.c Update copyright years. 2023-01-16 11:52:17 +01:00
gthr-vxworks-thread.c Update copyright years. 2023-01-16 11:52:17 +01:00
gthr-vxworks-tls.c Update copyright years. 2023-01-16 11:52:17 +01:00
gthr-vxworks.c Update copyright years. 2023-01-16 11:52:17 +01:00
gthr-vxworks.h Update copyright years. 2023-01-16 11:52:17 +01:00
hardfp.c Update copyright years. 2023-01-16 11:52:17 +01:00
libgcc-glibc.ver Update copyright years. 2023-01-16 11:52:17 +01:00
libgcc-libsystem.ver Darwin: Rework handling for unwinder code in libgcc_s and specs [PR80556]. 2021-11-19 19:58:11 +00:00
no-sfp-machine.h
no-unwind.h
t-crtfm
t-crtstuff-pic
t-darwin Darwin, libgcc : Adjust min version supported for the OS. 2023-05-19 09:06:01 +01:00
t-darwin-ehs Darwin, libgcc: Fix build errors on powerpc-darwin8. 2022-03-04 16:44:54 +00:00
t-darwin-min-1 Darwin, libgcc : Adjust min version supported for the OS. 2023-05-19 09:06:01 +01:00
t-darwin-min-5 Darwin, libgcc : Adjust min version supported for the OS. 2023-05-19 09:06:01 +01:00
t-darwin-min-8 Darwin, libgcc : Adjust min version supported for the OS. 2023-05-19 09:06:01 +01:00
t-dfprules
t-eh-dw2-dip
t-fdpbit
t-fixedpoint-gnu-prefix
t-fpbit
t-freebsd-thread
t-gnu-prefix
t-gthr-noweak
t-gthr-vxworks
t-gthr-vxworksae
t-hardfp Update copyright years. 2023-01-16 11:52:17 +01:00
t-hardfp-sfdf Update copyright years. 2023-01-16 11:52:17 +01:00
t-libgcc-pic
t-libunwind
t-libunwind-elf Update copyright years. 2023-01-16 11:52:17 +01:00
t-linux
t-openbsd-thread
t-rtems
t-slibgcc Update copyright years. 2023-01-16 11:52:17 +01:00
t-slibgcc-darwin libgcc, Darwin: No early install for the compatibility libgcc_s.1.dylib. 2022-12-24 13:52:46 +00:00
t-slibgcc-elf-ver
t-slibgcc-fuchsia Update copyright years. 2023-01-16 11:52:17 +01:00
t-slibgcc-gld
t-slibgcc-gld-nover
t-slibgcc-hpux
t-slibgcc-libgcc Update copyright years. 2023-01-16 11:52:17 +01:00
t-slibgcc-nolc-override
t-slibgcc-sld
t-slibgcc-vms
t-softfp libgcc _BitInt support [PR102989] 2023-09-06 17:33:05 +02:00
t-softfp-compat
t-softfp-excl
t-softfp-sfdf
t-softfp-sfdftf libgcc _BitInt support [PR102989] 2023-09-06 17:33:05 +02:00
t-softfp-tf libgcc _BitInt support [PR102989] 2023-09-06 17:33:05 +02:00
t-stack
t-tls
t-vxcrtstuff
t-vxcrtstuffS Tigthen libc_internal and crtstuff for VxWorks shared objects 2021-12-13 18:03:03 +00:00
t-vxworks Adjust LIBGCC2_INCLUDES for VxWorks and augment comment 2022-10-02 09:33:00 +00:00
t-vxworksae
unwind-dw2-fde-darwin.c Update copyright years. 2023-01-16 11:52:17 +01:00
vxcrtstuff.c Improve comments and INITFINI macro use in vxcrtsutff.c 2022-09-29 18:02:21 +00:00