aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-11-27 14:06:48 +0100
committerMartin Liska <marxin@gcc.gnu.org>2018-11-27 13:06:48 +0000
commitfacf0354cfdaa555f376311b9d3c8fec79747f09 (patch)
tree3ef0c2c2a134b5685f82b8144402a410645d79a7 /gcc/fortran/decl.c
parent2ff5ffb623e17b6bb81532394cb1f42fe7b354c8 (diff)
downloadgcc-facf0354cfdaa555f376311b9d3c8fec79747f09.zip
gcc-facf0354cfdaa555f376311b9d3c8fec79747f09.tar.gz
gcc-facf0354cfdaa555f376311b9d3c8fec79747f09.tar.bz2
Support simd function declarations via a pre-include.
2018-11-27 Martin Liska <mliska@suse.cz> * config/gnu-user.h (TARGET_F951_OPTIONS): New. * gcc.c (find_fortran_preinclude_file): New function to handle Fortran pre-include. 2018-11-27 Martin Liska <mliska@suse.cz> * decl.c (gfc_match_gcc_builtin): New function. * gfortran.h (struct vect_builtin_tuple): New. (gfc_adjust_builtins): Likewise. * lang-specs.h (TARGET_F951_OPTIONS): New. (F951_OPTIONS): Use it. * lang.opt: Add new option -fpre-include. * match.h (gfc_match_gcc_builtin): Declare new function. * parse.c (decode_gcc_attribute): Handle builtin. (parse_progunit): Call gfc_adjust_builtins. * scanner.c (gfc_new_file): Load pre-included header file when provided. * trans-intrinsic.c (add_simd_flag_for_built_in): New. (gfc_adjust_builtins): Likewise. 2018-11-27 Martin Liska <mliska@suse.cz> * gfortran.dg/simd-builtins-1.f90: New test. * gfortran.dg/simd-builtins-1.h: New test. * gfortran.dg/simd-builtins-2.f90: New test. * gfortran.dg/simd-builtins-3.f90: New test. * gfortran.dg/simd-builtins-3.h: New test. * gfortran.dg/simd-builtins-4.f: New test. * gfortran.dg/simd-builtins-4.h: New test. * gfortran.dg/simd-builtins-5.f: New test. * gfortran.dg/simd-builtins-6.f90: New test. From-SVN: r266509
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 2b77d95..ac86798 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -98,6 +98,9 @@ bool gfc_matching_function;
/* Set upon parsing a !GCC$ unroll n directive for use in the next loop. */
int directive_unroll = -1;
+/* Map of middle-end built-ins that should be vectorized. */
+hash_map<nofree_string_hash, int> *gfc_vectorized_builtins;
+
/* If a kind expression of a component of a parameterized derived type is
parameterized, temporarily store the expression here. */
static gfc_expr *saved_kind_expr = NULL;
@@ -11243,3 +11246,41 @@ gfc_match_gcc_unroll (void)
gfc_error ("Syntax error in !GCC$ UNROLL directive at %C");
return MATCH_ERROR;
}
+
+/* Match a !GCC$ builtin (b) attributes simd flags form:
+
+ The parameter b is name of a middle-end built-in.
+ Flags are one of:
+ - (empty)
+ - inbranch
+ - notinbranch
+
+ 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];
+
+ if (gfc_match (" ( %n ) attributes simd", builtin) != MATCH_YES)
+ return MATCH_ERROR;
+
+ gfc_simd_clause clause = SIMD_NONE;
+ if (gfc_match (" ( notinbranch ) ") == MATCH_YES)
+ clause = SIMD_NOTINBRANCH;
+ else if (gfc_match (" ( inbranch ) ") == MATCH_YES)
+ clause = SIMD_INBRANCH;
+
+ if (gfc_vectorized_builtins == NULL)
+ gfc_vectorized_builtins = new hash_map<nofree_string_hash, int> ();
+
+ char *r = XNEWVEC (char, strlen (builtin) + 32);
+ sprintf (r, "__builtin_%s", builtin);
+
+ bool existed;
+ int &value = gfc_vectorized_builtins->get_or_insert (r, &existed);
+ value |= clause;
+ if (existed)
+ free (r);
+
+ return MATCH_YES;
+}