Hi,
This patch set enables the _Float16 type specified in ISO/IEC TS 18661-3
for AArch64.
To do this, we first need to update the excess precision logic to support
possibly computing _Float16 values in 16-bit range and precision, and to
set the FLT_EVAL_METHOD macro to "16" as appropriate. That requires some
more expressiveness than we currently get with TARGET_FLT_EVAL_METHOD, so
we first need a new target hook - TARGET_C_EXCESS_PRECISION (patch 1/11),
which we implement in the i386, s390 and m68k back-ends in patches 2-4/11.
However, the meaning of the new value "16" for FLT_EVAL_METHOD is not
specified under C99/C11, and conforming code may have been written assuming
that the only possible values for FLT_EVAL_METHOD were negative values and
{ 0, 1, 2 }. In [patch 5/11] we work around that with a new option -
-fpermitted-flt-eval-methods=[c11|ts-18661-3]. This option will restrict
the compiler to only using the C99/C11 values for FLT_EVAL_METHOD, and is
set to -fpermitted-flt-eval-methods=c11 by default when in a standards
compliant mode like -std=c11.
Patch 6/11 does the work of rewriting the excess precision logic along
the guidelines given in https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00410.html
Patch 7/11 finishes the hookization of TARGET_FLT_EVAL_METHOD by poisoning
the old macro.
Patch 8/11 removes the restriction in targhooks.c:default_floatn_mode that
currently disables HFmode support. This patch is not strictly necessary,
and an alternative route to the same goal would override TARGET_FLOATN_MODE
in AArch64. However, now we've cleaned up the excess precision logic,
I don't believe there is any reason this patch would not be correct.
Patch 9/11 imports the soft-fp changes from
https://sourceware.org/ml/libc-alpha/2016-09/msg00310.html to libgcc.
Patch 10/11 enables these conversion routines for AArch64.
And finally patch 11/11 adds support for the various hooks that the AArch64
back-end requires to turn _Float16 support on.
The patch series as a whole passes a bootstrap and test cycle on x86_64
and AArch64. I've bootstrapped and tested each patch individually on x86_64.
All new tests added and enabled pass as appropriate.
The AArch64 enablement requires
https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00268.html
OK?
Thanks,
James
ChangeLogs:
[Patch 1/11] Add a new target hook for describing excess precision intentions
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* target.def (excess_precision): New hook.
* target.h (flt_eval_method): New.
(excess_precision_type): Likewise.
* targhooks.c (default_excess_precision): New.
* targhooks.h (default_excess_precision): New.
* doc/tm.texi.in (TARGET_EXCESS_PRECISION): New.
* doc/tm.texi: Regenerate.
[Patch 2/11] Implement TARGET_C_EXCESS_PRECISION for i386
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* config/i386/i386.c (ix86_excess_precision): New.
(TARGET_C_EXCESS_PRECISION): Define.
[Patch 3/11] Implement TARGET_C_EXCESS_PRECISION for s390
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* config/s390/s390.c (s390_excess_precision): New.
(TARGET_C_EXCESS_PRECISION): Define.
[Patch 4/11] Implement TARGET_C_EXCESS_PRECISION for m68k
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* config/m68k/m68k.c (m68k_excess_precision): New.
(TARGET_C_EXCESS_PRECISION): Define.
[Patch 5/11] Add -fpermitted-flt-eval-methods=[c11|ts-18661-3]
gcc/c-family/
2016-09-30 James Greenhalgh <[email protected]>
* c-opts.c (c_common_post_options): Add logic to handle the default
case for -fpermitted-flt-eval-methods.
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* common.opt (fpermitted-flt-eval-methods): New.
* doc/invoke.texi (-fpermitted-flt-eval-methods): Document it.
* flag_types.h (permitted_flt_eval_methods): New.
gcc/testsuite/
2016-09-30 James Greenhalgh <[email protected]>
* gcc.dg/fpermitted-flt-eval-methods_1.c: New.
* gcc.dg/fpermitted-flt-eval-methods_2.c: New.
[Patch 6/11] Migrate excess precision logic to use TARGET_EXCESS_PRECISION
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* toplev.c (init_excess_precision): Delete most logic.
* tree.c (excess_precision_type): Rewrite to use
TARGET_EXCESS_PRECISION.
* doc/invoke.texi (-fexcess-precision): Document behaviour in a
more generic fashion.
gcc/c-family/
2016-09-30 James Greenhalgh <[email protected]>
* c-common.c (excess_precision_mode_join): New.
(c_ts18661_flt_eval_method): New.
(c_c11_flt_eval_method): Likewise.
(c_flt_eval_method): Likewise.
* c-common.h (excess_precision_mode_join): New.
(c_flt_eval_method): Likewise.
* c-cppbuiltin.c (c_cpp_flt_eval_method_iec_559): New.
(cpp_iec_559_value): Call it.
(c_cpp_builtins): Modify logic for __LIBGCC_*_EXCESS_PRECISION__,
call c_flt_eval_method to set __FLT_EVAL_METHOD__ and
__FLT_EVAL_METHOD_C99__.
[Patch 7/11] Delete TARGET_FLT_EVAL_METHOD and poison it.
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* config/s390/s390.h (TARGET_FLT_EVAL_METHOD): Delete.
* config/m68k/m68k.h (TARGET_FLT_EVAL_METHOD): Delete.
* config/i386/i386.h (TARGET_FLT_EVAL_METHOD): Delete.
* defaults.h (TARGET_FLT_EVAL_METHOD): Delete.
* doc/tm.texi.in (TARGET_FLT_EVAL_METHOD): Delete.
* doc/tm.texi: Regenerate.
* system.h (TARGET_FLT_EVAL_METHOD): Poison.
[Patch 8/11] Make _Float16 available if HFmode is available
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* targhooks.c (default_floatn_mode): Enable _Float16 if a target
provides HFmode.
[Patch libgcc 9/11] Update soft-fp from glibc
libgcc/
2016-09-30 James Greenhalgh <[email protected]>
* soft-fp/extendhftf2.c: New.
* soft-fp/fixhfti.c: Likewise.
* soft-fp/fixunshfti.c: Likewise.
* soft-fp/floattihf.c: Likewise.
* soft-fp/floatuntihf.c: Likewise.
* soft-fp/half.h: Likewise.
* soft-fp/trunctfhf2.c: Likewise.
[Patch libgcc AArch64 10/11] Enable hfmode soft-float conversions and
truncations
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* config/aarch64/aarch64-c.c (aarch64_scalar_mode_supported_p): New.
(TARGET_SCALAR_MODE_SUPPORTED_P): Define.
libgcc/
2016-09-30 James Greenhalgh <[email protected]>
* config/aarch64/sfp-machine.h (_FP_NANFRAC_H): Define.
(_FP_NANSIGN_H): Likewise.
* config/aarch64/t-softfp (softfp_extensions): Add hftf.
(softfp_truncations): Add tfhf.
(softfp_extras): Add required conversion functions.
[Patch AArch64 11/11] Enable _Float16
gcc/
2016-09-30 James Greenhalgh <[email protected]>
* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Update
__FLT_EVAL_METHOD__ and __FLT_EVAL_METHOD_C99__ when we switch
architecture levels.
* config/aarch64/aarch64.c (aarch64_promoted_type): Only promote
the aarch64_fp16_type_node, not all HFmode types.
(aarch64_libgcc_floating_mode_supported_p): Support HFmode.
(aarch64_scalar_mode_supported_p): Likewise.
(aarch64_excess_precision): New.
(TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Define.
(TARGET_SCALAR_MODE_SUPPORTED_P): Likewise.
(TARGET_C_EXCESS_PRECISION): Likewise.
gcc/testsuite/
2016-09-30 James Greenhalgh <[email protected]>
* gcc.target/aarch64/_Float16_1.c: New.
* gcc.target/aarch64/_Float16_2.c: Likewise.
* gcc.target/aarch64/_Float16_3.c: Likewise.