]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Support if statement in !GCC$ builtin directive.
authorMartin Liska <mliska@suse.cz>
Mon, 18 Feb 2019 08:19:47 +0000 (09:19 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 18 Feb 2019 08:19:47 +0000 (08:19 +0000)
2019-02-18  Martin Liska  <mliska@suse.cz>

* config/i386/i386.c (ix86_get_multilib_abi_name): New function.
(TARGET_GET_MULTILIB_ABI_NAME): New macro defined.
* doc/tm.texi: Document new target hook.
* doc/tm.texi.in: Likewise.
* target.def: Add new target macro.
* gcc.c (find_fortran_preinclude_file): Do not search multilib
suffixes.
2019-02-18  Martin Liska  <mliska@suse.cz>

* decl.c (gfc_match_gcc_builtin): Add support for filtering
of builtin directive based on multilib ABI name.
2019-02-18  Martin Liska  <mliska@suse.cz>

* gfortran.dg/simd-builtins-7.f90: New test.
* gfortran.dg/simd-builtins-7.h: New test.

From-SVN: r268978

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/gcc.c
gcc/target.def
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/simd-builtins-7.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/simd-builtins-7.h [new file with mode: 0644]

index 74f96a29089b647a8de0c798ad69d0d9dd424072..a200aac3434795ec93fd8dd395a6d8a4ba6954f9 100644 (file)
@@ -1,3 +1,13 @@
+2019-02-18  Martin Liska  <mliska@suse.cz>
+
+       * config/i386/i386.c (ix86_get_multilib_abi_name): New function.
+       (TARGET_GET_MULTILIB_ABI_NAME): New macro defined.
+       * doc/tm.texi: Document new target hook.
+       * doc/tm.texi.in: Likewise.
+       * target.def: Add new target macro.
+       * gcc.c (find_fortran_preinclude_file): Do not search multilib
+       suffixes.
+
 2019-02-17  Alan Modra  <amodra@gmail.com>
 
        PR target/89271
index 609273e4fc45c79f04f97ee0a060f7621c5667ba..591a7cdccdc7178758dbb1e6a79924eae2c3e1ef 100644 (file)
@@ -29579,6 +29579,19 @@ ix86_warn_parameter_passing_abi (cumulative_args_t cum_v, tree type)
   cum->warn_empty = false;
 }
 
+/* This hook returns name of multilib ABI.  */
+
+static const char *
+ix86_get_multilib_abi_name (void)
+{
+  if (!(TARGET_64BIT_P (ix86_isa_flags)))
+    return "i386";
+  else if (TARGET_X32_P (ix86_isa_flags))
+    return "x32";
+  else
+    return "x86_64";
+}
+
 /* Compute the alignment for a variable for Intel MCU psABI.  TYPE is
    the data type, and ALIGN is the alignment that the object would
    ordinarily have.  */
@@ -51806,6 +51819,10 @@ ix86_run_selftests (void)
 #undef TARGET_WARN_PARAMETER_PASSING_ABI
 #define TARGET_WARN_PARAMETER_PASSING_ABI ix86_warn_parameter_passing_abi
 
+#undef TARGET_GET_MULTILIB_ABI_NAME
+#define TARGET_GET_MULTILIB_ABI_NAME \
+  ix86_get_multilib_abi_name
+
 #if CHECKING_P
 #undef TARGET_RUN_TARGET_SELFTESTS
 #define TARGET_RUN_TARGET_SELFTESTS selftest::ix86_run_selftests
index 4347f89cd2f08af99082f2e261f9d8a859d177e8..8c8978bb13a7933b3ae6997de87a6b65edd6c842 100644 (file)
@@ -1931,6 +1931,10 @@ superset of all other ABIs.  @var{call_1} must always be a call insn,
 call_2 may be NULL or a call insn.
 @end deftypefn
 
+@deftypefn {Target Hook} {const char *} TARGET_GET_MULTILIB_ABI_NAME (void)
+This hook returns name of multilib ABI name.
+@end deftypefn
+
 @findex fixed_regs
 @findex call_used_regs
 @findex global_regs
index 41a6cb11cb0fe696b3033a0926c3ae715d65f2a2..fe1194ef91ae3dc7a4de4976a306d33801b2a89e 100644 (file)
@@ -1711,6 +1711,8 @@ of @code{CALL_USED_REGISTERS}.
 
 @hook TARGET_RETURN_CALL_WITH_MAX_CLOBBERS
 
+@hook TARGET_GET_MULTILIB_ABI_NAME
+
 @findex fixed_regs
 @findex call_used_regs
 @findex global_regs
index 4f150e257eb529e9f60dcdd68006eb2bdcb423f7..a03cfd2a70bed7aaec2d6cbe1d39c637821f6d12 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-18  Martin Liska  <mliska@suse.cz>
+
+       * decl.c (gfc_match_gcc_builtin): Add support for filtering
+       of builtin directive based on multilib ABI name.
+
 2019-02-17  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/88299
index 3658e432e7cee4c1c172a9723674c5700bf25e8a..9d6aa7d25c647472dea655e4174d0de3417c1482 100644 (file)
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "match.h"
 #include "parse.h"
 #include "constructor.h"
+#include "target.h"
 
 /* Macros to access allocate memory for gfc_data_variable,
    gfc_data_value and gfc_data.  */
@@ -11360,19 +11361,22 @@ gfc_match_gcc_unroll (void)
   return MATCH_ERROR;
 }
 
-/* Match a !GCC$ builtin (b) attributes simd flags form:
+/* Match a !GCC$ builtin (b) attributes simd flags if('target') form:
 
    The parameter b is name of a middle-end built-in.
-   Flags are one of:
-     - (empty)
-     - inbranch
-     - notinbranch
+   FLAGS is optional and must be one of:
+     - (inbranch)
+     - (notinbranch)
+
+   IF('target') is optional and TARGET is a name of a multilib ABI.
 
    When we come here, we have already matched the !GCC$ builtin string.  */
+
 match
 gfc_match_gcc_builtin (void)
 {
   char builtin[GFC_MAX_SYMBOL_LEN + 1];
+  char target[GFC_MAX_SYMBOL_LEN + 1];
 
   if (gfc_match (" ( %n ) attributes simd", builtin) != MATCH_YES)
     return MATCH_ERROR;
@@ -11383,6 +11387,13 @@ gfc_match_gcc_builtin (void)
   else if (gfc_match (" ( inbranch ) ") == MATCH_YES)
     clause = SIMD_INBRANCH;
 
+  if (gfc_match (" if ( '%n' ) ", target) == MATCH_YES)
+    {
+      const char *abi = targetm.get_multilib_abi_name ();
+      if (abi == NULL || strcmp (abi, target) != 0)
+       return MATCH_YES;
+    }
+
   if (gfc_vectorized_builtins == NULL)
     gfc_vectorized_builtins = new hash_map<nofree_string_hash, int> ();
 
index 797ed36616f6e605179b74463a2912d504a20924..481e8289ad30ae84e3c087cdb8dc7a3c9915b51f 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -9965,24 +9965,24 @@ find_fortran_preinclude_file (int argc, const char **argv)
 
   /* Search first for 'finclude' folder location for a header file
      installed by the compiler (similar to omp_lib.h).  */
-  add_prefix (&prefixes, argv[2], NULL, 0, 0, false);
+  add_prefix (&prefixes, argv[2], NULL, 0, 0, 0);
 #ifdef TOOL_INCLUDE_DIR
   /* Then search: <prefix>/<target>/<include>/finclude */
   add_prefix (&prefixes, TOOL_INCLUDE_DIR "/finclude/",
-             NULL, 0, 0, false);
+             NULL, 0, 0, 0);
 #endif
 #ifdef NATIVE_SYSTEM_HEADER_DIR
   /* Then search: <sysroot>/usr/include/finclude/<multilib> */
   add_sysrooted_hdrs_prefix (&prefixes, NATIVE_SYSTEM_HEADER_DIR "/finclude/",
-                            NULL, 0, 0, false);
+                            NULL, 0, 0, 0);
 #endif
 
-  const char *path = find_a_file (&include_prefixes, argv[1], R_OK, true);
+  const char *path = find_a_file (&include_prefixes, argv[1], R_OK, false);
   if (path != NULL)
     result = concat (argv[0], path, NULL);
   else
     {
-      path = find_a_file (&prefixes, argv[1], R_OK, true);
+      path = find_a_file (&prefixes, argv[1], R_OK, false);
       if (path != NULL)
        result = concat (argv[0], path, NULL);
     }
index 05c9cc1da2822e29286b037b02bd0b20e05904fb..66cee075018b94fa9786a10f7cfe6ede8ead6b20 100644 (file)
@@ -5791,6 +5791,12 @@ call_2 may be NULL or a call insn.",
  rtx_insn *, (rtx_insn *call_1, rtx_insn *call_2),
  NULL)
 
+DEFHOOK
+(get_multilib_abi_name,
+ "This hook returns name of multilib ABI name.",
+ const char *, (void),
+ hook_constcharptr_void_null)
+
 DEFHOOK
 (remove_extra_call_preserved_regs,
  "This hook removes registers from the set of call-clobbered registers\n\
index 9b197cc7947e92f22641b1ccae5b7f80d7490f28..a09997c87fe2b110a67c3b6c1e6c2600cb296baa 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-18  Martin Liska  <mliska@suse.cz>
+
+       * gfortran.dg/simd-builtins-7.f90: New test.
+       * gfortran.dg/simd-builtins-7.h: New test.
+
 2019-02-17  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/88299
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-7.f90 b/gcc/testsuite/gfortran.dg/simd-builtins-7.f90
new file mode 100644 (file)
index 0000000..75734d4
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } }
+! { dg-additional-options "-msse2 -mno-avx -nostdinc -Ofast -fpre-include=simd-builtins-7.h -fdump-tree-optimized" }
+
+program test_overloaded_intrinsic
+  real(4) :: x4(3200), y4(3200)
+  real(8) :: x8(3200), y8(3200)
+
+  y4 = sin(x4)
+  print *, y4
+
+  y4 = sin(x8)
+  print *, y8
+end
+
+! { dg-final { scan-tree-dump "sinf.simdclone" "optimized" { target ia32 } } } */
+! { dg-final { scan-tree-dump-not "sin.simdclone" "optimized" { target ia32 } } } */
+
+! { dg-final { scan-tree-dump "sin.simdclone" "optimized" { target lp64} } } */
+! { dg-final { scan-tree-dump-not "sinf.simdclone" "optimized" { target lp64 } } } */
diff --git a/gcc/testsuite/gfortran.dg/simd-builtins-7.h b/gcc/testsuite/gfortran.dg/simd-builtins-7.h
new file mode 100644 (file)
index 0000000..1c19b88
--- /dev/null
@@ -0,0 +1,2 @@
+!GCC$ builtin (sin) attributes simd (notinbranch) if('x86_64')
+!GCC$ builtin (sinf) attributes simd (notinbranch) if('i386')