diff options
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 41 |
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; +} |