Stefan Schulze Frielinghaus 5d6d56d837 s390: Add HF mode support
This patch adds support for _Float16.  As time of writing this, there is
no hardware _Float16 support on s390.  Therefore, _Float16 operations
have to be extended and truncated which is supported via soft-fp.

The ABI demands that _Float16 values are left aligned in FP registers
similar as it is already the case for 32-bit FP values.  If vector
extensions are available, copying between left-aligned FPRs and
right-aligned GPRs is natively supported.  Without vector extensions,
the alignment has to be taken care of manually.  For target z10,
instructions lgdr/ldgr can be used in conjunction with shifts.  Copying
via lgdr from an FPR into a GPR is the easy case since for the shift the
target GPR can be utilized.  However, copying via ldgr from a GPR into a
FPR requires a secondary reload register which is used for the shift
result and is then copied into the FPR.  Prior z10, there is no hardware
support in order to copy directly between FPRs and GPRs.  Therefore, in
order to copy from a GPR into an FPR we would require a secondary reload
register for the shift and secondary memory for copying the aligned
value.  Since this is not supported, _Float16 support starts with z10.
As a consequence, for all targets older than z10 test
libstdc++-abi/abi_check fails.

gcc/ChangeLog:

	* config/s390/s390-modes.def (FLOAT_MODE): Add HF mode.
	(VECTOR_MODE): Add V{1,2,4,8,16}HF modes.
	* config/s390/s390.cc (s390_scalar_mode_supported_p): For 64-bit
	targets z10 and newer support HF mode.
	(s390_vector_mode_supported_p): Add HF mode.
	(s390_register_move_cost): Keep HF mode operands in registers.
	(s390_legitimate_constant_p): Support zero constant.
	(s390_secondary_reload): For GPR to FPR moves a secondary reload
	register is required.
	(s390_secondary_memory_needed): GPR<->FPR moves don't require
	secondary memory.
	(s390_libgcc_floating_mode_supported_p): For 64-bit targets z10
	and newer support HF mode.
	(s390_hard_regno_mode_ok): Allow HF mode for FPRs and VRs.
	(s390_function_arg_float): Consider HF mode, too.
	(s390_excess_precision): For EXCESS_PRECISION_TYPE_FLOAT16
	return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16.
	(TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Define.
	* config/s390/s390.md (movhf): Define.
	(reload_half_gprtofpr_z10): Define.
	(signbithf2): Define.
	* config/s390/vector.md: Add new vector modes to various
	iterators.

libgcc/ChangeLog:

	* config.host: Include s390/t-float16.
	* config/s390/libgcc-glibc.ver: Export symbols
	__trunc{sf,df,tf}hf2, __extendhf{sf,df,tf}2, __fix{,uns}hfti,
	__float{,un}tihf, __floatbitinthf.
	* config/s390/t-softfp: Add to softfp_extras instead of setting
	it.
	* configure: Regenerate.
	* configure.ac: Support float16 only for 64-bit targets z10 and
	newer.
	* config/s390/_dpd_dd_to_hf.c: New file.
	* config/s390/_dpd_hf_to_dd.c: New file.
	* config/s390/_dpd_hf_to_sd.c: New file.
	* config/s390/_dpd_hf_to_td.c: New file.
	* config/s390/_dpd_sd_to_hf.c: New file.
	* config/s390/_dpd_td_to_hf.c: New file.
	* config/s390/t-float16: New file.

libstdc++-v3/ChangeLog:

	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Add
	names {,P,K}DF16.

gcc/testsuite/ChangeLog:

	* g++.target/s390/float16-1.C: New test.
	* g++.target/s390/float16-2.C: New test.
	* gcc.target/s390/float16-1-2.h: New test.
	* gcc.target/s390/float16-1.c: New test.
	* gcc.target/s390/float16-10.c: New test.
	* gcc.target/s390/float16-2.c: New test.
	* gcc.target/s390/float16-3.c: New test.
	* gcc.target/s390/float16-4.c: New test.
	* gcc.target/s390/float16-5.c: New test.
	* gcc.target/s390/float16-6.c: New test.
	* gcc.target/s390/float16-7.c: New test.
	* gcc.target/s390/float16-8.c: New test.
	* gcc.target/s390/float16-9.c: New test.
	* gcc.target/s390/float16-signbit.h: New test.
	* gcc.target/s390/vector/vec-extract-4.c: New test.
	* gcc.target/s390/vector/vec-float16-1.c: New test.
2026-01-10 17:22:46 +01:00
2026-01-10 00:16:49 +00:00
2026-01-10 00:16:49 +00:00
2026-01-10 17:22:46 +01:00
2026-01-10 00:16:49 +00:00
2026-01-10 00:16:49 +00:00
2026-01-10 00:16:49 +00:00
2026-01-10 17:22:46 +01:00
2026-01-10 00:16:49 +00:00
2026-01-10 00:16:49 +00:00
2026-01-10 17:22:46 +01:00
2026-01-10 00:16:49 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 5.1 GiB
Languages
C++ 32%
C 30.9%
Ada 12.1%
D 6.5%
Go 6.5%
Other 11.5%