The FP16 extension introduced with the ARMv8.2-A architecture adds instructions operating on FP16 values to the VFP and NEON instruction sets.
The patch adds the feature macro __ARM_FEATURE_FP16_SCALAR_ARITHMETIC which is defined to be 1 if the VFP FP16 instructions are available; it is otherwise undefined. The patch also adds the feature macro __ARM_FEATURE_FP16_VECTOR_ARITHMETIC which is defined to be 1 if the NEON FP16 instructions are available; it is otherwise undefined. These two macros will appear in a future version of the ACLE. Tested the series for arm-none-linux-gnueabihf with native bootstrap and make check and for arm-none-eabi and armeb-none-eabi with make check on an ARMv8.2-A emulator. Ok for trunk? Matthew 2016-05-17 Matthew Wahab <matthew.wa...@arm.com> * config/arm/arm-c.c (arm_cpu_builtins): Define "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC" and "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC". testsuite/ 2016-05-17 Matthew Wahab <matthew.wa...@arm.com> * gcc.target/arm/attr-fp16-arith-1.c: New.
>From 688b4d34a64a40abd4705a9bdaea40929a7a1d26 Mon Sep 17 00:00:00 2001 From: Matthew Wahab <matthew.wa...@arm.com> Date: Thu, 7 Apr 2016 13:32:15 +0100 Subject: [PATCH 04/17] [PATCH 4/17][ARM] Define feature macros for FP16. 2016-05-17 Matthew Wahab <matthew.wa...@arm.com> * config/arm/arm-c.c (arm_cpu_builtins): Define "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC" and "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC". testsuite/ 2016-05-17 Matthew Wahab <matthew.wa...@arm.com> * gcc.target/arm/attr-fp16-arith-1.c: New. --- gcc/config/arm/arm-c.c | 5 +++ gcc/testsuite/gcc.target/arm/attr-fp16-arith-1.c | 45 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/attr-fp16-arith-1.c diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c index b98470f..7283700 100644 --- a/gcc/config/arm/arm-c.c +++ b/gcc/config/arm/arm-c.c @@ -142,6 +142,11 @@ arm_cpu_builtins (struct cpp_reader* pfile) def_or_undef_macro (pfile, "__ARM_FP16_ARGS", arm_fp16_format != ARM_FP16_FORMAT_NONE); + def_or_undef_macro (pfile, "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", + TARGET_VFP_FP16INST); + def_or_undef_macro (pfile, "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", + TARGET_NEON_FP16INST); + def_or_undef_macro (pfile, "__ARM_FEATURE_FMA", TARGET_FMA); def_or_undef_macro (pfile, "__ARM_NEON__", TARGET_NEON); def_or_undef_macro (pfile, "__ARM_NEON", TARGET_NEON); diff --git a/gcc/testsuite/gcc.target/arm/attr-fp16-arith-1.c b/gcc/testsuite/gcc.target/arm/attr-fp16-arith-1.c new file mode 100644 index 0000000..5011315 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/attr-fp16-arith-1.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_v8_2a_fp16_neon_ok } */ +/* { dg-options "-O2" } */ +/* { dg-add-options arm_v8_2a_fp16_scalar } */ + +/* Reset fpu to a value compatible with the next pragmas. */ +#pragma GCC target ("fpu=vfp") + +#pragma GCC push_options +#pragma GCC target ("fpu=fp-armv8") + +#ifndef __ARM_FEATURE_FP16_SCALAR_ARITHMETIC +#error __ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined. +#endif + +#pragma GCC push_options +#pragma GCC target ("fpu=neon-fp-armv8") + +#ifndef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC +#error __ARM_FEATURE_FP16_VECTOR_ARITHMETIC not defined. +#endif + +#ifndef __ARM_NEON +#error __ARM_NEON not defined. +#endif + +#if !defined (__ARM_FP) || !(__ARM_FP & 0x2) +#error Invalid value for __ARM_FP +#endif + +#pragma GCC pop_options + +/* Check that the FP version is correctly reset to mfpu=fp-armv8. */ + +#if !defined (__ARM_FP) || !(__ARM_FP & 0x2) +#error __ARM_FP should record FP16 support. +#endif + +#pragma GCC pop_options + +/* Check that the FP version is correctly reset to mfpu=vfp. */ + +#if !defined (__ARM_FP) || (__ARM_FP & 0x2) +#error Unexpected value for __ARM_FP. +#endif -- 2.1.4