ARMv8.2-A extends the ARMv8.1-A architecture, adding features that include an optional extension to support FP16 in floating-point and Adv.SIMD instructions. This patch adds the command line and feature flags for ARMv8.2-A and the FP16 support.
The new command option -march=armv8.2-a will enable the new ARMv8.2-A feature macro, which is a superset of the ARMv8.1 features. The new feature "fp16" can be enabled by -march=armv8.2-a+fp16 which will enable ARMv8.2 FP16 extension support. The feature macro __ARM_FEATURE_FP16_SCALAR_ARITHMETIC is defined to be 1 if the scalar FP16 instructions are available, it is otherwise undefined. The feature macro __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is defined to be 1 if the vector FP16 instructions are available, it is otherwise undefined. OK for trunk? Thanks. 2016-06-07 Matthew Wahab<matthew.wa...@arm.com> Jiong Wang<jiong.w...@arm.com> * config/aarch64/aarch64-arches.def: Add "armv8.2-a". * config/aarch64/aarch64.h (AARCH64_FL_V8_2): New. (AARCH64_FL_F16): New. (AARCH64_FL_FOR_ARCH8_2): New. (AARCH64_ISA_8_2): New. (AARCH64_ISA_F16): New. (TARGET_FP_F16INST): New. (TARGET_SIMD_F16INST): New. * config/aarch64/aarch64-option-extensions.def: New entry for "fp16". * config/aarch64/aarch64-c.c (arch64_update_cpp_builtins): Conditionally define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC and __ARM_FEATURE_FP16_VECTOR_ARITHMETIC. * doc/invoke.texi (AArch64 Options): Document "armv8.2-a" and "fp16".
diff --git a/gcc/config/aarch64/aarch64-arches.def b/gcc/config/aarch64/aarch64-arches.def index 1e9d90b1b66a21ebbe4c238ce844c6fd3a192201..7dcf140411f6eb95504d9b92df9dadce50529a28 100644 --- a/gcc/config/aarch64/aarch64-arches.def +++ b/gcc/config/aarch64/aarch64-arches.def @@ -32,4 +32,5 @@ AARCH64_ARCH("armv8-a", generic, 8A, 8, AARCH64_FL_FOR_ARCH8) AARCH64_ARCH("armv8.1-a", generic, 8_1A, 8, AARCH64_FL_FOR_ARCH8_1) +AARCH64_ARCH("armv8.2-a", generic, 8_2A, 8, AARCH64_FL_FOR_ARCH8_2) diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c index e64dc7676ccae10e87ade3946904408fe425730d..3380ed6f2cd0ae35fd6a4e53177604256875e6de 100644 --- a/gcc/config/aarch64/aarch64-c.c +++ b/gcc/config/aarch64/aarch64-c.c @@ -95,6 +95,11 @@ aarch64_update_cpp_builtins (cpp_reader *pfile) else cpp_undef (pfile, "__ARM_FP"); + aarch64_def_or_undef (TARGET_FP_F16INST, + "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", pfile); + aarch64_def_or_undef (TARGET_SIMD_F16INST, + "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", pfile); + aarch64_def_or_undef (TARGET_SIMD, "__ARM_FEATURE_NUMERIC_MAXMIN", pfile); aarch64_def_or_undef (TARGET_SIMD, "__ARM_NEON", pfile); diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def index e8706d1c2e798872b8028cce1d9d193df8fef0be..ff59dceabffe780adc84d953823800ba2abca5f3 100644 --- a/gcc/config/aarch64/aarch64-option-extensions.def +++ b/gcc/config/aarch64/aarch64-option-extensions.def @@ -55,3 +55,6 @@ AARCH64_OPT_EXTENSION("crc", AARCH64_FL_CRC, 0, 0, "crc32") /* Enabling or disabling "lse" only changes "lse". */ AARCH64_OPT_EXTENSION("lse", AARCH64_FL_LSE, 0, 0, "atomics") + +/* Enabling or disabling "fp16" only changes "fp16". */ +AARCH64_OPT_EXTENSION("fp16", AARCH64_FL_F16, 0, 0, "fp16") diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 15d7e4019adf207d5127ebba31af35a8b3437c5b..a71420382069b66e2faef15c238f07374683b4fc 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -135,6 +135,8 @@ extern unsigned aarch64_architecture_version; /* ARMv8.1 architecture extensions. */ #define AARCH64_FL_LSE (1 << 4) /* Has Large System Extensions. */ #define AARCH64_FL_V8_1 (1 << 5) /* Has ARMv8.1 extensions. */ +#define AARCH64_FL_V8_2 (1 << 8) /* Has ARMv8.2 features. */ +#define AARCH64_FL_F16 (1 << 9) /* Has ARMv8.2 FP16 extensions. */ /* Has FP and SIMD. */ #define AARCH64_FL_FPSIMD (AARCH64_FL_FP | AARCH64_FL_SIMD) @@ -146,6 +148,8 @@ extern unsigned aarch64_architecture_version; #define AARCH64_FL_FOR_ARCH8 (AARCH64_FL_FPSIMD) #define AARCH64_FL_FOR_ARCH8_1 \ (AARCH64_FL_FOR_ARCH8 | AARCH64_FL_LSE | AARCH64_FL_CRC | AARCH64_FL_V8_1) +#define AARCH64_FL_FOR_ARCH8_2 \ + (AARCH64_FL_FOR_ARCH8_1 | AARCH64_FL_V8_2) /* Macros to test ISA flags. */ @@ -155,6 +159,8 @@ extern unsigned aarch64_architecture_version; #define AARCH64_ISA_SIMD (aarch64_isa_flags & AARCH64_FL_SIMD) #define AARCH64_ISA_LSE (aarch64_isa_flags & AARCH64_FL_LSE) #define AARCH64_ISA_RDMA (aarch64_isa_flags & AARCH64_FL_V8_1) +#define AARCH64_ISA_V8_2 (aarch64_isa_flags & AARCH64_FL_V8_2) +#define AARCH64_ISA_F16 (aarch64_isa_flags & AARCH64_FL_F16) /* Crypto is an optional extension to AdvSIMD. */ #define TARGET_CRYPTO (TARGET_SIMD && AARCH64_ISA_CRYPTO) @@ -165,6 +171,10 @@ extern unsigned aarch64_architecture_version; /* Atomic instructions that can be enabled through the +lse extension. */ #define TARGET_LSE (AARCH64_ISA_LSE) +/* ARMv8.2-A FP16 support that can be enabled through the +fp16 extension. */ +#define TARGET_FP_F16INST (TARGET_FLOAT && AARCH64_ISA_F16) +#define TARGET_SIMD_F16INST (TARGET_SIMD && AARCH64_ISA_F16) + /* Make sure this is always defined so we don't have to check for ifdefs but rather use normal ifs. */ #ifndef TARGET_FIX_ERR_A53_835769_DEFAULT diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e9763d44d8d7aa6a64821a4b1811e55025aaaa4e..c4a6c7276eab38589f4e831982b071f12bd88665 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -12928,7 +12928,10 @@ more feature modifiers. This option has the form @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}. The permissible values for @var{arch} are @samp{armv8-a}, -@samp{armv8.1-a} or @var{native}. +@samp{armv8.1-a}, @samp{armv8.2-a} or @var{native}. + +The value @samp{armv8.2-a} implies @samp{armv8.1-a} and enables compiler +support for the ARMv8.2 architecture extensions. The value @samp{armv8.1-a} implies @samp{armv8-a} and enables compiler support for the ARMv8.1 architecture extension. In particular, it @@ -13041,6 +13044,8 @@ instructions. This is on by default for all possible values for options @item lse Enable Large System Extension instructions. This is on by default for @option{-march=armv8.1-a}. +@item fp16 +Enable FP16 extension. @end table