This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ARM] Enable __fp16 as a function parameter and return type.
- From: Ramana Radhakrishnan <ramana dot gcc at googlemail dot com>
- To: Matthew Wahab <matthew dot wahab at foss dot arm dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 13 May 2016 14:41:20 +0100
- Subject: Re: [ARM] Enable __fp16 as a function parameter and return type.
- Authentication-results: sourceware.org; auth=none
- References: <5721D5C1 dot 3080000 at foss dot arm dot com>
On Thu, Apr 28, 2016 at 10:20 AM, Matthew Wahab
<matthew.wahab@foss.arm.com> wrote:
> Hello,
>
> The ARM target supports the half-precision floating point type __fp16
> but does not allow its use as a function return or parameter type. This
> patch removes that restriction and defines the ACLE macro
> __ARM_FP16_ARGS to indicate this. The code generated for passing __fp16
> values into and out of functions depends on the level of hardware
> support but conforms to the AAPCS (see
> http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf).
>
> This patch enables data movement for HF-mode values using VFP registers,
> when they are available, to support passing arguments and return values
> through the registers.
>
> This patch also fixes the definition of TARGET_NEON_FP16 which used to
> require both neon and fp16 features to be enabled. This was
> inadvertently weakened, when the macro definition was changed to use
> ARM_FPU_FSET_HAS, to only require one of neon or fp16 to be
> enabled. This patch returns to the original
> requirements. TARGET_NEON_FP16 is only used in instruction selection for
> HF-mode data moves.
>
> Tested for arm-none-eabi with cross-compiled check-gcc and for
> arm-none-linux-gnueabihf with native bootstrap and make check.
>
> Ok for trunk?
> Matthew
This is OK - thanks.
We have to deal with Joseph's points around the issue with double
rounding but I think that's the subject of a separate patch.
regards
Ramana
>
> gcc/
> 2016-04-27 Matthew Wahab <matthew.wahab@arm.com>
> Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
> Jiong Wang <jiong.wang@arm.com>
>
> * config/arm/arm-c.c (arm_cpu_builtins): Use def_or_undef_macro
> for __ARM_FP16_FORMAT_IEEE and __ARM_FP16_FORMAT_ALTERNATIVE.
> Define __ARM_FP16_ARGS when appropriate.
> * config/arm/arm.c (arm_invalid_parameter_type): Remove
> declaration.
> (arm_invalid_return_type): Likewise.
> (TARGET_INVALID_PARAMETER_TYPE): Remove.
> (TARGET_INVALID_RETURN_TYPE): Remove.
> (aapcs_vfp_sub_candidate): Allow HFmode.
> (aapcs_vfp_allocate): Add comment. Support HFmode.
> (aapcs_vfp_allocate_return_reg): Likewise.
> (struct aapcs_cp_arg_layout): Slightly reword comments for
> is_return_candidate and allocate_return_reg.
> (output_mov_vfp): Update assert.
> (arm_hard_regno_mode_ok): Remove comment, update HF-mode
> condition.
> (arm_invalid_parameter_type): Remove.
> (amr_invalid_return_type): Remove.
> * config/arm/arm.h (TARGET_NEON_FP16): Fix definition.
> * config/arm/arm.md (*arm32_movhf): Disable for TARGET_VFP.
> * config/arm/vfp.md (*movhf_vfp): Enable for TARGET_VFP.
>
> gcc/testsuite/
> 2016-04-27 Matthew Wahab <matthew.wahab@arm.com>
>
> * g++.dg/ext/arm-fp16/fp16-param-1.c: Update expected output. Add
> test for __ARM_FP16_ARGS.
> * g++.dg/ext/arm-fp16/fp16-return-1.c: Update expected output.
> * gcc.target/arm/aapcs/neon-vect10.c: New.
> * gcc.target/arm/aapcs/neon-vect9.c: New.
> * gcc.target/arm/aapcs/vfp18.c: New.
> * gcc.target/arm/aapcs/vfp19.c: New.
> * gcc.target/arm/aapcs/vfp20.c: New.
> * gcc.target/arm/aapcs/vfp21.c: New.
> * gcc.target/arm/fp16-aapcs-1.c: New.
> * g++.target/arm/fp16-param-1.c: Update expected output. Add
> test for __ARM_FP16_ARGS.
> * g++.target/arm/fp16-return-1.c: Update expected output.