handle_omp_declare_simd_attribute, false },
{ "cilk simd function", 0, -1, true, false, false,
handle_omp_declare_simd_attribute, false },
- { "simd", 0, 0, true, false, false,
+ { "simd", 0, 1, true, false, false,
handle_simd_attribute, false },
{ "omp declare target", 0, 0, true, false, false,
handle_omp_declare_target_attribute, false },
/* Handle a "simd" attribute. */
static tree
-handle_simd_attribute (tree *node, tree name, tree, int, bool *no_add_attrs)
+handle_simd_attribute (tree *node, tree name, tree args, int, bool *no_add_attrs)
{
if (TREE_CODE (*node) == FUNCTION_DECL)
{
*no_add_attrs = true;
}
else
- DECL_ATTRIBUTES (*node)
- = tree_cons (get_identifier ("omp declare simd"),
- NULL_TREE, DECL_ATTRIBUTES (*node));
+ {
+ tree t = get_identifier ("omp declare simd");
+ tree attr = NULL_TREE;
+ if (args)
+ {
+ tree id = TREE_VALUE (args);
+
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error ("attribute %qE argument not a string", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (strcmp (TREE_STRING_POINTER (id), "notinbranch") == 0)
+ attr = build_omp_clause (DECL_SOURCE_LOCATION (*node),
+ OMP_CLAUSE_NOTINBRANCH);
+ else
+ if (strcmp (TREE_STRING_POINTER (id), "inbranch") == 0)
+ attr = build_omp_clause (DECL_SOURCE_LOCATION (*node),
+ OMP_CLAUSE_INBRANCH);
+ else
+ {
+ error ("only %<inbranch%> and %<notinbranch%> flags are "
+ "allowed for %<__simd__%> attribute");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ }
+
+ DECL_ATTRIBUTES (*node) = tree_cons (t,
+ build_tree_list (NULL_TREE,
+ attr),
+ DECL_ATTRIBUTES (*node));
+ }
}
else
{
dynamically call a clone suitable for current architecture.
@item simd
+@itemx simd("@var{mask}")
@cindex @code{simd} function attribute.
This attribute enables creation of one or more function versions that
can process multiple arguments using SIMD instructions from a
If the attribute is specified and @code{#pragma omp declare simd}
present on a declaration and @code{-fopenmp} or @code{-fopenmp-simd}
switch is specified, then the attribute is ignored.
+The optional argument @var{mask} may have "notinbranch" or "inbranch"
+value and instructs the compiler to generate non-masked or masked
+clones correspondingly. By default, all clones are generated.
@item target (@var{options})
@cindex @code{target} function attribute