public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Matthew Wahab <matthew.wahab@foss.arm.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH 11/17][ARM] Add builtins for VFP FP16 intrinsics.
Date: Tue, 17 May 2016 14:41:00 -0000	[thread overview]
Message-ID: <573B2D9E.2000202@foss.arm.com> (raw)
In-Reply-To: <573B28A3.9030603@foss.arm.com>

[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]

The ACLE intrinsics introduced to support the ARMv8.2 FP16 extensions
require that intrinsics for scalar floating pointer (VFP) instructions
are available under different conditions from those for the NEON
intrinsics.

This patch adds the support code and builtins data for the new VFP
intrinsics. Because of the similarities between the scalar and NEON
builtins, the support code for the scalar builtins follows the code for
the NEON builtins. The declarations for the VFP builtins are also added
in this patch since the support code expects non-empty tables.

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.wahab@arm.com>

	* config/arm/arm-builtins.c (hf_UP): New.
	(si_UP): New.
	(arm_vfp_builtin_data): New.  Update comment.
	(enum arm_builtins): Include arm_vfp_builtins.def.
	(ARM_BUILTIN_VFP_PATTERN_START): New.
	(arm_init_vfp_builtins): New.
	(arm_init_builtins): Add arm_init_vfp_builtins.
	(arm_expand_vfp_builtin): New.
	(arm_expand_builtins: Update for arm_expand_vfp_builtin.  Fix
	long line.
	* config/arm/arm_vfp_builtins.c: New file.
	* config/arm/t-arm (arm.o): Add arm_vfp_builtins.def.
	(arm-builtins.o): Likewise.


[-- Attachment #2: 0011-PATCH-11-17-ARM-Add-builtins-for-VFP-FP16-intrinsics.patch --]
[-- Type: text/x-patch, Size: 8655 bytes --]

From d1f2b10a2e672b1dc886d8d1efb136d970f967f1 Mon Sep 17 00:00:00 2001
From: Matthew Wahab <matthew.wahab@arm.com>
Date: Thu, 7 Apr 2016 15:33:14 +0100
Subject: [PATCH 11/17] [PATCH 11/17][ARM] Add builtins for VFP FP16
 intrinsics.

2016-05-17  Matthew Wahab  <matthew.wahab@arm.com>

	* config/arm/arm-builtins.c (hf_UP): New.
	(si_UP): New.
	(arm_vfp_builtin_data): New.  Update comment.
	(arm_init_vfp_builtins): New.
	(arm_init_builtins): Add arm_init_vfp_builtins.
	(arm_expand_vfp_builtin): New.
	(arm_expand_builtins): Update for arm_expand_vfp_builtin.  Fix
	long line.
	* config/arm/arm_vfp_builtins.c: New file.
	* config/arm/t-arm (arm.o): Add arm_vfp_builtins.def.
	(arm-builtins.o): Likewise.
---
 gcc/config/arm/arm-builtins.c       | 75 +++++++++++++++++++++++++++++++++----
 gcc/config/arm/arm_vfp_builtins.def | 56 +++++++++++++++++++++++++++
 gcc/config/arm/t-arm                |  4 +-
 3 files changed, 126 insertions(+), 9 deletions(-)
 create mode 100644 gcc/config/arm/arm_vfp_builtins.def

diff --git a/gcc/config/arm/arm-builtins.c b/gcc/config/arm/arm-builtins.c
index 5a22b91..58c68a6 100644
--- a/gcc/config/arm/arm-builtins.c
+++ b/gcc/config/arm/arm-builtins.c
@@ -190,6 +190,8 @@ arm_storestruct_lane_qualifiers[SIMD_MAX_BUILTIN_ARGS]
 #define ti_UP	 TImode
 #define ei_UP	 EImode
 #define oi_UP	 OImode
+#define hf_UP	 HFmode
+#define si_UP	 SImode
 
 #define UP(X) X##_UP
 
@@ -239,12 +241,22 @@ typedef struct {
   VAR11 (T, N, A, B, C, D, E, F, G, H, I, J, K) \
   VAR1 (T, N, L)
 
-/* The NEON builtin data can be found in arm_neon_builtins.def.
-   The mode entries in the following table correspond to the "key" type of the
-   instruction variant, i.e. equivalent to that which would be specified after
-   the assembler mnemonic, which usually refers to the last vector operand.
-   The modes listed per instruction should be the same as those defined for
-   that instruction's pattern in neon.md.  */
+/* The NEON builtin data can be found in arm_neon_builtins.def and
+   arm_vfp_builtins.def.  The entries in arm_neon_builtins.def require
+   TARGET_NEON to be true.  The entries in arm_vfp_builtins.def require
+   TARGET_VFP to be true.  The feature tests are checked when the builtins are
+   expanded.
+
+   The mode entries in the following table correspond to
+   the "key" type of the instruction variant, i.e. equivalent to that which
+   would be specified after the assembler mnemonic, which usually refers to the
+   last vector operand.  The modes listed per instruction should be the same as
+   those defined for that instruction's pattern in neon.md.  */
+
+static neon_builtin_datum vfp_builtin_data[] =
+{
+#include "arm_vfp_builtins.def"
+};
 
 static neon_builtin_datum neon_builtin_data[] =
 {
@@ -534,6 +546,10 @@ enum arm_builtins
 #undef CRYPTO2
 #undef CRYPTO3
 
+  ARM_BUILTIN_VFP_BASE,
+
+#include "arm_vfp_builtins.def"
+
   ARM_BUILTIN_NEON_BASE,
   ARM_BUILTIN_NEON_LANE_CHECK = ARM_BUILTIN_NEON_BASE,
 
@@ -542,6 +558,9 @@ enum arm_builtins
   ARM_BUILTIN_MAX
 };
 
+#define ARM_BUILTIN_VFP_PATTERN_START \
+  (ARM_BUILTIN_VFP_BASE + 1)
+
 #define ARM_BUILTIN_NEON_PATTERN_START \
   (ARM_BUILTIN_NEON_BASE + 1)
 
@@ -1033,6 +1052,20 @@ arm_init_neon_builtins (void)
     }
 }
 
+/* Set up all the scalar floating point builtins.  */
+
+static void
+arm_init_vfp_builtins (void)
+{
+  unsigned int i, fcode = ARM_BUILTIN_VFP_PATTERN_START;
+
+  for (i = 0; i < ARRAY_SIZE (vfp_builtin_data); i++, fcode++)
+    {
+      neon_builtin_datum *d = &vfp_builtin_data[i];
+      arm_init_neon_builtin (fcode, d);
+    }
+}
+
 static void
 arm_init_crypto_builtins (void)
 {
@@ -1777,7 +1810,7 @@ arm_init_builtins (void)
   if (TARGET_HARD_FLOAT)
     {
       arm_init_neon_builtins ();
-
+      arm_init_vfp_builtins ();
       arm_init_crypto_builtins ();
     }
 
@@ -2324,6 +2357,27 @@ arm_expand_neon_builtin (int fcode, tree exp, rtx target)
   return arm_expand_neon_builtin_1 (fcode, exp, target, d);
 }
 
+/* Expand a VFP builtin, if TARGET_VFP is true.  These builtins are treated like
+   neon builtins except that the data is looked up in table
+   VFP_BUILTIN_DATA.  */
+
+static rtx
+arm_expand_vfp_builtin (int fcode, tree exp, rtx target)
+{
+  if (fcode >= ARM_BUILTIN_VFP_BASE && ! TARGET_VFP)
+    {
+      fatal_error (input_location,
+		   "You must enable VFP instructions"
+		   " to use these intrinsics.");
+      return const0_rtx;
+    }
+
+  neon_builtin_datum *d
+    = &vfp_builtin_data[fcode - ARM_BUILTIN_VFP_PATTERN_START];
+
+  return arm_expand_neon_builtin_1 (fcode, exp, target, d);
+}
+
 /* Expand an expression EXP that calls a built-in function,
    with result going to TARGET if that's convenient
    (and in mode MODE if that's convenient).
@@ -2361,13 +2415,18 @@ arm_expand_builtin (tree exp,
   if (fcode >= ARM_BUILTIN_NEON_BASE)
     return arm_expand_neon_builtin (fcode, exp, target);
 
+  if (fcode >= ARM_BUILTIN_VFP_BASE)
+    return arm_expand_vfp_builtin (fcode, exp, target);
+
   /* Check in the context of the function making the call whether the
      builtin is supported.  */
   if (fcode >= ARM_BUILTIN_CRYPTO_BASE
       && (!TARGET_CRYPTO || !TARGET_HARD_FLOAT))
     {
       fatal_error (input_location,
-		   "You must enable crypto intrinsics (e.g. include -mfloat-abi=softfp -mfpu=crypto-neon...) to use these intrinsics.");
+		   "You must enable crypto instructions"
+		   " (e.g. include -mfloat-abi=softfp -mfpu=crypto-neon...)"
+		   " to use these intrinsics.");
       return const0_rtx;
     }
 
diff --git a/gcc/config/arm/arm_vfp_builtins.def b/gcc/config/arm/arm_vfp_builtins.def
new file mode 100644
index 0000000..35014ce
--- /dev/null
+++ b/gcc/config/arm/arm_vfp_builtins.def
@@ -0,0 +1,56 @@
+/* VFP instruction builtin definitions.
+   Copyright (C) 2016 Free Software Foundation, Inc.
+   Contributed by ARM Ltd.
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This file lists the builtins that may be available when VFP is enabled but
+   not NEON is enabled.  The entries otherwise have the same requirements and
+   generate the same structures as those in the arm_neon_builtins.def.  */
+
+/* FP16 Arithmetic instructions.  */
+VAR1 (UNOP, vabs, hf)
+VAR2 (UNOP, vcvths, hf, si)
+VAR2 (UNOP, vcvthu, hf, si)
+VAR1 (UNOP, vcvtahs, si)
+VAR1 (UNOP, vcvtahu, si)
+VAR1 (UNOP, vcvtmhs, si)
+VAR1 (UNOP, vcvtmhu, si)
+VAR1 (UNOP, vcvtnhs, si)
+VAR1 (UNOP, vcvtnhu, si)
+VAR1 (UNOP, vcvtphs, si)
+VAR1 (UNOP, vcvtphu, si)
+VAR1 (UNOP, vneg, hf)
+VAR1 (UNOP, vrnd, hf)
+VAR1 (UNOP, vrnda, hf)
+VAR1 (UNOP, vrndi, hf)
+VAR1 (UNOP, vrndm, hf)
+VAR1 (UNOP, vrndn, hf)
+VAR1 (UNOP, vrndp, hf)
+VAR1 (UNOP, vrndx, hf)
+VAR1 (UNOP, vsqrt, hf)
+
+VAR1 (BINOP, vadd, hf)
+VAR2 (BINOP, vcvths_n, hf, si)
+VAR2 (BINOP, vcvthu_n, hf, si)
+VAR1 (BINOP, vdiv, hf)
+VAR1 (BINOP, vmaxnm, hf)
+VAR1 (BINOP, vminnm, hf)
+VAR1 (BINOP, vmulf, hf)
+VAR1 (BINOP, vsub, hf)
+
+VAR1 (TERNOP, vfma, hf)
+VAR1 (TERNOP, vfms, hf)
diff --git a/gcc/config/arm/t-arm b/gcc/config/arm/t-arm
index 749a58d..803baa2 100644
--- a/gcc/config/arm/t-arm
+++ b/gcc/config/arm/t-arm
@@ -95,7 +95,8 @@ arm.o: $(srcdir)/config/arm/arm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
   $(srcdir)/config/arm/arm-cores.def \
   $(srcdir)/config/arm/arm-arches.def $(srcdir)/config/arm/arm-fpus.def \
   $(srcdir)/config/arm/arm-protos.h \
-  $(srcdir)/config/arm/arm_neon_builtins.def
+  $(srcdir)/config/arm/arm_neon_builtins.def \
+  $(srcdir)/config/arm/arm_vfp_builtins.def
 
 arm-builtins.o: $(srcdir)/config/arm/arm-builtins.c $(CONFIG_H) \
   $(SYSTEM_H) coretypes.h $(TM_H) \
@@ -103,6 +104,7 @@ arm-builtins.o: $(srcdir)/config/arm/arm-builtins.c $(CONFIG_H) \
   $(DIAGNOSTIC_CORE_H) $(OPTABS_H) \
   $(srcdir)/config/arm/arm-protos.h \
   $(srcdir)/config/arm/arm_neon_builtins.def \
+  $(srcdir)/config/arm/arm_vfp_builtins.def \
   $(srcdir)/config/arm/arm-simd-builtin-types.def
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/arm/arm-builtins.c
-- 
2.1.4


  parent reply	other threads:[~2016-05-17 14:41 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17 14:20 [PATCH 0/17][ARM] ARMv8.2-A and FP16 extension support Matthew Wahab
2016-05-17 14:23 ` [PATCH 1/17][ARM] Add ARMv8.2-A command line option and profile Matthew Wahab
2016-07-04 13:46   ` Matthew Wahab
2016-09-21 13:57     ` Ramana Radhakrishnan
2016-05-17 14:25 ` [PATCH 2/17][Testsuite] Add a selector for ARM FP16 alternative format support Matthew Wahab
2016-07-27 13:34   ` Ramana Radhakrishnan
2016-05-17 14:26 ` [PATCH 3/17][Testsuite] Add ARM support for ARMv8.2-A with FP16 arithmetic instructions Matthew Wahab
2016-07-04 13:49   ` Matthew Wahab
2016-07-27 13:34     ` Ramana Radhakrishnan
2016-05-17 14:28 ` [PATCH 4/17][ARM] Define feature macros for FP16 Matthew Wahab
2016-07-27 13:35   ` Ramana Radhakrishnan
2016-05-17 14:29 ` [PATCH 5/17][ARM] Enable HI mode moves for floating point values Matthew Wahab
2016-07-27 13:57   ` Ramana Radhakrishnan
2016-09-26 13:20     ` Christophe Lyon
2016-09-26 13:26       ` Matthew Wahab
2016-05-17 14:32 ` [PATCH 6/17][ARM] Add data processing intrinsics for float16_t Matthew Wahab
2016-07-27 13:59   ` Ramana Radhakrishnan
2016-09-25 14:44     ` Christophe Lyon
2016-09-26  9:56       ` Matthew Wahab
2016-09-26 12:54         ` Christophe Lyon
2016-09-26 13:11           ` Ramana Radhakrishnan
2016-09-26 13:19             ` Matthew Wahab
2016-09-26 13:21             ` Christophe Lyon
2016-09-26 20:02               ` Christophe Lyon
2016-05-17 14:34 ` [PATCH 7/17][ARM] Add FP16 data movement instructions Matthew Wahab
2016-07-04 13:57   ` Matthew Wahab
2016-07-27 14:01     ` Ramana Radhakrishnan
2016-05-17 14:36 ` [PATCH 8/17][ARM] Add VFP FP16 arithmetic instructions Matthew Wahab
2016-05-18  0:52   ` Joseph Myers
2016-05-18  0:57     ` Joseph Myers
2016-05-18 13:40     ` Matthew Wahab
2016-05-18 15:21       ` Joseph Myers
2016-05-19 14:54         ` Matthew Wahab
2016-07-04 14:02   ` Matthew Wahab
2016-07-28 11:37     ` Ramana Radhakrishnan
2016-08-03 11:52       ` Ramana Radhakrishnan
2016-08-03 13:10         ` Matthew Wahab
2016-08-03 14:45         ` James Greenhalgh
2016-08-03 17:44         ` Joseph Myers
2016-05-17 14:37 ` [PATCH 9/17][ARM] Add NEON " Matthew Wahab
2016-05-18  0:58   ` Joseph Myers
2016-05-19 17:01     ` Jiong Wang
2016-05-19 17:29       ` Joseph Myers
2016-06-08  8:46         ` James Greenhalgh
2016-06-08 20:02           ` Joseph Myers
2016-07-04 14:09     ` Matthew Wahab
2016-07-28 11:53       ` Ramana Radhakrishnan
2016-05-17 14:39 ` [PATCH 10/17][ARM] Refactor support code for NEON builtins Matthew Wahab
2016-07-28 11:54   ` Ramana Radhakrishnan
2016-12-05 16:47     ` [arm-embedded][committed][PATCH 10/17] " Andre Vieira (lists)
2016-05-17 14:41 ` Matthew Wahab [this message]
2016-07-04 14:12   ` [PATCH 11/17][ARM] Add builtins for VFP FP16 intrinsics Matthew Wahab
2016-07-28 11:55     ` Ramana Radhakrishnan
2016-05-17 14:43 ` [PATCH 12/17][ARM] Add builtins for NEON " Matthew Wahab
2016-07-04 14:13   ` Matthew Wahab
2016-07-28 11:56     ` Ramana Radhakrishnan
2016-05-17 14:44 ` [PATCH 13/17][ARM] Add VFP FP16 instrinsics Matthew Wahab
2016-07-04 14:14   ` Matthew Wahab
2016-07-28 11:57     ` Ramana Radhakrishnan
2016-05-17 14:47 ` [PATCH 14/17][ARM] Add NEON " Matthew Wahab
2016-07-04 14:16   ` Matthew Wahab
2016-08-03 12:57     ` Ramana Radhakrishnan
2016-05-17 14:49 ` [PATCH 15/17][ARM] Add tests for ARMv8.2-A FP16 support Matthew Wahab
2016-07-04 14:17   ` Matthew Wahab
2016-08-04  8:34     ` Ramana Radhakrishnan
2016-05-17 14:51 ` [PATCH 16/17][ARM] Add tests for VFP FP16 ACLE instrinsics Matthew Wahab
2016-05-18  1:07   ` Joseph Myers
2016-05-18 10:58     ` Matthew Wahab
2016-07-04 14:18       ` Matthew Wahab
2016-08-04  8:35         ` Ramana Radhakrishnan
2016-05-17 14:52 ` [PATCH 17/17][ARM] Add tests for NEON FP16 ACLE intrinsics Matthew Wahab
2016-07-04 14:22   ` Matthew Wahab
2016-08-04  9:01     ` Ramana Radhakrishnan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=573B2D9E.2000202@foss.arm.com \
    --to=matthew.wahab@foss.arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).